From 6cf5878068c5a56667b4fb2bcf479ef064826669 Mon Sep 17 00:00:00 2001 From: tbro Date: Tue, 21 Jan 2025 18:16:19 -0300 Subject: [PATCH 01/22] add CI workflow --- .github/workflows/migration.yaml | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/migration.yaml diff --git a/.github/workflows/migration.yaml b/.github/workflows/migration.yaml new file mode 100644 index 00000000..a4d4f865 --- /dev/null +++ b/.github/workflows/migration.yaml @@ -0,0 +1,38 @@ +name: Migration Test +run-name: CI triggered from @${{ github.actor }} of ${{ github.head_ref }} + +on: + workflow_dispatch: + merge_group: + push: + schedule: + # Run at the end of every day + - cron: "0 0 * * *" + +# Cancel in-progress jobs except for integration branch +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ !contains(github.ref, 'integration/')}} + +jobs: + migration_test: + runs-on: ubuntu-24.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Nix + uses: cachix/install-nix-action@v30 + + - name: Enable Cachix + uses: cachix/cachix-action@v15 + + - name: Migration Test + run: | + nix develop + espresso-tests/migration-test.bash + timeout-minutes: 45 + From 1aa34c8cc5533036293fc9eb4dd7cf7b04e24d4c Mon Sep 17 00:00:00 2001 From: tbro Date: Tue, 21 Jan 2025 18:29:44 -0300 Subject: [PATCH 02/22] cachix config --- .github/workflows/migration.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/migration.yaml b/.github/workflows/migration.yaml index a4d4f865..3a05cd4d 100644 --- a/.github/workflows/migration.yaml +++ b/.github/workflows/migration.yaml @@ -29,6 +29,12 @@ jobs: - name: Enable Cachix uses: cachix/cachix-action@v15 + continue-on-error: true + with: + name: espresso-systems-private + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + extraPullNames: nix-community + skipPush: ${{ github.actor == 'dependabot[bot]' }} - name: Migration Test run: | From 8a72fcb201649cf002c236fdc890d569d838924c Mon Sep 17 00:00:00 2001 From: tbro Date: Tue, 21 Jan 2025 18:43:24 -0300 Subject: [PATCH 03/22] try to fix nix --- .github/workflows/migration.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/migration.yaml b/.github/workflows/migration.yaml index 3a05cd4d..64d49339 100644 --- a/.github/workflows/migration.yaml +++ b/.github/workflows/migration.yaml @@ -35,10 +35,9 @@ jobs: authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" extraPullNames: nix-community skipPush: ${{ github.actor == 'dependabot[bot]' }} - - - name: Migration Test + + - name: Migration Test run: | - nix develop - espresso-tests/migration-test.bash + nix develop $DEVSHELL --accept-flake-config --option sandbox relaxed \ + -c espresso-tests/migration-test.bash timeout-minutes: 45 - From 2c90aaa4bc4337e86000f659009459055cdb90ac Mon Sep 17 00:00:00 2001 From: tbro Date: Tue, 21 Jan 2025 18:44:55 -0300 Subject: [PATCH 04/22] I don't think we have DEVSHELL defined here --- .github/workflows/migration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/migration.yaml b/.github/workflows/migration.yaml index 64d49339..d4e603e0 100644 --- a/.github/workflows/migration.yaml +++ b/.github/workflows/migration.yaml @@ -38,6 +38,6 @@ jobs: - name: Migration Test run: | - nix develop $DEVSHELL --accept-flake-config --option sandbox relaxed \ + nix develop --accept-flake-config --option sandbox relaxed \ -c espresso-tests/migration-test.bash timeout-minutes: 45 From d086b94e7f1ed8bc07927b328a7a6cf9aeafe0ea Mon Sep 17 00:00:00 2001 From: tbro Date: Tue, 21 Jan 2025 18:49:09 -0300 Subject: [PATCH 05/22] Rename `DeployAndInitEspressoSequencerInboxTest` --- espresso-tests/migration-test.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index 1b063751..c311e685 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -67,7 +67,7 @@ forge script --chain $PARENT_CHAIN_CHAIN_ID ../espresso-tests/DeployAndInitEspre # Extract new_osp_entry address from run-latest.json # * Essential migration sub step * These addresses are likely known addresses to operators in the event of a real migration after they have deployed the new OSP contracts, however, if operators create a script for the migration, this command is useful. -NEW_SEQUENCER_INBOX_IMPL_ADDRESS=$(cat broadcast/DeployAndInitEspressoSequencerInbox.s.sol/1337/run-latest.json | jq -r '.transactions[0].contractAddress'| cast to-checksum) +NEW_SEQUENCER_INBOX_IMPL_ADDRESS=$(cat broadcast/DeployAndInitEspressoSequencerInboxTest.s.sol/1337/run-latest.json | jq -r '.transactions[0].contractAddress'| cast to-checksum) # Echo for debugging. echo "Deployed new SequencerInbox at $NEW_SEQUENCER_INBOX_IMPL_ADDRESS" From 9596b013c67ec052159a5ecf33853b86b7659322 Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 22 Jan 2025 14:14:22 +0100 Subject: [PATCH 06/22] Integration test fixes - Rename deploy script used in test to `...ForTest`. - Add missing variable `IS_REVERT` to .env file. - Remove most logs because they are noisy but keep them if DEBUG=true, use DEBUG=true in CI. - Remove repeated calls to `forge update`. - Recursively init submodules to make sure we have submodules of submodules. - Print out how long we are waiting for confirmed nodes. - Output environment variables we are setting. --- espresso-tests/.env | 1 + ...ndInitEspressoSequencerInboxForTest.s.sol} | 2 +- espresso-tests/migration-test.bash | 120 ++++++++++++++++-- flake.nix | 1 + 4 files changed, 110 insertions(+), 14 deletions(-) rename espresso-tests/{DeployAndInitEspressoSequencerInboxTest.s.sol => DeployAndInitEspressoSequencerInboxForTest.s.sol} (96%) diff --git a/espresso-tests/.env b/espresso-tests/.env index 64ef26e8..bbe56b74 100644 --- a/espresso-tests/.env +++ b/espresso-tests/.env @@ -18,6 +18,7 @@ UPGRADE_TIMESTAMP="1723664126" READER_ADDRESS="0x7DD3F2a3fAeF3B9F2364c335163244D3388Feb83" IS_USING_FEE_TOKEN="false" IS_MIGRATION_TEST="true" +IS_REVERT="false" MAX_DATA_SIZE="117964" OLD_BATCH_POSTER_ADDRESS="0xe2148eE53c0755215Df69b2616E552154EdC584f" NEW_BATCH_POSTER_ADDRESS="0xe2148eE53c0755215Df69b2616E552154EdC584f" diff --git a/espresso-tests/DeployAndInitEspressoSequencerInboxTest.s.sol b/espresso-tests/DeployAndInitEspressoSequencerInboxForTest.s.sol similarity index 96% rename from espresso-tests/DeployAndInitEspressoSequencerInboxTest.s.sol rename to espresso-tests/DeployAndInitEspressoSequencerInboxForTest.s.sol index f213bc41..f52c050d 100644 --- a/espresso-tests/DeployAndInitEspressoSequencerInboxTest.s.sol +++ b/espresso-tests/DeployAndInitEspressoSequencerInboxForTest.s.sol @@ -9,7 +9,7 @@ import "nitro-contracts/bridge/ISequencerInbox.sol"; /// with the espresso confirmation layer /// @dev BATCH_POSTER_ADDRS should be a comma delimited list that includes addresses. This list will give batch posting affordances to those addresses /// For chains using the Espresso TEE integration, this will be the address of your new batch poster, if you decide to change it. -contract DeployAndInitEspressoSequencerInboxTest is Script { +contract DeployAndInitEspressoSequencerInbox is Script { function run() external { bool isMigrationTest = vm.envBool("IS_MIGRATION_TEST"); // Grab addresses from env diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index c311e685..f8632dde 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -6,68 +6,157 @@ fail(){ set -euo pipefail set -a # automatically export all variables -set -x # print each command before executing it, for debugging +# set -x # print each command before executing it, for debugging +# CI is "true" in the CI +CI="${CI:-false}" +# Output debug information on CI +DEBUG="${DEBUG:-false}" +if [ "$CI" = "true" ]; then + set -x + DEBUG=true +fi + +# Show the command we are running, then run it. Due to piping this spawns a +# subshell so does not work for command like `cd` or `source`. +function run { + echo -e "\033[34m>>> $*\033[0m" + "$@" 2>&1 | fmt +} + +function cd { + emph "cd $*" + builtin cd "$@" +} + +function emph { + echo -e "\033[34m>>> $*\033[0m\n" +} + +# Display only the last line of piped input, continuously updating +function fmt { + # Leave output unchanged in DEBUG mode + if [ "$DEBUG" = "true" ]; then + cat + return + fi + # rewrite the last line to avoid noisy output + while read -r line; do + tput cr; tput el; echo -n "$line"; + done + echo +} + +# Remove log files on exit +trap "exit" INT TERM +trap cleanup EXIT +function cleanup { + rm -vf "$TESTNODE_LOG_FILE" + rm -vf "$ESPRESSO_DEVNODE_LOG_FILE" +} # Find directory of this script, the project, and the orbit-actions submodule TEST_DIR="$(dirname $(readlink -f $0))" +TESTNODE_LOG_FILE=$(mktemp -t nitro-test-node-logs-XXXXXXXX) +ESPRESSO_DEVNODE_LOG_FILE=$(mktemp -t espresso-dev-node-logs-XXXXXXXX) TESTNODE_DIR="$(dirname "$TEST_DIR")" ORBIT_ACTIONS_DIR="$TESTNODE_DIR/orbit-actions" # Change to orbit actions directory, update the submodule, and install any dependencies for the purposes of the test. cd "$ORBIT_ACTIONS_DIR" -git submodule update --init -forge update -yarn +run git submodule update --init --recursive + +run yarn + +# ensure we can compile the contracts +run forge build # Change to the top level directory for the purposes of the test. cd "$TESTNODE_DIR" +# NOTE: the test-node.bash script (or potentially docker compose) does not work +# well with the `fmt` utility function and hangs at the end. I don't know why. +# Furthermore the long warning lines don't work with the `fmt` function but I +# can't work out a way to be able to filter the lines (e. g. grep -v WARN) and +# still have the output show up. + # Initialize a standard network not compatible with espresso to simulate a pre-upgrade orbit network e.g. not needed for the real migration -./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils +emph ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils +if [ "$DEBUG" = "true" ]; then + ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils +else + echo "This command starts up an entire Nitro stack. It takes a long time." + echo "Run \`tail -f $TESTNODE_LOG_FILE\` to see logs, if necessary." + ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils > "$TESTNODE_LOG_FILE" 2>&1 +fi # Start espresso sequencer node for the purposes of the test e.g. not needed for the real migration. -docker compose up espresso-dev-node --detach +emph docker compose up espresso-dev-node --detach +if [ "$DEBUG" = "true" ]; then + docker compose up espresso-dev-node --detach +else + echo "Run \`tail -f $ESPRESSO_DEVNODE_LOG_FILE\` to see logs, if necessary." + docker compose up espresso-dev-node --detach > "$ESPRESSO_DEVNODE_LOG_FILE" 2>&1 +fi # Export environment variables in .env file # A similar env file should be supplied for whatever +emph . "$TEST_DIR/.env" . "$TEST_DIR/.env" +echo +echo Loaded env vars: +echo +cat "$TEST_DIR/.env" | sed 's/^/ /' +echo # Overwrite the ROLLUP_ADDRESS for this test, it might not be the same as the one in the .env file #* Essential migration sub step * This address (the rollup proxy address) is likely a known address to operators. ROLLUP_ADDRESS=$(docker compose run --entrypoint cat scripts /config/deployed_chain_info.json | jq -r '.[0].rollup.rollup' | tail -n 1 | tr -d '\r\n') +declare -p ROLLUP_ADDRESS # A convoluted way to get the address of the child chain upgrade executor, maybe there's a better way? # These steps below are just for the purposes of the test. In a real deployment operators will likely already know their child-chain's upgrade executor address, and it should be included in a .env file for the migration run. INBOX_ADDRESS=$(docker compose run --entrypoint cat scripts /config/deployed_chain_info.json | jq -r '.[0].rollup.inbox' | tail -n 1 | tr -d '\r\n') +declare -p INBOX_ADDRESS + L1_TOKEN_BRIDGE_CREATOR_ADDRESS=$(docker compose run --entrypoint cat scripts /tokenbridge-data/network.json | jq -r '.l1TokenBridgeCreator' | tail -n 1 | tr -d '\r\n') +declare -p L1_TOKEN_BRIDGE_CREATOR_ADDRESS + CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS=$(cast call $L1_TOKEN_BRIDGE_CREATOR_ADDRESS 'inboxToL2Deployment(address)(address,address,address,address,address,address,address,address,address)' $INBOX_ADDRESS | tail -n 2 | head -n 1 | tr -d '\r\n') +declare -p CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS # Export l2 owner private key and address # These commands are exclusive to the test. # * Essential migration sub step * These addresses are likely known addresses to operators in the event of a real migration PRIVATE_KEY="$(docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n')" +# This is a private key used for testing, save to print +declare -p PRIVATE_KEY + OWNER_ADDRESS="$(docker compose run scripts print-address --account l2owner | tail -n 1 | tr -d '\r\n')" +declare -p OWNER_ADDRESS cd $ORBIT_ACTIONS_DIR -forge update echo "Deploying mock espresso tee verifier" forge script --chain $PARENT_CHAIN_CHAIN_ID ../espresso-tests/DeployMockVerifier.s.sol:DeployMockVerifier --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv ESPRESSO_TEE_VERIFIER_ADDRESS=$(cat broadcast/DeployMockVerifier.s.sol/1337/run-latest.json | jq -r '.transactions[0].contractAddress' | cast to-checksum) +declare -p ESPRESSO_TEE_VERIFIER_ADDRESS + echo "Mock TEE Address:" echo $ESPRESSO_TEE_VERIFIER_ADDRESS +declare -p ESPRESSO_TEE_VERIFIER_ADDRESS # Echo for debug echo "Deploying and initializing Espresso SequencerInbox" # ** Essential migration step ** Forge script to deploy the new SequencerInbox. We do this to later point the rollups challenge manager to the espresso integrated OSP. -forge script --chain $PARENT_CHAIN_CHAIN_ID ../espresso-tests/DeployAndInitEspressoSequencerInboxTest.s.sol:DeployAndInitEspressoSequencerInboxTest --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv --skip-simulation +forge script --chain $PARENT_CHAIN_CHAIN_ID ../espresso-tests/DeployAndInitEspressoSequencerInboxForTest.s.sol:DeployAndInitEspressoSequencerInbox --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv --skip-simulation -# Extract new_osp_entry address from run-latest.json # * Essential migration sub step * These addresses are likely known addresses to operators in the event of a real migration after they have deployed the new OSP contracts, however, if operators create a script for the migration, this command is useful. -NEW_SEQUENCER_INBOX_IMPL_ADDRESS=$(cat broadcast/DeployAndInitEspressoSequencerInboxTest.s.sol/1337/run-latest.json | jq -r '.transactions[0].contractAddress'| cast to-checksum) +NEW_SEQUENCER_INBOX_IMPL_ADDRESS=$(cat broadcast/DeployAndInitEspressoSequencerInboxForTest.s.sol/1337/run-latest.json | jq -r '.receipts[0].contractAddress'| cast to-checksum) +declare -p NEW_SEQUENCER_INBOX_IMPL_ADDRESS + # Echo for debugging. echo "Deployed new SequencerInbox at $NEW_SEQUENCER_INBOX_IMPL_ADDRESS" @@ -75,21 +164,23 @@ echo "Deployed new SequencerInbox at $NEW_SEQUENCER_INBOX_IMPL_ADDRESS" echo "Deploying Espresso SequencerInbox migration action" # ** Essential migration step ** Forge script to deploy Espresso OSP migration action -forge script --chain $PARENT_CHAIN_CHAIN_ID contracts/parent-chain/espresso-migration/DeployEspressoSequencerMigrationAction.s.sol:DeployEspressoSequencerMigrationAction --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv +run forge script --chain $PARENT_CHAIN_CHAIN_ID contracts/parent-chain/espresso-migration/DeployEspressoSequencerMigrationAction.s.sol:DeployEspressoSequencerMigrationAction --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv # Capture new OSP address # * Essential migration sub step ** Essential migration sub step * operators will be able to manually determine this address while running the upgrade, but this can be useful if they wish to make a script. SEQUENCER_MIGRATION_ACTION=$(cat broadcast/DeployEspressoSequencerMigrationAction.s.sol/1337/run-latest.json | jq -r '.transactions[0].contractAddress' | cast to-checksum) +declare -p SEQUENCER_MIGRATION_ACTION echo "Deployed new EspressoSequencerMigrationAction at $SEQUENCER_MIGRATION_ACTION" echo "Deploying ArbOS Upgrade action" # Forge script to deploy the Espresso ArbOS upgrade action. # ** Essential migration step ** the ArbOS upgrade signifies that the chain is now espresso compatible. -forge script --chain $CHILD_CHAIN_CHAIN_NAME contracts/child-chain/espresso-migration/DeployArbOSUpgradeAction.s.sol:DeployArbOSUpgradeAction --rpc-url $CHILD_CHAIN_RPC_URL --broadcast -vvvv +run forge script --chain $CHILD_CHAIN_CHAIN_NAME contracts/child-chain/espresso-migration/DeployArbOSUpgradeAction.s.sol:DeployArbOSUpgradeAction --rpc-url $CHILD_CHAIN_RPC_URL --broadcast -vvvv # Get the address of the newly deployed upgrade action. ARBOS_UPGRADE_ACTION=$(cat broadcast/DeployArbOSUpgradeAction.s.sol/412346/run-latest.json | jq -r '.transactions[0].contractAddress') +declare -p ARBOS_UPGRADE_ACTION # Echo information for debugging. echo "Deployed ArbOSUpgradeAction at $ARBOS_UPGRADE_ACTION" @@ -173,10 +264,13 @@ fi echo "Balance of $RECIPIENT_ADDRESS changed from $BALANCE_ORIG to $BALANCE_NEW" # Check that the staker is making progress after the upgrade +START=$SECONDS +echo "Waiting for confirmed nodes." while [ "$NUM_CONFIRMED_NODES_BEFORE_UPGRADE" == "$(cast call --rpc-url $PARENT_CHAIN_RPC_URL $ROLLUP_ADDRESS 'latestConfirmed()(uint256)')" ]; do - echo "Waiting for confirmed nodes ..." sleep 5 + echo "Waited $(( SECONDS - START )) seconds for confirmed nodes." done + # Echo to confirm that stakers are behaving normally. echo "Confirmed nodes have progressed" diff --git a/flake.nix b/flake.nix index 1a367bb5..eb5fdfeb 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,7 @@ packages = with pkgs; [ bashInteractive jq + jnv # interactive JSON filter, useful to search forge broadcast files nodejs yarn openssl # used by test-node.bash From 69fd31ce1b9abce8be3883706ccfb2841947cd17 Mon Sep 17 00:00:00 2001 From: tbro Date: Wed, 22 Jan 2025 10:35:23 -0300 Subject: [PATCH 07/22] try to run both branch w/ matrix --- .github/workflows/migration.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/migration.yaml b/.github/workflows/migration.yaml index d4e603e0..46f13d87 100644 --- a/.github/workflows/migration.yaml +++ b/.github/workflows/migration.yaml @@ -17,10 +17,14 @@ concurrency: jobs: migration_test: runs-on: ubuntu-24.04 + strategy: + matrix: + branch: [integration, celestia-integration] steps: - name: Checkout uses: actions/checkout@v4 + ref: ${{matrix.branch}} with: submodules: recursive From 3e8144c850cc3f894a6f419ff7e7e8d98343748f Mon Sep 17 00:00:00 2001 From: tbro Date: Wed, 22 Jan 2025 10:49:13 -0300 Subject: [PATCH 08/22] fix yaml --- .github/workflows/migration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/migration.yaml b/.github/workflows/migration.yaml index 46f13d87..ce55102a 100644 --- a/.github/workflows/migration.yaml +++ b/.github/workflows/migration.yaml @@ -24,8 +24,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - ref: ${{matrix.branch}} with: + ref: ${{matrix.branch}} submodules: recursive - name: Install Nix From 22752c0f1aba9118bdecadaf8d92ffeae5cac9a2 Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 22 Jan 2025 14:52:09 +0100 Subject: [PATCH 09/22] Some more cleanup --- espresso-tests/migration-test.bash | 92 +++++++++++++++++------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index f8632dde..7b92816c 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -48,6 +48,11 @@ function fmt { echo } +# Show something with a comment in front, to distinguish it from console output. +function info { + echo "# $@" +} + # Remove log files on exit trap "exit" INT TERM trap cleanup EXIT @@ -62,15 +67,18 @@ TESTNODE_LOG_FILE=$(mktemp -t nitro-test-node-logs-XXXXXXXX) ESPRESSO_DEVNODE_LOG_FILE=$(mktemp -t espresso-dev-node-logs-XXXXXXXX) TESTNODE_DIR="$(dirname "$TEST_DIR")" ORBIT_ACTIONS_DIR="$TESTNODE_DIR/orbit-actions" +ENV_FILE="$TEST_DIR/.env" # Change to orbit actions directory, update the submodule, and install any dependencies for the purposes of the test. cd "$ORBIT_ACTIONS_DIR" +info "Ensuring submodules are checked out" run git submodule update --init --recursive +info "Ensuring nodejs dependencies are installed" run yarn -# ensure we can compile the contracts +info "Ensuring we can compile the migration smart contracts" run forge build # Change to the top level directory for the purposes of the test. @@ -82,46 +90,59 @@ cd "$TESTNODE_DIR" # can't work out a way to be able to filter the lines (e. g. grep -v WARN) and # still have the output show up. -# Initialize a standard network not compatible with espresso to simulate a pre-upgrade orbit network e.g. not needed for the real migration +info Deploying a vanilla Nitro stack locally, to be migrated to Espresso later. emph ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils if [ "$DEBUG" = "true" ]; then ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils else - echo "This command starts up an entire Nitro stack. It takes a long time." - echo "Run \`tail -f $TESTNODE_LOG_FILE\` to see logs, if necessary." + info "This command starts up an entire Nitro stack. It takes a long time." + info "Run \`tail -f $TESTNODE_LOG_FILE\` to see logs, if necessary." + echo ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils > "$TESTNODE_LOG_FILE" 2>&1 fi # Start espresso sequencer node for the purposes of the test e.g. not needed for the real migration. +info "Starting a local Espresso confirmation layer development node" emph docker compose up espresso-dev-node --detach if [ "$DEBUG" = "true" ]; then docker compose up espresso-dev-node --detach else - echo "Run \`tail -f $ESPRESSO_DEVNODE_LOG_FILE\` to see logs, if necessary." + info "Run \`tail -f $ESPRESSO_DEVNODE_LOG_FILE\` to see logs, if necessary." + echo docker compose up espresso-dev-node --detach > "$ESPRESSO_DEVNODE_LOG_FILE" 2>&1 fi -# Export environment variables in .env file +info "Load environment variables in $ENV_FILE" # A similar env file should be supplied for whatever emph . "$TEST_DIR/.env" . "$TEST_DIR/.env" echo -echo Loaded env vars: +info "Loaded env vars:" echo cat "$TEST_DIR/.env" | sed 's/^/ /' echo +function trim-last { + tail -n 1 | tr -d '\r\n' + +} +function get-addr { + local file="$1" + local path="$2" + docker compose run --entrypoint cat scripts $file 2>/dev/null | jq -r "$path" | trim-last +} + # Overwrite the ROLLUP_ADDRESS for this test, it might not be the same as the one in the .env file #* Essential migration sub step * This address (the rollup proxy address) is likely a known address to operators. -ROLLUP_ADDRESS=$(docker compose run --entrypoint cat scripts /config/deployed_chain_info.json | jq -r '.[0].rollup.rollup' | tail -n 1 | tr -d '\r\n') +ROLLUP_ADDRESS=$(get-addr /config/deployed_chain_info.json '.[0].rollup.rollup') declare -p ROLLUP_ADDRESS # A convoluted way to get the address of the child chain upgrade executor, maybe there's a better way? # These steps below are just for the purposes of the test. In a real deployment operators will likely already know their child-chain's upgrade executor address, and it should be included in a .env file for the migration run. -INBOX_ADDRESS=$(docker compose run --entrypoint cat scripts /config/deployed_chain_info.json | jq -r '.[0].rollup.inbox' | tail -n 1 | tr -d '\r\n') +INBOX_ADDRESS=$(get-addr /config/deployed_chain_info.json '.[0].rollup.inbox') declare -p INBOX_ADDRESS -L1_TOKEN_BRIDGE_CREATOR_ADDRESS=$(docker compose run --entrypoint cat scripts /tokenbridge-data/network.json | jq -r '.l1TokenBridgeCreator' | tail -n 1 | tr -d '\r\n') +L1_TOKEN_BRIDGE_CREATOR_ADDRESS=$(get-addr /tokenbridge-data/network.json '.l1TokenBridgeCreator') declare -p L1_TOKEN_BRIDGE_CREATOR_ADDRESS CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS=$(cast call $L1_TOKEN_BRIDGE_CREATOR_ADDRESS 'inboxToL2Deployment(address)(address,address,address,address,address,address,address,address,address)' $INBOX_ADDRESS | tail -n 2 | head -n 1 | tr -d '\r\n') @@ -130,26 +151,22 @@ declare -p CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS # Export l2 owner private key and address # These commands are exclusive to the test. # * Essential migration sub step * These addresses are likely known addresses to operators in the event of a real migration -PRIVATE_KEY="$(docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n')" +PRIVATE_KEY="$(docker compose run scripts print-private-key --account l2owner 2>dev/null | trim-last)" # This is a private key used for testing, save to print declare -p PRIVATE_KEY -OWNER_ADDRESS="$(docker compose run scripts print-address --account l2owner | tail -n 1 | tr -d '\r\n')" +OWNER_ADDRESS="$(docker compose run scripts print-address --account l2owner 2>/dev/null | trim-last)" declare -p OWNER_ADDRESS cd $ORBIT_ACTIONS_DIR -echo "Deploying mock espresso tee verifier" +info "Deploying mock espresso tee verifier" forge script --chain $PARENT_CHAIN_CHAIN_ID ../espresso-tests/DeployMockVerifier.s.sol:DeployMockVerifier --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv ESPRESSO_TEE_VERIFIER_ADDRESS=$(cat broadcast/DeployMockVerifier.s.sol/1337/run-latest.json | jq -r '.transactions[0].contractAddress' | cast to-checksum) declare -p ESPRESSO_TEE_VERIFIER_ADDRESS -echo "Mock TEE Address:" -echo $ESPRESSO_TEE_VERIFIER_ADDRESS -declare -p ESPRESSO_TEE_VERIFIER_ADDRESS - # Echo for debug -echo "Deploying and initializing Espresso SequencerInbox" +info "Deploying and initializing Espresso SequencerInbox" # ** Essential migration step ** Forge script to deploy the new SequencerInbox. We do this to later point the rollups challenge manager to the espresso integrated OSP. forge script --chain $PARENT_CHAIN_CHAIN_ID ../espresso-tests/DeployAndInitEspressoSequencerInboxForTest.s.sol:DeployAndInitEspressoSequencerInbox --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv --skip-simulation @@ -158,10 +175,10 @@ NEW_SEQUENCER_INBOX_IMPL_ADDRESS=$(cat broadcast/DeployAndInitEspressoSequencerI declare -p NEW_SEQUENCER_INBOX_IMPL_ADDRESS # Echo for debugging. -echo "Deployed new SequencerInbox at $NEW_SEQUENCER_INBOX_IMPL_ADDRESS" +info "Deployed new SequencerInbox at $NEW_SEQUENCER_INBOX_IMPL_ADDRESS" # Echo for debug -echo "Deploying Espresso SequencerInbox migration action" +info "Deploying Espresso SequencerInbox migration action" # ** Essential migration step ** Forge script to deploy Espresso OSP migration action run forge script --chain $PARENT_CHAIN_CHAIN_ID contracts/parent-chain/espresso-migration/DeployEspressoSequencerMigrationAction.s.sol:DeployEspressoSequencerMigrationAction --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv @@ -171,9 +188,9 @@ run forge script --chain $PARENT_CHAIN_CHAIN_ID contracts/parent-chain/espresso- SEQUENCER_MIGRATION_ACTION=$(cat broadcast/DeployEspressoSequencerMigrationAction.s.sol/1337/run-latest.json | jq -r '.transactions[0].contractAddress' | cast to-checksum) declare -p SEQUENCER_MIGRATION_ACTION -echo "Deployed new EspressoSequencerMigrationAction at $SEQUENCER_MIGRATION_ACTION" +info "Deployed new EspressoSequencerMigrationAction at $SEQUENCER_MIGRATION_ACTION" -echo "Deploying ArbOS Upgrade action" +info "Deploying ArbOS Upgrade action" # Forge script to deploy the Espresso ArbOS upgrade action. # ** Essential migration step ** the ArbOS upgrade signifies that the chain is now espresso compatible. run forge script --chain $CHILD_CHAIN_CHAIN_NAME contracts/child-chain/espresso-migration/DeployArbOSUpgradeAction.s.sol:DeployArbOSUpgradeAction --rpc-url $CHILD_CHAIN_RPC_URL --broadcast -vvvv @@ -183,19 +200,20 @@ ARBOS_UPGRADE_ACTION=$(cat broadcast/DeployArbOSUpgradeAction.s.sol/412346/run-l declare -p ARBOS_UPGRADE_ACTION # Echo information for debugging. -echo "Deployed ArbOSUpgradeAction at $ARBOS_UPGRADE_ACTION" +info "Deployed ArbOSUpgradeAction at $ARBOS_UPGRADE_ACTION" # Change directories to start nitro node in new docker container with espresso image cd $TESTNODE_DIR -docker stop nitro-testnode-sequencer-1 -docker wait nitro-testnode-sequencer-1 +run docker stop nitro-testnode-sequencer-1 +run docker wait nitro-testnode-sequencer-1 + # Start nitro node in new docker container with espresso image -./espresso-tests/create-espresso-integrated-nitro-node.bash +run ./espresso-tests/create-espresso-integrated-nitro-node.bash # Use cast to call the upgradeExecutor and execute the L1 upgrade actions.This will point the challenge manager at the new OSP entry, as well as update the wasmModuleRoot for the rollup. ** Essential migration step ** -cast send $PARENT_CHAIN_UPGRADE_EXECUTOR "execute(address, bytes)" $SEQUENCER_MIGRATION_ACTION $(cast calldata "perform()") --rpc-url $PARENT_CHAIN_RPC_URL --private-key $PRIVATE_KEY +run cast send $PARENT_CHAIN_UPGRADE_EXECUTOR "execute(address, bytes)" $SEQUENCER_MIGRATION_ACTION $(cast calldata "perform()") --rpc-url $PARENT_CHAIN_RPC_URL --private-key $PRIVATE_KEY -echo "Executed SequencerMigrationAction via UpgradeExecutor" +info "Executed SequencerMigrationAction via UpgradeExecutor" # Get the number of confirmed nodes before the upgrade to ensure the staker is still working. NUM_CONFIRMED_NODES_BEFORE_UPGRADE=$(cast call --rpc-url $PARENT_CHAIN_RPC_URL $ROLLUP_ADDRESS 'latestConfirmed()(uint256)') @@ -204,14 +222,14 @@ NUM_CONFIRMED_NODES_BEFORE_UPGRADE=$(cast call --rpc-url $PARENT_CHAIN_RPC_URL $ # Wait for CHILD_CHAIN_RPC_URL to be available # * Essential migration sub step * This is technically essential to the migration, but doesn't usually take long and shouldn't need to be programmatically determined during a live migration. while ! curl -s $CHILD_CHAIN_RPC_URL > /dev/null; do - echo "Waiting for $CHILD_CHAIN_RPC_URL to be available..." + info "Waiting for $CHILD_CHAIN_RPC_URL to be available..." sleep 5 done # Echo for debugging -echo "Adding child chain upgrade executor as an L2 chain owner" +info "Adding child chain upgrade executor as an L2 chain owner" # This step is done for the purposes of the test, as there should already be an upgrade executor on the child chain that is a chain owner -cast send 0x0000000000000000000000000000000000000070 'addChainOwner(address)' $CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY +run cast send 0x0000000000000000000000000000000000000070 'addChainOwner(address)' $CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY cd $ORBIT_ACTIONS_DIR # Grab the pre-upgrade ArbOS version for testing. @@ -219,13 +237,13 @@ ARBOS_VERSION_BEFORE_UPGRADE=$(cast call "0x000000000000000000000000000000000000 # Use the Upgrde executor on the child chain to execute the ArbOS upgrade to signify that the node is now operating in espresso mode. This is essential for the migration. # ** Essential migration step ** This step can technically be done before all of the others as it is just scheduling the ArbOS upgrade. The unix timestamp at which the upgrade occurrs can be determined by operators, but for the purposes of the test we use 0 to upgrade immediately. -cast send $CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS "execute(address, bytes)" $ARBOS_UPGRADE_ACTION $(cast calldata "perform()") --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY +run cast send $CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS "execute(address, bytes)" $ARBOS_UPGRADE_ACTION $(cast calldata "perform()") --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY cd $TEST_DIR # write tee verifier address into chain config jq -r '.arbitrum.EspressoTEEVerifierAddress |= $ESPRESSO_TEE_VERIFIER_ADDRESS' test-chain-config.json > sent-chain-config.json --arg ESPRESSO_TEE_VERIFIER_ADDRESS $ESPRESSO_TEE_VERIFIER_ADDRESS CHAIN_CONFIG=$(cat sent-chain-config.json) -cast send $CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS $(cast calldata "executeCall(address, bytes)" "0x0000000000000000000000000000000000000070" $(cast calldata "setChainConfig(string)" "$CHAIN_CONFIG")) --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY +run cast send $CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS $(cast calldata "executeCall(address, bytes)" "0x0000000000000000000000000000000000000070" $(cast calldata "setChainConfig(string)" "$CHAIN_CONFIG")) --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY # Set the chain config # Check the upgrade happened @@ -244,14 +262,10 @@ if [ $ARBOS_VERSION_AFTER_UPGRADE != "90" ]; then fail "ArbOS version not updated: Expected 90, Actual $ARBOS_VERSION_AFTER_UPGRADE" fi -# Check for balance before transfer. -# The following sequence is to check that transactions are still successfully being sequenced on the L2 -ORIGINAL_OWNER_BALANCE=$(cast balance $OWNER_ADDRESS -e --rpc-url $CHILD_CHAIN_RPC_URL) - -# Send 1 eth as the owner +info "Testing if the Espresso integration works by doing an Eth transfer." RECIPIENT_ADDRESS=0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA BALANCE_ORIG=$(cast balance $RECIPIENT_ADDRESS -e --rpc-url $CHILD_CHAIN_RPC_URL) -cast send $RECIPIENT_ADDRESS --value 1ether --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY +run cast send $RECIPIENT_ADDRESS --value 1ether --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY # Get the new balance after the transfer. BALANCE_NEW=$(cast balance $RECIPIENT_ADDRESS -e --rpc-url $CHILD_CHAIN_RPC_URL) From bc8230df99580d491b33bf89b1121a7e0414788c Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 22 Jan 2025 14:57:23 +0100 Subject: [PATCH 10/22] Fix typo --- espresso-tests/migration-test.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index 7b92816c..10fb84e9 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -151,7 +151,7 @@ declare -p CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS # Export l2 owner private key and address # These commands are exclusive to the test. # * Essential migration sub step * These addresses are likely known addresses to operators in the event of a real migration -PRIVATE_KEY="$(docker compose run scripts print-private-key --account l2owner 2>dev/null | trim-last)" +PRIVATE_KEY="$(docker compose run scripts print-private-key --account l2owner 2>/dev/null | trim-last)" # This is a private key used for testing, save to print declare -p PRIVATE_KEY From 17dc7267c1c81d3d8be3106435b601cd5515efbe Mon Sep 17 00:00:00 2001 From: tbro Date: Wed, 22 Jan 2025 10:58:20 -0300 Subject: [PATCH 11/22] Revert "try to run both branch w/ matrix" and "fix yaml" This reverts commit 69fd31ce1b9abce8be3883706ccfb2841947cd17 and 3e8144c850cc3f894a6f419ff7e7e8d98343748f. --- .github/workflows/migration.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/migration.yaml b/.github/workflows/migration.yaml index ce55102a..fc205016 100644 --- a/.github/workflows/migration.yaml +++ b/.github/workflows/migration.yaml @@ -17,15 +17,12 @@ concurrency: jobs: migration_test: runs-on: ubuntu-24.04 - strategy: - matrix: - branch: [integration, celestia-integration] steps: - name: Checkout uses: actions/checkout@v4 + ref: ${{matrix.branch}} with: - ref: ${{matrix.branch}} submodules: recursive - name: Install Nix From 759ec1cb6418117cf53cfe7e74f44b397171ff00 Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 22 Jan 2025 15:00:31 +0100 Subject: [PATCH 12/22] More info for the user --- espresso-tests/migration-test.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index 10fb84e9..db3daa58 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -246,7 +246,7 @@ CHAIN_CONFIG=$(cat sent-chain-config.json) run cast send $CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS $(cast calldata "executeCall(address, bytes)" "0x0000000000000000000000000000000000000070" $(cast calldata "setChainConfig(string)" "$CHAIN_CONFIG")) --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY # Set the chain config -# Check the upgrade happened +info Check the ArbOS upgrade happened # Grab the post upgrade ArbOS version. ARBOS_VERSION_AFTER_UPGRADE=$(cast call "0x0000000000000000000000000000000000000064" "arbOSVersion()(uint64)" --rpc-url $CHILD_CHAIN_RPC_URL) @@ -277,7 +277,9 @@ fi # Echo successful balance update echo "Balance of $RECIPIENT_ADDRESS changed from $BALANCE_ORIG to $BALANCE_NEW" -# Check that the staker is making progress after the upgrade +info Check that the staker is making progress after the upgrade +echo + START=$SECONDS echo "Waiting for confirmed nodes." while [ "$NUM_CONFIRMED_NODES_BEFORE_UPGRADE" == "$(cast call --rpc-url $PARENT_CHAIN_RPC_URL $ROLLUP_ADDRESS 'latestConfirmed()(uint256)')" ]; do From ff608eec0a740fe03d75396c42e6672455d4190d Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 22 Jan 2025 16:01:03 +0100 Subject: [PATCH 13/22] Fix indentation, dump logs if exit code is nonzero --- espresso-tests/migration-test.bash | 59 +++++++++++++++++++----------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index db3daa58..048d8ff5 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -36,16 +36,16 @@ function emph { # Display only the last line of piped input, continuously updating function fmt { - # Leave output unchanged in DEBUG mode - if [ "$DEBUG" = "true" ]; then - cat - return - fi - # rewrite the last line to avoid noisy output - while read -r line; do - tput cr; tput el; echo -n "$line"; - done - echo + # Leave output unchanged in DEBUG mode + if [ "$DEBUG" = "true" ]; then + cat + return + fi + # rewrite the last line to avoid noisy output + while read -r line; do + tput cr; tput el; echo -n "$line"; + done + echo } # Show something with a comment in front, to distinguish it from console output. @@ -57,8 +57,23 @@ function info { trap "exit" INT TERM trap cleanup EXIT function cleanup { - rm -vf "$TESTNODE_LOG_FILE" - rm -vf "$ESPRESSO_DEVNODE_LOG_FILE" + exit_code=$? + if [ $exit_code -ne 0 ]; then + echo + echo "An error occurred." + if [ -s "$ESPRESSO_DEVNODE_LOG_FILE" ]; then + echo "Espresso dev node logs:" + cat "$ESPRESSO_DEVNODE_LOG_FILE" + exit $exit_code + elif [ -s "$TESTNODE_LOG_FILE" ]; then + echo "Nitro testnode logs:" + cat "$TESTNODE_LOG_FILE" + exit $exit_code + fi + else + rm -vf "$TESTNODE_LOG_FILE" + rm -vf "$ESPRESSO_DEVNODE_LOG_FILE" + fi } # Find directory of this script, the project, and the orbit-actions submodule @@ -93,23 +108,23 @@ cd "$TESTNODE_DIR" info Deploying a vanilla Nitro stack locally, to be migrated to Espresso later. emph ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils if [ "$DEBUG" = "true" ]; then - ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils + ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils else - info "This command starts up an entire Nitro stack. It takes a long time." - info "Run \`tail -f $TESTNODE_LOG_FILE\` to see logs, if necessary." - echo - ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils > "$TESTNODE_LOG_FILE" 2>&1 + info "This command starts up an entire Nitro stack. It takes a long time." + info "Run \`tail -f $TESTNODE_LOG_FILE\` to see logs, if necessary." + echo + ./test-node.bash --simple --init-force --tokenbridge --detach --no-build-utils > "$TESTNODE_LOG_FILE" 2>&1 fi # Start espresso sequencer node for the purposes of the test e.g. not needed for the real migration. info "Starting a local Espresso confirmation layer development node" emph docker compose up espresso-dev-node --detach if [ "$DEBUG" = "true" ]; then - docker compose up espresso-dev-node --detach + docker compose up espresso-dev-node --detach else - info "Run \`tail -f $ESPRESSO_DEVNODE_LOG_FILE\` to see logs, if necessary." - echo - docker compose up espresso-dev-node --detach > "$ESPRESSO_DEVNODE_LOG_FILE" 2>&1 + info "Run \`tail -f $ESPRESSO_DEVNODE_LOG_FILE\` to see logs, if necessary." + echo + docker compose up espresso-dev-node --detach > "$ESPRESSO_DEVNODE_LOG_FILE" 2>&1 fi info "Load environment variables in $ENV_FILE" @@ -123,7 +138,7 @@ cat "$TEST_DIR/.env" | sed 's/^/ /' echo function trim-last { - tail -n 1 | tr -d '\r\n' + tail -n 1 | tr -d '\r\n' } function get-addr { From 2e5c394e97dab4781922dd6ec52c00bb6a5103b3 Mon Sep 17 00:00:00 2001 From: tbro Date: Wed, 22 Jan 2025 12:37:53 -0300 Subject: [PATCH 14/22] fix yaml again --- .github/workflows/migration.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/migration.yaml b/.github/workflows/migration.yaml index fc205016..d4e603e0 100644 --- a/.github/workflows/migration.yaml +++ b/.github/workflows/migration.yaml @@ -21,7 +21,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - ref: ${{matrix.branch}} with: submodules: recursive From da957910b014977d764fa9ebcdbc9f0067670d58 Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 22 Jan 2025 16:40:57 +0100 Subject: [PATCH 15/22] trim lines that are longer than terminal - Hide docker compose warnings due to orphan containers. These warnings show up a lot because of the ephemeral script containers. --- ...create-espresso-integrated-nitro-node.bash | 6 +++--- espresso-tests/migration-test.bash | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/espresso-tests/create-espresso-integrated-nitro-node.bash b/espresso-tests/create-espresso-integrated-nitro-node.bash index 3670c7c1..c042105b 100755 --- a/espresso-tests/create-espresso-integrated-nitro-node.bash +++ b/espresso-tests/create-espresso-integrated-nitro-node.bash @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -set -x # print each command before executing it, for debugging +# set -x # print each command before executing it, for debugging ESPRESSO_VERSION=ghcr.io/espressosystems/nitro-espresso-integration/nitro-node-dev:integration lightClientAddr=0xb6eb235fa509e3206f959761d11e3777e16d0e98 @@ -18,5 +18,5 @@ docker compose run scripts-espresso write-config --simple --simpleWithValidator # do whatever other espresso setup is needed. -# run esprsso-integrated nitro node for sequencing. -docker compose up sequencer-on-espresso --detach +# run Espresso integrated nitro node for sequencing. +docker compose up sequencer-on-espresso diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index 048d8ff5..dcfff74e 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -43,7 +43,9 @@ function fmt { fi # rewrite the last line to avoid noisy output while read -r line; do - tput cr; tput el; echo -n "$line"; + tput cr + tput el + echo "$line" | cut -c -"$(tput cols)" | tr -d '\r\n' done echo } @@ -83,6 +85,11 @@ ESPRESSO_DEVNODE_LOG_FILE=$(mktemp -t espresso-dev-node-logs-XXXXXXXX) TESTNODE_DIR="$(dirname "$TEST_DIR")" ORBIT_ACTIONS_DIR="$TESTNODE_DIR/orbit-actions" ENV_FILE="$TEST_DIR/.env" +# Hide docker compose warnings about orphaned containers. +export COMPOSE_IGNORE_ORPHANS=true + +info Ensuring docker compose project is stopped +run docker compose down --remove-orphans # Change to orbit actions directory, update the submodule, and install any dependencies for the purposes of the test. cd "$ORBIT_ACTIONS_DIR" @@ -144,7 +151,7 @@ function trim-last { function get-addr { local file="$1" local path="$2" - docker compose run --entrypoint cat scripts $file 2>/dev/null | jq -r "$path" | trim-last + docker compose run --entrypoint cat scripts $file | jq -r "$path" | trim-last } # Overwrite the ROLLUP_ADDRESS for this test, it might not be the same as the one in the .env file @@ -174,8 +181,8 @@ OWNER_ADDRESS="$(docker compose run scripts print-address --account l2owner 2>/d declare -p OWNER_ADDRESS cd $ORBIT_ACTIONS_DIR -info "Deploying mock espresso tee verifier" -forge script --chain $PARENT_CHAIN_CHAIN_ID ../espresso-tests/DeployMockVerifier.s.sol:DeployMockVerifier --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv +info "Deploying mock espresso TEE verifier" +run forge script --chain $PARENT_CHAIN_CHAIN_ID ../espresso-tests/DeployMockVerifier.s.sol:DeployMockVerifier --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv ESPRESSO_TEE_VERIFIER_ADDRESS=$(cat broadcast/DeployMockVerifier.s.sol/1337/run-latest.json | jq -r '.transactions[0].contractAddress' | cast to-checksum) declare -p ESPRESSO_TEE_VERIFIER_ADDRESS @@ -183,7 +190,7 @@ declare -p ESPRESSO_TEE_VERIFIER_ADDRESS # Echo for debug info "Deploying and initializing Espresso SequencerInbox" # ** Essential migration step ** Forge script to deploy the new SequencerInbox. We do this to later point the rollups challenge manager to the espresso integrated OSP. -forge script --chain $PARENT_CHAIN_CHAIN_ID ../espresso-tests/DeployAndInitEspressoSequencerInboxForTest.s.sol:DeployAndInitEspressoSequencerInbox --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv --skip-simulation +run forge script --chain $PARENT_CHAIN_CHAIN_ID ../espresso-tests/DeployAndInitEspressoSequencerInboxForTest.s.sol:DeployAndInitEspressoSequencerInbox --rpc-url $PARENT_CHAIN_RPC_URL --broadcast -vvvv --skip-simulation # * Essential migration sub step * These addresses are likely known addresses to operators in the event of a real migration after they have deployed the new OSP contracts, however, if operators create a script for the migration, this command is useful. NEW_SEQUENCER_INBOX_IMPL_ADDRESS=$(cat broadcast/DeployAndInitEspressoSequencerInboxForTest.s.sol/1337/run-latest.json | jq -r '.receipts[0].contractAddress'| cast to-checksum) @@ -308,4 +315,4 @@ echo "Confirmed nodes have progressed" # Echo to signal that test has been successful echo "Migration successfully completed!" -docker compose down +docker compose down --remove-orphans From fca6da731865ac2cb5ccc532f7849a4a251c35f7 Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 22 Jan 2025 17:17:55 +0100 Subject: [PATCH 16/22] Also remove volumes on startup --- espresso-tests/migration-test.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index dcfff74e..293a3c08 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -89,7 +89,7 @@ ENV_FILE="$TEST_DIR/.env" export COMPOSE_IGNORE_ORPHANS=true info Ensuring docker compose project is stopped -run docker compose down --remove-orphans +run docker compose down -v --remove-orphans # Change to orbit actions directory, update the submodule, and install any dependencies for the purposes of the test. cd "$ORBIT_ACTIONS_DIR" From b9e0c81ffb1d01b0ce1532ffc4508e499b015bfc Mon Sep 17 00:00:00 2001 From: tbro Date: Wed, 22 Jan 2025 15:29:40 -0300 Subject: [PATCH 17/22] bump the timeout --- .github/workflows/migration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/migration.yaml b/.github/workflows/migration.yaml index d4e603e0..600e674a 100644 --- a/.github/workflows/migration.yaml +++ b/.github/workflows/migration.yaml @@ -40,4 +40,4 @@ jobs: run: | nix develop --accept-flake-config --option sandbox relaxed \ -c espresso-tests/migration-test.bash - timeout-minutes: 45 + timeout-minutes: 60 From 222523cd160344c5c942c5ce84e4d1a6ba94d795 Mon Sep 17 00:00:00 2001 From: Jeremy <297323986@qq.com> Date: Thu, 23 Jan 2025 17:01:15 +0800 Subject: [PATCH 18/22] Add detach to the nitro node --- espresso-tests/create-espresso-integrated-nitro-node.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/espresso-tests/create-espresso-integrated-nitro-node.bash b/espresso-tests/create-espresso-integrated-nitro-node.bash index c042105b..f946ca6e 100755 --- a/espresso-tests/create-espresso-integrated-nitro-node.bash +++ b/espresso-tests/create-espresso-integrated-nitro-node.bash @@ -19,4 +19,4 @@ docker compose run scripts-espresso write-config --simple --simpleWithValidator # do whatever other espresso setup is needed. # run Espresso integrated nitro node for sequencing. -docker compose up sequencer-on-espresso +docker compose up sequencer-on-espresso --detach From 49d4213ebea0ee99fe1da41f796c7eabd4e5c615 Mon Sep 17 00:00:00 2001 From: tbro Date: Thu, 23 Jan 2025 07:52:39 -0300 Subject: [PATCH 19/22] Revert "bump the timeout" This reverts commit b9e0c81ffb1d01b0ce1532ffc4508e499b015bfc. --- .github/workflows/migration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/migration.yaml b/.github/workflows/migration.yaml index 600e674a..d4e603e0 100644 --- a/.github/workflows/migration.yaml +++ b/.github/workflows/migration.yaml @@ -40,4 +40,4 @@ jobs: run: | nix develop --accept-flake-config --option sandbox relaxed \ -c espresso-tests/migration-test.bash - timeout-minutes: 60 + timeout-minutes: 45 From 94175fc01674c9cc137776ff89642b5fee3adc5a Mon Sep 17 00:00:00 2001 From: sveitser Date: Thu, 23 Jan 2025 15:20:58 +0100 Subject: [PATCH 20/22] format output of docker compose down --- espresso-tests/migration-test.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index 293a3c08..07fa4c02 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -315,4 +315,4 @@ echo "Confirmed nodes have progressed" # Echo to signal that test has been successful echo "Migration successfully completed!" -docker compose down --remove-orphans +run docker compose down -v --remove-orphans From bc367fc2c9fca2c4ecef6953314444a5d2e9085c Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Thu, 23 Jan 2025 16:39:17 -0500 Subject: [PATCH 21/22] Update orbit-actions sub-module --- orbit-actions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orbit-actions b/orbit-actions index c44e3451..e7535cde 160000 --- a/orbit-actions +++ b/orbit-actions @@ -1 +1 @@ -Subproject commit c44e345109976d6cc12828087de5961ae201a785 +Subproject commit e7535cde6891a911dd28adcbb16e4f4bd3a57927 From 692c25d83bd02624b48a48b3034a0f84127f57c1 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Thu, 23 Jan 2025 16:39:45 -0500 Subject: [PATCH 22/22] Update migration test to reflect updated orbit-actions --- espresso-tests/migration-test.bash | 49 ------------------------------ 1 file changed, 49 deletions(-) diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index 07fa4c02..8d88f080 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -212,19 +212,6 @@ declare -p SEQUENCER_MIGRATION_ACTION info "Deployed new EspressoSequencerMigrationAction at $SEQUENCER_MIGRATION_ACTION" -info "Deploying ArbOS Upgrade action" -# Forge script to deploy the Espresso ArbOS upgrade action. -# ** Essential migration step ** the ArbOS upgrade signifies that the chain is now espresso compatible. -run forge script --chain $CHILD_CHAIN_CHAIN_NAME contracts/child-chain/espresso-migration/DeployArbOSUpgradeAction.s.sol:DeployArbOSUpgradeAction --rpc-url $CHILD_CHAIN_RPC_URL --broadcast -vvvv - -# Get the address of the newly deployed upgrade action. -ARBOS_UPGRADE_ACTION=$(cat broadcast/DeployArbOSUpgradeAction.s.sol/412346/run-latest.json | jq -r '.transactions[0].contractAddress') -declare -p ARBOS_UPGRADE_ACTION - -# Echo information for debugging. -info "Deployed ArbOSUpgradeAction at $ARBOS_UPGRADE_ACTION" - -# Change directories to start nitro node in new docker container with espresso image cd $TESTNODE_DIR run docker stop nitro-testnode-sequencer-1 @@ -248,42 +235,6 @@ while ! curl -s $CHILD_CHAIN_RPC_URL > /dev/null; do sleep 5 done -# Echo for debugging -info "Adding child chain upgrade executor as an L2 chain owner" -# This step is done for the purposes of the test, as there should already be an upgrade executor on the child chain that is a chain owner -run cast send 0x0000000000000000000000000000000000000070 'addChainOwner(address)' $CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY - -cd $ORBIT_ACTIONS_DIR -# Grab the pre-upgrade ArbOS version for testing. -ARBOS_VERSION_BEFORE_UPGRADE=$(cast call "0x0000000000000000000000000000000000000064" "arbOSVersion()(uint64)" --rpc-url $CHILD_CHAIN_RPC_URL) - -# Use the Upgrde executor on the child chain to execute the ArbOS upgrade to signify that the node is now operating in espresso mode. This is essential for the migration. -# ** Essential migration step ** This step can technically be done before all of the others as it is just scheduling the ArbOS upgrade. The unix timestamp at which the upgrade occurrs can be determined by operators, but for the purposes of the test we use 0 to upgrade immediately. -run cast send $CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS "execute(address, bytes)" $ARBOS_UPGRADE_ACTION $(cast calldata "perform()") --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY -cd $TEST_DIR -# write tee verifier address into chain config -jq -r '.arbitrum.EspressoTEEVerifierAddress |= $ESPRESSO_TEE_VERIFIER_ADDRESS' test-chain-config.json > sent-chain-config.json --arg ESPRESSO_TEE_VERIFIER_ADDRESS $ESPRESSO_TEE_VERIFIER_ADDRESS -CHAIN_CONFIG=$(cat sent-chain-config.json) - -run cast send $CHILD_CHAIN_UPGRADE_EXECUTOR_ADDRESS $(cast calldata "executeCall(address, bytes)" "0x0000000000000000000000000000000000000070" $(cast calldata "setChainConfig(string)" "$CHAIN_CONFIG")) --rpc-url $CHILD_CHAIN_RPC_URL --private-key $PRIVATE_KEY -# Set the chain config - -info Check the ArbOS upgrade happened - -# Grab the post upgrade ArbOS version. -ARBOS_VERSION_AFTER_UPGRADE=$(cast call "0x0000000000000000000000000000000000000064" "arbOSVersion()(uint64)" --rpc-url $CHILD_CHAIN_RPC_URL) -# Wait to observe the ArbOS version update. (potentially add a timeout or max retry number before failing) -while [ $ARBOS_VERSION_BEFORE_UPGRADE == $ARBOS_VERSION_AFTER_UPGRADE ] -do - sleep 5 - ARBOS_VERSION_AFTER_UPGRADE=$(cast call "0x0000000000000000000000000000000000000064" "arbOSVersion()(uint64)" --rpc-url $CHILD_CHAIN_RPC_URL) -done - -# We are upgrading the ArbOS version to 35 so the expect the return value to be 55 + 35 = 90 -if [ $ARBOS_VERSION_AFTER_UPGRADE != "90" ]; then - fail "ArbOS version not updated: Expected 90, Actual $ARBOS_VERSION_AFTER_UPGRADE" -fi - info "Testing if the Espresso integration works by doing an Eth transfer." RECIPIENT_ADDRESS=0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA BALANCE_ORIG=$(cast balance $RECIPIENT_ADDRESS -e --rpc-url $CHILD_CHAIN_RPC_URL)