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 {
// L2 rollup
engine *engine.EngineController
derivationMetrics *testutils.TestDerivationMetrics
derivation *derive.DerivationPipeline
safeHeadListener rollup.SafeHeadListener
......@@ -88,7 +89,8 @@ type safeDB interface {
func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher,
blobsSrc derive.L1BlobsFetcher, altDASrc driver.AltDAIface,
eng L2API, cfg *rollup.Config, syncCfg *sync.Config, safeHeadListener safeDB,
interopBackend interop.InteropBackend) *L2Verifier {
interopBackend interop.InteropBackend,
) *L2Verifier {
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)
......@@ -162,6 +164,7 @@ func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher,
log: log,
Eng: eng,
engine: ec,
derivationMetrics: metrics,
derivation: pipeline,
safeHeadListener: safeHeadListener,
syncCfg: syncCfg,
......@@ -238,6 +241,10 @@ func (s *l2VerifierBackend) OnUnsafeL2Payload(ctx context.Context, envelope *eth
return nil
}
func (s *L2Verifier) DerivationMetricsTracer() *testutils.TestDerivationMetrics {
return s.derivationMetrics
}
func (s *L2Verifier) L2Finalized() eth.L2BlockRef {
return s.engine.Finalized()
}
......
......@@ -17,6 +17,11 @@ func runChannelTimeoutTest(gt *testing.T, testCfg *helpers.TestCfg[any]) {
env := helpers.NewL2FaultProofEnv(t, testCfg, tp, helpers.NewBatcherCfg())
channelTimeout := env.Sd.ChainSpec.ChannelTimeout(0)
var timedOutChannels uint
env.Sequencer.DerivationMetricsTracer().FnRecordChannelTimedOut = func() {
timedOutChannels++
}
const NumL2Blocks = 10
// Build NumL2Blocks empty blocks on L2
......@@ -62,6 +67,9 @@ func runChannelTimeoutTest(gt *testing.T, testCfg *helpers.TestCfg[any]) {
l2SafeHead = env.Engine.L2Chain().CurrentSafeBlock()
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,
// submitted across 2 transactions.
for i := 0; i < 2; i++ {
......@@ -103,6 +111,11 @@ func runChannelTimeoutTest_CloseChannelLate(gt *testing.T, testCfg *helpers.Test
env := helpers.NewL2FaultProofEnv(t, testCfg, tp, helpers.NewBatcherCfg())
channelTimeout := env.Sd.ChainSpec.ChannelTimeout(0)
var timedOutChannels uint
env.Sequencer.DerivationMetricsTracer().FnRecordChannelTimedOut = func() {
timedOutChannels++
}
const NumL2Blocks = 10
// Build NumL2Blocks empty blocks on L2
......@@ -148,6 +161,9 @@ func runChannelTimeoutTest_CloseChannelLate(gt *testing.T, testCfg *helpers.Test
l2SafeHead = env.Engine.L2Chain().CurrentSafeBlock()
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.
for i := 0; i < NumL2Blocks/2; i++ {
env.Batcher.ActL2BatchBuffer(t)
......
......@@ -14,6 +14,7 @@ type TestDerivationMetrics struct {
FnRecordL2Ref func(name string, ref eth.L2BlockRef)
FnRecordUnsafePayloads func(length uint64, memSize uint64, next eth.BlockID)
FnRecordChannelInputBytes func(inputCompressedBytes int)
FnRecordChannelTimedOut func()
}
func (t *TestDerivationMetrics) CountSequencedTxs(count int) {
......@@ -59,6 +60,9 @@ func (t *TestDerivationMetrics) RecordHeadChannelOpened() {
}
func (t *TestDerivationMetrics) RecordChannelTimedOut() {
if t.FnRecordChannelTimedOut != nil {
t.FnRecordChannelTimedOut()
}
}
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