Skip to content

Commit

Permalink
Merge pull request #7953 from testinprod-io/tip/batches-test-refactoring
Browse files Browse the repository at this point in the history
Batch validation test refactoring
  • Loading branch information
protolambda authored Nov 1, 2023
2 parents 9bfaf92 + 87a0644 commit 58c8b1f
Show file tree
Hide file tree
Showing 2 changed files with 409 additions and 334 deletions.
8 changes: 4 additions & 4 deletions op-node/rollup/derive/batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,18 @@ func checkSpanBatch(ctx context.Context, cfg *rollup.Config, log log.Logger, l1B
if batch.GetTimestamp() < nextTimestamp {
if batch.GetTimestamp() > l2SafeHead.Time {
// batch timestamp cannot be between safe head and next timestamp
log.Warn("batch has misaligned timestamp")
log.Warn("batch has misaligned timestamp, block time is too short")
return BatchDrop
}
if (l2SafeHead.Time-batch.GetTimestamp())%cfg.BlockTime != 0 {
log.Warn("batch has misaligned timestamp")
log.Warn("batch has misaligned timestamp, not overlapped exactly")
return BatchDrop
}
parentNum = l2SafeHead.Number - (l2SafeHead.Time-batch.GetTimestamp())/cfg.BlockTime - 1
var err error
parentBlock, err = l2Fetcher.L2BlockRefByNumber(ctx, parentNum)
if err != nil {
log.Error("failed to fetch L2 block", "number", parentNum, "err", err)
log.Warn("failed to fetch L2 block", "number", parentNum, "err", err)
// unable to validate the batch for now. retry later.
return BatchUndecided
}
Expand Down Expand Up @@ -332,7 +332,7 @@ func checkSpanBatch(ctx context.Context, cfg *rollup.Config, log log.Logger, l1B
safeBlockNum := parentNum + i + 1
safeBlockPayload, err := l2Fetcher.PayloadByNumber(ctx, safeBlockNum)
if err != nil {
log.Error("failed to fetch L2 block payload", "number", parentNum, "err", err)
log.Warn("failed to fetch L2 block payload", "number", parentNum, "err", err)
// unable to validate the batch for now. retry later.
return BatchUndecided
}
Expand Down
Loading

0 comments on commit 58c8b1f

Please sign in to comment.