Skip to content

Commit 8e1e627

Browse files
authored
TA1: Add devnet test for batcher restart (#204)
* 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 * Build containers in dependency order * Don't copy config file into Docker image at build time * Checkout submodules in CI * Don't copy config file into Docker image at build time * Run devnet test in separate workflow
1 parent 0092252 commit 8e1e627

File tree

11 files changed

+533
-47
lines changed

11 files changed

+533
-47
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
}

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)