Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e/system: add test for the batcher recovering from an L2 chain rewind #13386

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions op-e2e/system/da/l2_rewind_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package da

import (
"context"
"testing"
"time"

op_e2e "github.com/ethereum-optimism/optimism/op-e2e"

"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"
"github.com/stretchr/testify/require"
)

// This test verifies that the batcher can recover from a rewind of the L2 chain.
func TestBatcherL2Rewind(t *testing.T) {
op_e2e.InitParallel(t)
cfg := e2esys.DefaultSystemConfig(t)
cfg.DisableProposer = true
sys, err := cfg.Start(t)
require.NoError(t, err, "Error starting up system")

l2Seq := sys.NodeClient("sequencer")

// Wait for a short safe chain to be built.
safeChainLength := 5
err = wait.ForSafeBlock(context.Background(), sys.RollupClient("sequencer"), uint64(safeChainLength))
require.NoError(t, err)

// rewind the L2 unsafe chain
result := make(map[string]interface{})
err = l2Seq.Client().Call(&result, "debug_setHead", "0x0")
require.NoError(t, err)
t.Log("INTERVENTION: called debugSetHead with result: ", result)

// Wait for the intervention to take effect
time.Sleep(time.Second * 5)
Comment on lines +36 to +37
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this wait, here -- appreciate any suggestions on how to make this more event-driven.


// The batcher should be able to recover from the sequencer rewind
require.Eventually(t, func() bool {
ss, err := sys.RollupClient(e2esys.RoleSeq).SyncStatus(context.Background())
if err == nil && ss.SafeL2.Number > uint64(safeChainLength) {
return true
}
t.Log("Waiting for safe head to advance", "safe head", ss.SafeL2.Number)
return false
}, time.Second*10, time.Second, "Safe head did not advance")
}