From d7886ed5fa318876723de6ae3af73eaea7b5f8ac Mon Sep 17 00:00:00 2001 From: cddrown Date: Fri, 16 Aug 2024 11:52:43 +0100 Subject: [PATCH 01/21] Replace pnpm with just --- Dockerfile | 9 ++++++--- scripts/prepare.sh | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4ce73c6..97846a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,10 @@ RUN mkdir -p /etc/apt/keyrings && \ apt-get install nodejs -y # Install PNPM -RUN npm install -g pnpm +#RUN npm install -g pnpm + +# Install just +RUN apt install just # Install Go RUN ARCH=$(dpkg --print-architecture) && echo "Architecture: ${ARCH}" && \ @@ -59,8 +62,8 @@ RUN chmod +x /app/clone-repos.sh RUN chmod +x /app/prepare.sh # MacOS pnpm fix -RUN mkdir -p /app/pnpm/store -RUN pnpm config set store-dir /app/pnpm/store +#RUN mkdir -p /app/pnpm/store +#RUN pnpm config set store-dir /app/pnpm/store # Set the clone-repos.sh script as the entry point ENTRYPOINT ["/app/prepare.sh"] diff --git a/scripts/prepare.sh b/scripts/prepare.sh index fd8599e..171d806 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -10,9 +10,11 @@ set -e if [ ! -f "$BIN_DIR/op-node" ] || [ ! -f "$BIN_DIR/op-batcher" ] || [ ! -f "$BIN_DIR/op-proposer" ] || [ ! -f "$BIN_DIR/geth" ]; then # Build op-node, op-batcher and op-proposer cd "$OPTIMISM_DIR" - pnpm install + #pnpm install + just install make op-node op-batcher op-proposer - pnpm build + #pnpm build + just build # Copy binaries to the bin volume cp -f "$OPTIMISM_DIR"/op-node/bin/op-node "$BIN_DIR"/ From 04a7757a22429005de2d3ce876974b839ab4e3e4 Mon Sep 17 00:00:00 2001 From: cddrown Date: Fri, 16 Aug 2024 18:01:07 +0100 Subject: [PATCH 02/21] Fixed docker just installation --- Dockerfile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 97846a9..86448d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,8 +24,21 @@ RUN mkdir -p /etc/apt/keyrings && \ # Install PNPM #RUN npm install -g pnpm +# Set the makedeb release you want. +ENV MAKEDEB_RELEASE='makedeb' + +# Run the install script. Note that it's `bash -c` and not `bash -ci` now. +RUN [/bin/bash, -c, "$(wget -qO - 'https://shlink.makedeb.org/install')"] + +RUN git clone https://mpr.makedeb.org/just +RUN cd just +RUN makedeb -si +RUN cd .. + # Install just -RUN apt install just +RUN mkdir -p /app/bin +RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /app/bin +ENV PATH="$PATH:/app/bin" # Install Go RUN ARCH=$(dpkg --print-architecture) && echo "Architecture: ${ARCH}" && \ From 5def60bee08eff87a4da603c0ad54cce25763c2d Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sat, 17 Aug 2024 19:22:46 +0300 Subject: [PATCH 03/21] chore: improve logs --- scripts/prepare.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index fd8599e..6d444da 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -30,18 +30,18 @@ fi # Create jwt.txt if it does not exist [ -f "$CONFIG_PATH/jwt.txt" ] || openssl rand -hex 32 > "$CONFIG_PATH"/jwt.txt -# Check if all required config files exist +# Check if all required genesis files exist if [ -f "$CONFIG_PATH/genesis.json" ] && [ -f "$CONFIG_PATH/rollup.json" ]; then - echo "L2 config files are present, skipping script." + echo "L2 genesis files are present, skipping prepare.sh script." exec "$@" exit 0 elif [ -f "$CONFIG_PATH/genesis.json" ] || [ -f "$CONFIG_PATH/rollup.json" ]; then - echo "Error: Partial L2 config files are present, but not all. Exiting script." + echo "Error: One of the genesis.json or rollup.json files is missing." exit 1 fi -# If no components exist, continue with the script -echo "No required components are present, continuing script execution." +# If no genesis files exist, continue with the script +echo "No required genesis files are present, continuing script execution." # Check if all or none of the private keys are provided if [ -z "$BATCHER_PRIVATE_KEY" ] && [ -z "$PROPOSER_PRIVATE_KEY" ] && [ -z "$SEQUENCER_PRIVATE_KEY" ]; then From 1533ad33ad8b25c1865ae76b1da6a8a2861f04a1 Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sat, 17 Aug 2024 19:24:35 +0300 Subject: [PATCH 04/21] refactor: remove unnecessary setting of L1_BLOCKHASH and L1_TIMESTAMP vars --- scripts/prepare.sh | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 6d444da..2eb04d1 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -60,20 +60,6 @@ else exit 1 fi -# Check if both L1_BLOCKHASH and L1_TIMESTAMP are set or unset -if [ -n "$L1_BLOCKHASH" ] && [ -z "$L1_TIMESTAMP" ] || [ -z "$L1_BLOCKHASH" ] && [ -n "$L1_TIMESTAMP" ]; then - echo "Error: Both L1_BLOCKHASH and L1_TIMESTAMP must be set or unset." - exit 1 -elif [ -z "$L1_BLOCKHASH" ] && [ -z "$L1_TIMESTAMP" ]; then - # Fetch block details if both variables are unset - echo "Fetching block details from L1_RPC_URL..." - block=$(cast block finalized --rpc-url "$L1_RPC_URL") - L1_TIMESTAMP=$(echo "$block" | awk '/timestamp/ { print $2 }') - export L1_TIMESTAMP - L1_BLOCKHASH=$(echo "$block" | awk '/hash/ { print $2 }') - export L1_BLOCKHASH -fi - L1_CHAIN_ID=$(cast chain-id --rpc-url "$L1_RPC_URL") export L1_CHAIN_ID From 677d2d013f3f6d4f0a10aa1b528a69a4c64514d4 Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sat, 17 Aug 2024 21:41:19 +0300 Subject: [PATCH 05/21] feat: v1.7.7-v1.9.0 deployment fix --- entrypoints/op-proposer.sh | 6 ++--- scripts/prepare.sh | 55 ++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/entrypoints/op-proposer.sh b/entrypoints/op-proposer.sh index 820fb83..a5e33f2 100644 --- a/entrypoints/op-proposer.sh +++ b/entrypoints/op-proposer.sh @@ -13,12 +13,12 @@ fi # Check if OP_PROPOSER_L2OO_ADDRESS environment variable is set if [ -z "$OP_PROPOSER_L2OO_ADDRESS" ]; then # If not set, check if the file exists - if [ ! -f "$DEPLOYMENT_DIR/.deploy" ]; then - echo "File $DEPLOYMENT_DIR/.deploy does not exist. Please import data/deployments or set the OP_PROPOSER_L2OO_ADDRESS variable." + if [ ! -f "$DEPLOYMENT_DIR/artifact.json" ]; then + echo "File $DEPLOYMENT_DIR/artifact.json does not exist. Please import data/deployments or set the OP_PROPOSER_L2OO_ADDRESS variable." exit 1 fi # Use the address from the $DEPLOYMENT_DIR - OP_PROPOSER_L2OO_ADDRESS=$(jq -r .L2OutputOracleProxy $DEPLOYMENT_DIR/.deploy) + OP_PROPOSER_L2OO_ADDRESS=$(jq -r .L2OutputOracleProxy $DEPLOYMENT_DIR/artifact.json) fi exec "$BIN_DIR"/op-proposer diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 2eb04d1..ba7514e 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -60,6 +60,7 @@ else exit 1 fi +# Get L1 chain ID and export it L1_CHAIN_ID=$(cast chain-id --rpc-url "$L1_RPC_URL") export L1_CHAIN_ID @@ -82,26 +83,21 @@ rm -f ./deploy-config/internal-opstack-compose.json if [ -f "/app/data/configurations/deploy-config.json" ]; then # Populate deploy-config.json with env variables echo "Populating deploy-config.json with env variables..." - # NOTE: scripts/Deploy.s.sol:Deploy expects the deploy-config.json file to be in $OPTIMISM_DIR/packages/contracts-bedrock/deploy-config/ envsubst < /app/data/configurations/deploy-config.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json -elif [ -f "./deploy-config/$DEPLOYMENT_CONTEXT.json" ]; then - # Populate deploy-config.json with env variables - echo "Populating deploy-config.json with env variables..." - # NOTE: scripts/Deploy.s.sol:Deploy expects the deploy-config.json file to be in $OPTIMISM_DIR/packages/contracts-bedrock/deploy-config/ - envsubst < ./deploy-config/$DEPLOYMENT_CONTEXT.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json else - # If deploy-config.json does not exist, use config.sh to generate it - echo "Generating deploy-config.json..." + # If deploy-config.json does not exist, use config.sh to generate getting-started.json + echo "Generating getting-started.json..." ./scripts/getting-started/config.sh mv ./deploy-config/getting-started.json ./deploy-config/internal-opstack-compose.json fi # Fix L1 and L2 Chain ID to the one set in the environment variable -export BATCH_INBOX_ADDRESS_TEMP=$(openssl rand -hex 32 | head -c 40) +BATCH_INBOX_ADDRESS_TEMP=$(openssl rand -hex 32 | head -c 40) +export BATCH_INBOX_ADDRESS_TEMP jq \ - --argjson l1ChainID $L1_CHAIN_ID \ - --argjson l2ChainID $L2_CHAIN_ID \ + --argjson l1ChainID "$L1_CHAIN_ID" \ + --argjson l2ChainID "$L2_CHAIN_ID" \ --arg batchInboxAddress "0x$BATCH_INBOX_ADDRESS_TEMP" \ '.l1ChainID = $l1ChainID | .l2ChainID = $l2ChainID | .batchInboxAddress = $batchInboxAddress' \ ./deploy-config/internal-opstack-compose.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json @@ -116,42 +112,37 @@ cat ./deploy-config/internal-opstack-compose.json # Generate IMPL_SALT if [ -z "$IMPL_SALT" ]; then - export IMPL_SALT=$(sha256sum ./deploy-config/internal-opstack-compose.json | cut -d ' ' -f1) + IMPL_SALT=$(sha256sum ./deploy-config/internal-opstack-compose.json | cut -d ' ' -f1) + export IMPL_SALT fi # If not deployed -if [ ! -f /app/data/deployments/.deploy ]; then - # Set deployment context to internal - export DEPLOYMENT_CONTEXT=internal-opstack-compose - - export DEPLOY_CONFIG_PATH=deploy-config/internal-opstack-compose.json - mkdir -p deployments - mkdir deployments/internal-opstack-compose - export DEPLOYMENT_OUTFILE="$OPTIMISM_DIR"/packages/contracts-bedrock/deployments/"$DEPLOYMENT_CONTEXT"/.deploy +if [ ! -f /app/data/deployments/artifact.json ]; then + export DEPLOYMENT_OUTFILE=./deployments/artifact.json + export DEPLOY_CONFIG_PATH=./deploy-config/internal-opstack-compose.json # Deploy the L1 contracts - forge script scripts/Deploy.s.sol:Deploy --private-key "$DEPLOYER_PRIVATE_KEY" --broadcast --rpc-url "$L1_RPC_URL" - - # Save the deployment address - cp -r "$OPTIMISM_DIR"/packages/contracts-bedrock/deployments/"$DEPLOYMENT_CONTEXT"/. /app/data/deployments/ + forge script scripts/deploy/Deploy.s.sol:Deploy --private-key "$DEPLOYER_PRIVATE_KEY" --broadcast --rpc-url "$L1_RPC_URL" - # Copy deploy-config.json to the configurations volume - cp ./deploy-config/internal-opstack-compose.json "$CONFIG_PATH"/deploy-config.json + # Copy the deployment files to the data volume + cp $DEPLOYMENT_OUTFILE /app/data/deployments/ + cp $DEPLOY_CONFIG_PATH "$CONFIG_PATH"/deploy-config.json fi -export CONTRACT_ADDRESSES_PATH=/app/data/deployments/.deploy +export CONTRACT_ADDRESSES_PATH=/app/data/deployments/artifact.json +export DEPLOY_CONFIG_PATH="$CONFIG_PATH"/deploy-config.json export STATE_DUMP_PATH=/app/data/deployments/allocs.json -forge script scripts/L2Genesis.s.sol:L2Genesis --chain-id $L2_CHAIN_ID --sig 'runWithAllUpgrades()' --private-key $DEPLOYER_PRIVATE_KEY +forge script scripts/L2Genesis.s.sol:L2Genesis --chain-id $L2_CHAIN_ID --sig 'runWithAllUpgrades()' --private-key $DEPLOYER_PRIVATE_KEY # OR runWithStateDump() -# Generate the L2 config files +# Generate the L2 genesis files cd "$OPTIMISM_DIR"/op-node go run cmd/main.go genesis l2 \ - --deploy-config "$CONFIG_PATH"/deploy-config.json \ - --l1-deployments "/app/data/deployments/.deploy" \ + --deploy-config "$DEPLOY_CONFIG_PATH" \ + --l1-deployments $CONTRACT_ADDRESSES_PATH \ --outfile.l2 genesis.json \ --outfile.rollup rollup.json \ --l1-rpc "$L1_RPC_URL" \ - --l2-allocs /app/data/deployments/allocs.json + --l2-allocs $STATE_DUMP_PATH cp genesis.json "$CONFIG_PATH"/ cp rollup.json "$CONFIG_PATH"/ From f90f9bae4e023187f5bd1c0d97ec6d426f1fe9fd Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sat, 17 Aug 2024 21:46:22 +0300 Subject: [PATCH 06/21] feat: OP Stack v1.9.0 --- .env.example | 7 ++----- scripts/clone-repos.sh | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 0669dfa..2d18a8b 100644 --- a/.env.example +++ b/.env.example @@ -19,10 +19,10 @@ CELESTIA_MODE=false # If not set, default to the official optimism implementation OPTIMISM_REPO_URL=https://github.com/ethereum-optimism/optimism.git -OPTIMISM_BRANCH_OR_COMMIT=v1.8.0 +OPTIMISM_BRANCH_OR_COMMIT=v1.9.0 OP_GETH_REPO_URL=https://github.com/ethereum-optimism/op-geth.git -OP_GETH_BRANCH_OR_COMMIT=v1.101315.2 +OP_GETH_BRANCH_OR_COMMIT=v1.101315.3 ################################################## # Accounts Info # @@ -66,9 +66,6 @@ L2_CHAIN_ID=42069 L2_BLOCK_TIME=2 -# Name for the deploy config file (Default to getting-started) -DEPLOYMENT_CONTEXT=getting-started - ################################################## # celestia-da Configuration # ################################################## diff --git a/scripts/clone-repos.sh b/scripts/clone-repos.sh index a9a9588..576c708 100644 --- a/scripts/clone-repos.sh +++ b/scripts/clone-repos.sh @@ -67,9 +67,9 @@ clone_repo() { # Use environment variables if set, otherwise default to the official repositories OPTIMISM_REPO=${OPTIMISM_REPO_URL:-https://github.com/ethereum-optimism/optimism.git} -OPTIMISM_BRANCH_OR_COMMIT=${OPTIMISM_BRANCH_OR_COMMIT:-op-node/v1.3.0} +OPTIMISM_BRANCH_OR_COMMIT=${OPTIMISM_BRANCH_OR_COMMIT:-v1.9.0} OP_GETH_REPO=${OP_GETH_REPO_URL:-https://github.com/ethereum-optimism/op-geth.git} -OP_GETH_BRANCH_OR_COMMIT=${OP_GETH_BRANCH_OR_COMMIT:-v1.101304.2} +OP_GETH_BRANCH_OR_COMMIT=${OP_GETH_BRANCH_OR_COMMIT:-v1.101315.3} # Cloning repositories clone_repo "$OPTIMISM_REPO" "$OPTIMISM_BRANCH_OR_COMMIT" "$OPTIMISM_DIR" || exit 1 From 2c8eeaa9908f9582c74990f0466ebfd9dad4c60e Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sat, 17 Aug 2024 23:18:08 +0300 Subject: [PATCH 07/21] fix(deployment): generating l2 allocs --- scripts/prepare.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index ba7514e..f89016c 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -116,11 +116,12 @@ if [ -z "$IMPL_SALT" ]; then export IMPL_SALT fi +# NOTE: The $DEPLOYMENT_OUTFILE and $DEPLOY_CONFIG_PATH vars are required for line 136 +export DEPLOYMENT_OUTFILE=./deployments/artifact.json +export DEPLOY_CONFIG_PATH=./deploy-config/internal-opstack-compose.json # "$CONFIG_PATH"/deploy-config.json not suitable due to the error "... not allowed to be accessed for read operations" + # If not deployed if [ ! -f /app/data/deployments/artifact.json ]; then - export DEPLOYMENT_OUTFILE=./deployments/artifact.json - export DEPLOY_CONFIG_PATH=./deploy-config/internal-opstack-compose.json - # Deploy the L1 contracts forge script scripts/deploy/Deploy.s.sol:Deploy --private-key "$DEPLOYER_PRIVATE_KEY" --broadcast --rpc-url "$L1_RPC_URL" @@ -130,10 +131,10 @@ if [ ! -f /app/data/deployments/artifact.json ]; then fi export CONTRACT_ADDRESSES_PATH=/app/data/deployments/artifact.json -export DEPLOY_CONFIG_PATH="$CONFIG_PATH"/deploy-config.json export STATE_DUMP_PATH=/app/data/deployments/allocs.json forge script scripts/L2Genesis.s.sol:L2Genesis --chain-id $L2_CHAIN_ID --sig 'runWithAllUpgrades()' --private-key $DEPLOYER_PRIVATE_KEY # OR runWithStateDump() +export DEPLOY_CONFIG_PATH="$CONFIG_PATH"/deploy-config.json # Generate the L2 genesis files cd "$OPTIMISM_DIR"/op-node go run cmd/main.go genesis l2 \ From c47cd9bfc3691376d6e0060438ae49c4ddccf582 Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sat, 17 Aug 2024 23:19:06 +0300 Subject: [PATCH 08/21] chore: improve logs --- scripts/prepare.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index f89016c..9c5b6d7 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -30,9 +30,9 @@ fi # Create jwt.txt if it does not exist [ -f "$CONFIG_PATH/jwt.txt" ] || openssl rand -hex 32 > "$CONFIG_PATH"/jwt.txt -# Check if all required genesis files exist +# Check if all required config files exist if [ -f "$CONFIG_PATH/genesis.json" ] && [ -f "$CONFIG_PATH/rollup.json" ]; then - echo "L2 genesis files are present, skipping prepare.sh script." + echo "L2 config files are present, skipping prepare.sh script." exec "$@" exit 0 elif [ -f "$CONFIG_PATH/genesis.json" ] || [ -f "$CONFIG_PATH/rollup.json" ]; then @@ -40,8 +40,8 @@ elif [ -f "$CONFIG_PATH/genesis.json" ] || [ -f "$CONFIG_PATH/rollup.json" ]; th exit 1 fi -# If no genesis files exist, continue with the script -echo "No required genesis files are present, continuing script execution." +# If no L2 config files exist, continue with the script +echo "No required L2 config files are present, continuing script execution." # Check if all or none of the private keys are provided if [ -z "$BATCHER_PRIVATE_KEY" ] && [ -z "$PROPOSER_PRIVATE_KEY" ] && [ -z "$SEQUENCER_PRIVATE_KEY" ]; then @@ -130,6 +130,7 @@ if [ ! -f /app/data/deployments/artifact.json ]; then cp $DEPLOY_CONFIG_PATH "$CONFIG_PATH"/deploy-config.json fi +# Generating L2 Allocs export CONTRACT_ADDRESSES_PATH=/app/data/deployments/artifact.json export STATE_DUMP_PATH=/app/data/deployments/allocs.json forge script scripts/L2Genesis.s.sol:L2Genesis --chain-id $L2_CHAIN_ID --sig 'runWithAllUpgrades()' --private-key $DEPLOYER_PRIVATE_KEY # OR runWithStateDump() From 8d263d99cc14a0e92587d839b948e15f11b9ec8c Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sun, 18 Aug 2024 00:02:31 +0300 Subject: [PATCH 09/21] chore: shell lint --- scripts/prepare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 9c5b6d7..7451ffe 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -133,7 +133,7 @@ fi # Generating L2 Allocs export CONTRACT_ADDRESSES_PATH=/app/data/deployments/artifact.json export STATE_DUMP_PATH=/app/data/deployments/allocs.json -forge script scripts/L2Genesis.s.sol:L2Genesis --chain-id $L2_CHAIN_ID --sig 'runWithAllUpgrades()' --private-key $DEPLOYER_PRIVATE_KEY # OR runWithStateDump() +forge script scripts/L2Genesis.s.sol:L2Genesis --chain-id "$L2_CHAIN_ID" --sig 'runWithAllUpgrades()' --private-key "$DEPLOYER_PRIVATE_KEY" # OR runWithStateDump() export DEPLOY_CONFIG_PATH="$CONFIG_PATH"/deploy-config.json # Generate the L2 genesis files From d0d60816b46640b1f6cfff995ec22c9587e86daf Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sun, 18 Aug 2024 01:42:21 +0300 Subject: [PATCH 10/21] fix: v1.7.6 --- scripts/prepare.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 7451ffe..5906bd7 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -122,8 +122,11 @@ export DEPLOY_CONFIG_PATH=./deploy-config/internal-opstack-compose.json # "$CONF # If not deployed if [ ! -f /app/data/deployments/artifact.json ]; then + # Determine the script path (fix for v1.7.6) + DEPLOY_SCRIPT_PATH=$(test -f scripts/deploy/Deploy.s.sol && echo "scripts/deploy/Deploy.s.sol" || echo "scripts/Deploy.s.sol") + # Deploy the L1 contracts - forge script scripts/deploy/Deploy.s.sol:Deploy --private-key "$DEPLOYER_PRIVATE_KEY" --broadcast --rpc-url "$L1_RPC_URL" + forge script "$DEPLOY_SCRIPT_PATH" --private-key "$DEPLOYER_PRIVATE_KEY" --broadcast --rpc-url "$L1_RPC_URL" # Copy the deployment files to the data volume cp $DEPLOYMENT_OUTFILE /app/data/deployments/ From fb892bc1928533e7df5832ec073a49b4a6a0abd2 Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sun, 18 Aug 2024 02:06:51 +0300 Subject: [PATCH 11/21] chore: typo, fix for 1.7.7, not 1.7.6 --- scripts/prepare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 5906bd7..3f165b0 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -122,7 +122,7 @@ export DEPLOY_CONFIG_PATH=./deploy-config/internal-opstack-compose.json # "$CONF # If not deployed if [ ! -f /app/data/deployments/artifact.json ]; then - # Determine the script path (fix for v1.7.6) + # Determine the script path (fix for v1.7.7) DEPLOY_SCRIPT_PATH=$(test -f scripts/deploy/Deploy.s.sol && echo "scripts/deploy/Deploy.s.sol" || echo "scripts/Deploy.s.sol") # Deploy the L1 contracts From 4fa3b983d3de675e550a034af25bbca346c21b05 Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sun, 18 Aug 2024 02:24:57 +0300 Subject: [PATCH 12/21] feat: auto-rename .env.example to .env if missing --- run | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/run b/run index 0445104..36380ca 100755 --- a/run +++ b/run @@ -1,5 +1,31 @@ #!/bin/bash +# Define colors +ORANGE='\e[0;33m' +BLUE='\e[0;34m' +RED='\e[0;31m' +GREEN='\e[0;32m' +NC='\e[0m' + +# Check if .env file exists +if [ ! -f .env ]; then + if [ -f .env.example ]; then + echo -e "${RED}Error${NC}: .env file not found." + echo -ne "${ORANGE}Do you want to use .env.example and rename it to .env? (yes/no): ${NC}" + read -r rename_confirm + if [[ "$rename_confirm" =~ ^(yes|y)$ ]]; then + mv .env.example .env + echo -e "${GREEN}.env.example has been renamed to .env.${NC}" + else + echo "Exiting." + exit 1 + fi + else + echo -e "${RED}Error${NC}: .env and .env.example files not found. Exiting." + exit 1 + fi +fi + # Load environment variables from .env file # shellcheck disable=SC1091 source .env @@ -11,11 +37,6 @@ command="docker compose" [ "$SEQUENCER_MODE" = "true" ] && command+=" --profile sequencer" [ "$CELESTIA_MODE" = "true" ] && command+=" --profile celestia" -# Define colors -ORANGE='\e[0;33m' -BLUE='\e[0;34m' -NC='\e[0m' - if [ "$SKIP_DEPLOYMENT_CHECK" = "true" ]; then echo -e "${ORANGE}NOTE${NC}: Only genesis.json and rollup.json will be checked (SKIP_DEPLOYMENT_CHECK=$SKIP_DEPLOYMENT_CHECK)." fi From 22dbafe0af6a7086937aa5fa6ecfed3754483148 Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sun, 18 Aug 2024 14:33:20 +0300 Subject: [PATCH 13/21] refactor: use and --- scripts/prepare.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 3f165b0..1971ad4 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -80,10 +80,10 @@ cd "$OPTIMISM_DIR"/packages/contracts-bedrock rm -f ./deploy-config/internal-opstack-compose.json # Check if deploy-config.json exists -if [ -f "/app/data/configurations/deploy-config.json" ]; then +if [ -f "$CONFIG_PATH/deploy-config.json" ]; then # Populate deploy-config.json with env variables echo "Populating deploy-config.json with env variables..." - envsubst < /app/data/configurations/deploy-config.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json + envsubst < "$CONFIG_PATH"/deploy-config.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json else # If deploy-config.json does not exist, use config.sh to generate getting-started.json echo "Generating getting-started.json..." @@ -103,8 +103,8 @@ jq \ ./deploy-config/internal-opstack-compose.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json # Merge deploy override -if [ -f /app/data/configurations/deploy-override.json ]; then - jq -s '.[0] * .[1]' ./deploy-config/internal-opstack-compose.json /app/data/configurations/deploy-override.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json +if [ -f "$CONFIG_PATH"/deploy-override.json ]; then + jq -s '.[0] * .[1]' ./deploy-config/internal-opstack-compose.json "$CONFIG_PATH"/deploy-override.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json fi # Show deployment config for better debuggability @@ -121,7 +121,7 @@ export DEPLOYMENT_OUTFILE=./deployments/artifact.json export DEPLOY_CONFIG_PATH=./deploy-config/internal-opstack-compose.json # "$CONFIG_PATH"/deploy-config.json not suitable due to the error "... not allowed to be accessed for read operations" # If not deployed -if [ ! -f /app/data/deployments/artifact.json ]; then +if [ ! -f "$DEPLOYMENT_DIR"/artifact.json ]; then # Determine the script path (fix for v1.7.7) DEPLOY_SCRIPT_PATH=$(test -f scripts/deploy/Deploy.s.sol && echo "scripts/deploy/Deploy.s.sol" || echo "scripts/Deploy.s.sol") @@ -129,13 +129,13 @@ if [ ! -f /app/data/deployments/artifact.json ]; then forge script "$DEPLOY_SCRIPT_PATH" --private-key "$DEPLOYER_PRIVATE_KEY" --broadcast --rpc-url "$L1_RPC_URL" # Copy the deployment files to the data volume - cp $DEPLOYMENT_OUTFILE /app/data/deployments/ + cp $DEPLOYMENT_OUTFILE "$DEPLOYMENT_DIR"/ cp $DEPLOY_CONFIG_PATH "$CONFIG_PATH"/deploy-config.json fi # Generating L2 Allocs -export CONTRACT_ADDRESSES_PATH=/app/data/deployments/artifact.json -export STATE_DUMP_PATH=/app/data/deployments/allocs.json +export CONTRACT_ADDRESSES_PATH=$DEPLOYMENT_DIR/artifact.json +export STATE_DUMP_PATH=$DEPLOYMENT_DIR/allocs.json forge script scripts/L2Genesis.s.sol:L2Genesis --chain-id "$L2_CHAIN_ID" --sig 'runWithAllUpgrades()' --private-key "$DEPLOYER_PRIVATE_KEY" # OR runWithStateDump() export DEPLOY_CONFIG_PATH="$CONFIG_PATH"/deploy-config.json @@ -143,11 +143,11 @@ export DEPLOY_CONFIG_PATH="$CONFIG_PATH"/deploy-config.json cd "$OPTIMISM_DIR"/op-node go run cmd/main.go genesis l2 \ --deploy-config "$DEPLOY_CONFIG_PATH" \ - --l1-deployments $CONTRACT_ADDRESSES_PATH \ + --l1-deployments "$CONTRACT_ADDRESSES_PATH" \ --outfile.l2 genesis.json \ --outfile.rollup rollup.json \ --l1-rpc "$L1_RPC_URL" \ - --l2-allocs $STATE_DUMP_PATH + --l2-allocs "$STATE_DUMP_PATH" cp genesis.json "$CONFIG_PATH"/ cp rollup.json "$CONFIG_PATH"/ From 2468ef4ca2532f043dd0b0a477243475ae014829 Mon Sep 17 00:00:00 2001 From: Artem <48246993+quertc@users.noreply.github.com> Date: Sun, 18 Aug 2024 16:16:13 +0300 Subject: [PATCH 14/21] fix: checking existing allocs --- scripts/prepare.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 1971ad4..578335a 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -136,7 +136,12 @@ fi # Generating L2 Allocs export CONTRACT_ADDRESSES_PATH=$DEPLOYMENT_DIR/artifact.json export STATE_DUMP_PATH=$DEPLOYMENT_DIR/allocs.json -forge script scripts/L2Genesis.s.sol:L2Genesis --chain-id "$L2_CHAIN_ID" --sig 'runWithAllUpgrades()' --private-key "$DEPLOYER_PRIVATE_KEY" # OR runWithStateDump() + +if [ -f "$STATE_DUMP_PATH" ]; then + echo "State dump already exists, skipping state dump generation." +else + forge script scripts/L2Genesis.s.sol:L2Genesis --chain-id "$L2_CHAIN_ID" --sig 'runWithAllUpgrades()' --private-key "$DEPLOYER_PRIVATE_KEY" # OR runWithStateDump() +fi export DEPLOY_CONFIG_PATH="$CONFIG_PATH"/deploy-config.json # Generate the L2 genesis files From c01fd45838a4506cdba20dfe4af29485ecd8bb9d Mon Sep 17 00:00:00 2001 From: cddrown Date: Mon, 19 Aug 2024 12:32:39 +0100 Subject: [PATCH 15/21] fix deploy script reference --- scripts/clone-repos.sh | 2 +- scripts/prepare.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/clone-repos.sh b/scripts/clone-repos.sh index a9a9588..ac162df 100644 --- a/scripts/clone-repos.sh +++ b/scripts/clone-repos.sh @@ -55,7 +55,7 @@ clone_repo() { # Clone the repository echo "Cloning $repo_url into $dest_dir" - git clone "$repo_url" . + git clone --recursive "$repo_url" . echo "Cloning complete" # Checkout to the specific branch or commit diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 171d806..ad170d1 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -146,7 +146,7 @@ if [ ! -f /app/data/deployments/.deploy ]; then export DEPLOYMENT_OUTFILE="$OPTIMISM_DIR"/packages/contracts-bedrock/deployments/"$DEPLOYMENT_CONTEXT"/.deploy # Deploy the L1 contracts - forge script scripts/Deploy.s.sol:Deploy --private-key "$DEPLOYER_PRIVATE_KEY" --broadcast --rpc-url "$L1_RPC_URL" + forge script scripts/deploy/Deploy.s.sol:Deploy --private-key "$DEPLOYER_PRIVATE_KEY" --broadcast --rpc-url "$L1_RPC_URL" # Save the deployment address cp -r "$OPTIMISM_DIR"/packages/contracts-bedrock/deployments/"$DEPLOYMENT_CONTEXT"/. /app/data/deployments/ From 077a1e641a15b1356d0583887a9a8bacf1f3b430 Mon Sep 17 00:00:00 2001 From: cddrown Date: Mon, 19 Aug 2024 12:51:42 +0100 Subject: [PATCH 16/21] Fixes to just installation --- Dockerfile | 11 ----------- scripts/prepare.sh | 2 -- 2 files changed, 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 86448d8..73ffb87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,17 +24,6 @@ RUN mkdir -p /etc/apt/keyrings && \ # Install PNPM #RUN npm install -g pnpm -# Set the makedeb release you want. -ENV MAKEDEB_RELEASE='makedeb' - -# Run the install script. Note that it's `bash -c` and not `bash -ci` now. -RUN [/bin/bash, -c, "$(wget -qO - 'https://shlink.makedeb.org/install')"] - -RUN git clone https://mpr.makedeb.org/just -RUN cd just -RUN makedeb -si -RUN cd .. - # Install just RUN mkdir -p /app/bin RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /app/bin diff --git a/scripts/prepare.sh b/scripts/prepare.sh index c79769d..6844395 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -11,10 +11,8 @@ if [ ! -f "$BIN_DIR/op-node" ] || [ ! -f "$BIN_DIR/op-batcher" ] || [ ! -f "$BIN # Build op-node, op-batcher and op-proposer cd "$OPTIMISM_DIR" #pnpm install - just install make op-node op-batcher op-proposer #pnpm build - just build # Copy binaries to the bin volume cp -f "$OPTIMISM_DIR"/op-node/bin/op-node "$BIN_DIR"/ From af84d4bbccbc8c54ec837d77032e5f09ea86b42d Mon Sep 17 00:00:00 2001 From: cddrown Date: Mon, 19 Aug 2024 13:39:44 +0100 Subject: [PATCH 17/21] Fix incorrect merge --- scripts/prepare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 6844395..3e18648 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -126,7 +126,7 @@ if [ ! -f "$DEPLOYMENT_DIR"/artifact.json ]; then DEPLOY_SCRIPT_PATH=$(test -f scripts/deploy/Deploy.s.sol && echo "scripts/deploy/Deploy.s.sol" || echo "scripts/Deploy.s.sol") # Deploy the L1 contracts - forge script scripts/Deploy.s.sol:Deploy --private-key "$DEPLOYER_PRIVATE_KEY" --broadcast --rpc-url "$L1_RPC_URL" + forge script $DEPLOY_SCRIPT_PATH --private-key "$DEPLOYER_PRIVATE_KEY" --broadcast --rpc-url "$L1_RPC_URL" # Copy the deployment files to the data volume cp $DEPLOYMENT_OUTFILE "$DEPLOYMENT_DIR"/ From 029f8f144ece40b2ae24b5ea63f1623b244e4e21 Mon Sep 17 00:00:00 2001 From: cddrown Date: Tue, 20 Aug 2024 12:40:47 +0100 Subject: [PATCH 18/21] clean up commented code --- Dockerfile | 3 --- scripts/prepare.sh | 2 -- 2 files changed, 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 73ffb87..9c4ce8a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,9 +21,6 @@ RUN mkdir -p /etc/apt/keyrings && \ apt-get update && \ apt-get install nodejs -y -# Install PNPM -#RUN npm install -g pnpm - # Install just RUN mkdir -p /app/bin RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /app/bin diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 3e18648..c71a365 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -10,9 +10,7 @@ set -e if [ ! -f "$BIN_DIR/op-node" ] || [ ! -f "$BIN_DIR/op-batcher" ] || [ ! -f "$BIN_DIR/op-proposer" ] || [ ! -f "$BIN_DIR/geth" ]; then # Build op-node, op-batcher and op-proposer cd "$OPTIMISM_DIR" - #pnpm install make op-node op-batcher op-proposer - #pnpm build # Copy binaries to the bin volume cp -f "$OPTIMISM_DIR"/op-node/bin/op-node "$BIN_DIR"/ From b2d09b9687f3e7fab68722d8849e30086c22bb5d Mon Sep 17 00:00:00 2001 From: cddrown Date: Wed, 21 Aug 2024 08:53:27 +0100 Subject: [PATCH 19/21] added InvalidClockExtension workaround --- scripts/prepare.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/prepare.sh b/scripts/prepare.sh index c71a365..9b12097 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -100,6 +100,10 @@ jq \ '.l1ChainID = $l1ChainID | .l2ChainID = $l2ChainID | .batchInboxAddress = $batchInboxAddress' \ ./deploy-config/internal-opstack-compose.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json +# Workaround for issue with 'InvalidClockExtension' error +export PREIMAGE_ORACLE_CHALLENGE_PERIOD = 120 +jq --arg preimageOracleChallengePeriod "$PREIMAGE_ORACLE_CHALLENGE_PERIOD" '.preimageOracleChallengePeriod = $preimageOracleChallengePeriod' ./deploy-config/internal-opstack-compose.json "$CONFIG_PATH"/deploy-override.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json + # Merge deploy override if [ -f "$CONFIG_PATH"/deploy-override.json ]; then jq -s '.[0] * .[1]' ./deploy-config/internal-opstack-compose.json "$CONFIG_PATH"/deploy-override.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json From 10837095313f8df7e4b36aef26e0796c971d3b48 Mon Sep 17 00:00:00 2001 From: cddrown Date: Wed, 21 Aug 2024 11:03:24 +0100 Subject: [PATCH 20/21] fix to workaround --- .env.example | 2 +- scripts/prepare.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 2d18a8b..36317ad 100644 --- a/.env.example +++ b/.env.example @@ -19,7 +19,7 @@ CELESTIA_MODE=false # If not set, default to the official optimism implementation OPTIMISM_REPO_URL=https://github.com/ethereum-optimism/optimism.git -OPTIMISM_BRANCH_OR_COMMIT=v1.9.0 +OPTIMISM_BRANCH_OR_COMMIT=develop OP_GETH_REPO_URL=https://github.com/ethereum-optimism/op-geth.git OP_GETH_BRANCH_OR_COMMIT=v1.101315.3 diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 9b12097..a9a175a 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -101,8 +101,8 @@ jq \ ./deploy-config/internal-opstack-compose.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json # Workaround for issue with 'InvalidClockExtension' error -export PREIMAGE_ORACLE_CHALLENGE_PERIOD = 120 -jq --arg preimageOracleChallengePeriod "$PREIMAGE_ORACLE_CHALLENGE_PERIOD" '.preimageOracleChallengePeriod = $preimageOracleChallengePeriod' ./deploy-config/internal-opstack-compose.json "$CONFIG_PATH"/deploy-override.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json +export PREIMAGE_ORACLE_CHALLENGE_PERIOD=120 +jq --arg preimageOracleChallengePeriod "$PREIMAGE_ORACLE_CHALLENGE_PERIOD" '.preimageOracleChallengePeriod = $preimageOracleChallengePeriod' ./deploy-config/internal-opstack-compose.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json # Merge deploy override if [ -f "$CONFIG_PATH"/deploy-override.json ]; then From 3077a5a6dbd4ddd826c2ab929d63f9c462a53928 Mon Sep 17 00:00:00 2001 From: cddrown Date: Tue, 3 Sep 2024 14:53:12 +0100 Subject: [PATCH 21/21] Set to v1.9.1 and remove workaround --- .env.example | 2 +- scripts/prepare.sh | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 36317ad..439ae57 100644 --- a/.env.example +++ b/.env.example @@ -19,7 +19,7 @@ CELESTIA_MODE=false # If not set, default to the official optimism implementation OPTIMISM_REPO_URL=https://github.com/ethereum-optimism/optimism.git -OPTIMISM_BRANCH_OR_COMMIT=develop +OPTIMISM_BRANCH_OR_COMMIT=v1.9.1 OP_GETH_REPO_URL=https://github.com/ethereum-optimism/op-geth.git OP_GETH_BRANCH_OR_COMMIT=v1.101315.3 diff --git a/scripts/prepare.sh b/scripts/prepare.sh index a9a175a..c71a365 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -100,10 +100,6 @@ jq \ '.l1ChainID = $l1ChainID | .l2ChainID = $l2ChainID | .batchInboxAddress = $batchInboxAddress' \ ./deploy-config/internal-opstack-compose.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json -# Workaround for issue with 'InvalidClockExtension' error -export PREIMAGE_ORACLE_CHALLENGE_PERIOD=120 -jq --arg preimageOracleChallengePeriod "$PREIMAGE_ORACLE_CHALLENGE_PERIOD" '.preimageOracleChallengePeriod = $preimageOracleChallengePeriod' ./deploy-config/internal-opstack-compose.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json - # Merge deploy override if [ -f "$CONFIG_PATH"/deploy-override.json ]; then jq -s '.[0] * .[1]' ./deploy-config/internal-opstack-compose.json "$CONFIG_PATH"/deploy-override.json > /app/temp-deploy-config.json && mv /app/temp-deploy-config.json ./deploy-config/internal-opstack-compose.json