Skip to content

Commit 3f96717

Browse files
shenkeyaojbearerAyigaphilippecamacho
authored
IA1.2.11 Write scripts and documentation for demo (#211)
* Add devnet test for batcher restart * Check error returns * Separate op-geth instances for each L2 node * Build devnet dockers in CI * Build op-deployer in CI * Try larger runner * Increase test outage and recovery time * Try to speed up transaction verification * Do not drop batches before we have seen a finalized L1 block * Remove unnecessary sleep * Add scripts for demo and documentation * Build containers in dependency order * Don't copy config file into Docker image at build time * Fix syntax * Checkout submodules in CI * Don't copy config file into Docker image at build time * Remove another COPY * Run devnet test in separate workflow * Add exposed ports for more nodes in docker-compose The `verifier`, `caff-node`, and `sequencer` all do not have their ports forwarded to the host machine. Having these ports exposed can make testing / debugging easier by utilizing the optimism RPC API. This change exposes these ports. * Fix CAFF environment variables The CAFF environment variables utilized in the `docker-compose.yml` need to have a prefix of `OP_NODE_`, otherwise they will not apply. These not applying causes the `caff-node` to never make progress. This change corrects the misconfigured `caff-node` environment variables, and cleans up an unnecessary one. * Set `caff.node` to `true` for `caff-node` The `caff-node` is meant to be running a derivation based on information retrieved from Espresso's network. However, it needs to be enabled to do so. This change enables the `caff-node`'s mode by explicitly setting `caff.node` to `true` in the launch configuration. * Support alias and input check * Add scripts and instructions for running utility script In order to showcase the speed and progress of the Espresso solution with the Caff node, versus the existing sequencer, or the L1 derived verifier, a script has been added that utilities `watch` and `tmux` to provide a nice visual comparison between the three nodes. * Update scripts after separating geth * Update readme * tmux in flake.nix * Update shell being targeted in get_sync_status.sh The `get_sync_status.sh` script attempts to target `zsh` residing within `/bin/zsh`, but this isn't a universally available. It is better to target a more commonly available like `/bin/bash`. This change modifies the script to target `/bin/bash` instead of `/bin/zsh`. --------- Co-authored-by: Jeb Bearer <[email protected]> Co-authored-by: Theodore Schnepper <[email protected]> Co-authored-by: Philippe Camacho <[email protected]>
1 parent 8e1e627 commit 3f96717

File tree

11 files changed

+345
-15
lines changed

11 files changed

+345
-15
lines changed

README_ESPRESSO.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ docker compose down -v
338338
docker volume prune -a
339339
```
340340

341-
* If you have changed OP contracts, you will have to start the devnet fresh and re-generate
341+
* If you have changed OP contracts, you will have to start the devnet fresh and re-generate
342342
the genesis allocations by running `prepare-allocs.sh`
343343

344344

@@ -380,3 +380,87 @@ In order to refresh this AMI one needs to:
380380
1. Create an AWS EC2 instance with the characteristics described in (see `.github/workflows/enclave.yaml` *Launch EC2 Instance* job).
381381
2. Copy the script `espresso/scrips/enclave-prepare-ami.sh` in the EC2 instance (e.g. using scp) and run it.
382382
3. [Export the AMI instance](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/tkv-create-ami-from-instance.html).
383+
384+
## Demo to Celo
385+
For convenience some scripts have been added to make it easier to showcase the
386+
results, and monitor the progress of the docker compose file. The primary
387+
script concerns evaluating `optimism_syncStatus` and displaying the results.
388+
389+
This script requires the commands `tmux`, and `watch` to be installed and
390+
in the `PATH`. Check to see if you have them, and if you don't, be sure to
391+
install them using whatever method you deem necessary in order to run the
392+
script.
393+
394+
After that has been done you should be able to spin up the simple script
395+
using the following command:
396+
```console
397+
./espresso/scripts/demo_tmux_get_sync_status.sh
398+
```
399+
400+
This will launch a `tmux` session setup with a script to automatically
401+
query and display the `optimism_syncStatus` result for the `sequencer`,
402+
`verifier`, and `caff-node`.
403+
404+
It assumes that the `docker-file.yml` is being run with the default values
405+
and will attempt to connect to them as needed.
406+
407+
If you're not used to `tmux` you should be able to disconnect from the session
408+
using `<C-b> d`. This only detaches from the session, the session will still
409+
exist and be running in the background. You can kill the session using the
410+
following command:
411+
```console
412+
tmux kill-session
413+
```
414+
415+
Or you can reattach to it using this command instead:
416+
```console
417+
tmux attach
418+
```
419+
420+
If you want to target different RPC endpoints for optimism, if you're not
421+
running the local demo, and want to target the remote, you can always
422+
specify environment variables before running the script:
423+
```console
424+
OP_RPC_SEQUENCER=http://sequencer.example.com:4545 \
425+
OP_RPC_VERIFIER=http://verifier.example.com:4545 \
426+
OP_RPC_CAFF=http://caff.example.com:4545 \
427+
./espresso/scripts/demo_tmux_get_sync_status.sh
428+
```
429+
430+
### Prepare for the Demo
431+
* Go to the scripts directory.
432+
```console
433+
cd espresso/scripts
434+
```
435+
* Allow access to scripts.
436+
```console
437+
chmod +x startup.sh
438+
chmod +x logs.sh
439+
chmod +x shutdown.sh
440+
```
441+
442+
### Prebuild Everything and Start All Services
443+
Note that `l2-genesis` is expected to take around 2 minutes.
444+
```console
445+
./startup.sh
446+
```
447+
448+
### View Logs
449+
There are 15 services in total, as listed in `logs.sh`. It is supported to run logs for any
450+
service, but we may want to show logs selectively, e.g., by running the following commands one by
451+
one. Note that some service names are replaced by more convenient alias, but it is also suported to
452+
use their full names.
453+
```console
454+
./logs.sh l1-geth
455+
./logs.sh dev-node
456+
./logs.sh op-geth-sequencer
457+
./logs.sh sequencer
458+
./logs.sh verifier
459+
./logs.sh caff-node
460+
./logs.sh batcher
461+
```
462+
463+
### Shut Down All Services
464+
```console
465+
./shutdown.sh
466+
```

espresso/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ L1_HTTP_PORT=8545
2424
L1_BEACON_PORT=5052
2525

2626
ROLLUP_PORT=9545
27+
VERIFIER_PORT=9546
28+
CAFF_PORT=9547
2729

2830
OP_ENGINE_PORT=8552
2931
OP_HTTP_PORT=8546

espresso/devnet-tests/devnet_tools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (d *Devnet) Up() (err error) {
9696
}()
9797

9898
// Open RPC clients for the different nodes.
99-
d.L2Seq, err = d.serviceClient("op-geth-seq", 8546)
99+
d.L2Seq, err = d.serviceClient("op-geth-sequencer", 8546)
100100
if err != nil {
101101
return err
102102
}

espresso/docker-compose.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ services:
108108
environment:
109109
- MODE=rollup
110110
- L1_RPC=http://l1-geth:${L1_HTTP_PORT:?err}
111-
- OP_RPC=http://op-geth-seq:${OP_HTTP_PORT:?err}
111+
- OP_RPC=http://op-geth-sequencer:${OP_HTTP_PORT:?err}
112112
depends_on:
113113
l1-geth:
114114
condition: service_healthy
115115
l1-genesis:
116116
condition: service_completed_successfully
117-
op-geth-seq:
117+
op-geth-sequencer:
118118
condition: service_healthy
119119
volumes:
120120
- ./deployment/l2-config:/config
@@ -136,7 +136,7 @@ services:
136136
- ./deployment/l2-config:/config
137137
- ./deployment/deployer:/deployer:ro
138138

139-
op-geth-seq:
139+
op-geth-sequencer:
140140
extends:
141141
file: docker-compose-op-geth.yml
142142
service: op-geth
@@ -166,16 +166,17 @@ services:
166166
depends_on:
167167
l2-rollup:
168168
condition: service_completed_successfully
169-
op-geth-seq:
169+
op-geth-sequencer:
170170
condition: service_healthy
171171
l1-validator:
172172
condition: service_started
173173
environment:
174-
CAFF_L1_ETH_RPC: http://l1-geth:${L1_HTTP_PORT}
175174
OP_NODE_L1_ETH_RPC: http://l1-geth:${L1_HTTP_PORT}
176175
OP_NODE_L1_BEACON: http://l1-beacon:${L1_BEACON_PORT}
177-
OP_NODE_L2_ENGINE_RPC: http://op-geth-seq:${OP_ENGINE_PORT}
176+
OP_NODE_L2_ENGINE_RPC: http://op-geth-sequencer:${OP_ENGINE_PORT}
178177
OP_NODE_RPC_PORT: ${ROLLUP_PORT}
178+
ports:
179+
- "${ROLLUP_PORT}:${ROLLUP_PORT}"
179180
volumes:
180181
- ./deployment/l2-config:/config:ro
181182
- /etc/localtime:/etc/localtime:ro
@@ -208,12 +209,16 @@ services:
208209
OP_NODE_L1_ETH_RPC: http://l1-geth:${L1_HTTP_PORT}
209210
OP_NODE_L1_BEACON: http://l1-beacon:${L1_BEACON_PORT}
210211
OP_NODE_L2_ENGINE_RPC: http://op-geth-verifier:${OP_ENGINE_PORT}
212+
OP_NODE_RPC_PORT: ${VERIFIER_PORT}
213+
ports:
214+
- "${VERIFIER_PORT}:${VERIFIER_PORT}"
211215
volumes:
212216
- ./deployment/l2-config:/config:ro
213217
command:
214218
- op-node
215219
- --l2.jwt-secret=/config/jwt.txt
216220
- --rollup.config=/config/rollup.json
221+
- --rpc.addr=0.0.0.0
217222
- --l1.http-poll-interval=1s
218223
- --l1.epoch-poll-interval=1s
219224
- --p2p.disable=true
@@ -232,20 +237,24 @@ services:
232237
l2-rollup:
233238
condition: service_completed_successfully
234239
environment:
235-
CAFF_L1_ETH_RPC: http://l1-geth:${L1_HTTP_PORT}
236240
OP_NODE_L1_ETH_RPC: http://l1-geth:${L1_HTTP_PORT}
237241
OP_NODE_L1_BEACON: http://l1-beacon:${L1_BEACON_PORT}
238242
OP_NODE_L2_ENGINE_RPC: http://op-geth-caff-node:${OP_ENGINE_PORT}
239-
CAFF_ESPRESSO_LIGHT_CLIENT_ADDR: "0x703848f4c85f18e3acd8196c8ec91eb0b7bd0797"
240-
CAFF_HOTSHOT_URLS: http://espresso-dev-node:${ESPRESSO_SEQUENCER_API_PORT},http://espresso-dev-node:${ESPRESSO_SEQUENCER_API_PORT}
243+
OP_NODE_CAFF_L1_ETH_RPC: http://l1-geth:${L1_HTTP_PORT}
244+
OP_NODE_CAFF_ESPRESSO_LIGHT_CLIENT_ADDR: "0x703848f4c85f18e3acd8196c8ec91eb0b7bd0797"
245+
OP_NODE_CAFF_HOTSHOT_URLS: http://espresso-dev-node:${ESPRESSO_SEQUENCER_API_PORT},http://espresso-dev-node:${ESPRESSO_SEQUENCER_API_PORT}
246+
OP_NODE_RPC_PORT: ${CAFF_PORT}
247+
ports:
248+
- "${CAFF_PORT}:${CAFF_PORT}"
241249
volumes:
242250
- ./deployment/l2-config:/config:ro
243251
command:
244252
- op-node
245253
- --l2.jwt-secret=/config/jwt.txt
246254
- --rollup.config=/config/rollup.json
247-
- --caff.node=true
255+
- --rpc.addr=0.0.0.0
248256
- --sequencer.enabled=false
257+
- --caff.node=true
249258
- --verifier.l1-confs=0
250259
- --rollup.load-protocol-versions=false
251260
- --rollup.halt=none
@@ -269,7 +278,7 @@ services:
269278
depends_on:
270279
l1-geth:
271280
condition: service_healthy
272-
op-geth-seq:
281+
op-geth-sequencer:
273282
condition: service_started
274283
op-node-sequencer:
275284
condition: service_started
@@ -280,7 +289,7 @@ services:
280289
environment:
281290
L1_RPC: http://l1-geth:${L1_HTTP_PORT}
282291
OP_BATCHER_L1_ETH_RPC: http://l1-geth:${L1_HTTP_PORT}
283-
OP_BATCHER_L2_ETH_RPC: http://op-geth-seq:${OP_HTTP_PORT}
292+
OP_BATCHER_L2_ETH_RPC: http://op-geth-sequencer:${OP_HTTP_PORT}
284293
OP_BATCHER_ROLLUP_RPC: http://op-node-sequencer:${ROLLUP_PORT}
285294
OP_BATCHER_ESPRESSO_URL: http://espresso-dev-node:${ESPRESSO_SEQUENCER_API_PORT},http://espresso-dev-node:${ESPRESSO_SEQUENCER_API_PORT}
286295
volumes:

espresso/docker/op-geth/op-geth-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if [ "$MODE" = "genesis" ]; then
3131
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["finalized", false],"id":1}' \
3232
"$L1_RPC" | jq -r '.result.number')
3333

34-
if [[ -z "$$finalized_block" || "$$finalized_block" == "null" ]]; then
34+
if [[ -z "$finalized_block" || "$finalized_block" == "null" ]]; then
3535
echo "No finalized block yet, waiting..."
3636
sleep 3
3737
continue
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
OP_RPC_SEQUENCER=${OP_RPC_SEQUENCER:-http://localhost:9545}
4+
OP_RPC_VERIFIER=${OP_RPC_VERIFIER:-http://localhost:9546}
5+
OP_RPC_CAFF=${OP_RPC_CAFF:-http://localhost:9547}
6+
7+
set -euC pipefail
8+
9+
# Change the current directory to the script's directory
10+
cd "$(dirname "$0")"
11+
12+
# If the tmux session already exists, we will attach to it.
13+
if tmux has-session -t '=get_sync_status' 2>/dev/null; then
14+
echo "Tmux session 'get_sync_status' already exists. Exiting."
15+
tmux kill-session -t get_sync_status || true
16+
fi
17+
18+
# Create a new tmux session, detached, named "get_sync_status"
19+
tmux new-session -d -s get_sync_status \; \
20+
send-keys "NODE_NAME=sequencer RPC_ADDRESS=$OP_RPC_SEQUENCER watch -p -n 1 -c -d ./get_sync_status.sh" ENTER \; \
21+
split-window -h "NODE_NAME=verifier RPC_ADDRESS=$OP_RPC_VERIFIER watch -p -n 1 -c -d ./get_sync_status.sh" \; \
22+
split-window -h "NODE_NAME=caff-node RPC_ADDRESS=$OP_RPC_CAFF watch -p -n 1 -c -d ./get_sync_status.sh" \; \
23+
select-layout even-horizontal \; \
24+
attach
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# This is a convenience script to fetch data from the optimism node for
3+
# "optimism_syncStatus" RPC method.
4+
5+
echo "NODE $NODE_NAME"
6+
JSON_DATA=$(curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"optimism_syncStatus","params":[],"id":1}' $RPC_ADDRESS 2>/dev/null)
7+
8+
# Make sure the the RPC call was successful
9+
if [ $? -ne 0 ]; then
10+
echo "Failed to connect to $RPC_ADDRESS"
11+
exit 1
12+
fi
13+
14+
15+
# Store the results for easier processing
16+
RESULT=$(echo $JSON_DATA | jq .result)
17+
18+
# Extract and print some fields from the JSON response
19+
output_block_details() {
20+
BLOCK=$(echo $RESULT | jq -r .$1)
21+
echo "$1: ($(echo $BLOCK | jq -r .number))"
22+
echo " hash: $(echo $BLOCK | jq -r .hash)"
23+
echo " parentHash: $(echo $BLOCK | jq -r .parentHash)"
24+
echo " timestamp: $(echo $BLOCK | jq -r .timestamp)"
25+
}
26+
27+
# Output the block details in a simple format
28+
output_block_details "current_l1"
29+
output_block_details "current_l1_finalized"
30+
output_block_details "head_l1"
31+
output_block_details "safe_l1"
32+
output_block_details "finalized_l1"
33+
echo
34+
output_block_details "unsafe_l2"
35+
output_block_details "safe_l2"
36+
output_block_details "finalized_l2"

0 commit comments

Comments
 (0)