From 9d18f530aa2638f5dbb7c9d98ef8325ae0548bc9 Mon Sep 17 00:00:00 2001 From: TucksonDev Date: Thu, 12 Nov 2026 11:22:25 +0000 Subject: [PATCH 1/3] qol: allow a custom wasmModuleRoot and base directory --- docker-compose.yaml | 2 +- test-node.bash | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 939d1279..86ccf91e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -338,7 +338,7 @@ services: - "127.0.0.1:8949:8549" volumes: - "config:/config" - command: --conf.file /config/validation_node_config.json + command: --conf.file /config/validation_node_config.json --validation.wasm.root-path /config/machines scripts: build: scripts/ diff --git a/test-node.bash b/test-node.bash index 72034c2d..b2398e88 100755 --- a/test-node.bash +++ b/test-node.bash @@ -22,6 +22,7 @@ echo "Using TOKEN_BRIDGE_BRANCH: $TOKEN_BRIDGE_BRANCH" mydir=`dirname $0` cd "$mydir" +project=$(basename "$PWD") run_script() { docker compose run --rm scripts "$@" @@ -33,7 +34,7 @@ if [[ $# -gt 0 ]] && [[ $1 == "script" ]]; then exit $? fi -num_volumes=`docker volume ls --filter label=com.docker.compose.project=nitro-testnode -q | wc -l` +num_volumes=`docker volume ls --filter label=com.docker.compose.project=$project -q | wc -l` if [[ $num_volumes -eq 0 ]]; then force_init=true @@ -473,12 +474,12 @@ fi if $force_init; then echo == Removing old data.. docker compose down --remove-orphans --timeout 10 2>/dev/null || true - leftoverContainers=`docker container ls -a --filter label=com.docker.compose.project=nitro-testnode -q | xargs echo` + leftoverContainers=`docker container ls -a --filter label=com.docker.compose.project=$project -q | xargs echo` if [ `echo $leftoverContainers | wc -w` -gt 0 ]; then docker rm -f $leftoverContainers fi - docker volume prune -f --filter label=com.docker.compose.project=nitro-testnode - leftoverVolumes=`docker volume ls --filter label=com.docker.compose.project=nitro-testnode -q | xargs echo` + docker volume prune -f --filter label=com.docker.compose.project=$project + leftoverVolumes=`docker volume ls --filter label=com.docker.compose.project=$project -q | xargs echo` if [ `echo $leftoverVolumes | wc -w` -gt 0 ]; then docker volume rm -f $leftoverVolumes fi @@ -555,7 +556,8 @@ if $force_init; then sequenceraddress=`run_script print-address --account sequencer | tail -n 1 | tr -d '\r\n'` l2ownerKey=`run_script print-private-key --account l2owner | tail -n 1 | tr -d '\r\n'` - wasmroot=`docker compose run --rm --entrypoint sh sequencer -c "cat /home/user/target/machines/latest/module-root.txt"` + # WASM_MODULE_ROOT sets the rollup's initial root, which otherwise is the image's latest machine + wasmroot=${WASM_MODULE_ROOT:-`docker compose run --rm --entrypoint sh sequencer -c "cat /home/user/target/machines/latest/module-root.txt"`} echo "== Deploying L2 chain" docker compose run --rm -e PARENT_CHAIN_RPC="http://geth:8545" -e DEPLOYER_PRIVKEY=$l2ownerKey -e PARENT_CHAIN_ID=$l1chainid -e CHILD_CHAIN_NAME="arb-dev-test" -e MAX_DATA_SIZE=117964 -e OWNER_ADDRESS=$l2ownerAddress -e WASM_MODULE_ROOT=$wasmroot -e SEQUENCER_ADDRESS=$sequenceraddress -e AUTHORIZE_VALIDATORS=10 -e CHILD_CHAIN_CONFIG_PATH="/config/l2_chain_config.json" -e CHAIN_DEPLOYMENT_INFO="/config/deployment.json" -e CHILD_CHAIN_INFO="/config/deployed_chain_info.json" rollupcreator create-rollup-testnode @@ -646,6 +648,11 @@ if $force_init; then run_script redis-init --redundancy $redundantsequencers fi + # The validation node serves the machines of one directory, so link the image's legacy and current machines into one. + # That way it can validate a rollup that starts on an older root, and the consensus-v61 root after an upgrade + echo == Linking legacy and current machines for the validation node + docker compose run --rm --entrypoint sh validation_node -c "mkdir -p /config/machines && ln -sfn /home/user/nitro-legacy/machines/0x* /home/user/target/machines/* /config/machines/" + echo == Funding l2 funnel and dev key docker compose up --wait $INITIAL_SEQ_NODES sleep 45 # in case we need to create a smart contract wallet, allow for parent chain to recieve the contract creation tx and process it From 8a701f67616d6506260491b4d2d4d9d7895e0e15 Mon Sep 17 00:00:00 2001 From: TucksonDev Date: Mon, 16 Nov 2026 12:55:52 +0000 Subject: [PATCH 2/3] Address feedback --- docker-compose.yaml | 6 ++++-- test-node.bash | 31 +++++++++++++++++++------------ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 86ccf91e..d3eb5856 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -333,12 +333,14 @@ services: validation_node: pid: host # allow debugging image: nitro-node-dev-testnode - entrypoint: /usr/local/bin/nitro-val + # Serve the image's legacy and current machines from one directory, so the node can validate a rollup that starts + # on an older root and the latest root after an upgrade. Built on every start, so it follows the image + entrypoint: ["sh", "-c", "mkdir -p /tmp/machines && ln -sfn /home/user/nitro-legacy/machines/0x* /home/user/target/machines/* /tmp/machines/ && exec /usr/local/bin/nitro-val \"$$@\"", "--"] ports: - "127.0.0.1:8949:8549" volumes: - "config:/config" - command: --conf.file /config/validation_node_config.json --validation.wasm.root-path /config/machines + command: --conf.file /config/validation_node_config.json --validation.wasm.root-path /tmp/machines scripts: build: scripts/ diff --git a/test-node.bash b/test-node.bash index b2398e88..3a7941e8 100755 --- a/test-node.bash +++ b/test-node.bash @@ -22,7 +22,6 @@ echo "Using TOKEN_BRIDGE_BRANCH: $TOKEN_BRIDGE_BRANCH" mydir=`dirname $0` cd "$mydir" -project=$(basename "$PWD") run_script() { docker compose run --rm scripts "$@" @@ -34,7 +33,15 @@ if [[ $# -gt 0 ]] && [[ $1 == "script" ]]; then exit $? fi -num_volumes=`docker volume ls --filter label=com.docker.compose.project=$project -q | wc -l` +# Env files are skipped since blockscout's is missing when its submodule isn't checked out; compose before v2.35 has +# no flag for that and needs the submodule. Compose quotes project names that look like numbers or booleans +project=$({ docker compose config --no-env-resolution 2>/dev/null || docker compose config; } | sed -n 's/^name: //p' | tr -d '"') +if [ -z "$project" ]; then + echo "Error: could not determine the docker compose project name" + exit 1 +fi + +num_volumes=`docker volume ls --filter "label=com.docker.compose.project=$project" -q | wc -l` if [[ $num_volumes -eq 0 ]]; then force_init=true @@ -474,12 +481,12 @@ fi if $force_init; then echo == Removing old data.. docker compose down --remove-orphans --timeout 10 2>/dev/null || true - leftoverContainers=`docker container ls -a --filter label=com.docker.compose.project=$project -q | xargs echo` + leftoverContainers=`docker container ls -a --filter "label=com.docker.compose.project=$project" -q | xargs echo` if [ `echo $leftoverContainers | wc -w` -gt 0 ]; then docker rm -f $leftoverContainers fi - docker volume prune -f --filter label=com.docker.compose.project=$project - leftoverVolumes=`docker volume ls --filter label=com.docker.compose.project=$project -q | xargs echo` + docker volume prune -f --filter "label=com.docker.compose.project=$project" + leftoverVolumes=`docker volume ls --filter "label=com.docker.compose.project=$project" -q | xargs echo` if [ `echo $leftoverVolumes | wc -w` -gt 0 ]; then docker volume rm -f $leftoverVolumes fi @@ -556,8 +563,13 @@ if $force_init; then sequenceraddress=`run_script print-address --account sequencer | tail -n 1 | tr -d '\r\n'` l2ownerKey=`run_script print-private-key --account l2owner | tail -n 1 | tr -d '\r\n'` - # WASM_MODULE_ROOT sets the rollup's initial root, which otherwise is the image's latest machine - wasmroot=${WASM_MODULE_ROOT:-`docker compose run --rm --entrypoint sh sequencer -c "cat /home/user/target/machines/latest/module-root.txt"`} + # WASM_MODULE_ROOT sets the initial root of the L2 and L3 rollups, which otherwise is the image's latest machine + if [ -n "${WASM_MODULE_ROOT:-}" ]; then + wasmroot=$WASM_MODULE_ROOT + docker compose run --rm --entrypoint sh sequencer -c 'grep -qsxiF "$1" /home/user/target/machines/*/module-root.txt /home/user/nitro-legacy/machines/*/module-root.txt' sh "$wasmroot" || { echo "Error: WASM_MODULE_ROOT $wasmroot is not a machine of the nitro image"; exit 1; } + else + wasmroot=`docker compose run --rm --entrypoint sh sequencer -c "cat /home/user/target/machines/latest/module-root.txt"` + fi echo "== Deploying L2 chain" docker compose run --rm -e PARENT_CHAIN_RPC="http://geth:8545" -e DEPLOYER_PRIVKEY=$l2ownerKey -e PARENT_CHAIN_ID=$l1chainid -e CHILD_CHAIN_NAME="arb-dev-test" -e MAX_DATA_SIZE=117964 -e OWNER_ADDRESS=$l2ownerAddress -e WASM_MODULE_ROOT=$wasmroot -e SEQUENCER_ADDRESS=$sequenceraddress -e AUTHORIZE_VALIDATORS=10 -e CHILD_CHAIN_CONFIG_PATH="/config/l2_chain_config.json" -e CHAIN_DEPLOYMENT_INFO="/config/deployment.json" -e CHILD_CHAIN_INFO="/config/deployed_chain_info.json" rollupcreator create-rollup-testnode @@ -648,11 +660,6 @@ if $force_init; then run_script redis-init --redundancy $redundantsequencers fi - # The validation node serves the machines of one directory, so link the image's legacy and current machines into one. - # That way it can validate a rollup that starts on an older root, and the consensus-v61 root after an upgrade - echo == Linking legacy and current machines for the validation node - docker compose run --rm --entrypoint sh validation_node -c "mkdir -p /config/machines && ln -sfn /home/user/nitro-legacy/machines/0x* /home/user/target/machines/* /config/machines/" - echo == Funding l2 funnel and dev key docker compose up --wait $INITIAL_SEQ_NODES sleep 45 # in case we need to create a smart contract wallet, allow for parent chain to recieve the contract creation tx and process it From 7807d37fc6065bcace6f7f203a708edae60e577b Mon Sep 17 00:00:00 2001 From: TucksonDev Date: Wed, 18 Nov 2026 12:12:45 +0000 Subject: [PATCH 3/3] Move WMR option to parameter, cleanup its usage, increase validation of project name --- docker-compose.yaml | 3 ++- scripts/config.ts | 5 +++++ test-node.bash | 53 +++++++++++++++++++++++++++++++++------------ 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index d3eb5856..7baca0b1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -334,7 +334,8 @@ services: pid: host # allow debugging image: nitro-node-dev-testnode # Serve the image's legacy and current machines from one directory, so the node can validate a rollup that starts - # on an older root and the latest root after an upgrade. Built on every start, so it follows the image + # on an older root and the latest root after an upgrade. Legacy machines lack machine.v2.wavm.br, so they only + # validate through JIT and can't run challenges. Built on every start, so it follows the image entrypoint: ["sh", "-c", "mkdir -p /tmp/machines && ln -sfn /home/user/nitro-legacy/machines/0x* /home/user/target/machines/* /tmp/machines/ && exec /usr/local/bin/nitro-val \"$$@\"", "--"] ports: - "127.0.0.1:8949:8549" diff --git a/scripts/config.ts b/scripts/config.ts index 88407678..0dc39c89 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -265,6 +265,11 @@ function writeConfigs(argv: any) { "id": 412346, "info-files": [chainInfoFile], }, + "validation": { + "wasm": { + "allowed-wasm-module-roots": ["/home/user/nitro-legacy/machines", "/home/user/target/machines"] + } + }, "node": { "bold": { "rpc-block-number": "latest", diff --git a/test-node.bash b/test-node.bash index 4e85e6e6..09867391 100755 --- a/test-node.bash +++ b/test-node.bash @@ -35,13 +35,10 @@ fi # Env files are skipped since blockscout's is missing when its submodule isn't checked out; compose before v2.35 has # no flag for that and needs the submodule. Compose quotes project names that look like numbers or booleans -project=$({ docker compose config --no-env-resolution 2>/dev/null || docker compose config; } | sed -n 's/^name: //p' | tr -d '"') -if [ -z "$project" ]; then - echo "Error: could not determine the docker compose project name" - exit 1 -fi +project=$({ docker compose config --no-env-resolution 2>/dev/null || docker compose config; } | sed -n 's/^name: //p' | tr -d "\"'") +project_filter="label=com.docker.compose.project=$project" -num_volumes=`docker volume ls --filter "label=com.docker.compose.project=$project" -q | wc -l` +num_volumes=`docker volume ls --filter "$project_filter" -q | wc -l` if [[ $num_volumes -eq 0 ]]; then force_init=true @@ -72,6 +69,7 @@ l2referenceda=false l2timeboost=false l2txfiltering=false l2filteringreport=false +wasmroot="" # Use the dev versions of nitro/blockscout dev_nitro=false @@ -320,6 +318,15 @@ while [[ $# -gt 0 ]]; do l3_traffic=false shift ;; + --wasm-module-root) + wasmroot=${2-} + if ! [[ $wasmroot =~ ^0x[0-9a-fA-F]{64}$ ]]; then + echo "Error: --wasm-module-root must be 0x followed by 64 hex characters." + exit 1 + fi + shift + shift + ;; *) echo Usage: $0 \[OPTIONS..] echo $0 script [SCRIPT-ARGS] @@ -359,12 +366,25 @@ while [[ $# -gt 0 ]]; do echo --build-utils rebuild scripts, rollupcreator, token bridge docker images echo --no-build-utils don\'t rebuild scripts, rollupcreator, token bridge docker images echo --force-build-utils force rebuilding utils, useful if NITRO_CONTRACTS_BRANCH or TOKEN_BRIDGE_BRANCH changes + echo --wasm-module-root initial WASM module root of the L2 and L3 rollups, one of the nitro image\'s machines \(default: the latest\). Needs an init, and a machine that supports the ArbOS version the chains start on. The nitro-legacy machines can\'t run challenges echo echo script runs inside a separate docker. For SCRIPT-ARGS, run $0 script --help exit 0 esac done +# Project is checked here to allow showing the --help information even when the project name can't be found +if [ -z "$project" ]; then + echo "Error: could not determine the docker compose project name" + exit 1 +fi + +# Wasm module root can only be set when initializing +if [ -n "$wasmroot" ] && ! $force_init; then + echo "Error: --wasm-module-root only applies when initializing." + exit 1 +fi + NODES="sequencer" INITIAL_SEQ_NODES="sequencer" @@ -465,6 +485,15 @@ else docker tag $NITRO_NODE_VERSION nitro-node-dev-testnode fi +# Validate the specified Wasm module root against the available machines in the nitro image +if [ -n "$wasmroot" ]; then + image_roots=`docker run --rm --entrypoint sh nitro-node-dev-testnode -c "cat /home/user/*/machines/*/module-root.txt"` + if ! grep -qxiF "$wasmroot" <<< "$image_roots"; then + echo "Error: $wasmroot is not a machine of the nitro image." + exit 1 + fi +fi + if $blockscout; then if $dev_blockscout; then docker tag blockscout:latest blockscout-testnode @@ -481,12 +510,12 @@ fi if $force_init; then echo == Removing old data.. docker compose down --remove-orphans --timeout 10 2>/dev/null || true - leftoverContainers=`docker container ls -a --filter "label=com.docker.compose.project=$project" -q | xargs echo` + leftoverContainers=`docker container ls -a --filter "$project_filter" -q | xargs echo` if [ `echo $leftoverContainers | wc -w` -gt 0 ]; then docker rm -f $leftoverContainers fi - docker volume prune -f --filter "label=com.docker.compose.project=$project" - leftoverVolumes=`docker volume ls --filter "label=com.docker.compose.project=$project" -q | xargs echo` + docker volume prune -f --filter "$project_filter" + leftoverVolumes=`docker volume ls --filter "$project_filter" -q | xargs echo` if [ `echo $leftoverVolumes | wc -w` -gt 0 ]; then docker volume rm -f $leftoverVolumes fi @@ -563,11 +592,7 @@ if $force_init; then sequenceraddress=`run_script print-address --account sequencer | tail -n 1 | tr -d '\r\n'` l2ownerKey=`run_script print-private-key --account l2owner | tail -n 1 | tr -d '\r\n'` - # WASM_MODULE_ROOT sets the initial root of the L2 and L3 rollups, which otherwise is the image's latest machine - if [ -n "${WASM_MODULE_ROOT:-}" ]; then - wasmroot=$WASM_MODULE_ROOT - docker compose run --rm --entrypoint sh sequencer -c 'grep -qsxiF "$1" /home/user/target/machines/*/module-root.txt /home/user/nitro-legacy/machines/*/module-root.txt' sh "$wasmroot" || { echo "Error: WASM_MODULE_ROOT $wasmroot is not a machine of the nitro image"; exit 1; } - else + if [ -z "$wasmroot" ]; then wasmroot=`docker compose run --rm --entrypoint sh sequencer -c "cat /home/user/target/machines/latest/module-root.txt"` fi