From b33fc8d47e964e49150e9fea6ecdffe733090b56 Mon Sep 17 00:00:00 2001 From: Sneh Koul <35871990+Sneh1999@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:59:09 -0500 Subject: [PATCH] Add smoke test for finality node (#58) * Add smoke test for finality node * add smoke test to ci * use wscat * use wscat * update bash * fix yaml * cleanup * cleanup * fix smoke test * fix smoke test --- .github/workflows/smoke-test.yml | 20 +++++++++++++++++--- docker-compose.yaml | 18 ++++++++++++++++++ scripts/config.ts | 23 +++++++++++++++++++++-- scripts/index.ts | 1 + smoke-test-espresso-finality-node.bash | 26 ++++++++++++++++++++++++++ test-node.bash | 14 ++++++++++++-- 6 files changed, 95 insertions(+), 7 deletions(-) create mode 100755 smoke-test-espresso-finality-node.bash diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 074d41e8..9eb5933a 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -14,13 +14,18 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ !contains(github.ref, 'integration/')}} - jobs: smoke_test: - strategy: matrix: - test-script: [ ./smoke-test.bash, ./smoke-test-l3.bash, ./smoke-test-nitro-simple.bash, ./smoke-test-full-node.bash ] + test-script: + [ + ./smoke-test.bash, + ./smoke-test-l3.bash, + ./smoke-test-nitro-simple.bash, + ./smoke-test-full-node.bash, + ./smoke-test-espresso-finality-node.bash, + ] runs-on: ubuntu-24.04 @@ -30,6 +35,15 @@ jobs: with: submodules: recursive + # Install wscat for finality node smoke test to listen to sequencer feed + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "16" + + - name: Install wscat + run: npm install -g wscat + - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: diff --git a/docker-compose.yaml b/docker-compose.yaml index cd2d8ad2..08f87711 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -182,6 +182,23 @@ services: depends_on: - geth + sequencer-espresso-finality: + pid: host # allow debugging + image: nitro-node-dev-testnode + entrypoint: /usr/local/bin/nitro + ports: + - "127.0.0.1:8549:8547" + - "127.0.0.1:8550:8548" + - "127.0.0.1:9645:9642" + volumes: + - "seqdata_espresso_finality:/home/user/.arbitrum/local/nitro" + - "l1keystore:/home/user/l1keystore" + - "config:/config" + - "tokenbridge-data:/tokenbridge-data" + command: --conf.file /config/espresso_finality_sequencer_config.json --node.feed.output.enable --node.feed.output.port 9642 --http.api net,web3,eth,txpool,debug --node.seq-coordinator.my-url ws://sequencer:8548 --graphql.enable --graphql.vhosts * --graphql.corsdomain * + depends_on: + - geth + sequencer_b: pid: host # allow debugging image: nitro-node-dev-testnode @@ -451,6 +468,7 @@ volumes: seqdata_b: seqdata_c: seqdata_d: + seqdata_espresso_finality: unsafestaker-data: validator-data: poster-data: diff --git a/scripts/config.ts b/scripts/config.ts index 1936b4d9..6b80e692 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -352,8 +352,27 @@ function writeConfigs(argv: any) { } else { sequencerConfig.node["seq-coordinator"].enable = true } - fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(sequencerConfig)) - + + if (argv.espresso && argv.enableEspressoFinalityNode) { + sequencerConfig.execution.sequencer["enable-espresso-finality-node"] = + true; + sequencerConfig.execution.sequencer["enable-espresso-sovereign"] = false; + sequencerConfig.execution.sequencer["espresso-finality-node-config"] = { + "hotshot-url": argv.espressoUrl, + "start-block": 0, + namespace: 412346, + }; + fs.writeFileSync( + path.join(consts.configpath, "espresso_finality_sequencer_config.json"), + JSON.stringify(sequencerConfig) + ); + } else { + fs.writeFileSync( + path.join(consts.configpath, "sequencer_config.json"), + JSON.stringify(sequencerConfig) + ); + } + let posterConfig = JSON.parse(baseConfJSON) if (argv.espresso) { posterConfig.node.feed.input.url.push("ws://sequencer:9642") diff --git a/scripts/index.ts b/scripts/index.ts index 43d1650c..3de0835c 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -36,6 +36,7 @@ async function main() { espresso: { boolean: true, decription: 'use Espresso Sequencer for sequencing and DA', default: false }, espressoUrl: { string: true, description: 'Espresso Sequencer url', default: 'http://espresso-dev-node:41000' }, lightClientAddress: { string: true, description: 'address of the light client contract', default: ''}, + enableEspressoFinalityNode: {boolean: true, description: 'enable finality node', default: false}, }) .command(bridgeFundsCommand) .command(bridgeToL3Command) diff --git a/smoke-test-espresso-finality-node.bash b/smoke-test-espresso-finality-node.bash new file mode 100755 index 00000000..3597c20e --- /dev/null +++ b/smoke-test-espresso-finality-node.bash @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +listen_to_sequencer_feed() { + # Listen to the sequencer feed and check if the sender address is detected + while read -r message; do + # Check if the message contains the specific sender address + if [[ "$message" == *"\"sender\":\"0xdd6bd74674c356345db88c354491c7d3173c6806\""* ]]; then + echo "Sender address detected" + break + fi + done < <(wscat -c ws://127.0.0.1:9642) +} + + +./test-node.bash --espresso --latest-espresso-image --validate --tokenbridge --init-force --detach --espresso-finality-node + +# Start the espresso finality node +docker compose up -d sequencer-espresso-finality --wait --detach + +# Sending L2 transaction +./test-node.bash script send-l2 --ethamount 100 --to user_l2user --wait + +listen_to_sequencer_feed + +docker compose down diff --git a/test-node.bash b/test-node.bash index b9a40625..3bb88336 100755 --- a/test-node.bash +++ b/test-node.bash @@ -63,7 +63,6 @@ devprivkey=b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 l1chainid=1337 simple=true simple_with_validator=false - while [[ $# -gt 0 ]]; do case $1 in --init) @@ -106,6 +105,10 @@ while [[ $# -gt 0 ]]; do l2_espresso=true shift ;; + --espresso-finality-node) + enableEspressoFinalityNode=true + shift + ;; --latest-espresso-image) latest_espresso_image=true shift @@ -234,6 +237,7 @@ while [[ $# -gt 0 ]]; do echo --no-tokenbridge don\'t build or launch tokenbridge echo --no-run does not launch nodes \(useful with build or init\) echo --no-simple run a full configuration with separate sequencer/batch-poster/validator/relayer + echo --enable-finality-node enable espresso finality node echo echo script runs inside a separate docker. For SCRIPT-ARGS, run $0 script --help exit 0 @@ -294,6 +298,7 @@ if [ $batchposters -gt 2 ]; then fi + if $validate; then NODES="$NODES validator" elif ! $simple; then @@ -308,6 +313,7 @@ if $l3node; then 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 @@ -397,6 +403,7 @@ if $force_init; then docker compose run --entrypoint sh geth -c "chown -R 1000:1000 /keystore" docker compose run --entrypoint sh geth -c "chown -R 1000:1000 /config" + if $consensusclient; then echo == Writing configs docker compose run scripts write-geth-genesis-config @@ -454,7 +461,10 @@ if $force_init; then else echo == Writing configs docker compose run scripts write-config --espresso $l2_espresso --lightClientAddress $lightClientAddr - + if $enableEspressoFinalityNode; then + echo == Writing configs for finality node + docker compose run scripts write-config --espresso $l2_espresso --enableEspressoFinalityNode --lightClientAddress $lightClientAddr + fi echo == Initializing redis docker compose up --wait redis docker compose run scripts redis-init --redundancy $redundantsequencers