Skip to content

Commit 85aeb89

Browse files
ImJeremyHesveitser
andauthored
Fix the l3node (OffchainLabs#41)
* Fix the L3 node * Add comments for l3node with espresso mode * Fix smoke test * Add l3 node test in smoke test * Separate the l3 test bash * Add flake.nix --------- Co-authored-by: sveitser <sveitser@gmail.com>
1 parent 792eaed commit 85aeb89

9 files changed

Lines changed: 205 additions & 10 deletions

File tree

.envrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then
2+
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" "sha256-RuwIS+QKFj/T9M2TFXScjBsLR6V3A17YVoEW/Q6AZ1w="
3+
fi
4+
5+
use nix
6+
watch_file flake.nix
7+
watch_file flake.lock

.github/workflows/smoke-test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ concurrency:
1717

1818
jobs:
1919
smoke_test:
20+
21+
strategy:
22+
matrix:
23+
test-script: [ ./smoke-test.bash, ./smoke-test-l3.bash ]
24+
2025
runs-on: ubuntu-24.04
2126

2227
steps:
@@ -61,7 +66,7 @@ jobs:
6166
build-args: |
6267
TOKEN_BRIDGE_BRANCH=v1.2.2
6368
64-
- name: Start Smoke Test with Latest Espresso Image
69+
- name: Smoke Test with Latest Espresso Image
6570
run: |
66-
./smoke-test.bash
71+
${{ matrix.test-script }}
6772
timeout-minutes: 30

docker-compose.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ services:
306306
depends_on:
307307
- sequencer
308308
- validation_node
309+
- espresso-dev-node
309310

310311
validation_node:
311312
pid: host # allow debugging
@@ -376,6 +377,18 @@ services:
376377
- ESPRESSO_DEV_NODE_PORT
377378
- RUST_LOG=info
378379
- RUST_LOG_FORMAT
380+
- ESPRESSO_DEPLOYER_ALT_CHAIN_PROVIDERS
381+
- ESPRESSO_DEPLOYER_ALT_MNEMONICS
382+
- ESPRESSO_SEQUENCER_DEPLOYER_ALT_INDICES
383+
depends_on:
384+
- geth
385+
- sequencer
386+
healthcheck:
387+
test: ["CMD-SHELL", "curl -fL http://localhost:$ESPRESSO_DEV_NODE_PORT || exit 1"]
388+
interval: 30s
389+
timeout: 10s
390+
retries: 5
391+
start_period: 40s
379392
extra_hosts:
380393
- "host.docker.internal:host-gateway"
381394

flake.lock

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
description = "A Nix-flake-based Node.js development environment";
3+
4+
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
5+
inputs.foundry.url = "github:shazow/foundry.nix/monthly"; # Use monthly branch for permanent releases
6+
7+
outputs = { self, nixpkgs, foundry }:
8+
let
9+
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
10+
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
11+
pkgs = import nixpkgs {
12+
inherit system; overlays = [
13+
foundry.overlay
14+
self.overlays.default
15+
];
16+
};
17+
});
18+
in
19+
{
20+
overlays.default = final: prev: rec {
21+
nodejs = prev.nodejs;
22+
yarn = (prev.yarn.override { inherit nodejs; });
23+
};
24+
25+
devShells = forEachSupportedSystem ({ pkgs }: {
26+
default = pkgs.mkShell {
27+
packages = with pkgs; [
28+
nodejs
29+
yarn
30+
openssl # used by test-node.bash
31+
foundry-bin
32+
];
33+
shellHook = ''
34+
yarn install --cwd "$PWD/scripts"
35+
export PATH="$PWD/scripts/node_modules/.bin:$PATH"
36+
'';
37+
};
38+
});
39+
};
40+
}

scripts/config.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ function writeConfigs(argv: any) {
334334
l3Config.node["delayed-sequencer"]["use-merge-finality"] = false
335335
l3Config.node["batch-poster"].enable = true
336336
l3Config.node["batch-poster"]["redis-url"] = ""
337+
if (argv.espresso) {
338+
l3Config.execution.sequencer.espresso = true
339+
l3Config.execution.sequencer["hotshot-url"] = argv.espressoUrl
340+
l3Config.node.feed.output.enable = true
341+
l3Config.node.dangerous["no-sequencer-coordinator"] = true
342+
}
337343
fs.writeFileSync(path.join(consts.configpath, "l3node_config.json"), JSON.stringify(l3Config))
338344

339345
let validationNodeConfig = JSON.parse(JSON.stringify({
@@ -405,6 +411,7 @@ function writeL3ChainConfig(argv: any) {
405411
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
406412
"eip155Block": 0,
407413
"eip158Block": 0,
414+
"espresso": argv.espresso,
408415
"byzantiumBlock": 0,
409416
"constantinopleBlock": 0,
410417
"petersburgBlock": 0,
@@ -422,9 +429,13 @@ function writeL3ChainConfig(argv: any) {
422429
"DataAvailabilityCommittee": false,
423430
"InitialArbOSVersion": 30,
424431
"InitialChainOwner": argv.l2owner,
425-
"GenesisBlockNum": 0
432+
"GenesisBlockNum": 0,
433+
"EnableEspresso": false
426434
}
427435
}
436+
if (argv.espresso) {
437+
l3ChainConfig.arbitrum.EnableEspresso = true
438+
}
428439
const l3ChainConfigJSON = JSON.stringify(l3ChainConfig)
429440
fs.writeFileSync(path.join(consts.configpath, "l3_chain_config.json"), l3ChainConfigJSON)
430441
}

smoke-test-l3.bash

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
./test-node.bash --init-force --espresso --latest-espresso-image --l3node --l3-token-bridge --l3-fee-token --detach
5+
6+
echo "Sending L3 transaction"
7+
user=user_l3
8+
./test-node.bash script send-l3 --ethamount 5 --to $user --wait
9+
userAddress=$(docker compose run scripts print-address --account $user | tail -n 1 | tr -d '\r\n')
10+
11+
balance=$(cast balance $userAddress --rpc-url http://localhost:3347)
12+
13+
if [ "$balance" -eq 0 ]; then
14+
echo "Transfer failed in l3 node"
15+
exit 1
16+
fi
17+
18+
rollupAddress=$(docker compose run --entrypoint sh poster -c "jq -r '.[0].rollup.rollup' /config/deployed_l3_chain_info.json | tail -n 1 | tr -d '\r\n'")
19+
while true; do
20+
confirmed=$(cast call --rpc-url http://localhost:8547 $rollupAddress 'latestConfirmed()(uint256)')
21+
echo "Number of confirmed staking nodes: $confirmed"
22+
if [ "$confirmed" -gt 0 ]; then
23+
break
24+
else
25+
echo "Waiting for more confirmed nodes ..."
26+
fi
27+
sleep 5
28+
done
29+
30+
echo "Smoke test succeeded."
31+
docker compose down

smoke-test.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
./test-node.bash --espresso --latest-espresso-image --validate --tokenbridge --init --detach
4+
./test-node.bash --espresso --latest-espresso-image --validate --tokenbridge --init-force --detach
55

66
# Sending L2 transaction
77
./test-node.bash script send-l2 --ethamount 100 --to user_l2user --wait
@@ -18,4 +18,4 @@ while true; do
1818
sleep 5
1919
done
2020

21-
echo "Smoke test succeeded"
21+
docker compose down

test-node.bash

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ l3node=false
4545
consensusclient=false
4646
redundantsequencers=0
4747
lightClientAddr=0xb6eb235fa509e3206f959761d11e3777e16d0e98
48+
lightClientAddrForL3=0x5e36aa9caaf5f708fca5c04d2d4c776a62b2b258
4849
dev_build_nitro=false
4950
dev_build_blockscout=false
5051
espresso=false
52+
l2_espresso=false
5153
latest_espresso_image=false
5254
l3_custom_fee_token=false
5355
l3_token_bridge=false
@@ -96,6 +98,7 @@ while [[ $# -gt 0 ]]; do
9698
--espresso)
9799
simple=false
98100
espresso=true
101+
l2_espresso=true
99102
shift
100103
;;
101104
--latest-espresso-image)
@@ -277,13 +280,21 @@ elif ! $simple; then
277280
fi
278281
if $l3node; then
279282
NODES="$NODES l3node"
283+
export ESPRESSO_DEPLOYER_ALT_CHAIN_PROVIDERS="http://sequencer:8547"
284+
export ESPRESSO_DEPLOYER_ALT_MNEMONICS="indoor dish desk flag debris potato excuse depart ticket judge file exit"
285+
export ESPRESSO_SEQUENCER_DEPLOYER_ALT_INDICES="6"
280286
fi
281287
if $blockscout; then
282288
NODES="$NODES blockscout"
283289
fi
284290

285291
if $espresso; then
286-
if $force_build; then
292+
if $l3node; then
293+
# If we run the `l3node` with enabling espresso mode, then the
294+
# l2 node will run without `espresso` mode.
295+
l2_espresso=false
296+
fi
297+
if $force_build && $l2_espresso; then
287298
INITIAL_SEQ_NODES="$INITIAL_SEQ_NODES espresso-dev-node"
288299
else
289300
NODES="$NODES espresso-dev-node"
@@ -396,9 +407,10 @@ if $force_init; then
396407
docker compose run scripts send-l1 --ethamount 0.0001 --from user_l1user --to user_l1user_b --wait --delay 500 --times 1000000 > /dev/null &
397408

398409
l2ownerAddress=`docker compose run scripts print-address --account l2owner | tail -n 1 | tr -d '\r\n'`
410+
echo $l2ownerAddress
399411

400412
echo == Writing l2 chain config
401-
docker compose run scripts --l2owner $l2ownerAddress write-l2-chain-config --espresso $espresso
413+
docker compose run scripts --l2owner $l2ownerAddress write-l2-chain-config --espresso $l2_espresso
402414

403415
sequenceraddress=`docker compose run scripts print-address --account sequencer | tail -n 1 | tr -d '\r\n'`
404416
l2ownerKey=`docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n'`
@@ -407,13 +419,14 @@ if $force_init; then
407419
echo == Deploying L2 chain
408420
docker compose run -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" -e LIGHT_CLIENT_ADDR=$lightClientAddr rollupcreator create-rollup-testnode
409421
docker compose run --entrypoint sh rollupcreator -c "jq [.[]] /config/deployed_chain_info.json > /config/l2_chain_info.json"
422+
docker compose run --entrypoint sh rollupcreator -c "cat /config/l2_chain_info.json"
410423

411424
if $simple; then
412425
echo == Writing configs
413426
docker compose run scripts write-config --simple
414427
else
415428
echo == Writing configs
416-
docker compose run scripts write-config --espresso $espresso --lightClientAddress $lightClientAddr
429+
docker compose run scripts write-config --espresso $l2_espresso --lightClientAddress $lightClientAddr
417430

418431
echo == Initializing redis
419432
docker compose up --wait redis
@@ -460,7 +473,7 @@ if $force_init; then
460473
echo == Writing l3 chain config
461474
l3owneraddress=`docker compose run scripts print-address --account l3owner | tail -n 1 | tr -d '\r\n'`
462475
echo l3owneraddress $l3owneraddress
463-
docker compose run scripts --l2owner $l3owneraddress write-l3-chain-config
476+
docker compose run scripts --l2owner $l3owneraddress write-l3-chain-config --espresso $espresso
464477

465478
if $l3_custom_fee_token; then
466479
echo == Deploying custom fee token
@@ -474,7 +487,7 @@ if $force_init; then
474487
l3ownerkey=`docker compose run scripts print-private-key --account l3owner | tail -n 1 | tr -d '\r\n'`
475488
l3sequenceraddress=`docker compose run scripts print-address --account l3sequencer | tail -n 1 | tr -d '\r\n'`
476489

477-
docker compose run -e DEPLOYER_PRIVKEY=$l3ownerkey -e PARENT_CHAIN_RPC="http://sequencer:8547" -e PARENT_CHAIN_ID=412346 -e CHILD_CHAIN_NAME="orbit-dev-test" -e MAX_DATA_SIZE=104857 -e OWNER_ADDRESS=$l3owneraddress -e WASM_MODULE_ROOT=$wasmroot -e SEQUENCER_ADDRESS=$l3sequenceraddress -e AUTHORIZE_VALIDATORS=10 -e CHILD_CHAIN_CONFIG_PATH="/config/l3_chain_config.json" -e CHAIN_DEPLOYMENT_INFO="/config/l3deployment.json" -e CHILD_CHAIN_INFO="/config/deployed_l3_chain_info.json" $EXTRA_L3_DEPLOY_FLAG rollupcreator create-rollup-testnode
490+
docker compose run -e DEPLOYER_PRIVKEY=$l3ownerkey -e PARENT_CHAIN_RPC="http://sequencer:8547" -e PARENT_CHAIN_ID=412346 -e CHILD_CHAIN_NAME="orbit-dev-test" -e MAX_DATA_SIZE=104857 -e OWNER_ADDRESS=$l3owneraddress -e WASM_MODULE_ROOT=$wasmroot -e SEQUENCER_ADDRESS=$l3sequenceraddress -e AUTHORIZE_VALIDATORS=10 -e CHILD_CHAIN_CONFIG_PATH="/config/l3_chain_config.json" -e CHAIN_DEPLOYMENT_INFO="/config/l3deployment.json" -e CHILD_CHAIN_INFO="/config/deployed_l3_chain_info.json" -e LIGHT_CLIENT_ADDR=$lightClientAddrForL3 $EXTRA_L3_DEPLOY_FLAG rollupcreator create-rollup-testnode
478491
docker compose run --entrypoint sh rollupcreator -c "jq [.[]] /config/deployed_l3_chain_info.json > /config/l3_chain_info.json"
479492

480493
echo == Funding l3 funnel and dev key

0 commit comments

Comments
 (0)