Skip to content

Commit

Permalink
Merge pull request OffchainLabs#47 from EspressoSystems/backwards-com…
Browse files Browse the repository at this point in the history
…patible

Fix running a simple nitro node
  • Loading branch information
ImJeremyHe authored Aug 22, 2024
2 parents 85aeb89 + 78daf09 commit 98187ea
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by nix-direnv
.direnv/
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ services:
build:
context: rollupcreator/
args:
NITRO_CONTRACTS_REPO: ${NITRO_CONTRACTS_REPO:-}
NITRO_CONTRACTS_BRANCH: ${NITRO_CONTRACTS_BRANCH:-}
volumes:
- "config:/config"
Expand Down
3 changes: 2 additions & 1 deletion rollupcreator/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
30 changes: 17 additions & 13 deletions scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -239,9 +235,6 @@ function writeConfigs(argv: any) {
"execution": {
"sequencer": {
"enable": false,
"espresso": false,
"hotshot-url": "",
"espresso-namespace": 412346,
},
"forwarding-target": "null",
},
Expand All @@ -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)

Expand Down Expand Up @@ -373,7 +377,6 @@ function writeL2ChainConfig(argv: any) {
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"espresso": argv.espresso,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
Expand All @@ -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)
Expand All @@ -411,7 +415,6 @@ function writeL3ChainConfig(argv: any) {
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"espresso": argv.espresso,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
Expand All @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions smoke-test-nitro-simple.bash
Original file line number Diff line number Diff line change
@@ -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
18 changes: 16 additions & 2 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 98187ea

Please sign in to comment.