From 4b0a390b7aaf4a0c792b167adcec212ab0510068 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Tue, 4 Jun 2024 15:39:31 +0200 Subject: [PATCH] add latest contract --- Dockerfile | 5 ++-- README.md | 14 ++++++++++ main.star | 39 +++++++++++++++++++++------- src/contracts/contract_deployer.star | 24 ++++++++++------- src/package_io/input_parser.star | 2 ++ 5 files changed, 64 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2e5c7f7..316b1e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,9 +39,9 @@ RUN curl -L https://foundry.paradigm.xyz | bash ENV PATH="/root/.foundry/bin:${PATH}" RUN foundryup -RUN git clone https://github.com/ethereum-optimism/optimism.git && \ +RUN git clone https://github.com/barnabasbusa/optimism.git && \ cd optimism && \ - git checkout develop && \ + git checkout bbusa/customize-chain-info && \ pnpm install && \ pnpm build @@ -55,6 +55,7 @@ WORKDIR /workspace RUN apt-get update && apt-get install -y --no-install-recommends \ jq \ direnv \ + git \ bash \ curl \ ca-certificates \ diff --git a/README.md b/README.md index e5167c2..10bbd48 100644 --- a/README.md +++ b/README.md @@ -1 +1,15 @@ ## Welcome to Optimism Package +default package for Optimism +```yaml +optimism_package: + participants: + - el_type: op-geth + el_image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:latest + cl_type: op-node + cl_image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:develop + count: 1 + network_params: + network: kurtosis + network_id: "2151908" + seconds_per_slot: 2 +``` diff --git a/main.star b/main.star index 68140be..e414c35 100644 --- a/main.star +++ b/main.star @@ -7,6 +7,14 @@ static_files = import_module( participant_network = import_module("./src/participant_network.star") +def get_l1_stuff(all_l1_participants, l1_network_params): + 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 + l1_chain_id = l1_network_params.network_id + l1_block_time = l1_network_params.seconds_per_slot + return first_l1_el_node, first_l1_cl_node, l1_chain_id, l1_block_time + + def run(plan, args={}): """Deploy a Optimism L2 with a local L1. @@ -25,30 +33,43 @@ def run(plan, args={}): plan.print("Deploying a local L1") l1 = ethereum_package.run(plan, ethereum_args) all_l1_participants = l1.all_participants + l1_network_params = l1.network_params 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 - el_cl_data = 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") optimism_args = args["optimism_package"] + first_l1_el_node, first_l1_cl_node, l1_chain_id, l1_block_time = get_l1_stuff( + all_l1_participants, l1_network_params + ) + + args_with_right_defaults = input_parser.input_parser(plan, optimism_args) + network_params = args_with_right_defaults.network_params + + l2_block_time = network_params.seconds_per_slot + l2_chain_id = network_params.network_id + + el_cl_data = contract_deployer.launch_contract_deployer( + plan, + first_l1_el_node, + first_l1_cl_node, + priv_key, + l1_chain_id, + l2_chain_id, + l1_block_time, + l2_block_time, + ) + # Deploy the L2 plan.print("Deploying a local L2") - args_with_right_defaults = input_parser.input_parser(plan, optimism_args) jwt_file = plan.upload_files( src=static_files.JWT_PATH_FILEPATH, name="op_jwt_file", ) - network_params = args_with_right_defaults.network_params all_participants = participant_network.launch_participant_network( plan, diff --git a/src/contracts/contract_deployer.star b/src/contracts/contract_deployer.star index 1834f28..daeba23 100644 --- a/src/contracts/contract_deployer.star +++ b/src/contracts/contract_deployer.star @@ -1,4 +1,4 @@ -IMAGE = "parithoshj/op-test:v3" +IMAGE = "bbusa/op:latest" ENVRC_PATH = "/workspace/optimism/.envrc" @@ -11,6 +11,10 @@ def launch_contract_deployer( el_rpc_http_url, cl_rpc_http_url, priv_key, + l1_chain_id, + l2_chain_id, + l1_block_time, + l2_block_time, ): op_genesis = 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)", @@ -20,6 +24,15 @@ def launch_contract_deployer( "WEB3_PRIVATE_KEY": str(priv_key), "CL_RPC_URL": str(cl_rpc_http_url), "FUND_VALUE": "10", + "DEPLOYMENT_OUTFILE": "deployments/artifact.json", + "DEPLOY_CONFIG_PATH": "/workspace/optimism/packages/contracts-bedrock/deployments/getting-started/", + "L1_RPC_KIND": "any", + "L1_RPC_URL": str(el_rpc_http_url), + "L1_CHAIN_ID": str(l1_chain_id), + "L2_CHAIN_ID": str(l2_chain_id), + "L1_BLOCK_TIME": str(l1_block_time), + "L2_BLOCK_TIME": str(l2_block_time), + "DEPLOYMENT_CONTEXT": "getting-started", }, store=[ StoreSpec(src="/network-configs", name="op-genesis-configs"), @@ -32,17 +45,11 @@ def launch_contract_deployer( "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), + "mkdir -p /network-configs", "web3 transfer $FUND_VALUE to $GS_ADMIN_ADDRESS", # Fund Admin "sleep 3", "web3 transfer $FUND_VALUE to $GS_BATCHER_ADDRESS", # Fund Batcher @@ -65,7 +72,6 @@ def launch_contract_deployer( "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", diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index ff841c0..4f467fa 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -41,6 +41,7 @@ def input_parser(plan, input_args): network_params=struct( network=result["network_params"]["network"], network_id=result["network_params"]["network_id"], + seconds_per_slot=result["network_params"]["seconds_per_slot"], ), ) @@ -95,6 +96,7 @@ def default_network_params(): return { "network": "kurtosis", "network_id": "2151908", + "seconds_per_slot": 2, }