Skip to content
Merged
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
10 changes: 10 additions & 0 deletions node/derivation/batch_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,22 @@ func (bi *BatchInfo) ParseBatch(batch geth.RPCRollupBatch) error {
if err := startBlock.Decode(batchBytes[:60]); err != nil {
return fmt.Errorf("decode chunk block context error:%v", err)
}
// Guard against uint64 underflow for malformed batches whose
// LastBlockNumber is below the decoded start block.
if batch.LastBlockNumber < startBlock.Number {
return fmt.Errorf("invalid batch: lastBlockNumber %d < start block %d", batch.LastBlockNumber, startBlock.Number)
}
blockCount = batch.LastBlockNumber - startBlock.Number + 1
} else {
parentBatchBlock, err := parentBatchHeader.LastBlockNumber()
if err != nil {
return fmt.Errorf("decode batch header lastBlockNumber error:%v", err)
}
// Guard against uint64 underflow for malformed batches whose
// LastBlockNumber is below the parent's lastBlockNumber.
if batch.LastBlockNumber < parentBatchBlock {
return fmt.Errorf("invalid batch: lastBlockNumber %d < parent lastBlockNumber %d", batch.LastBlockNumber, parentBatchBlock)
}
blockCount = batch.LastBlockNumber - parentBatchBlock
}
}
Expand Down
Loading