Skip to content

Commit 7192f2a

Browse files
committed
Extend nitro-testnode to run consensus and exection separately
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
1 parent 146111b commit 7192f2a

4 files changed

Lines changed: 154 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ To fund the address 0x1111222233334444555566667777888899990000 on l2, use:
100100
./test-node.bash script send-l2 --to address_0x1111222233334444555566667777888899990000
101101
```
102102

103+
To get private key of an account you can:
104+
```bash
105+
./test-node.bash script print-private-key --account funnel
106+
```
107+
103108
For help and further scripts, see:
104109

105110
```bash

docker-compose.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,99 @@ services:
154154
- "consensus:/consensus"
155155
- "config:/config"
156156

157+
execution-follower-node:
158+
pid: host # allow debugging
159+
image: nitro-node-dev-testnode
160+
entrypoint: /usr/local/bin/nitro
161+
ports:
162+
- "127.0.0.1:7247:8547"
163+
- "127.0.0.1:7248:8548"
164+
- "127.0.0.1:9682:9682"
165+
volumes:
166+
- "seqdata:/home/user/.arbitrum/local/nitro"
167+
- "l1keystore:/home/user/l1keystore"
168+
- "config:/config"
169+
- "tokenbridge-data:/tokenbridge-data"
170+
command:
171+
- --conf.file=/config/consensus_config.json
172+
- --node.feed.output.enable
173+
- --http.api=net,web3,eth,txpool,debug,timeboost,auctioneer
174+
- --node.seq-coordinator.my-url=http://sequencer:8547
175+
- --graphql.enable
176+
- --graphql.vhosts=*
177+
- --graphql.corsdomain=*
178+
- --ws.addr=0.0.0.0
179+
- --ws.port=9682
180+
- --ws.api=net,web3,eth,txpool,debug,nitroexecution
181+
- --execution.rpc-server.enable
182+
- --execution.rpc-server.public
183+
- --execution.rpc-server.authenticated=false
184+
- --execution.consensus-rpc-client.url=ws://consensus-follower-node:8552
185+
- --execution.consensus-rpc-client.jwtsecret=/config/jwt.hex
186+
- --execution.consensus-rpc-client.retries=3
187+
- --execution.consensus-rpc-client.connection-wait=15s
188+
- --execution.consensus-rpc-client.retry-delay=1s
189+
depends_on:
190+
- geth
191+
192+
consensus-follower-node:
193+
pid: host # allow debugging
194+
image: nitro-node-dev-testnode
195+
entrypoint: /usr/local/bin/nitro
196+
ports:
197+
- "127.0.0.1:7147:8547"
198+
- "127.0.0.1:7148:8548"
199+
- "127.0.0.1:8552:8552"
200+
volumes:
201+
- "seqdata:/home/user/.arbitrum/local/nitro"
202+
- "l1keystore:/home/user/l1keystore"
203+
- "config:/config"
204+
- "tokenbridge-data:/tokenbridge-data"
205+
command:
206+
- --conf.file=/config/consensus_config.json
207+
- --http.api=net,web3,eth,txpool,debug,timeboost,auctioneer
208+
- --node.seq-coordinator.my-url=http://sequencer:8547
209+
- --http.api=net,web3,eth,txpool,debug,timeboost,auctioneer
210+
- --graphql.enable
211+
- --graphql.vhosts=*
212+
- --graphql.corsdomain=*
213+
- --ws.addr=0.0.0.0
214+
- --ws.port=8552
215+
- --ws.api=net,web3,eth,txpool,debug,nitroconsensus
216+
- --node.rpc-server.enable
217+
- --node.rpc-server.public
218+
- --node.rpc-server.authenticated=false
219+
- --node.execution-rpc-client.url=ws://execution-follower-node:9682
220+
- --node.execution-rpc-client.jwtsecret=/config/jwt.hex
221+
- --node.execution-rpc-client.retries=3
222+
- --node.execution-rpc-client.connection-wait=15s
223+
- --node.execution-rpc-client.retry-delay=1s
224+
depends_on:
225+
- geth
226+
227+
regular-follower-node:
228+
pid: host # allow debugging
229+
image: nitro-node-dev-testnode
230+
entrypoint: /usr/local/bin/nitro
231+
ports:
232+
- "127.0.0.1:7447:8547"
233+
- "127.0.0.1:7548:8548"
234+
volumes:
235+
- "seqdata:/home/user/.arbitrum/local/nitro"
236+
- "l1keystore:/home/user/l1keystore"
237+
- "config:/config"
238+
- "tokenbridge-data:/tokenbridge-data"
239+
command:
240+
- --conf.file=/config/consensus_config.json
241+
- --http.api=net,web3,eth,txpool,debug,timeboost,auctioneer
242+
- --node.seq-coordinator.my-url=http://sequencer:8547
243+
- --http.api=net,web3,eth,txpool,debug,timeboost,auctioneer
244+
- --graphql.enable
245+
- --graphql.vhosts=*
246+
- --graphql.corsdomain=*
247+
depends_on:
248+
- geth
249+
157250
sequencer:
158251
pid: host # allow debugging
159252
image: nitro-node-dev-testnode

scripts/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ function writeConfigs(argv: any) {
303303

304304
const baseConfJSON = JSON.stringify(baseConfig)
305305

306+
// setup consensus config
307+
let consensusConfig = JSON.parse(baseConfJSON)
308+
consensusConfig.persistent.chain = "consensus-local"
309+
fs.writeFileSync(path.join(consts.configpath, "consensus_config.json"), JSON.stringify(consensusConfig))
310+
306311
if (argv.simple) {
307312
let simpleConfig = JSON.parse(baseConfJSON)
308313
simpleConfig.node.staker.enable = true

test-node.bash

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ blockscout=false
5050
tokenbridge=false
5151
l3node=false
5252
consensusclient=false
53+
run_consensus_and_execution_in_different_processes=false
54+
follower_node=false
5355
redundantsequencers=0
5456
l3_custom_fee_token=false
5557
l3_custom_fee_token_pricer=false
@@ -174,6 +176,14 @@ while [[ $# -gt 0 ]]; do
174176
build_utils=true
175177
shift
176178
;;
179+
--run-consensus-and-execution-in-different-processes)
180+
run_consensus_and_execution_in_different_processes=true
181+
shift
182+
;;
183+
--follower-node)
184+
follower_node=true
185+
shift
186+
;;
177187
--validate)
178188
simple=false
179189
validate=true
@@ -321,6 +331,7 @@ while [[ $# -gt 0 ]]; do
321331
echo --l2-referenceda run the L2 with reference external data availability provider
322332
echo --l2-timeboost run the L2 with Timeboost enabled, including auctioneer and bid validator
323333
echo --batchposters batch posters [0-3]
334+
echo --follower-node run a follower node
324335
echo --redundantsequencers redundant sequencers [0-3]
325336
echo --detach detach from nodes after running them
326337
echo --blockscout build or launch blockscout
@@ -337,16 +348,52 @@ while [[ $# -gt 0 ]]; do
337348
echo --no-build-dev-blockscout don\'t rebuild dev blockscout docker image
338349
echo --build-utils rebuild scripts, rollupcreator, token bridge docker images
339350
echo --no-build-utils don\'t rebuild scripts, rollupcreator, token bridge docker images
351+
echo --run-consensus-and-execution-in-different-processes run consensus and execution node in different processed communicating over rpc
340352
echo --force-build-utils force rebuilding utils, useful if NITRO_CONTRACTS_BRANCH or TOKEN_BRIDGE_BRANCH changes
341353
echo
342354
echo script runs inside a separate docker. For SCRIPT-ARGS, run $0 script --help
343355
exit 0
344356
esac
345357
done
346358

359+
# TODO: We can't run a full execution client and a consensus in different processes. Needs https://github.com/OffchainLabs/nitro/pull/4264
360+
# NODES=""
361+
# INITIAL_SEQ_NODES=""
362+
363+
# # TODO: what to do in case when l3node is enabled or l2timeboost is enabled? sequencer seems to be hardcoded there.
364+
# if $run_consensus_and_execution_in_different_processes && $simple; then
365+
# echo == Setting up node to run in split mode using RPC
366+
# NODES="$NODES sequencer consensus-follower-node execution-follower-node"
367+
# INITIAL_SEQ_NODES="$INITIAL_SEQ_NODES sequencer consensus-follower-node execution-follower-node"
368+
# if [ $redundantsequencers -gt 0 ]; then
369+
# echo !!! Redundant sequencers not allowed when running in split mode !!!
370+
# fi
371+
# else
372+
# NODES="$NODES sequencer"
373+
# INITIAL_SEQ_NODES="$INITIAL_SEQ_NODES sequencer"
374+
# if [ $redundantsequencers -gt 0 ]; then
375+
# NODES="$NODES sequencer_b"
376+
# INITIAL_SEQ_NODES="$INITIAL_SEQ_NODES sequencer_b"
377+
# fi
378+
# if [ $redundantsequencers -gt 1 ]; then
379+
# NODES="$NODES sequencer_c"
380+
# fi
381+
# if [ $redundantsequencers -gt 2 ]; then
382+
# NODES="$NODES sequencer_d"
383+
# fi
384+
# fi
385+
347386
NODES="sequencer"
348387
INITIAL_SEQ_NODES="sequencer"
349388

389+
if $run_consensus_and_execution_in_different_processes && $simple; then
390+
NODES="$NODES consensus-follower-node execution-follower-node"
391+
fi
392+
393+
if $follower_node && $simple; then
394+
NODES="$NODES regular-follower-node"
395+
fi
396+
350397
if ! $simple; then
351398
NODES="$NODES redis"
352399
fi
@@ -598,10 +645,13 @@ if $force_init; then
598645
run_script redis-init --redundancy $redundantsequencers
599646
fi
600647

601-
echo == Funding l2 funnel and dev key
648+
echo == Spinning up sequencer nodes
602649
docker compose up --wait $INITIAL_SEQ_NODES
650+
echo == Sleeping for 45s allow for parent chain to recieve the contract creation tx and process it
603651
sleep 45 # in case we need to create a smart contract wallet, allow for parent chain to recieve the contract creation tx and process it
652+
echo == Funding l2 funnel and dev key
604653
run_script bridge-funds --ethamount 100000 --wait
654+
echo == Funding l2owner
605655
run_script send-l2 --ethamount 100 --to l2owner --wait
606656
rollupAddress=`docker compose run --rm --entrypoint sh poster -c "jq -r '.[0].rollup.rollup' /config/deployed_chain_info.json | tail -n 1 | tr -d '\r\n'"`
607657

0 commit comments

Comments
 (0)