diff --git a/compose/docker-compose-fixturenet-optimism.yml b/compose/docker-compose-fixturenet-optimism.yml index d59608d..b260900 100644 --- a/compose/docker-compose-fixturenet-optimism.yml +++ b/compose/docker-compose-fixturenet-optimism.yml @@ -29,14 +29,33 @@ services: extra_hosts: - "host.docker.internal:host-gateway" + l2-config-generation: + restart: on-failure + image: cerc/optimism-op-node:local + depends_on: + fixturenet-optimism-contracts: + condition: service_completed_successfully + env_file: + - ../config/fixturenet-optimism/l1-params.env + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_L1_CHAIN_ID: ${CERC_L1_CHAIN_ID} + CERC_L1_RPC: ${CERC_L1_RPC} + volumes: + - ../config/fixturenet-optimism/generate-l2-config.sh:/generate-l2-config.sh + - l1_deployment:/l1-deployment:ro + - l2_config:/l2-config + entrypoint: "bash" + command: "/generate-l2-config.sh" + # Initializes and runs the L2 execution client (outputs to volume l2_geth_data) op-geth: restart: always image: cerc/optimism-l2geth:local hostname: op-geth depends_on: - op-node: - condition: service_started + l2-config-generation: + condition: service_completed_successfully volumes: - ../config/fixturenet-optimism/run-op-geth.sh:/run-op-geth.sh - l2_config:/l2-config:ro @@ -63,8 +82,8 @@ services: image: cerc/optimism-op-node:local hostname: op-node depends_on: - fixturenet-optimism-contracts: - condition: service_completed_successfully + op-geth: + condition: service_healthy env_file: - ../config/fixturenet-optimism/l1-params.env environment: diff --git a/config/fixturenet-optimism/generate-l2-config.sh b/config/fixturenet-optimism/generate-l2-config.sh new file mode 100644 index 0000000..4274dd7 --- /dev/null +++ b/config/fixturenet-optimism/generate-l2-config.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +CERC_L1_CHAIN_ID="${CERC_L1_CHAIN_ID:-${DEFAULT_CERC_L1_CHAIN_ID}}" +CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}" +DEPLOYMENT_CONTEXT="$CERC_L1_CHAIN_ID" + +deploy_config_file="/l2-config/$DEPLOYMENT_CONTEXT.json" +l1_deployment_file="/l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json" +l2_allocs_file="/l2-config/allocs-l2.json" +genesis_outfile="/l2-config/genesis.json" +rollup_outfile="/l2-config/rollup.json" + +# Check if genesis.json and rollup.json already exist +if [ -f "$genesis_outfile" ] && [ -f "$rollup_outfile" ]; then + echo "Skipping generation, files already exist: $genesis_outfile, $rollup_outfile" + exit 0 +fi + +# If files don't exist, proceed with generation +echo "Generating l2 config files..." + +op-node genesis l2 \ + --deploy-config "$deploy_config_file" \ + --l1-deployments "$l1_deployment_file" \ + --l2-allocs "$l2_allocs_file" \ + --outfile.l2 "$genesis_outfile" \ + --outfile.rollup "$rollup_outfile" \ + --l1-rpc "$CERC_L1_RPC" + +echo "Generated the l2 config files successfully" +echo "Exiting" diff --git a/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh b/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh index 9bed4a6..5146141 100755 --- a/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh +++ b/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh @@ -16,10 +16,10 @@ export IMPL_SALT=$(openssl rand -hex 32) echo "Using L1 RPC endpoint ${CERC_L1_RPC}" # Exit if a deployment already exists (on restarts) -if [ -d "/l1-deployment/$DEPLOYMENT_CONTEXT" ]; then - echo "Deployment directory /l1-deployment/$DEPLOYMENT_CONTEXT, checking OptimismPortal deployment" +if [ -d "/l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json" ]; then + echo "Deployment directory /l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json, checking OptimismPortal deployment" - OPTIMISM_PORTAL_ADDRESS=$(cat /l1-deployment/$DEPLOYMENT_CONTEXT/.deploy | jq -r .OptimismPortal) + OPTIMISM_PORTAL_ADDRESS=$(cat /l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json | jq -r .OptimismPortal) contract_code=$(cast code $OPTIMISM_PORTAL_ADDRESS --rpc-url $CERC_L1_RPC) if [ -z "${contract_code#0x}" ]; then @@ -117,7 +117,16 @@ if [ -z "$finalized" ]; then fi # Generate the deploy-config/getting-started.json file -GS_ADMIN_ADDRESS=$ADMIN GS_BATCHER_ADDRESS=$BATCHER GS_PROPOSER_ADDRESS=$PROPOSER GS_SEQUENCER_ADDRESS=$SEQ L1_RPC_URL=$CERC_L1_RPC $config_build_script +GS_ADMIN_ADDRESS=$ADMIN \ +GS_BATCHER_ADDRESS=$BATCHER \ +GS_PROPOSER_ADDRESS=$PROPOSER \ +GS_SEQUENCER_ADDRESS=$SEQ \ +L1_RPC_URL=$CERC_L1_RPC \ +L1_CHAIN_ID=$CERC_L1_CHAIN_ID \ +L2_CHAIN_ID=42069 \ +L1_BLOCK_TIME=12 \ +L2_BLOCK_TIME=2 \ +$config_build_script echo "Writing deployment config." deploy_config_file="deploy-config/$DEPLOYMENT_CONTEXT.json" @@ -127,7 +136,6 @@ cp deploy-config/getting-started.json $deploy_config_file # 1. Update L1 chain id # 2. Add missing faultGameWithdrawalDelay field # (see issue: https://github.com/ethereum-optimism/optimism/issues/9773#issuecomment-2080224969) -echo "$(jq ". += {"l1ChainID": $DEPLOYMENT_CONTEXT, "faultGameWithdrawalDelay": 604800}" $deploy_config_file)" > $deploy_config_file mkdir -p deployments/$DEPLOYMENT_CONTEXT @@ -147,22 +155,24 @@ if [ "$create2CodeSize" -eq 0 ]; then fi # Create the L2 deployment -# Writes out artifact to /app/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT/.deploy +# Writes out artifact to /app/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT-deploy.json echo "Deploying L1 Optimism contracts..." -forge script scripts/Deploy.s.sol:Deploy --private-key $ADMIN_KEY --broadcast --rpc-url $CERC_L1_RPC +DEPLOY_CONFIG_PATH=$deploy_config_file 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." +DEPLOY_CONFIG_PATH=$deploy_config_file \ +CONTRACT_ADDRESSES_PATH=deployments/$DEPLOYMENT_CONTEXT-deploy.json \ +forge script --chain-id $L2_CHAIN_ID scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithAllUpgrades()' --private-key $ADMIN_KEY +cp /app/packages/contracts-bedrock/state-dump-$L2_CHAIN_ID.json allocs-l2.json +echo "Done." echo "*************************************" # 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/deployments/$DEPLOYMENT_CONTEXT-deploy.json /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 diff --git a/config/fixturenet-optimism/run-op-node.sh b/config/fixturenet-optimism/run-op-node.sh index fde4a34..005c7e1 100755 --- a/config/fixturenet-optimism/run-op-node.sh +++ b/config/fixturenet-optimism/run-op-node.sh @@ -9,22 +9,11 @@ CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}" DEPLOYMENT_CONTEXT="$CERC_L1_CHAIN_ID" deploy_config_file="/l2-config/$DEPLOYMENT_CONTEXT.json" -l1_deployment_file="/l1-deployment/$DEPLOYMENT_CONTEXT/.deploy" +l1_deployment_file="/l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json" l2_allocs_file="/l2-config/allocs-l2.json" genesis_outfile="/l2-config/genesis.json" rollup_outfile="/l2-config/rollup.json" -# Generate L2 genesis (if not already done) -if [ ! -f "$genesis_outfile" ] || [ ! -f "$rollup_outfile" ]; then - op-node genesis l2 \ - --deploy-config $deploy_config_file \ - --l1-deployments $l1_deployment_file \ - --l2-allocs $l2_allocs_file \ - --outfile.l2 $genesis_outfile \ - --outfile.rollup $rollup_outfile \ - --l1-rpc $CERC_L1_RPC -fi - # Start op-node SEQ_KEY=$(cat /l2-accounts/accounts.json | jq -r .SeqKey) jwt_file=/l2-config/l2-jwt.txt @@ -44,4 +33,5 @@ op-node \ --rpc.enable-admin \ --p2p.sequencer.key="${SEQ_KEY#0x}" \ --l1=$CERC_L1_RPC \ - --l1.rpckind=$RPC_KIND + --l1.rpckind=$RPC_KIND \ + --l1.beacon=http://fixturenet-eth-lighthouse-1:8001 diff --git a/config/fixturenet-optimism/run-op-proposer.sh b/config/fixturenet-optimism/run-op-proposer.sh index 734cc9e..a11349c 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/.deploy | jq -r .L2OutputOracleProxy) +L2OO_ADDR=$(cat /l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json | jq -r .L2OutputOracleProxy) op-proposer \ --poll-interval=12s \ diff --git a/container-build/cerc-optimism-op-batcher/Dockerfile b/container-build/cerc-optimism-op-batcher/Dockerfile index ed15e02..541d0fd 100644 --- a/container-build/cerc-optimism-op-batcher/Dockerfile +++ b/container-build/cerc-optimism-op-batcher/Dockerfile @@ -6,7 +6,6 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash # build op-batcher with the shared go.mod & go.sum files COPY ./op-batcher /app/op-batcher -COPY ./op-bindings /app/op-bindings COPY ./op-node /app/op-node COPY ./op-service /app/op-service COPY ./op-plasma /app/op-plasma diff --git a/container-build/cerc-optimism-op-node/Dockerfile b/container-build/cerc-optimism-op-node/Dockerfile index 2044f33..4cb276f 100644 --- a/container-build/cerc-optimism-op-node/Dockerfile +++ b/container-build/cerc-optimism-op-node/Dockerfile @@ -8,7 +8,6 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash COPY ./op-node /app/op-node COPY ./op-chain-ops /app/op-chain-ops COPY ./op-service /app/op-service -COPY ./op-bindings /app/op-bindings COPY ./op-plasma /app/op-plasma COPY ./op-conductor /app/op-conductor COPY ./go.mod /app/go.mod diff --git a/container-build/cerc-optimism-op-proposer/Dockerfile b/container-build/cerc-optimism-op-proposer/Dockerfile index 7733367..99d76a2 100644 --- a/container-build/cerc-optimism-op-proposer/Dockerfile +++ b/container-build/cerc-optimism-op-proposer/Dockerfile @@ -6,7 +6,6 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash # build op-proposer with the shared go.mod & go.sum files COPY ./op-proposer /app/op-proposer -COPY ./op-bindings /app/op-bindings COPY ./op-node /app/op-node COPY ./op-service /app/op-service COPY ./op-plasma /app/op-plasma diff --git a/stack/fixturenet-optimism/stack.yml b/stack/fixturenet-optimism/stack.yml index 0ee05f3..dff9242 100644 --- a/stack/fixturenet-optimism/stack.yml +++ b/stack/fixturenet-optimism/stack.yml @@ -3,8 +3,8 @@ name: fixturenet-optimism description: "Optimism Fixturenet" repos: # L2 (optimism) - - github.com/ethereum-optimism/optimism@v1.7.4 - - github.com/ethereum-optimism/op-geth@v1.101311.0 + - github.com/ethereum-optimism/optimism@v1.7.7 + - github.com/ethereum-optimism/op-geth@v1.101315.2 containers: # L2 (optimism) - cerc/optimism-contracts