-
Notifications
You must be signed in to change notification settings - Fork 63
/
test-node.bash
executable file
·648 lines (578 loc) · 25.6 KB
/
test-node.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
#!/usr/bin/env bash
set -eu
NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.2.1-d81324d-dev
BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.1.0-0e716c8
DEFAULT_NITRO_CONTRACTS_VERSION="v2.1.1-beta.0"
DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.2"
# The is the latest bold-merge commit in nitro-contracts at the time
DEFAULT_BOLD_CONTRACTS_VERSION="42d80e40"
# Set default versions if not overriden by provided env vars
: ${NITRO_CONTRACTS_BRANCH:=$DEFAULT_NITRO_CONTRACTS_VERSION}
: ${BOLD_CONTRACTS_BRANCH:=$DEFAULT_BOLD_CONTRACTS_VERSION}
: ${TOKEN_BRIDGE_BRANCH:=$DEFAULT_TOKEN_BRIDGE_VERSION}
export NITRO_CONTRACTS_BRANCH
export BOLD_CONTRACTS_BRANCH
export TOKEN_BRIDGE_BRANCH
echo "Using NITRO_CONTRACTS_BRANCH: $NITRO_CONTRACTS_BRANCH"
echo "Using BOLD_CONTRACTS_BRANCH: $BOLD_CONTRACTS_BRANCH"
echo "Using TOKEN_BRIDGE_BRANCH: $TOKEN_BRIDGE_BRANCH"
mydir=`dirname $0`
cd "$mydir"
if [[ $# -gt 0 ]] && [[ $1 == "script" ]]; then
shift
docker compose run scripts "$@"
exit $?
fi
num_volumes=`docker volume ls --filter label=com.docker.compose.project=nitro-testnode -q | wc -l`
if [[ $num_volumes -eq 0 ]]; then
force_init=true
else
force_init=false
fi
run=true
ci=false
validate=false
detach=false
nowait=false
blockscout=false
tokenbridge=false
l3node=false
consensusclient=false
boldupgrade=false
redundantsequencers=0
l3_custom_fee_token=false
l3_token_bridge=false
l3_custom_fee_token_decimals=18
batchposters=1
devprivkey=b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
l1chainid=1337
simple=true
l2anytrust=false
# Use the dev versions of nitro/blockscout
dev_nitro=false
dev_blockscout=false
# Rebuild docker images
build_dev_nitro=false
build_dev_blockscout=false
build_utils=false
force_build_utils=false
build_node_images=false
while [[ $# -gt 0 ]]; do
case $1 in
--init)
if ! $force_init; then
echo == Warning! this will remove all previous data
read -p "are you sure? [y/n]" -n 1 response
if [[ $response == "y" ]] || [[ $response == "Y" ]]; then
force_init=true
echo
else
exit 0
fi
fi
build_utils=true
build_node_images=true
shift
;;
--init-force)
force_init=true
build_utils=true
build_node_images=true
shift
;;
--dev)
simple=false
shift
if [[ $# -eq 0 || $1 == -* ]]; then
# If no argument after --dev, set both flags to true
dev_nitro=true
build_dev_nitro=true
dev_blockscout=true
build_dev_blockscout=true
else
while [[ $# -gt 0 && $1 != -* ]]; do
if [[ $1 == "nitro" ]]; then
dev_nitro=true
build_dev_nitro=true
elif [[ $1 == "blockscout" ]]; then
dev_blockscout=true
build_dev_blockscout=true
fi
shift
done
fi
;;
--ci)
ci=true
shift
;;
--build)
build_dev_nitro=true
build_dev_blockscout=true
build_utils=true
build_node_images=true
shift
;;
--no-build)
build_dev_nitro=false
build_dev_blockscout=false
build_utils=false
build_node_images=false
shift
;;
--build-dev-nitro)
build_dev_nitro=true
shift
;;
--no-build-dev-nitro)
build_dev_nitro=false
shift
;;
--build-dev-blockscout)
build_dev_blockscout=true
shift
;;
--no-build-dev-blockscout)
build_dev_blockscout=false
shift
;;
--build-utils)
build_utils=true
shift
;;
--no-build-utils)
build_utils=false
shift
;;
--force-build-utils)
force_build_utils=true
shift
;;
--validate)
simple=false
validate=true
shift
;;
--blockscout)
blockscout=true
shift
;;
--tokenbridge)
tokenbridge=true
shift
;;
--no-tokenbridge)
tokenbridge=false
shift
;;
--no-run)
run=false
shift
;;
--detach)
detach=true
shift
;;
--nowait)
if ! $detach; then
echo "Error: --nowait requires --detach to be provided."
exit 1
fi
nowait=true
shift
;;
--batchposters)
simple=false
batchposters=$2
if ! [[ $batchposters =~ [0-3] ]] ; then
echo "batchposters must be between 0 and 3 value:$batchposters."
exit 1
fi
shift
shift
;;
--pos)
consensusclient=true
l1chainid=1337
shift
;;
--bold-upgrade)
boldupgrade=true
shift
;;
--l3node)
l3node=true
shift
;;
--l3-fee-token)
if ! $l3node; then
echo "Error: --l3-fee-token requires --l3node to be provided."
exit 1
fi
l3_custom_fee_token=true
shift
;;
--l3-fee-token-decimals)
if ! $l3_custom_fee_token; then
echo "Error: --l3-fee-token-decimals requires --l3-fee-token to be provided."
exit 1
fi
l3_custom_fee_token_decimals=$2
if [[ $l3_custom_fee_token_decimals -lt 0 || $l3_custom_fee_token_decimals -gt 36 ]]; then
echo "l3-fee-token-decimals must be in range [0,36], value: $l3_custom_fee_token_decimals."
exit 1
fi
shift
shift
;;
--l3-token-bridge)
if ! $l3node; then
echo "Error: --l3-token-bridge requires --l3node to be provided."
exit 1
fi
l3_token_bridge=true
shift
;;
--l2-anytrust)
l2anytrust=true
shift
;;
--redundantsequencers)
simple=false
redundantsequencers=$2
if ! [[ $redundantsequencers =~ [0-3] ]] ; then
echo "redundantsequencers must be between 0 and 3 value:$redundantsequencers."
exit 1
fi
shift
shift
;;
--simple)
simple=true
shift
;;
--no-simple)
simple=false
shift
;;
*)
echo Usage: $0 \[OPTIONS..]
echo $0 script [SCRIPT-ARGS]
echo
echo OPTIONS:
echo --build rebuild docker images
echo --no-build don\'t rebuild docker images
echo --dev build nitro and blockscout dockers from source instead of pulling them. Disables simple mode
echo --init remove all data, rebuild, deploy new rollup
echo --pos l1 is a proof-of-stake chain \(using prysm for consensus\)
echo --validate heavy computation, validating all blocks in WASM
echo --l3node deploys an L3 node on top of the L2
echo --l3-fee-token L3 chain is set up to use custom fee token. Only valid if also '--l3node' is provided
echo --l3-fee-token-decimals Number of decimals to use for custom fee token. Only valid if also '--l3-fee-token' is provided
echo --l3-token-bridge Deploy L2-L3 token bridge. Only valid if also '--l3node' is provided
echo --l2-anytrust run the L2 as an AnyTrust chain
echo --batchposters batch posters [0-3]
echo --redundantsequencers redundant sequencers [0-3]
echo --detach detach from nodes after running them
echo --blockscout build or launch blockscout
echo --simple run a simple configuration. one node as sequencer/batch-poster/staker \(default unless using --dev\)
echo --tokenbridge deploy L1-L2 token bridge.
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 --build-dev-nitro rebuild dev nitro docker image
echo --no-build-dev-nitro don\'t rebuild dev nitro docker image
echo --build-dev-blockscout rebuild dev blockscout docker image
echo --no-build-dev-blockscout don\'t rebuild dev blockscout docker image
echo --build-utils rebuild scripts, rollupcreator, boldupgrader, token bridge docker images
echo --no-build-utils don\'t rebuild scripts, rollupcreator, boldupgrader, token bridge docker images
echo --force-build-utils force rebuilding utils, useful if NITRO_CONTRACTS_ or TOKEN_BRIDGE_BRANCH changes
echo
echo script runs inside a separate docker. For SCRIPT-ARGS, run $0 script --help
exit 0
esac
done
NODES="sequencer"
INITIAL_SEQ_NODES="sequencer"
if ! $simple; then
NODES="$NODES redis"
fi
if [ $redundantsequencers -gt 0 ]; then
NODES="$NODES sequencer_b"
INITIAL_SEQ_NODES="$INITIAL_SEQ_NODES sequencer_b"
fi
if [ $redundantsequencers -gt 1 ]; then
NODES="$NODES sequencer_c"
fi
if [ $redundantsequencers -gt 2 ]; then
NODES="$NODES sequencer_d"
fi
if [ $batchposters -gt 0 ] && ! $simple; then
NODES="$NODES poster"
fi
if [ $batchposters -gt 1 ]; then
NODES="$NODES poster_b"
fi
if [ $batchposters -gt 2 ]; then
NODES="$NODES poster_c"
fi
if $validate; then
NODES="$NODES validator"
elif ! $simple; then
NODES="$NODES staker-unsafe"
fi
if $l3node; then
NODES="$NODES l3node"
fi
if $blockscout; then
NODES="$NODES blockscout"
fi
if $dev_nitro && $build_dev_nitro; then
echo == Building Nitro
if ! [ -n "${NITRO_SRC+set}" ]; then
NITRO_SRC=`dirname $PWD`
fi
if ! grep ^FROM "${NITRO_SRC}/Dockerfile" | grep nitro-node 2>&1 > /dev/null; then
echo nitro source not found in "$NITRO_SRC"
echo execute from a sub-directory of nitro or use NITRO_SRC environment variable
exit 1
fi
docker build "$NITRO_SRC" -t nitro-node-dev --target nitro-node-dev
fi
if $dev_blockscout && $build_dev_blockscout; then
if $blockscout; then
echo == Building Blockscout
docker build blockscout -t blockscout -f blockscout/docker/Dockerfile
fi
fi
if $build_utils; then
LOCAL_BUILD_NODES="scripts rollupcreator boldupgrader"
# always build tokenbridge in CI mode to avoid caching issues
if $tokenbridge || $l3_token_bridge || $ci; then
LOCAL_BUILD_NODES="$LOCAL_BUILD_NODES tokenbridge"
fi
if [ "$ci" == true ]; then
# workaround to cache docker layers and keep using docker-compose in CI
docker buildx bake --file docker-compose.yaml --file docker-compose-ci-cache.json $LOCAL_BUILD_NODES
else
UTILS_NOCACHE=""
if $force_build_utils; then
UTILS_NOCACHE="--no-cache"
fi
docker compose build --no-rm $UTILS_NOCACHE $LOCAL_BUILD_NODES
fi
fi
if $dev_nitro; then
docker tag nitro-node-dev:latest nitro-node-dev-testnode
else
docker pull $NITRO_NODE_VERSION
docker tag $NITRO_NODE_VERSION nitro-node-dev-testnode
fi
if $blockscout; then
if $dev_blockscout; then
docker tag blockscout:latest blockscout-testnode
else
docker pull $BLOCKSCOUT_VERSION
docker tag $BLOCKSCOUT_VERSION blockscout-testnode
fi
fi
if $build_node_images; then
docker compose build --no-rm $NODES
fi
if $force_init; then
echo == Removing old data..
docker compose down
leftoverContainers=`docker container ls -a --filter label=com.docker.compose.project=nitro-testnode -q | xargs echo`
if [ `echo $leftoverContainers | wc -w` -gt 0 ]; then
docker rm $leftoverContainers
fi
docker volume prune -f --filter label=com.docker.compose.project=nitro-testnode
leftoverVolumes=`docker volume ls --filter label=com.docker.compose.project=nitro-testnode -q | xargs echo`
if [ `echo $leftoverVolumes | wc -w` -gt 0 ]; then
docker volume rm $leftoverVolumes
fi
echo == Generating l1 keys
docker compose run scripts write-accounts
docker compose run --entrypoint sh geth -c "echo passphrase > /datadir/passphrase"
docker compose run --entrypoint sh geth -c "chown -R 1000:1000 /keystore"
docker compose run --entrypoint sh geth -c "chown -R 1000:1000 /config"
echo == Writing geth configs
docker compose run scripts write-geth-genesis-config
if $consensusclient; then
echo == Writing prysm configs
docker compose run scripts write-prysm-config
echo == Creating prysm genesis
docker compose run create_beacon_chain_genesis
fi
echo == Initializing go-ethereum genesis configuration
docker compose run geth init --state.scheme hash --datadir /datadir/ /config/geth_genesis.json
if $consensusclient; then
echo == Running prysm
docker compose up --wait prysm_beacon_chain
docker compose up --wait prysm_validator
fi
echo == Starting geth
docker compose up --wait geth
echo == Waiting for geth to sync
docker compose run scripts wait-for-sync --url http://geth:8545
echo == Funding validator, sequencer and l2owner
docker compose run scripts send-l1 --ethamount 1000 --to validator --wait
docker compose run scripts send-l1 --ethamount 1000 --to sequencer --wait
docker compose run scripts send-l1 --ethamount 1000 --to l2owner --wait
echo == create l1 traffic
docker compose run scripts send-l1 --ethamount 1000 --to user_l1user --wait
docker compose run scripts send-l1 --ethamount 0.0001 --from user_l1user --to user_l1user_b --wait --delay 500 --times 1000000 > /dev/null &
l2ownerAddress=`docker compose run scripts print-address --account l2owner | tail -n 1 | tr -d '\r\n'`
if $l2anytrust; then
echo "== Writing l2 chain config (anytrust enabled)"
docker compose run scripts --l2owner $l2ownerAddress write-l2-chain-config --anytrust
else
echo == Writing l2 chain config
docker compose run scripts --l2owner $l2ownerAddress write-l2-chain-config
fi
sequenceraddress=`docker compose run scripts print-address --account sequencer | tail -n 1 | tr -d '\r\n'`
l2ownerKey=`docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n'`
wasmroot=`docker compose run --entrypoint sh sequencer -c "cat /home/user/target/machines/latest/module-root.txt"`
echo == Deploying L2 chain
docker compose run -e PARENT_CHAIN_RPC="http://geth:8545" -e DEPLOYER_PRIVKEY=$l2ownerKey -e PARENT_CHAIN_ID=$l1chainid -e CHILD_CHAIN_NAME="arb-dev-test" -e MAX_DATA_SIZE=117964 -e OWNER_ADDRESS=$l2ownerAddress -e WASM_MODULE_ROOT=$wasmroot -e SEQUENCER_ADDRESS=$sequenceraddress -e AUTHORIZE_VALIDATORS=10 -e CHILD_CHAIN_CONFIG_PATH="/config/l2_chain_config.json" -e CHAIN_DEPLOYMENT_INFO="/config/deployment.json" -e CHILD_CHAIN_INFO="/config/deployed_chain_info.json" rollupcreator create-rollup-testnode
docker compose run --entrypoint sh rollupcreator -c "jq [.[]] /config/deployed_chain_info.json > /config/l2_chain_info.json"
fi # $force_init
anytrustNodeConfigLine=""
# Remaining init may require AnyTrust committee/mirrors to have been started
if $l2anytrust; then
if $force_init; then
echo == Generating AnyTrust Config
docker compose run --user root --entrypoint sh datool -c "mkdir /das-committee-a/keys /das-committee-a/data /das-committee-a/metadata /das-committee-b/keys /das-committee-b/data /das-committee-b/metadata /das-mirror/data /das-mirror/metadata"
docker compose run --user root --entrypoint sh datool -c "chown -R 1000:1000 /das*"
docker compose run datool keygen --dir /das-committee-a/keys
docker compose run datool keygen --dir /das-committee-b/keys
docker compose run scripts write-l2-das-committee-config
docker compose run scripts write-l2-das-mirror-config
das_bls_a=`docker compose run --entrypoint sh datool -c "cat /das-committee-a/keys/das_bls.pub"`
das_bls_b=`docker compose run --entrypoint sh datool -c "cat /das-committee-b/keys/das_bls.pub"`
docker compose run scripts write-l2-das-keyset-config --dasBlsA $das_bls_a --dasBlsB $das_bls_b
docker compose run --entrypoint sh datool -c "/usr/local/bin/datool dumpkeyset --conf.file /config/l2_das_keyset.json | grep 'Keyset: ' | awk '{ printf \"%s\", \$2 }' > /config/l2_das_keyset.hex"
docker compose run scripts set-valid-keyset
anytrustNodeConfigLine="--anytrust --dasBlsA $das_bls_a --dasBlsB $das_bls_b"
fi
if $run; then
echo == Starting AnyTrust committee and mirror
docker compose up --wait das-committee-a das-committee-b das-mirror
fi
fi
if $force_init; then
if $simple; then
echo == Writing configs
docker compose run scripts write-config --simple $anytrustNodeConfigLine
else
echo == Writing configs
docker compose run scripts write-config $anytrustNodeConfigLine
echo == Initializing redis
docker compose up --wait redis
docker compose run scripts redis-init --redundancy $redundantsequencers
fi
echo == Funding l2 funnel and dev key
docker compose up --wait $INITIAL_SEQ_NODES
docker compose run scripts bridge-funds --ethamount 100000 --wait
docker compose run scripts send-l2 --ethamount 100 --to l2owner --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'"`
if $tokenbridge; then
echo == Deploying L1-L2 token bridge
sleep 10 # no idea why this sleep is needed but without it the deploy fails randomly
docker compose run -e ROLLUP_OWNER_KEY=$l2ownerKey -e ROLLUP_ADDRESS=$rollupAddress -e PARENT_KEY=$devprivkey -e PARENT_RPC=http://geth:8545 -e CHILD_KEY=$devprivkey -e CHILD_RPC=http://sequencer:8547 tokenbridge deploy:local:token-bridge
docker compose run --entrypoint sh tokenbridge -c "cat network.json && cp network.json l1l2_network.json && cp network.json localNetwork.json"
echo
fi
echo == Deploy CacheManager on L2
docker compose run -e CHILD_CHAIN_RPC="http://sequencer:8547" -e CHAIN_OWNER_PRIVKEY=$l2ownerKey rollupcreator deploy-cachemanager-testnode
if $boldupgrade; then
echo == Deploying WETH as BOLD stake token
stakeTokenAddress=`docker compose run scripts create-weth --deployer l2owner --deposit 100 | tail -n 1 | awk '{ print $NF }'`
echo BOLD stake token address: $stakeTokenAddress
docker compose run scripts transfer-erc20 --token $stakeTokenAddress --l1 --amount 100 --from l2owner --to validator
echo == Preparing BOLD upgrade
docker compose run -e TESTNODE_MODE=true -e ROLLUP_ADDRESS=$rollupAddress -e STAKE_TOKEN=$stakeTokenAddress boldupgrader script:bold-prepare
# retry this 10 times because the staker might not have made a node yet
for i in {1..10}; do
docker compose run -e TESTNODE_MODE=true -e ROLLUP_ADDRESS=$rollupAddress -e STAKE_TOKEN=$stakeTokenAddress boldupgrader script:bold-populate-lookup && break || true
echo "Failed to populate lookup table, retrying..."
sleep 10
done
docker compose run -e TESTNODE_MODE=true -e ROLLUP_ADDRESS=$rollupAddress -e STAKE_TOKEN=$stakeTokenAddress boldupgrader script:bold-local-execute
fi
if $l3node; then
echo == Funding l3 users
docker compose run scripts send-l2 --ethamount 1000 --to l3owner --wait
docker compose run scripts send-l2 --ethamount 1000 --to l3sequencer --wait
echo == Funding l2 deployers
docker compose run scripts send-l1 --ethamount 100 --to user_token_bridge_deployer --wait
docker compose run scripts send-l2 --ethamount 100 --to user_token_bridge_deployer --wait
echo == Funding token deployer
docker compose run scripts send-l1 --ethamount 100 --to user_fee_token_deployer --wait
docker compose run scripts send-l2 --ethamount 100 --to user_fee_token_deployer --wait
echo == create l2 traffic
docker compose run scripts send-l2 --ethamount 100 --to user_traffic_generator --wait
docker compose run scripts send-l2 --ethamount 0.0001 --from user_traffic_generator --to user_fee_token_deployer --wait --delay 500 --times 1000000 > /dev/null &
echo == Writing l3 chain config
l3owneraddress=`docker compose run scripts print-address --account l3owner | tail -n 1 | tr -d '\r\n'`
echo l3owneraddress $l3owneraddress
docker compose run scripts --l2owner $l3owneraddress write-l3-chain-config
EXTRA_L3_DEPLOY_FLAG=""
if $l3_custom_fee_token; then
echo == Deploying custom fee token
nativeTokenAddress=`docker compose run scripts create-erc20 --deployer user_fee_token_deployer --bridgeable $tokenbridge --decimals $l3_custom_fee_token_decimals | tail -n 1 | awk '{ print $NF }'`
docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 10000 --from user_fee_token_deployer --to l3owner
docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 10000 --from user_fee_token_deployer --to user_token_bridge_deployer
EXTRA_L3_DEPLOY_FLAG="-e FEE_TOKEN_ADDRESS=$nativeTokenAddress"
fi
echo == Deploying L3
l3ownerkey=`docker compose run scripts print-private-key --account l3owner | tail -n 1 | tr -d '\r\n'`
l3sequenceraddress=`docker compose run scripts print-address --account l3sequencer | tail -n 1 | tr -d '\r\n'`
docker compose run -e DEPLOYER_PRIVKEY=$l3ownerkey -e PARENT_CHAIN_RPC="http://sequencer:8547" -e PARENT_CHAIN_ID=412346 -e CHILD_CHAIN_NAME="orbit-dev-test" -e MAX_DATA_SIZE=104857 -e OWNER_ADDRESS=$l3owneraddress -e WASM_MODULE_ROOT=$wasmroot -e SEQUENCER_ADDRESS=$l3sequenceraddress -e AUTHORIZE_VALIDATORS=10 -e CHILD_CHAIN_CONFIG_PATH="/config/l3_chain_config.json" -e CHAIN_DEPLOYMENT_INFO="/config/l3deployment.json" -e CHILD_CHAIN_INFO="/config/deployed_l3_chain_info.json" $EXTRA_L3_DEPLOY_FLAG rollupcreator create-rollup-testnode
docker compose run --entrypoint sh rollupcreator -c "jq [.[]] /config/deployed_l3_chain_info.json > /config/l3_chain_info.json"
echo == Funding l3 funnel and dev key
docker compose up --wait l3node sequencer
if $l3_token_bridge; then
echo == Deploying L2-L3 token bridge
deployer_key=`printf "%s" "user_token_bridge_deployer" | openssl dgst -sha256 | sed 's/^.*= //'`
rollupAddress=`docker compose run --entrypoint sh poster -c "jq -r '.[0].rollup.rollup' /config/deployed_l3_chain_info.json | tail -n 1 | tr -d '\r\n'"`
l2Weth=""
if $tokenbridge; then
# we deployed an L1 L2 token bridge
# we need to pull out the L2 WETH address and pass it as an override to the L2 L3 token bridge deployment
l2Weth=`docker compose run --entrypoint sh tokenbridge -c "cat l1l2_network.json" | jq -r '.l2Network.tokenBridge.l2Weth'`
fi
docker compose run -e PARENT_WETH_OVERRIDE=$l2Weth -e ROLLUP_OWNER_KEY=$l3ownerkey -e ROLLUP_ADDRESS=$rollupAddress -e PARENT_RPC=http://sequencer:8547 -e PARENT_KEY=$deployer_key -e CHILD_RPC=http://l3node:3347 -e CHILD_KEY=$deployer_key tokenbridge deploy:local:token-bridge
docker compose run --entrypoint sh tokenbridge -c "cat network.json && cp network.json l2l3_network.json"
# set L3 UpgradeExecutor, deployed by token bridge creator in previous step, to be the L3 chain owner. L3owner (EOA) and alias of L2 UpgradeExectuor have the executor role on the L3 UpgradeExecutor
echo == Set L3 UpgradeExecutor to be chain owner
tokenBridgeCreator=`docker compose run --entrypoint sh tokenbridge -c "cat l2l3_network.json" | jq -r '.l1TokenBridgeCreator'`
docker compose run scripts transfer-l3-chain-ownership --creator $tokenBridgeCreator
echo
fi
echo == Fund L3 accounts
if $l3_custom_fee_token; then
docker compose run scripts bridge-native-token-to-l3 --amount 5000 --from user_fee_token_deployer --wait
docker compose run scripts send-l3 --ethamount 100 --from user_fee_token_deployer --wait
else
docker compose run scripts bridge-to-l3 --ethamount 50000 --wait
fi
docker compose run scripts send-l3 --ethamount 10 --to l3owner --wait
echo == Deploy CacheManager on L3
docker compose run -e CHILD_CHAIN_RPC="http://l3node:3347" -e CHAIN_OWNER_PRIVKEY=$l3ownerkey rollupcreator deploy-cachemanager-testnode
fi
fi
if $run; then
UP_FLAG=""
if $detach; then
if $nowait; then
UP_FLAG="--detach"
else
UP_FLAG="--wait"
fi
fi
echo == Launching Sequencer
echo if things go wrong - use --init to create a new chain
echo
docker compose up $UP_FLAG $NODES
fi