From d42bd3397762118f2e9fd6fab094198493e9cac6 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Mon, 3 Jun 2024 14:22:25 +0200 Subject: [PATCH 1/8] feat: add funding contract deployer --- Dockerfile | 67 ++++++++++++++++++++++++++++ main.star | 12 ++++- network_params.yaml | 6 ++- src/contracts/contract_deployer.star | 65 +++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100644 src/contracts/contract_deployer.star diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e4ab8b2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,67 @@ +# Use the Debian base image for broader compatibility +FROM debian:latest + +# Install dependencies using apt +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + make \ + jq \ + direnv \ + bash \ + curl \ + gcc \ + g++ \ + python3 \ + python3-pip \ + nodejs \ + npm \ + vim \ + build-essential \ + libusb-1.0-0-dev \ + libssl-dev \ + ca-certificates \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install Go from the official golang image +COPY --from=golang:alpine /usr/local/go/ /usr/local/go/ +ENV PATH="/usr/local/go/bin:${PATH}" + +# Install pnpm +RUN npm install -g pnpm@9 + +# Install web3 cli +RUN curl -LSs https://raw.githubusercontent.com/gochain/web3/master/install.sh | sh + +# Install Rust and Foundry +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ + . $HOME/.cargo/env && \ + cargo install --git https://github.com/foundry-rs/foundry --profile local --locked forge cast chisel anvil + +# Ensure Foundry binaries are in PATH +ENV PATH="/root/.cargo/bin:${PATH}" + +# Clone the Optimism repository and set up the environment +WORKDIR /workspace +RUN git clone https://github.com/ethereum-optimism/optimism.git && \ + cd optimism && \ + git checkout tutorials/chain && \ + pnpm install && \ + #make op-node op-batcher op-proposer && \ + pnpm build + +# Verify installed versions +RUN git --version && \ + go version && \ + node --version && \ + pnpm --version && \ + forge --version && \ + cast --version && \ + make --version && \ + jq --version && \ + direnv --version + +# Set the working directory +WORKDIR /workspace/optimism + +# Default command +CMD ["bash"] diff --git a/main.star b/main.star index 1f93afc..9eed53b 100644 --- a/main.star +++ b/main.star @@ -1,5 +1,6 @@ input_parser = import_module("./src/package_io/input_parser.star") -ethereum_package = import_module("github.com/kurtosis-tech/ethereum-package/main.star@add-arbitrary-contract-def") +ethereum_package = import_module("github.com/kurtosis-tech/ethereum-package/main.star") +contract_deployer = import_module("./src/contracts/contract_deployer.star") def run(plan,args={}): """Deploy a Optimism L2 with a local L1. @@ -17,7 +18,14 @@ def run(plan,args={}): # Deploy the L1 plan.print("Deploying a local L1") - ethereum_package.run(plan, ethereum_args) + l1 = ethereum_package.run(plan, ethereum_args) + all_l1_participants = l1.all_participants + priv_key = l1.pre_funded_accounts[12].private_key # reserved for L2 contract deployer + # Deploy L2 smart contracts + plan.print("Deploying the L2 smart contracts") + first_l1_el_node = all_l1_participants[0].el_context.rpc_http_url + first_l1_cl_node = all_l1_participants[0].cl_context.beacon_http_url + contract_deployer.launch_contract_deployer(plan, first_l1_el_node, first_l1_cl_node, priv_key) # Parse the values for the args plan.print("Parsing the L2 input args") diff --git a/network_params.yaml b/network_params.yaml index 862ce97..5ab54e1 100644 --- a/network_params.yaml +++ b/network_params.yaml @@ -7,8 +7,10 @@ optimism_package: ethereum_package: participants: - - count: 2 + - el_type: geth + - el_type: reth network_params: - additional_preloaded_contracts: '{"0x123463a4B065722E99115D6c222f267d9cABb524": {"balance": "2ETH","code": "0x1234","storage": {}}}' + preset: minimal additional_services: - dora + - blockscout diff --git a/src/contracts/contract_deployer.star b/src/contracts/contract_deployer.star new file mode 100644 index 0000000..45c244e --- /dev/null +++ b/src/contracts/contract_deployer.star @@ -0,0 +1,65 @@ +# The min/max CPU/memory that mev-flood can use +MIN_CPU = 100 +MAX_CPU = 2000 +MIN_MEMORY = 128 +MAX_MEMORY = 1024 + +IMAGE = "bbusa/op:latest" + +ENVRC_PATH = "/workspace/optimism/.envrc" +ENTRYPOINT_ARGS = ["/bin/bash", "-c"] +def launch_contract_deployer( + plan, + el_rpc_http_url, + cl_rpc_http_url, + priv_key, +): + plan.add_service( + name="op-contract-deployer", + config=ServiceConfig( + image=IMAGE, + min_cpu=MIN_CPU, + max_cpu=MAX_CPU, + min_memory=MIN_MEMORY, + max_memory=MAX_MEMORY, + entrypoint=ENTRYPOINT_ARGS, + env_vars = { + "WEB3_RPC_URL": str(el_rpc_http_url), + "WEB3_PRIVATE_KEY": str(priv_key), + "CL_RPC_URL": str(cl_rpc_http_url), + "FUND_VALUE": "10", + }, + cmd=[ + " && ".join( + [ + "./packages/contracts-bedrock/scripts/getting-started/wallets.sh >> {0}".format(ENVRC_PATH), + "sed -i '1d' {0}".format(ENVRC_PATH), # Remove the first line (not commented out) + "echo 'export L1_RPC_KIND=any' >> {0}".format(ENVRC_PATH), + "echo 'export L1_RPC_URL={0}' >> {1}".format(el_rpc_http_url, ENVRC_PATH), + "echo 'export IMPL_SALT=$(openssl rand -hex 32)' >> {0}".format(ENVRC_PATH), + "echo 'export DEPLOYMENT_CONTEXT=getting-started' >> {0}".format(ENVRC_PATH), + "source {0}".format(ENVRC_PATH), + "web3 transfer $FUND_VALUE to $GS_ADMIN_ADDRESS", # Fund Admin + "sleep 3", + "web3 transfer $FUND_VALUE to $GS_BATCHER_ADDRESS", # Fund Batcher + "sleep 3", + "web3 transfer $FUND_VALUE to $GS_PROPOSER_ADDRESS", # Fund Proposer + "sleep 3", + # sleep till chain is finalized + "while true; do sleep 3; echo 'Chain is not yet finalized...'; if [ $(curl -s $CL_RPC_URL/eth/v1/beacon/states/1/finality_checkpoints | jq '.finalized') = true ]; then echo 'Chain is finalized!'; break; fi; done", + "cd /workspace/optimism/packages/contracts-bedrock", + "./scripts/getting-started/config.sh", + "cd /workspace/optimism", + "sleep 3", + # "cast codesize 0x4e59b44847b379578588920cA78FbF26c0B4956C --rpc-url $WEB3_RPC_URL", + # "web3 transfer $FUND_VALUE to 0x3fAB184622Dc19b6109349B94811493BF2a45362", # Fund Factory deployer + + # "sleep 12", + # "cast publish --rpc-url $WEB3_RPC_URL 0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222", + "sleep 100000", + ] + ) + ], + ), + ) + From e9474332f49a9b7c17287052bd6467b699f7220f Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Mon, 3 Jun 2024 17:52:49 +0200 Subject: [PATCH 2/8] fix contract deployment --- Dockerfile | 42 +++++++++-- README.md | 1 + main.star | 12 ++- src/contracts/contract_deployer.star | 108 +++++++++++++++------------ src/package_io/input_parser.star | 15 +++- 5 files changed, 118 insertions(+), 60 deletions(-) create mode 100644 README.md diff --git a/Dockerfile b/Dockerfile index e4ab8b2..67c6643 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -# Use the Debian base image for broader compatibility -FROM debian:latest +# Stage 1: Builder +FROM debian:latest AS builder -# Install dependencies using apt +# Install dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ git \ make \ @@ -49,6 +49,39 @@ RUN git clone https://github.com/ethereum-optimism/optimism.git && \ #make op-node op-batcher op-proposer && \ pnpm build +# Stage 2: Runner +FROM debian:latest + +# Install runtime dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + bash \ + ca-certificates \ + jq \ + direnv \ + curl \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# Copy Go from the builder stage +COPY --from=builder /usr/local/go/ /usr/local/go/ +ENV PATH="/usr/local/go/bin:${PATH}" + +# Copy pnpm from the builder stage +COPY --from=builder /usr/local/lib/node_modules/pnpm /usr/local/lib/node_modules/pnpm +COPY --from=builder /usr/local/bin/pnpm /usr/local/bin/pnpm + +# Copy web3 cli from the builder stage +COPY --from=builder /usr/local/bin/web3 /usr/local/bin/web3 + +# Copy Rust and Foundry from the builder stage +COPY --from=builder /root/.cargo /root/.cargo +ENV PATH="/root/.cargo/bin:${PATH}" + +# Copy the built application from the builder stage +COPY --from=builder /workspace/optimism /workspace/optimism + +# Set the working directory +WORKDIR /workspace/optimism + # Verify installed versions RUN git --version && \ go version && \ @@ -60,8 +93,5 @@ RUN git --version && \ jq --version && \ direnv --version -# Set the working directory -WORKDIR /workspace/optimism - # Default command CMD ["bash"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5167c2 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +## Welcome to Optimism Package diff --git a/main.star b/main.star index 9eed53b..6bb1130 100644 --- a/main.star +++ b/main.star @@ -2,7 +2,8 @@ input_parser = import_module("./src/package_io/input_parser.star") ethereum_package = import_module("github.com/kurtosis-tech/ethereum-package/main.star") contract_deployer = import_module("./src/contracts/contract_deployer.star") -def run(plan,args={}): + +def run(plan, args={}): """Deploy a Optimism L2 with a local L1. Args: @@ -20,12 +21,16 @@ def run(plan,args={}): plan.print("Deploying a local L1") l1 = ethereum_package.run(plan, ethereum_args) all_l1_participants = l1.all_participants - priv_key = l1.pre_funded_accounts[12].private_key # reserved for L2 contract deployer + priv_key = l1.pre_funded_accounts[ + 12 + ].private_key # reserved for L2 contract deployer # Deploy L2 smart contracts plan.print("Deploying the L2 smart contracts") first_l1_el_node = all_l1_participants[0].el_context.rpc_http_url first_l1_cl_node = all_l1_participants[0].cl_context.beacon_http_url - contract_deployer.launch_contract_deployer(plan, first_l1_el_node, first_l1_cl_node, priv_key) + contract_deployer.launch_contract_deployer( + plan, first_l1_el_node, first_l1_cl_node, priv_key + ) # Parse the values for the args plan.print("Parsing the L2 input args") @@ -35,4 +40,3 @@ def run(plan,args={}): plan.print("Deploying a local L2") args_with_right_defaults = input_parser.input_parser(plan, optimism_args) plan.print(args_with_right_defaults) - diff --git a/src/contracts/contract_deployer.star b/src/contracts/contract_deployer.star index 45c244e..a5fa375 100644 --- a/src/contracts/contract_deployer.star +++ b/src/contracts/contract_deployer.star @@ -7,59 +7,71 @@ MAX_MEMORY = 1024 IMAGE = "bbusa/op:latest" ENVRC_PATH = "/workspace/optimism/.envrc" -ENTRYPOINT_ARGS = ["/bin/bash", "-c"] + +FACTORY_DEPLOYER_ADDRESS = "0x3fAB184622Dc19b6109349B94811493BF2a45362" +FACTORY_DEPLOYER_CODE = "0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222" def launch_contract_deployer( plan, el_rpc_http_url, cl_rpc_http_url, priv_key, ): - plan.add_service( - name="op-contract-deployer", - config=ServiceConfig( - image=IMAGE, - min_cpu=MIN_CPU, - max_cpu=MAX_CPU, - min_memory=MIN_MEMORY, - max_memory=MAX_MEMORY, - entrypoint=ENTRYPOINT_ARGS, - env_vars = { - "WEB3_RPC_URL": str(el_rpc_http_url), - "WEB3_PRIVATE_KEY": str(priv_key), - "CL_RPC_URL": str(cl_rpc_http_url), - "FUND_VALUE": "10", - }, - cmd=[ - " && ".join( - [ - "./packages/contracts-bedrock/scripts/getting-started/wallets.sh >> {0}".format(ENVRC_PATH), - "sed -i '1d' {0}".format(ENVRC_PATH), # Remove the first line (not commented out) - "echo 'export L1_RPC_KIND=any' >> {0}".format(ENVRC_PATH), - "echo 'export L1_RPC_URL={0}' >> {1}".format(el_rpc_http_url, ENVRC_PATH), - "echo 'export IMPL_SALT=$(openssl rand -hex 32)' >> {0}".format(ENVRC_PATH), - "echo 'export DEPLOYMENT_CONTEXT=getting-started' >> {0}".format(ENVRC_PATH), - "source {0}".format(ENVRC_PATH), - "web3 transfer $FUND_VALUE to $GS_ADMIN_ADDRESS", # Fund Admin - "sleep 3", - "web3 transfer $FUND_VALUE to $GS_BATCHER_ADDRESS", # Fund Batcher - "sleep 3", - "web3 transfer $FUND_VALUE to $GS_PROPOSER_ADDRESS", # Fund Proposer - "sleep 3", - # sleep till chain is finalized - "while true; do sleep 3; echo 'Chain is not yet finalized...'; if [ $(curl -s $CL_RPC_URL/eth/v1/beacon/states/1/finality_checkpoints | jq '.finalized') = true ]; then echo 'Chain is finalized!'; break; fi; done", - "cd /workspace/optimism/packages/contracts-bedrock", - "./scripts/getting-started/config.sh", - "cd /workspace/optimism", - "sleep 3", - # "cast codesize 0x4e59b44847b379578588920cA78FbF26c0B4956C --rpc-url $WEB3_RPC_URL", - # "web3 transfer $FUND_VALUE to 0x3fAB184622Dc19b6109349B94811493BF2a45362", # Fund Factory deployer - - # "sleep 12", - # "cast publish --rpc-url $WEB3_RPC_URL 0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222", - "sleep 100000", - ] - ) - ], + plan.run_sh( + description="Deploying L2 contracts (takes a few minutes (30 mins for mainnet preset - 4 mins for minimal preset) -- L1 has to be finalized first)", + image=IMAGE, + env_vars={ + "WEB3_RPC_URL": str(el_rpc_http_url), + "WEB3_PRIVATE_KEY": str(priv_key), + "CL_RPC_URL": str(cl_rpc_http_url), + "FUND_VALUE": "10", + }, + store=[ + StoreSpec(src="/network-configs", name="op-genesis-configs"), + ], + run=" && ".join( + [ + "./packages/contracts-bedrock/scripts/getting-started/wallets.sh >> {0}".format( + ENVRC_PATH + ), + "sed -i '1d' {0}".format( + ENVRC_PATH + ), # Remove the first line (not commented out) + "echo 'export L1_RPC_KIND=any' >> {0}".format(ENVRC_PATH), + "echo 'export L1_RPC_URL={0}' >> {1}".format( + el_rpc_http_url, ENVRC_PATH + ), + "echo 'export IMPL_SALT=$(openssl rand -hex 32)' >> {0}".format( + ENVRC_PATH + ), + "echo 'export DEPLOYMENT_CONTEXT=getting-started' >> {0}".format( + ENVRC_PATH + ), + ". {0}".format(ENVRC_PATH), + "web3 transfer $FUND_VALUE to $GS_ADMIN_ADDRESS", # Fund Admin + "sleep 3", + "web3 transfer $FUND_VALUE to $GS_BATCHER_ADDRESS", # Fund Batcher + "sleep 3", + "web3 transfer $FUND_VALUE to $GS_PROPOSER_ADDRESS", # Fund Proposer + "sleep 3", + "web3 transfer $FUND_VALUE to {0}".format( + FACTORY_DEPLOYER_ADDRESS + ), # Fund Factory deployer + "sleep 3", + # sleep till chain is finalized + "while true; do sleep 3; echo 'Chain is not yet finalized...'; if [ \"$(curl -s $CL_RPC_URL/eth/v1/beacon/states/head/finality_checkpoints | jq -r '.data.finalized.epoch')\" != \"0\" ]; then echo 'Chain is finalized!'; break; fi; done", + "cd /workspace/optimism/packages/contracts-bedrock", + "./scripts/getting-started/config.sh", + "cast publish --rpc-url $WEB3_RPC_URL {0}".format(FACTORY_DEPLOYER_CODE), + "sleep 12", + "forge script scripts/Deploy.s.sol:Deploy --private-key $GS_ADMIN_PRIVATE_KEY --broadcast --rpc-url $L1_RPC_URL", + "sleep 3", + "cd /workspace/optimism/op-node", + "go run cmd/main.go genesis l2 --deploy-config ../packages/contracts-bedrock/deploy-config/getting-started.json --l1-deployments ../packages/contracts-bedrock/deployments/getting-started/.deploy --outfile.l2 genesis.json --outfile.rollup rollup.json --l1-rpc $L1_RPC_URL", + "mkdir -p /network-configs", + "mv /workspace/optimism/op-node/genesis.json /network-configs/genesis.json", + "mv /workspace/optimism/op-node/rollup.json /network-configs/rollup.json", + "mv /workspace/optimism/packages/contracts-bedrock/deployments/getting-started/.deploy /network-configs/.deploy", + ] ), + wait = "2000s", ) - diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index 72637e8..b035b0b 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -1,4 +1,6 @@ -ethereum_package_input_parser = import_module("github.com/kurtosis-tech/ethereum-package/src/package_io/input_parser.star") +ethereum_package_input_parser = import_module( + "github.com/kurtosis-tech/ethereum-package/src/package_io/input_parser.star" +) DEFAULT_EL_IMAGES = { "op-geth": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:latest", @@ -21,6 +23,7 @@ ATTR_TO_BE_SKIPPED_AT_ROOT = ( "participants", ) + def input_parser(plan, input_args): result = parse_network_params(plan, input_args) @@ -40,6 +43,7 @@ def input_parser(plan, input_args): ), ) + def parse_network_params(plan, input_args): result = default_input_args(input_args) @@ -60,7 +64,11 @@ def parse_network_params(plan, input_args): # if the value is set in input we set it in participant new_participant[sub_attr] = sub_value for _ in range(0, new_participant["count"]): - participant_copy = ethereum_package_input_parser.deep_copy_participant(new_participant) + participant_copy = ( + ethereum_package_input_parser.deep_copy_participant( + new_participant + ) + ) participants.append(participant_copy) result["participants"] = participants @@ -72,6 +80,7 @@ def parse_network_params(plan, input_args): return result + def default_input_args(input_args): network_params = default_network_params() participants = [default_participant()] @@ -80,11 +89,13 @@ def default_input_args(input_args): "network_params": network_params, } + def default_network_params(): return { "network": "kurtosis", } + def default_participant(): return { "el_type": "op-geth", From a97c44442bf0ff98f655c35e4fe783b8ff6eb8c1 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Mon, 3 Jun 2024 18:03:36 +0200 Subject: [PATCH 3/8] fix Dockerfile --- Dockerfile | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/Dockerfile b/Dockerfile index 67c6643..e4ab8b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -# Stage 1: Builder -FROM debian:latest AS builder +# Use the Debian base image for broader compatibility +FROM debian:latest -# Install dependencies +# Install dependencies using apt RUN apt-get update && apt-get install -y --no-install-recommends \ git \ make \ @@ -49,39 +49,6 @@ RUN git clone https://github.com/ethereum-optimism/optimism.git && \ #make op-node op-batcher op-proposer && \ pnpm build -# Stage 2: Runner -FROM debian:latest - -# Install runtime dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - bash \ - ca-certificates \ - jq \ - direnv \ - curl \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -# Copy Go from the builder stage -COPY --from=builder /usr/local/go/ /usr/local/go/ -ENV PATH="/usr/local/go/bin:${PATH}" - -# Copy pnpm from the builder stage -COPY --from=builder /usr/local/lib/node_modules/pnpm /usr/local/lib/node_modules/pnpm -COPY --from=builder /usr/local/bin/pnpm /usr/local/bin/pnpm - -# Copy web3 cli from the builder stage -COPY --from=builder /usr/local/bin/web3 /usr/local/bin/web3 - -# Copy Rust and Foundry from the builder stage -COPY --from=builder /root/.cargo /root/.cargo -ENV PATH="/root/.cargo/bin:${PATH}" - -# Copy the built application from the builder stage -COPY --from=builder /workspace/optimism /workspace/optimism - -# Set the working directory -WORKDIR /workspace/optimism - # Verify installed versions RUN git --version && \ go version && \ @@ -93,5 +60,8 @@ RUN git --version && \ jq --version && \ direnv --version +# Set the working directory +WORKDIR /workspace/optimism + # Default command CMD ["bash"] From 658a0936a2d17e9d00411bf4f7a99cbd0730f01e Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Mon, 3 Jun 2024 18:20:23 +0200 Subject: [PATCH 4/8] add actions --- .../conventional-pr-title-checker.yml | 22 +++++++ .github/workflows/per-pr.yml | 64 +++++++++++++++++++ .github/workflows/release-please.yml | 15 +++++ 3 files changed, 101 insertions(+) create mode 100644 .github/workflows/conventional-pr-title-checker.yml create mode 100644 .github/workflows/per-pr.yml create mode 100644 .github/workflows/release-please.yml diff --git a/.github/workflows/conventional-pr-title-checker.yml b/.github/workflows/conventional-pr-title-checker.yml new file mode 100644 index 0000000..845b07e --- /dev/null +++ b/.github/workflows/conventional-pr-title-checker.yml @@ -0,0 +1,22 @@ +# Check PR title for conventional commits +name: Check PR title +on: + pull_request_target: + types: + - opened + - reopened + - edited + - synchronize + +# cancel redundant builds +concurrency: + group: "title-checker-${{ github.head_ref }}" + cancel-in-progress: true + +jobs: + title_check: + runs-on: ubuntu-latest + steps: + - uses: aslafy-z/conventional-pr-title-action@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/per-pr.yml b/.github/workflows/per-pr.yml new file mode 100644 index 0000000..11f5315 --- /dev/null +++ b/.github/workflows/per-pr.yml @@ -0,0 +1,64 @@ +name: CI + +on: + pull_request: + +concurrency: + group: "tests-${{ github.head_ref }}" + cancel-in-progress: true + +jobs: + run_starlark: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Kurtosis + run: | + echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list + sudo apt update + sudo apt install kurtosis-cli + kurtosis analytics disable + + - name: Run Starlark + run: kurtosis run ${{ github.workspace }} --args-file network_params.yaml + + run_with_args: + strategy: + matrix: + file_name: + [ + "./network_params.yaml" + ] + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Kurtosis + run: | + echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list + sudo apt update + sudo apt install kurtosis-cli + kurtosis analytics disable + + - name: Run Starlark + run: kurtosis run ${{ github.workspace }} --args-file ${{ matrix.file_name }} + + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Kurtosis + run: | + echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list + sudo apt update + sudo apt install kurtosis-cli + kurtosis analytics disable + + - name: Kurtosis Lint + run: kurtosis lint ${{ github.workspace }} + diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..d3027d6 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,15 @@ +on: + push: + branches: [main] + +name: release-please +jobs: + release-please: + name: "Release please" + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + with: + release-type: simple + package-name: kurtosis + include-v-in-tag: false From 8362bb844e7bd380afd5590b7ae7efc180191afb Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Mon, 3 Jun 2024 18:21:23 +0200 Subject: [PATCH 5/8] fix lint --- src/contracts/contract_deployer.star | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/contracts/contract_deployer.star b/src/contracts/contract_deployer.star index a5fa375..276abb8 100644 --- a/src/contracts/contract_deployer.star +++ b/src/contracts/contract_deployer.star @@ -10,6 +10,8 @@ ENVRC_PATH = "/workspace/optimism/.envrc" FACTORY_DEPLOYER_ADDRESS = "0x3fAB184622Dc19b6109349B94811493BF2a45362" FACTORY_DEPLOYER_CODE = "0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222" + + def launch_contract_deployer( plan, el_rpc_http_url, @@ -61,7 +63,9 @@ def launch_contract_deployer( "while true; do sleep 3; echo 'Chain is not yet finalized...'; if [ \"$(curl -s $CL_RPC_URL/eth/v1/beacon/states/head/finality_checkpoints | jq -r '.data.finalized.epoch')\" != \"0\" ]; then echo 'Chain is finalized!'; break; fi; done", "cd /workspace/optimism/packages/contracts-bedrock", "./scripts/getting-started/config.sh", - "cast publish --rpc-url $WEB3_RPC_URL {0}".format(FACTORY_DEPLOYER_CODE), + "cast publish --rpc-url $WEB3_RPC_URL {0}".format( + FACTORY_DEPLOYER_CODE + ), "sleep 12", "forge script scripts/Deploy.s.sol:Deploy --private-key $GS_ADMIN_PRIVATE_KEY --broadcast --rpc-url $L1_RPC_URL", "sleep 3", @@ -73,5 +77,5 @@ def launch_contract_deployer( "mv /workspace/optimism/packages/contracts-bedrock/deployments/getting-started/.deploy /network-configs/.deploy", ] ), - wait = "2000s", + wait="2000s", ) From a2f557090af8c26ed63636a38cbbb2f619af96b9 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Mon, 3 Jun 2024 18:24:02 +0200 Subject: [PATCH 6/8] remove unneeded extra check --- .github/workflows/per-pr.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/per-pr.yml b/.github/workflows/per-pr.yml index 11f5315..514a332 100644 --- a/.github/workflows/per-pr.yml +++ b/.github/workflows/per-pr.yml @@ -8,22 +8,6 @@ concurrency: cancel-in-progress: true jobs: - run_starlark: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Setup Kurtosis - run: | - echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list - sudo apt update - sudo apt install kurtosis-cli - kurtosis analytics disable - - - name: Run Starlark - run: kurtosis run ${{ github.workspace }} --args-file network_params.yaml - run_with_args: strategy: matrix: From ef0841ff998c2d4604c2a5b86d6a8018035aaa69 Mon Sep 17 00:00:00 2001 From: parithosh Date: Mon, 3 Jun 2024 23:22:08 +0200 Subject: [PATCH 7/8] reduce image size --- Dockerfile | 63 +++++++++++++++------------- src/contracts/contract_deployer.star | 2 +- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index e4ab8b2..2655377 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ -# Use the Debian base image for broader compatibility -FROM debian:latest +FROM debian:latest as builder + +WORKDIR /workspace # Install dependencies using apt RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -20,48 +21,54 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libusb-1.0-0-dev \ libssl-dev \ ca-certificates \ - && apt-get clean && rm -rf /var/lib/apt/lists/* + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Install pnpm +RUN npm install -g pnpm@9 # Install Go from the official golang image COPY --from=golang:alpine /usr/local/go/ /usr/local/go/ ENV PATH="/usr/local/go/bin:${PATH}" -# Install pnpm -RUN npm install -g pnpm@9 - # Install web3 cli RUN curl -LSs https://raw.githubusercontent.com/gochain/web3/master/install.sh | sh # Install Rust and Foundry -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ - . $HOME/.cargo/env && \ - cargo install --git https://github.com/foundry-rs/foundry --profile local --locked forge cast chisel anvil - -# Ensure Foundry binaries are in PATH -ENV PATH="/root/.cargo/bin:${PATH}" +RUN curl -L https://foundry.paradigm.xyz | bash +ENV PATH="/root/.foundry/bin:${PATH}" +RUN foundryup -# Clone the Optimism repository and set up the environment -WORKDIR /workspace RUN git clone https://github.com/ethereum-optimism/optimism.git && \ cd optimism && \ git checkout tutorials/chain && \ pnpm install && \ - #make op-node op-batcher op-proposer && \ pnpm build -# Verify installed versions -RUN git --version && \ - go version && \ - node --version && \ - pnpm --version && \ - forge --version && \ - cast --version && \ - make --version && \ - jq --version && \ - direnv --version -# Set the working directory -WORKDIR /workspace/optimism +# Use multi-stage build to keep the final image lean +FROM debian:stable-slim + +WORKDIR /workspace -# Default command +# Install dependencies using apt +RUN apt-get update && apt-get install -y --no-install-recommends \ + jq \ + direnv \ + bash \ + curl \ + ca-certificates \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /usr/local /usr/local +COPY --from=builder /workspace/optimism /workspace/optimism +COPY --from=builder /root/.foundry /root/.foundry + +# Set up environment variables +ENV PATH="/root/.foundry/bin:/usr/local/go/bin:${PATH}" + + +# Set the working directory and default command +WORKDIR /workspace/optimism CMD ["bash"] diff --git a/src/contracts/contract_deployer.star b/src/contracts/contract_deployer.star index a5fa375..124a2d3 100644 --- a/src/contracts/contract_deployer.star +++ b/src/contracts/contract_deployer.star @@ -4,7 +4,7 @@ MAX_CPU = 2000 MIN_MEMORY = 128 MAX_MEMORY = 1024 -IMAGE = "bbusa/op:latest" +IMAGE = "parithoshj/op-test:v3" ENVRC_PATH = "/workspace/optimism/.envrc" From 323261006f39cae410eee37a6be10a2a5fdb1766 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Tue, 4 Jun 2024 10:15:35 +0200 Subject: [PATCH 8/8] yeet limits --- src/contracts/contract_deployer.star | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/contracts/contract_deployer.star b/src/contracts/contract_deployer.star index e821760..8afc3ba 100644 --- a/src/contracts/contract_deployer.star +++ b/src/contracts/contract_deployer.star @@ -1,9 +1,3 @@ -# The min/max CPU/memory that mev-flood can use -MIN_CPU = 100 -MAX_CPU = 2000 -MIN_MEMORY = 128 -MAX_MEMORY = 1024 - IMAGE = "parithoshj/op-test:v3" ENVRC_PATH = "/workspace/optimism/.envrc"