From 384c450f61876a41c6bf0a6a9e3e6f52ff6dcf23 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 30 Apr 2024 15:54:00 +0530 Subject: [PATCH] Update L2 genesis generation --- .../optimism-contracts/deploy-contracts.sh | 11 +++++++++-- config/fixturenet-optimism/run-op-node.sh | 6 ++++-- config/fixturenet-optimism/run-op-proposer.sh | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh b/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh index e7a8a7c..9bed4a6 100755 --- a/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh +++ b/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh @@ -19,7 +19,7 @@ echo "Using L1 RPC endpoint ${CERC_L1_RPC}" if [ -d "/l1-deployment/$DEPLOYMENT_CONTEXT" ]; then echo "Deployment directory /l1-deployment/$DEPLOYMENT_CONTEXT, checking OptimismPortal deployment" - OPTIMISM_PORTAL_ADDRESS=$(cat /l1-deployment/$DEPLOYMENT_CONTEXT/OptimismPortal.json | jq -r .address) + OPTIMISM_PORTAL_ADDRESS=$(cat /l1-deployment/$DEPLOYMENT_CONTEXT/.deploy | jq -r .OptimismPortal) contract_code=$(cast code $OPTIMISM_PORTAL_ADDRESS --rpc-url $CERC_L1_RPC) if [ -z "${contract_code#0x}" ]; then @@ -150,14 +150,21 @@ fi # Writes out artifact to /app/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT/.deploy echo "Deploying L1 Optimism contracts..." forge script scripts/Deploy.s.sol:Deploy --private-key $ADMIN_KEY --broadcast --rpc-url $CERC_L1_RPC +echo "Done deploying contracts." + +echo "Generating L2 genesis allocs..." +L2_CHAIN_ID=$(jq ".l2ChainID" $deploy_config_file) +CONTRACT_ADDRESSES_PATH=deployments/$DEPLOYMENT_CONTEXT/.deploy forge script --chain-id $L2_CHAIN_ID scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithAllUpgrades()' --private-key $ADMIN_KEY +echo "{ \"accounts\": $(jq '.' /app/packages/contracts-bedrock/state-dump-$L2_CHAIN_ID.json) }" > allocs-l2.json +echo "Done." echo "*************************************" -echo "Done deploying contracts." # Copy files needed by other containers to the appropriate shared volumes echo "Copying deployment artifacts volume l1_deployment and deploy-config to volume l2_config" cp -a /app/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT /l1-deployment cp /app/packages/contracts-bedrock/deploy-config/$DEPLOYMENT_CONTEXT.json /l2-config +cp allocs-l2.json /l2-config openssl rand -hex 32 > /l2-config/l2-jwt.txt echo "Deployment successful. Exiting" diff --git a/config/fixturenet-optimism/run-op-node.sh b/config/fixturenet-optimism/run-op-node.sh index 0b70c08..fde4a34 100755 --- a/config/fixturenet-optimism/run-op-node.sh +++ b/config/fixturenet-optimism/run-op-node.sh @@ -9,7 +9,8 @@ CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}" DEPLOYMENT_CONTEXT="$CERC_L1_CHAIN_ID" deploy_config_file="/l2-config/$DEPLOYMENT_CONTEXT.json" -deployment_dir="/l1-deployment/$DEPLOYMENT_CONTEXT" +l1_deployment_file="/l1-deployment/$DEPLOYMENT_CONTEXT/.deploy" +l2_allocs_file="/l2-config/allocs-l2.json" genesis_outfile="/l2-config/genesis.json" rollup_outfile="/l2-config/rollup.json" @@ -17,7 +18,8 @@ rollup_outfile="/l2-config/rollup.json" if [ ! -f "$genesis_outfile" ] || [ ! -f "$rollup_outfile" ]; then op-node genesis l2 \ --deploy-config $deploy_config_file \ - --deployment-dir $deployment_dir \ + --l1-deployments $l1_deployment_file \ + --l2-allocs $l2_allocs_file \ --outfile.l2 $genesis_outfile \ --outfile.rollup $rollup_outfile \ --l1-rpc $CERC_L1_RPC diff --git a/config/fixturenet-optimism/run-op-proposer.sh b/config/fixturenet-optimism/run-op-proposer.sh index 092705c..734cc9e 100755 --- a/config/fixturenet-optimism/run-op-proposer.sh +++ b/config/fixturenet-optimism/run-op-proposer.sh @@ -11,7 +11,7 @@ DEPLOYMENT_CONTEXT="$CERC_L1_CHAIN_ID" # Start op-proposer ROLLUP_RPC="http://op-node:8547" PROPOSER_KEY=$(cat /l2-accounts/accounts.json | jq -r .ProposerKey) -L2OO_ADDR=$(cat /l1-deployment/$DEPLOYMENT_CONTEXT/L2OutputOracleProxy.json | jq -r .address) +L2OO_ADDR=$(cat /l1-deployment/$DEPLOYMENT_CONTEXT/.deploy | jq -r .L2OutputOracleProxy) op-proposer \ --poll-interval=12s \