Skip to content

Commit

Permalink
Merge branch 'release' of github.com:OffchainLabs/nitro-testnode into…
Browse files Browse the repository at this point in the history
… jh/dev-node
  • Loading branch information
ImJeremyHe committed Jul 8, 2024
2 parents b36cb80 + 9dc0588 commit b178ffc
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 82 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI
run-name: CI triggered from @${{ github.actor }} of ${{ github.head_ref }}

on:
workflow_dispatch:
merge_group:
pull_request:
push:
branches:
- master
- develop


jobs:
build_and_run:
runs-on: ubuntu-8

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}
restore-keys: ${{ runner.os }}-buildx-

- name: Startup Nitro testnode
run: ${{ github.workspace }}/.github/workflows/testnode.bash
54 changes: 54 additions & 0 deletions .github/workflows/testnode.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
# The script starts up the test node and waits until the timeout (10min) or
# until send-l2 succeeds.

# Start the test node and get PID, to terminate it once send-l2 is done.
cd ${GITHUB_WORKSPACE}

# TODO once develop is merged into nitro-contract's master, remove the NITRO_CONTRACTS_BRANCH env var
./test-node.bash --init-force --l3node --no-simple --detach

START=$(date +%s)
L2_TRANSACTION_SUCCEEDED=false
L3_TRANSACTION_SUCCEEDED=false
SUCCEEDED=false

while true; do
if [ "$L2_TRANSACTION_SUCCEEDED" = false ]; then
if ${GITHUB_WORKSPACE}/test-node.bash script send-l2 --ethamount 100 --to user_l2user --wait; then
echo "Sending l2 transaction succeeded"
L2_TRANSACTION_SUCCEEDED=true
fi
fi

if [ "$L3_TRANSACTION_SUCCEEDED" = false ]; then
if ${GITHUB_WORKSPACE}/test-node.bash script send-l3 --ethamount 100 --to user_l3user --wait; then
echo "Sending l3 transaction succeeded"
L3_TRANSACTION_SUCCEEDED=true
fi
fi

if [ "$L2_TRANSACTION_SUCCEEDED" = true ] && [ "$L3_TRANSACTION_SUCCEEDED" = true ]; then
SUCCEEDED=true
break
fi

# Check if the timeout (10 min) has been reached.
NOW=$(date +%s)
DIFF=$((NOW - START))
if [ "$DIFF" -ge 600 ]; then
echo "Timed out"
break
fi

sleep 10
done

docker-compose stop

if [ "$SUCCEEDED" = false ]; then
docker-compose logs
exit 1
fi

exit 0
36 changes: 2 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Nitro Testnode

Nitro-testnode brings up a full environment for local nitro testing (with or without Stylus support) including a dev-mode geth L1, and multiple instances with different roles.
Nitro-testnode brings up a full environment for local nitro testing (with Stylus support) including a dev-mode geth L1, and multiple instances with different roles.

### Requirements

Expand All @@ -11,8 +11,6 @@ All must be installed in PATH.

## Using latest nitro release (recommended)

### Without Stylus support

Check out the release branch of the repository.

> Notice: release branch may be force-pushed at any time.
Expand All @@ -29,30 +27,12 @@ Initialize the node
```
To see more options, use `--help`.

### With Stylus support

Check out the stylus branch of the repository.
> Notice: stylus branch may be force-pushed at any time.
```bash
git clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git
cd nitro-testnode
```

Initialize the node

```bash
./test-node.bash --init
```
To see more options, use `--help`.

## Using current nitro code (local compilation)

Check out the nitro or stylus repository. Use the test-node submodule of nitro repository.
Check out the nitro repository. Use the test-node submodule of nitro repository.

> Notice: testnode may not always be up-to-date with config options of current nitro node, and is not considered stable when operated in that way.
### Without Stylus support
```bash
git clone --recurse-submodules https://github.com/OffchainLabs/nitro.git
cd nitro/nitro-testnode
Expand All @@ -64,18 +44,6 @@ Initialize the node in dev-mode (this will build the docker images from source)
```
To see more options, use `--help`.

### With Stylus support
```bash
git clone --recurse-submodules https://github.com/OffchainLabs/stylus.git
cd stylus/nitro-testnode
```

Initialize the node in dev-mode (this will build the docker images from source)
```bash
./test-node.bash --init --dev
```
To see more options, use `--help`.

## Further information

### Working with docker containers
Expand Down
35 changes: 30 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.9"
services:
blockscout:
depends_on:
Expand Down Expand Up @@ -152,6 +151,7 @@ services:
sequencer:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro
ports:
- "127.0.0.1:8547:8547"
- "127.0.0.1:8548:8548"
Expand All @@ -168,6 +168,7 @@ services:
sequencer_b:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro
ports:
- "127.0.0.1:8647:8547"
- "127.0.0.1:8648:8548"
Expand All @@ -182,6 +183,7 @@ services:
sequencer_c:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro
ports:
- "127.0.0.1:8747:8547"
- "127.0.0.1:8748:8548"
Expand All @@ -196,6 +198,7 @@ services:
sequencer_d:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro
ports:
- "127.0.0.1:8847:8547"
- "127.0.0.1:8848:8548"
Expand All @@ -210,6 +213,7 @@ services:
staker-unsafe:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro
ports:
- "127.0.0.1:8047:8547"
- "127.0.0.1:8048:8548"
Expand All @@ -226,6 +230,7 @@ services:
poster:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro
ports:
- "127.0.0.1:8147:8547"
- "127.0.0.1:8148:8548"
Expand All @@ -241,6 +246,7 @@ services:
poster_b:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro
ports:
- "127.0.0.1:9147:8547"
- "127.0.0.1:9148:8548"
Expand All @@ -256,6 +262,7 @@ services:
poster_c:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro
ports:
- "127.0.0.1:9247:8547"
- "127.0.0.1:9248:8548"
Expand All @@ -271,6 +278,7 @@ services:
validator:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro
ports:
- "127.0.0.1:8247:8547"
- "127.0.0.1:8248:8548"
Expand All @@ -286,6 +294,7 @@ services:
l3node:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro
ports:
- "127.0.0.1:3347:3347"
- "127.0.0.1:3348:3348"
Expand All @@ -301,12 +310,12 @@ services:
validation_node:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/nitro-val
ports:
- "127.0.0.1:8949:8549"
volumes:
- "config:/config"
command: --conf.file /config/validation_node_config.json
entrypoint: /usr/local/bin/nitro-val

scripts:
build: scripts/
Expand All @@ -318,24 +327,40 @@ services:
relay:
pid: host
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/relay
ports:
- "127.0.0.1:9652:9652"
entrypoint: bin/relay
command: --node.feed.output.port 9652 --node.feed.input.url ws://sequencer:9652
command: --chain.id 412346 --node.feed.input.url ws://sequencer:9642 --node.feed.output.port 9652

tokenbridge:
depends_on:
- geth
- sequencer
pid: host
build: tokenbridge/
build:
context: tokenbridge/
args:
TOKEN_BRIDGE_BRANCH: ${TOKEN_BRIDGE_BRANCH:-}
environment:
- ARB_URL=http://sequencer:8547
- ETH_URL=http://geth:8545
volumes:
- "tokenbridge-data:/workspace"
- /var/run/docker.sock:/var/run/docker.sock

rollupcreator:
depends_on:
- geth
- sequencer
pid: host
build:
context: rollupcreator/
args:
NITRO_CONTRACTS_BRANCH: ${NITRO_CONTRACTS_BRANCH:-}
volumes:
- "config:/config"
- /var/run/docker.sock:/var/run/docker.sock

espresso-dev-node:
image: ghcr.io/espressosystems/espresso-sequencer/espresso-dev-node:main
ports:
Expand Down
14 changes: 14 additions & 0 deletions rollupcreator/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:16-bullseye-slim
ARG NITRO_CONTRACTS_BRANCH=main
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/OffchainLabs/nitro-contracts.git ./
RUN git checkout ${NITRO_CONTRACTS_BRANCH}
RUN curl -L https://foundry.paradigm.xyz | bash
ENV PATH="${PATH}:/root/.foundry/bin"
RUN foundryup
RUN touch scripts/config.ts
RUN yarn install
RUN yarn build:all
ENTRYPOINT ["yarn"]
56 changes: 28 additions & 28 deletions scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,34 +361,34 @@ function writeConfigs(argv: any) {

function writeL2ChainConfig(argv: any) {
const l2ChainConfig = {
"chainId": 412346,
"homesteadBlock": 0,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"chainId": 412346,
"homesteadBlock": 0,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"espresso": argv.espresso,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"clique": {
"period": 0,
"epoch": 0
},
"arbitrum": {
"EnableArbOS": true,
"AllowDebugPrecompiles": true,
"DataAvailabilityCommittee": false,
"InitialArbOSVersion": 11,
"InitialChainOwner": argv.l2owner,
"GenesisBlockNum": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"clique": {
"period": 0,
"epoch": 0
},
"arbitrum": {
"EnableArbOS": true,
"AllowDebugPrecompiles": true,
"DataAvailabilityCommittee": false,
"InitialArbOSVersion": 30,
"InitialChainOwner": argv.l2owner,
"GenesisBlockNum": 0,
"EnableEspresso": false,
}
}
}
if (argv.espresso) {
l2ChainConfig.arbitrum.EnableEspresso = true
Expand Down Expand Up @@ -421,8 +421,8 @@ function writeL3ChainConfig(argv: any) {
"EnableArbOS": true,
"AllowDebugPrecompiles": true,
"DataAvailabilityCommittee": false,
"InitialArbOSVersion": 11,
"InitialChainOwner": "0x0000000000000000000000000000000000000000",
"InitialArbOSVersion": 30,
"InitialChainOwner": argv.l2owner,
"GenesisBlockNum": 0
}
}
Expand Down
Loading

0 comments on commit b178ffc

Please sign in to comment.