From 1a8edba6b9548115d17d83d1be47cf60beeeb483 Mon Sep 17 00:00:00 2001 From: ImJeremyHe Date: Thu, 22 Aug 2024 12:13:34 +0800 Subject: [PATCH 1/3] Fix test node with only '--simple' --- docker-compose.yaml | 1 + rollupcreator/Dockerfile | 3 ++- scripts/config.ts | 30 +++++++++++++++++------------- smoke-test-nitro-simple.bash | 21 +++++++++++++++++++++ test-node.bash | 18 ++++++++++++++++-- 5 files changed, 57 insertions(+), 16 deletions(-) create mode 100755 smoke-test-nitro-simple.bash diff --git a/docker-compose.yaml b/docker-compose.yaml index a8d2aecd..2d4ce4ec 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -357,6 +357,7 @@ services: build: context: rollupcreator/ args: + NITRO_CONTRACTS_REPO: ${NITRO_CONTRACTS_REPO:-} NITRO_CONTRACTS_BRANCH: ${NITRO_CONTRACTS_BRANCH:-} volumes: - "config:/config" diff --git a/rollupcreator/Dockerfile b/rollupcreator/Dockerfile index 09ecb815..3ae9349e 100644 --- a/rollupcreator/Dockerfile +++ b/rollupcreator/Dockerfile @@ -1,9 +1,10 @@ FROM node:18-bullseye-slim ARG NITRO_CONTRACTS_BRANCH=main +ARG NITRO_CONTRACTS_REPO=https://github.com/OffchainLabs/nitro-contracts.git RUN apt-get update && \ apt-get install -y git docker.io python3 build-essential curl jq WORKDIR /workspace -RUN git clone --no-checkout https://github.com/EspressoSystems/nitro-contracts.git ./ +RUN git clone --no-checkout ${NITRO_CONTRACTS_REPO} ./ RUN git checkout ${NITRO_CONTRACTS_BRANCH} RUN curl -L https://foundry.paradigm.xyz | bash ENV PATH="${PATH}:/root/.foundry/bin" diff --git a/scripts/config.ts b/scripts/config.ts index 16eb273e..1377979b 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -213,16 +213,12 @@ function writeConfigs(argv: any) { }, "wait-for-l1-finality": false }, - "hotshot-url": "", - "light-client-address": "", }, "block-validator": { "validation-server" : { "url": argv.validationNodeUrl, "jwtsecret": valJwtSecret, }, - "espresso": false, - "light-client-address": "", "dangerous": {"reset-block-validation": false}, }, "feed": { @@ -239,9 +235,6 @@ function writeConfigs(argv: any) { "execution": { "sequencer": { "enable": false, - "espresso": false, - "hotshot-url": "", - "espresso-namespace": 412346, }, "forwarding-target": "null", }, @@ -259,6 +252,17 @@ function writeConfigs(argv: any) { }, } + if (argv.espresso) { + let config = baseConfig as any + config.node['block-validator']["espresso"] = false + config.node['block-validator']["light-client-address"] = "" + config.node["batch-poster"]["hotshot-url"] = "" + config.node["batch-poster"]["light-client-address"] = "" + config["execution"]["sequencer"]["espresso"] = false + config["execution"]["sequencer"]["hotshot-url"] = "" + config["execution"]["sequencer"]["espresso-namespace"] = 412346 + } + const baseConfJSON = JSON.stringify(baseConfig) @@ -373,7 +377,6 @@ function writeL2ChainConfig(argv: any) { "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "eip155Block": 0, "eip158Block": 0, - "espresso": argv.espresso, "byzantiumBlock": 0, "constantinopleBlock": 0, "petersburgBlock": 0, @@ -392,11 +395,12 @@ function writeL2ChainConfig(argv: any) { "InitialArbOSVersion": 30, "InitialChainOwner": argv.l2owner, "GenesisBlockNum": 0, - "EnableEspresso": false, } } if (argv.espresso) { - l2ChainConfig.arbitrum.EnableEspresso = true + let chainConfig = l2ChainConfig as any + chainConfig.arbitrum["EnableEspresso"] = true + chainConfig["espresso"] = true } const l2ChainConfigJSON = JSON.stringify(l2ChainConfig) fs.writeFileSync(path.join(consts.configpath, "l2_chain_config.json"), l2ChainConfigJSON) @@ -411,7 +415,6 @@ function writeL3ChainConfig(argv: any) { "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "eip155Block": 0, "eip158Block": 0, - "espresso": argv.espresso, "byzantiumBlock": 0, "constantinopleBlock": 0, "petersburgBlock": 0, @@ -430,11 +433,12 @@ function writeL3ChainConfig(argv: any) { "InitialArbOSVersion": 30, "InitialChainOwner": argv.l2owner, "GenesisBlockNum": 0, - "EnableEspresso": false } } if (argv.espresso) { - l3ChainConfig.arbitrum.EnableEspresso = true + let chainConfig = l3ChainConfig as any + chainConfig.arbitrum["EnableEspresso"] = true + chainConfig["espresso"] = true } const l3ChainConfigJSON = JSON.stringify(l3ChainConfig) fs.writeFileSync(path.join(consts.configpath, "l3_chain_config.json"), l3ChainConfigJSON) diff --git a/smoke-test-nitro-simple.bash b/smoke-test-nitro-simple.bash new file mode 100755 index 00000000..92c8f783 --- /dev/null +++ b/smoke-test-nitro-simple.bash @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +./test-node.bash --init-force --simple --detach + +# Sending L2 transaction +./test-node.bash script send-l2 --ethamount 100 --to user_l2user --wait + +rollupAddress=$(docker compose run --entrypoint sh poster -c "jq -r '.[0].rollup.rollup' /config/deployed_chain_info.json | tail -n 1 | tr -d '\r\n'") +while true; do + confirmed=$(cast call --rpc-url http://localhost:8545 $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 + +docker compose down diff --git a/test-node.bash b/test-node.bash index 3d8a231c..e9cdd2ae 100755 --- a/test-node.bash +++ b/test-node.bash @@ -3,15 +3,19 @@ set -e NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.0.1-cf4b74e-dev -ESPRESSO_VERSION=ghcr.io/espressosystems/nitro-espresso-integration/nitro-node-dev:integration BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.0.0-c8db5b1 -DEFAULT_NITRO_CONTRACTS_VERSION="develop" +DEFAULT_NITRO_CONTRACTS_REPO="https://github.com/OffchainLabs/nitro-contracts.git" +DEFAULT_NITRO_CONTRACTS_VERSION="99c07a7db2fcce75b751c5a2bd4936e898cda065" DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.2" +ESPRESSO_VERSION=ghcr.io/espressosystems/nitro-espresso-integration/nitro-node-dev:integration + # Set default versions if not overriden by provided env vars +: ${NITRO_CONTRACTS_REPO:=$DEFAULT_NITRO_CONTRACTS_REPO} : ${NITRO_CONTRACTS_BRANCH:=$DEFAULT_NITRO_CONTRACTS_VERSION} : ${TOKEN_BRIDGE_BRANCH:=$DEFAULT_TOKEN_BRIDGE_VERSION} +export NITRO_CONTRACTS_REPO export NITRO_CONTRACTS_BRANCH export TOKEN_BRIDGE_BRANCH @@ -229,6 +233,16 @@ while [[ $# -gt 0 ]]; do esac done +if $espresso; then + NITRO_CONTRACTS_REPO=https://github.com/EspressoSystems/nitro-contracts.git + NITRO_CONTRACTS_BRANCH=develop + export NITRO_CONTRACTS_REPO + export NITRO_CONTRACTS_BRANCH + echo "Running espresso mode" + echo "Using NITRO_CONTRACTS_REPO: $NITRO_CONTRACTS_REPO" + echo "Using NITRO_CONTRACTS_BRANCH: $NITRO_CONTRACTS_BRANCH" +fi + if $force_init; then force_build=true fi From b8d5d22ded35838e8cdc158cfea67d91ce8d8e44 Mon Sep 17 00:00:00 2001 From: ImJeremyHe Date: Thu, 22 Aug 2024 12:14:45 +0800 Subject: [PATCH 2/3] Add .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..bf57234a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Generated by nix-direnv +.direnv/ From 78daf09d9889dd774d102e56e486f5b6a74586ac Mon Sep 17 00:00:00 2001 From: ImJeremyHe Date: Thu, 22 Aug 2024 12:29:59 +0800 Subject: [PATCH 3/3] Add to CI --- .github/workflows/smoke-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 9c275fd6..e9c52829 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: - test-script: [ ./smoke-test.bash, ./smoke-test-l3.bash ] + test-script: [ ./smoke-test.bash, ./smoke-test-l3.bash, ./smoke-test-nitro-simple.bash ] runs-on: ubuntu-24.04