@@ -32,7 +32,8 @@ const (
32
32
// The first entry of the l1Blocks should match the origin of the l2SafeHead. One or more consecutive l1Blocks should be provided.
33
33
// In case of only a single L1 block, the decision whether a batch is valid may have to stay undecided.
34
34
func CheckBatch (ctx context.Context , cfg * rollup.Config , log log.Logger , l1Blocks []eth.L1BlockRef ,
35
- l2SafeHead eth.L2BlockRef , batch * BatchWithL1InclusionBlock , l2Fetcher SafeBlockFetcher ) BatchValidity {
35
+ l2SafeHead eth.L2BlockRef , batch * BatchWithL1InclusionBlock , l2Fetcher SafeBlockFetcher ,
36
+ ) BatchValidity {
36
37
switch batch .Batch .GetBatchType () {
37
38
case SingularBatchType :
38
39
singularBatch , ok := batch .Batch .(* SingularBatch )
@@ -122,8 +123,9 @@ func checkSingularBatch(cfg *rollup.Config, log log.Logger, l1Blocks []eth.L1Blo
122
123
return BatchDrop
123
124
}
124
125
126
+ spec := rollup .NewChainSpec (cfg )
125
127
// Check if we ran out of sequencer time drift
126
- if max := batchOrigin .Time + cfg .MaxSequencerDrift ; batch .Timestamp > max {
128
+ if max := batchOrigin .Time + spec .MaxSequencerDrift ( batchOrigin . Time ) ; batch .Timestamp > max {
127
129
if len (batch .Transactions ) == 0 {
128
130
// If the sequencer is co-operating by producing an empty batch,
129
131
// then allow the batch if it was the right thing to do to maintain the L2 time >= L1 time invariant.
@@ -166,7 +168,8 @@ func checkSingularBatch(cfg *rollup.Config, log log.Logger, l1Blocks []eth.L1Blo
166
168
167
169
// checkSpanBatch implements SpanBatch validation rule.
168
170
func checkSpanBatch (ctx context.Context , cfg * rollup.Config , log log.Logger , l1Blocks []eth.L1BlockRef , l2SafeHead eth.L2BlockRef ,
169
- batch * SpanBatch , l1InclusionBlock eth.L1BlockRef , l2Fetcher SafeBlockFetcher ) BatchValidity {
171
+ batch * SpanBatch , l1InclusionBlock eth.L1BlockRef , l2Fetcher SafeBlockFetcher ,
172
+ ) BatchValidity {
170
173
// add details to the log
171
174
log = batch .LogContext (log )
172
175
@@ -266,10 +269,7 @@ func checkSpanBatch(ctx context.Context, cfg *rollup.Config, log log.Logger, l1B
266
269
}
267
270
268
271
originIdx := 0
269
- originAdvanced := false
270
- if startEpochNum == parentBlock .L1Origin .Number + 1 {
271
- originAdvanced = true
272
- }
272
+ originAdvanced := startEpochNum == parentBlock .L1Origin .Number + 1
273
273
274
274
for i := 0 ; i < batch .GetBlockCount (); i ++ {
275
275
if batch .GetBlockTimestamp (i ) <= l2SafeHead .Time {
@@ -282,7 +282,6 @@ func checkSpanBatch(ctx context.Context, cfg *rollup.Config, log log.Logger, l1B
282
282
originIdx = j
283
283
break
284
284
}
285
-
286
285
}
287
286
if i > 0 {
288
287
originAdvanced = false
@@ -296,8 +295,9 @@ func checkSpanBatch(ctx context.Context, cfg *rollup.Config, log log.Logger, l1B
296
295
return BatchDrop
297
296
}
298
297
298
+ spec := rollup .NewChainSpec (cfg )
299
299
// Check if we ran out of sequencer time drift
300
- if max := l1Origin .Time + cfg .MaxSequencerDrift ; blockTimestamp > max {
300
+ if max := l1Origin .Time + spec .MaxSequencerDrift ( l1Origin . Time ) ; blockTimestamp > max {
301
301
if len (batch .GetBlockTransactions (i )) == 0 {
302
302
// If the sequencer is co-operating by producing an empty batch,
303
303
// then allow the batch if it was the right thing to do to maintain the L2 time >= L1 time invariant.
0 commit comments