Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,15 @@ 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. 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 \"$$@\"", "--"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you confirmed in the --validate thread, challenges cannot run on the roots this adds: those directories hold machine.wavm.br, and the v3.12.2 arbitrator opens machine.v2.wavm.br. The image never verifies them with its prover either. There is a second cost: every nitro service logs unable to find validator machine directory for the on-chain WASM module root at startup, because the entrypoint: /usr/local/bin/nitro overrides drop the image's --validation.wasm.allowed-wasm-module-roots, so each node's own locator only sees target/machines.

The roots that work fully (v50, v51, v51.1, v61) are already in target/machines, and the validation node serves them with no change here. So I would limit WASM_MODULE_ROOT to /home/user/target/machines/*/module-root.txt and drop this entrypoint. If you want the legacy roots anyway: say in the comment and in the error message that they are JIT-only, and add validation.wasm.allowed-wasm-module-roots: ["/home/user/nitro-legacy/machines", "/home/user/target/machines"] to the base node config in scripts/config.ts, so the nodes stop logging that error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to keep the legacy roots to, for example, test upgrades from older chains (I'm currently testing an upgrade from a v32 chain, which is what triggered this PR). I added a comment in 7807d37 to specify that the legacy machines only validate through JIT and can't run challenges, and the base node config in scripts/config.ts sets validation.wasm.allowed-wasm-module-roots to both directories. The --help text of the new --wasm-module-root option also says the nitro-legacy machines can't run challenges. I put that there instead of in the error message, because the error only fires for a root that isn't in the image at all.

ports:
- "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 /tmp/machines

scripts:
build: scripts/
Expand Down
5 changes: 5 additions & 0 deletions scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
49 changes: 44 additions & 5 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ if [[ $# -gt 0 ]] && [[ $1 == "script" ]]; then
exit $?
fi

num_volumes=`docker volume ls --filter label=com.docker.compose.project=nitro-testnode -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 "\"'")
project_filter="label=com.docker.compose.project=$project"

num_volumes=`docker volume ls --filter "$project_filter" -q | wc -l`

if [[ $num_volumes -eq 0 ]]; then
force_init=true
Expand Down Expand Up @@ -64,6 +69,7 @@ l2referenceda=false
l2timeboost=false
l2txfiltering=false
l2filteringreport=false
wasmroot=""

# Use the dev versions of nitro/blockscout
dev_nitro=false
Expand Down Expand Up @@ -312,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]
Expand Down Expand Up @@ -351,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"

Expand Down Expand Up @@ -457,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
Expand All @@ -473,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=nitro-testnode -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=nitro-testnode
leftoverVolumes=`docker volume ls --filter label=com.docker.compose.project=nitro-testnode -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
Expand Down Expand Up @@ -555,7 +592,9 @@ 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"`
if [ -z "$wasmroot" ]; then
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
Expand Down
Loading