Skip to content

Commit

Permalink
Fix the l3node (#41)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ImJeremyHe and sveitser authored Aug 21, 2024
1 parent 792eaed commit 85aeb89
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" "sha256-RuwIS+QKFj/T9M2TFXScjBsLR6V3A17YVoEW/Q6AZ1w="
fi

use nix
watch_file flake.nix
watch_file flake.lock
9 changes: 7 additions & 2 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ concurrency:

jobs:
smoke_test:

strategy:
matrix:
test-script: [ ./smoke-test.bash, ./smoke-test-l3.bash ]

runs-on: ubuntu-24.04

steps:
Expand Down Expand Up @@ -61,7 +66,7 @@ jobs:
build-args: |
TOKEN_BRIDGE_BRANCH=v1.2.2
- name: Start Smoke Test with Latest Espresso Image
- name: Smoke Test with Latest Espresso Image
run: |
./smoke-test.bash
${{ matrix.test-script }}
timeout-minutes: 30
13 changes: 13 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ services:
depends_on:
- sequencer
- validation_node
- espresso-dev-node

validation_node:
pid: host # allow debugging
Expand Down Expand Up @@ -376,6 +377,18 @@ services:
- ESPRESSO_DEV_NODE_PORT
- RUST_LOG=info
- RUST_LOG_FORMAT
- ESPRESSO_DEPLOYER_ALT_CHAIN_PROVIDERS
- ESPRESSO_DEPLOYER_ALT_MNEMONICS
- ESPRESSO_SEQUENCER_DEPLOYER_ALT_INDICES
depends_on:
- geth
- sequencer
healthcheck:
test: ["CMD-SHELL", "curl -fL http://localhost:$ESPRESSO_DEV_NODE_PORT || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 40s
extra_hosts:
- "host.docker.internal:host-gateway"

Expand Down
75 changes: 75 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
description = "A Nix-flake-based Node.js development environment";

inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
inputs.foundry.url = "github:shazow/foundry.nix/monthly"; # Use monthly branch for permanent releases

outputs = { self, nixpkgs, foundry }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs {
inherit system; overlays = [
foundry.overlay
self.overlays.default
];
};
});
in
{
overlays.default = final: prev: rec {
nodejs = prev.nodejs;
yarn = (prev.yarn.override { inherit nodejs; });
};

devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
nodejs
yarn
openssl # used by test-node.bash
foundry-bin
];
shellHook = ''
yarn install --cwd "$PWD/scripts"
export PATH="$PWD/scripts/node_modules/.bin:$PATH"
'';
};
});
};
}
13 changes: 12 additions & 1 deletion scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ function writeConfigs(argv: any) {
l3Config.node["delayed-sequencer"]["use-merge-finality"] = false
l3Config.node["batch-poster"].enable = true
l3Config.node["batch-poster"]["redis-url"] = ""
if (argv.espresso) {
l3Config.execution.sequencer.espresso = true
l3Config.execution.sequencer["hotshot-url"] = argv.espressoUrl
l3Config.node.feed.output.enable = true
l3Config.node.dangerous["no-sequencer-coordinator"] = true
}
fs.writeFileSync(path.join(consts.configpath, "l3node_config.json"), JSON.stringify(l3Config))

let validationNodeConfig = JSON.parse(JSON.stringify({
Expand Down Expand Up @@ -405,6 +411,7 @@ function writeL3ChainConfig(argv: any) {
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"espresso": argv.espresso,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
Expand All @@ -422,9 +429,13 @@ function writeL3ChainConfig(argv: any) {
"DataAvailabilityCommittee": false,
"InitialArbOSVersion": 30,
"InitialChainOwner": argv.l2owner,
"GenesisBlockNum": 0
"GenesisBlockNum": 0,
"EnableEspresso": false
}
}
if (argv.espresso) {
l3ChainConfig.arbitrum.EnableEspresso = true
}
const l3ChainConfigJSON = JSON.stringify(l3ChainConfig)
fs.writeFileSync(path.join(consts.configpath, "l3_chain_config.json"), l3ChainConfigJSON)
}
Expand Down
31 changes: 31 additions & 0 deletions smoke-test-l3.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail

./test-node.bash --init-force --espresso --latest-espresso-image --l3node --l3-token-bridge --l3-fee-token --detach

echo "Sending L3 transaction"
user=user_l3
./test-node.bash script send-l3 --ethamount 5 --to $user --wait
userAddress=$(docker compose run scripts print-address --account $user | tail -n 1 | tr -d '\r\n')

balance=$(cast balance $userAddress --rpc-url http://localhost:3347)

if [ "$balance" -eq 0 ]; then
echo "Transfer failed in l3 node"
exit 1
fi

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'")
while true; do
confirmed=$(cast call --rpc-url http://localhost:8547 $rollupAddress 'latestConfirmed()(uint256)')
echo "Number of confirmed staking nodes: $confirmed"
if [ "$confirmed" -gt 0 ]; then
break
else
echo "Waiting for more confirmed nodes ..."
fi
sleep 5
done

echo "Smoke test succeeded."
docker compose down
4 changes: 2 additions & 2 deletions smoke-test.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

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

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

echo "Smoke test succeeded"
docker compose down
23 changes: 18 additions & 5 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ l3node=false
consensusclient=false
redundantsequencers=0
lightClientAddr=0xb6eb235fa509e3206f959761d11e3777e16d0e98
lightClientAddrForL3=0x5e36aa9caaf5f708fca5c04d2d4c776a62b2b258
dev_build_nitro=false
dev_build_blockscout=false
espresso=false
l2_espresso=false
latest_espresso_image=false
l3_custom_fee_token=false
l3_token_bridge=false
Expand Down Expand Up @@ -96,6 +98,7 @@ while [[ $# -gt 0 ]]; do
--espresso)
simple=false
espresso=true
l2_espresso=true
shift
;;
--latest-espresso-image)
Expand Down Expand Up @@ -277,13 +280,21 @@ elif ! $simple; then
fi
if $l3node; then
NODES="$NODES l3node"
export ESPRESSO_DEPLOYER_ALT_CHAIN_PROVIDERS="http://sequencer:8547"
export ESPRESSO_DEPLOYER_ALT_MNEMONICS="indoor dish desk flag debris potato excuse depart ticket judge file exit"
export ESPRESSO_SEQUENCER_DEPLOYER_ALT_INDICES="6"
fi
if $blockscout; then
NODES="$NODES blockscout"
fi

if $espresso; then
if $force_build; then
if $l3node; then
# If we run the `l3node` with enabling espresso mode, then the
# l2 node will run without `espresso` mode.
l2_espresso=false
fi
if $force_build && $l2_espresso; then
INITIAL_SEQ_NODES="$INITIAL_SEQ_NODES espresso-dev-node"
else
NODES="$NODES espresso-dev-node"
Expand Down Expand Up @@ -396,9 +407,10 @@ if $force_init; then
docker compose run scripts send-l1 --ethamount 0.0001 --from user_l1user --to user_l1user_b --wait --delay 500 --times 1000000 > /dev/null &

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

echo == Writing l2 chain config
docker compose run scripts --l2owner $l2ownerAddress write-l2-chain-config --espresso $espresso
docker compose run scripts --l2owner $l2ownerAddress write-l2-chain-config --espresso $l2_espresso

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

if $simple; then
echo == Writing configs
docker compose run scripts write-config --simple
else
echo == Writing configs
docker compose run scripts write-config --espresso $espresso --lightClientAddress $lightClientAddr
docker compose run scripts write-config --espresso $l2_espresso --lightClientAddress $lightClientAddr

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

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

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
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
docker compose run --entrypoint sh rollupcreator -c "jq [.[]] /config/deployed_l3_chain_info.json > /config/l3_chain_info.json"

echo == Funding l3 funnel and dev key
Expand Down

0 comments on commit 85aeb89

Please sign in to comment.