Commit dd7f5dbb authored by clabby's avatar clabby Committed by GitHub

chore(op-e2e): assert that the channel actually timed out (#11998)

* assert that the channel actually timed out

* fmt
parent c5007bb4
...@@ -50,6 +50,7 @@ type L2Verifier struct { ...@@ -50,6 +50,7 @@ type L2Verifier struct {
// L2 rollup // L2 rollup
engine *engine.EngineController engine *engine.EngineController
derivationMetrics *testutils.TestDerivationMetrics
derivation *derive.DerivationPipeline derivation *derive.DerivationPipeline
safeHeadListener rollup.SafeHeadListener safeHeadListener rollup.SafeHeadListener
...@@ -88,7 +89,8 @@ type safeDB interface { ...@@ -88,7 +89,8 @@ type safeDB interface {
func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher,
blobsSrc derive.L1BlobsFetcher, altDASrc driver.AltDAIface, blobsSrc derive.L1BlobsFetcher, altDASrc driver.AltDAIface,
eng L2API, cfg *rollup.Config, syncCfg *sync.Config, safeHeadListener safeDB, eng L2API, cfg *rollup.Config, syncCfg *sync.Config, safeHeadListener safeDB,
interopBackend interop.InteropBackend) *L2Verifier { interopBackend interop.InteropBackend,
) *L2Verifier {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel) t.Cleanup(cancel)
...@@ -162,6 +164,7 @@ func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, ...@@ -162,6 +164,7 @@ func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher,
log: log, log: log,
Eng: eng, Eng: eng,
engine: ec, engine: ec,
derivationMetrics: metrics,
derivation: pipeline, derivation: pipeline,
safeHeadListener: safeHeadListener, safeHeadListener: safeHeadListener,
syncCfg: syncCfg, syncCfg: syncCfg,
...@@ -238,6 +241,10 @@ func (s *l2VerifierBackend) OnUnsafeL2Payload(ctx context.Context, envelope *eth ...@@ -238,6 +241,10 @@ func (s *l2VerifierBackend) OnUnsafeL2Payload(ctx context.Context, envelope *eth
return nil return nil
} }
func (s *L2Verifier) DerivationMetricsTracer() *testutils.TestDerivationMetrics {
return s.derivationMetrics
}
func (s *L2Verifier) L2Finalized() eth.L2BlockRef { func (s *L2Verifier) L2Finalized() eth.L2BlockRef {
return s.engine.Finalized() return s.engine.Finalized()
} }
......
...@@ -17,6 +17,11 @@ func runChannelTimeoutTest(gt *testing.T, testCfg *helpers.TestCfg[any]) { ...@@ -17,6 +17,11 @@ func runChannelTimeoutTest(gt *testing.T, testCfg *helpers.TestCfg[any]) {
env := helpers.NewL2FaultProofEnv(t, testCfg, tp, helpers.NewBatcherCfg()) env := helpers.NewL2FaultProofEnv(t, testCfg, tp, helpers.NewBatcherCfg())
channelTimeout := env.Sd.ChainSpec.ChannelTimeout(0) channelTimeout := env.Sd.ChainSpec.ChannelTimeout(0)
var timedOutChannels uint
env.Sequencer.DerivationMetricsTracer().FnRecordChannelTimedOut = func() {
timedOutChannels++
}
const NumL2Blocks = 10 const NumL2Blocks = 10
// Build NumL2Blocks empty blocks on L2 // Build NumL2Blocks empty blocks on L2
...@@ -62,6 +67,9 @@ func runChannelTimeoutTest(gt *testing.T, testCfg *helpers.TestCfg[any]) { ...@@ -62,6 +67,9 @@ func runChannelTimeoutTest(gt *testing.T, testCfg *helpers.TestCfg[any]) {
l2SafeHead = env.Engine.L2Chain().CurrentSafeBlock() l2SafeHead = env.Engine.L2Chain().CurrentSafeBlock()
require.Equal(t, uint64(0), l2SafeHead.Number.Uint64()) require.Equal(t, uint64(0), l2SafeHead.Number.Uint64())
// Ensure that the channel was timed out.
require.EqualValues(t, 1, timedOutChannels)
// Instruct the batcher to submit the blocks to L1 in a new channel, // Instruct the batcher to submit the blocks to L1 in a new channel,
// submitted across 2 transactions. // submitted across 2 transactions.
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
...@@ -103,6 +111,11 @@ func runChannelTimeoutTest_CloseChannelLate(gt *testing.T, testCfg *helpers.Test ...@@ -103,6 +111,11 @@ func runChannelTimeoutTest_CloseChannelLate(gt *testing.T, testCfg *helpers.Test
env := helpers.NewL2FaultProofEnv(t, testCfg, tp, helpers.NewBatcherCfg()) env := helpers.NewL2FaultProofEnv(t, testCfg, tp, helpers.NewBatcherCfg())
channelTimeout := env.Sd.ChainSpec.ChannelTimeout(0) channelTimeout := env.Sd.ChainSpec.ChannelTimeout(0)
var timedOutChannels uint
env.Sequencer.DerivationMetricsTracer().FnRecordChannelTimedOut = func() {
timedOutChannels++
}
const NumL2Blocks = 10 const NumL2Blocks = 10
// Build NumL2Blocks empty blocks on L2 // Build NumL2Blocks empty blocks on L2
...@@ -148,6 +161,9 @@ func runChannelTimeoutTest_CloseChannelLate(gt *testing.T, testCfg *helpers.Test ...@@ -148,6 +161,9 @@ func runChannelTimeoutTest_CloseChannelLate(gt *testing.T, testCfg *helpers.Test
l2SafeHead = env.Engine.L2Chain().CurrentSafeBlock() l2SafeHead = env.Engine.L2Chain().CurrentSafeBlock()
require.Equal(t, uint64(0), l2SafeHead.Number.Uint64()) require.Equal(t, uint64(0), l2SafeHead.Number.Uint64())
// Ensure that the channel was timed out.
require.EqualValues(t, 1, timedOutChannels)
// Cache the second and final frame of the channel from the batcher, but do not submit it yet. // Cache the second and final frame of the channel from the batcher, but do not submit it yet.
for i := 0; i < NumL2Blocks/2; i++ { for i := 0; i < NumL2Blocks/2; i++ {
env.Batcher.ActL2BatchBuffer(t) env.Batcher.ActL2BatchBuffer(t)
......
...@@ -14,6 +14,7 @@ type TestDerivationMetrics struct { ...@@ -14,6 +14,7 @@ type TestDerivationMetrics struct {
FnRecordL2Ref func(name string, ref eth.L2BlockRef) FnRecordL2Ref func(name string, ref eth.L2BlockRef)
FnRecordUnsafePayloads func(length uint64, memSize uint64, next eth.BlockID) FnRecordUnsafePayloads func(length uint64, memSize uint64, next eth.BlockID)
FnRecordChannelInputBytes func(inputCompressedBytes int) FnRecordChannelInputBytes func(inputCompressedBytes int)
FnRecordChannelTimedOut func()
} }
func (t *TestDerivationMetrics) CountSequencedTxs(count int) { func (t *TestDerivationMetrics) CountSequencedTxs(count int) {
...@@ -59,6 +60,9 @@ func (t *TestDerivationMetrics) RecordHeadChannelOpened() { ...@@ -59,6 +60,9 @@ func (t *TestDerivationMetrics) RecordHeadChannelOpened() {
} }
func (t *TestDerivationMetrics) RecordChannelTimedOut() { func (t *TestDerivationMetrics) RecordChannelTimedOut() {
if t.FnRecordChannelTimedOut != nil {
t.FnRecordChannelTimedOut()
}
} }
func (t *TestDerivationMetrics) RecordFrame() { func (t *TestDerivationMetrics) RecordFrame() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment