Skip to content

Commit d028c53

Browse files
committed
fix off-by-one error with L1 messages
1 parent c6ae41e commit d028c53

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

encoding/codecv7.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ func (d *DACodecV7) NewDAChunk(chunk *Chunk, totalL1MessagePoppedBefore uint64)
9696
}
9797
// sanity check: L1 message indices are contiguous across blocks boundaries
9898
if numL1Messages > 0 {
99-
if l1MessageIndex+uint64(numL1Messages) != highestQueueIndex {
100-
return nil, fmt.Errorf("failed to sanity check L1 messages count: l1MessageIndex + numL1Messages != highestQueueIndex: %d + %d != %d", l1MessageIndex, numL1Messages, highestQueueIndex)
99+
if l1MessageIndex+uint64(numL1Messages) != highestQueueIndex+1 {
100+
return nil, fmt.Errorf("failed to sanity check L1 messages count after block %d: l1MessageIndex + numL1Messages != highestQueueIndex+1: %d + %d != %d", block.Header.Number.Uint64(), l1MessageIndex, numL1Messages, highestQueueIndex+1)
101101
}
102-
l1MessageIndex = highestQueueIndex
102+
l1MessageIndex += uint64(numL1Messages)
103103
}
104104

105105
daBlock := newDABlockV7(block.Header.Number.Uint64(), block.Header.Time, block.Header.BaseFee, block.Header.GasLimit, uint16(len(block.Transactions)), numL1Messages)
@@ -375,7 +375,12 @@ func (d *DACodecV7) estimateL1CommitBatchSizeAndBlobSize(batch *Batch) (uint64,
375375

376376
// EstimateChunkL1CommitBatchSizeAndBlobSize estimates the L1 commit batch size and blob size for a single chunk.
377377
func (d *DACodecV7) EstimateChunkL1CommitBatchSizeAndBlobSize(chunk *Chunk) (uint64, uint64, error) {
378-
return d.estimateL1CommitBatchSizeAndBlobSize(&Batch{Blocks: chunk.Blocks})
378+
return d.estimateL1CommitBatchSizeAndBlobSize(&Batch{
379+
Blocks: chunk.Blocks,
380+
InitialL1MessageIndex: chunk.InitialL1MessageIndex,
381+
InitialL1MessageQueueHash: chunk.InitialL1MessageQueueHash,
382+
LastL1MessageQueueHash: chunk.LastL1MessageQueueHash,
383+
})
379384
}
380385

381386
// EstimateBatchL1CommitBatchSizeAndBlobSize estimates the L1 commit batch size and blob size for a batch.

0 commit comments

Comments
 (0)