Skip to content

Commit c048b7e

Browse files
committed
merge main
2 parents 2901aef + 3f96717 commit c048b7e

20 files changed

+869
-51
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Run Espresso Devnet tests
2+
on:
3+
pull_request:
4+
branches:
5+
- "celo-integration*"
6+
push:
7+
branches:
8+
- "master"
9+
- "celo-integration*"
10+
workflow_dispatch:
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-24.04-8core
15+
env:
16+
ESPRESSO_DEVNET_TESTS_LIVENESS_PERIOD: '1m'
17+
ESPRESSO_DEVNET_TESTS_OUTAGE_PERIOD: '1m'
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
submodules: 'recursive'
23+
24+
- name: Install Nix
25+
uses: nixbuild/nix-quick-install-action@v30
26+
with:
27+
nix_conf: |
28+
keep-env-derivations = true
29+
keep-outputs = true
30+
- name: Restore Nix cache
31+
id: cache-nix-restore
32+
uses: nix-community/cache-nix-action/restore@v6
33+
with:
34+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
35+
- name: Set up Nix environment
36+
uses: nicknovitski/nix-develop@v1
37+
38+
- name: Cache Go modules
39+
uses: actions/setup-go@v5
40+
41+
- name: Compile contracts
42+
run: just compile-contracts
43+
44+
- name: Build Devnet
45+
run: |
46+
cd op-deployer
47+
just
48+
export PATH=$PATH:$PWD/bin
49+
cd ../espresso
50+
./scripts/prepare-allocs.sh
51+
docker compose build
52+
53+
- name: Run Devnet tests
54+
run: go test -timeout 30m -p 1 -count 1 -v ./espresso/devnet-tests/...
55+
56+
- name: Save Nix cache
57+
uses: nix-community/cache-nix-action/save@v6
58+
if: always() && steps.cache-nix-restore.outputs.hit-primary-key != 'true'
59+
with:
60+
primary-key: ${{ steps.cache-nix-restore.outputs.primary-key }}

.github/workflows/espresso-integration.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ jobs:
4848
total: 4
4949
packages: "./espresso/..."
5050
- name: Run Go tests for group ${{ matrix.group }}
51-
run: go test -timeout 30m -p 1 -count 1 -v -run "^(${{ steps.test_split.outputs.run}})$" ./espresso/...
51+
run: |
52+
go test -short -timeout 30m -p 1 -count 1 -v -run "^(${{ steps.test_split.outputs.run}})$" ./espresso/...
5253
5354
- name: Save Nix cache
5455
uses: nix-community/cache-nix-action/save@v6

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"editorconfig.generateAuto": false,
3-
"files.trimTrailingWhitespace": true
3+
"files.trimTrailingWhitespace": true,
4+
"makefile.configureOnOpen": false
45
}

README_ESPRESSO.md

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

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/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Espresso Devnet Tests
2+
3+
Test various end-to-end functionalities in a locally running devnet.
4+
5+
## Running
6+
7+
`go test ./espresso/devnet-tests/...`
8+
9+
Configure how long it takes to run the tests vs how stringent the tests are by setting
10+
`ESPRESSO_DEVNET_TESTS_LIVENESS_PERIOD` and `ESPRESSO_DEVNET_TESTS_OUTAGE_PERIOD`. These determine
11+
how long we need the devnet to run in a healthy state before considering a run successful, and how
12+
long to let an unhealthy state persist before attempting recovery, respectively. For the fullest
13+
test these are set to `1m` and `10m`, but for quick testing, more reasonable values would be around
14+
`10s`.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package devnet_tests
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/ethereum/go-ethereum"
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestBatcherRestart(t *testing.T) {
12+
ctx, cancel := context.WithCancel(context.Background())
13+
defer cancel()
14+
15+
d := NewDevnet(ctx, t)
16+
require.NoError(t, d.Up())
17+
defer func() {
18+
require.NoError(t, d.Down())
19+
}()
20+
21+
// Send a transaction just to check that everything has started up ok.
22+
require.NoError(t, d.RunSimpleL2Burn())
23+
24+
// Shut down the batcher and have another transaction submitted while it is down.
25+
require.NoError(t, d.ServiceDown("op-batcher"))
26+
d.SleepOutageDuration()
27+
28+
receipt, err := d.SubmitSimpleL2Burn()
29+
require.NoError(t, err)
30+
31+
// Check that while the batcher is down, the verifier does NOT process submitted transactions.
32+
d.SleepOutageDuration()
33+
_, err = d.L2Verif.TransactionReceipt(ctx, receipt.Receipt.TxHash)
34+
require.ErrorIs(t, err, ethereum.NotFound)
35+
36+
// Bring the batcher back up and check that it processes the transaction which was submitted
37+
// while it was down.
38+
require.NoError(t, d.ServiceUp("op-batcher"))
39+
require.NoError(t, d.VerifySimpleL2Burn(receipt))
40+
41+
// Submit another transaction at the end just to check that things stay working.
42+
d.SleepRecoveryDuration()
43+
require.NoError(t, d.RunSimpleL2Burn())
44+
}

0 commit comments

Comments
 (0)