Commit 26179b1e authored by protolambda's avatar protolambda

fix FillMissingBatches edge case, and correct spec off by 1

parent ec2b8a39
...@@ -70,8 +70,8 @@ func FillMissingBatches(batches []*BatchData, epoch eth.BlockID, blockTime, minL ...@@ -70,8 +70,8 @@ func FillMissingBatches(batches []*BatchData, epoch eth.BlockID, blockTime, minL
// - fill up to the next L1 block timestamp, if higher, to keep up with L1 time // - fill up to the next L1 block timestamp, if higher, to keep up with L1 time
// - fill up to the last valid batch, to keep up with L2 time // - fill up to the last valid batch, to keep up with L2 time
newHeadL2Timestamp := minL2Time newHeadL2Timestamp := minL2Time
if nextL1Time > newHeadL2Timestamp+blockTime { if nextL1Time > newHeadL2Timestamp+1 {
newHeadL2Timestamp = nextL1Time - blockTime newHeadL2Timestamp = nextL1Time - 1
} }
for _, b := range batches { for _, b := range batches {
m[b.BatchV1.Timestamp] = b m[b.BatchV1.Timestamp] = b
......
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/testutils" "github.com/ethereum-optimism/optimism/op-node/testutils"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
......
...@@ -181,8 +181,8 @@ To encode user-deposited transactions, refer to the following sections of the de ...@@ -181,8 +181,8 @@ To encode user-deposited transactions, refer to the following sections of the de
A sequencing window is derived into a variable number of L2 blocks, defined by a range of timestamps: A sequencing window is derived into a variable number of L2 blocks, defined by a range of timestamps:
- Starting at `min_l2_timestamp`, as defined in the batch filtering. - Starting at `min_l2_timestamp`, as defined in the batch filtering.
- Up to and including - Up to and including (including only if aligned with L2 block time)
`new_head_l2_timestamp = max(highest_valid_batch_timestamp, next_l1_timestamp - l2_block_time, min_l2_timestamp)` `new_head_l2_timestamp = max(highest_valid_batch_timestamp, next_l1_timestamp - 1, min_l2_timestamp)`
- `highest_valid_batch_timestamp = max(batch.timestamp for batch in filtered_batches)`, - `highest_valid_batch_timestamp = max(batch.timestamp for batch in filtered_batches)`,
or `0` if no there are no `filtered_batches`. or `0` if no there are no `filtered_batches`.
`batch.timestamp` refers to the L2 block timestamp encoded in the batch. `batch.timestamp` refers to the L2 block timestamp encoded in the batch.
......
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