Commit 183555b8 authored by protolambda's avatar protolambda

op-node: allow sequencer to produce block with txs at sequencer time drift...

op-node: allow sequencer to produce block with txs at sequencer time drift boundary to match derivation behavior
parent 8fed3675
...@@ -93,6 +93,10 @@ func TestLargeL1Gaps(gt *testing.T) { ...@@ -93,6 +93,10 @@ func TestLargeL1Gaps(gt *testing.T) {
makeL2BlockWithAliceTx() makeL2BlockWithAliceTx()
} }
n, err := cl.NonceAt(t.Ctx(), dp.Addresses.Alice, nil)
require.NoError(t, err)
require.Equal(t, uint64(16), n) // 16 valid blocks with txns.
verifyChainStateOnSequencer(8, 16, 8, 14, 7) verifyChainStateOnSequencer(8, 16, 8, 14, 7)
// Make the really long L1 block. Do include previous batches // Make the really long L1 block. Do include previous batches
...@@ -115,14 +119,15 @@ func TestLargeL1Gaps(gt *testing.T) { ...@@ -115,14 +119,15 @@ func TestLargeL1Gaps(gt *testing.T) {
// We created one transaction for every L2 block. So we should have created 40 transactions. // We created one transaction for every L2 block. So we should have created 40 transactions.
// The first 16 L2 block where included without issue. // The first 16 L2 block where included without issue.
// Then over the long block, 32s seq drift / 2s block time => 16 blocks with transactions // Then over the long block, 32s seq drift / 2s block time => 16 blocks with transactions
// That leaves 8 blocks without transactions. So we should have 16+16 = 32 transactions on chain. // Then at the last L2 block we reached the next origin, and accept txs again => 17 blocks with transactions
n, err := cl.PendingNonceAt(t.Ctx(), dp.Addresses.Alice) // That leaves 7 L2 blocks without transactions. So we should have 16+17 = 33 transactions on chain.
n, err = cl.PendingNonceAt(t.Ctx(), dp.Addresses.Alice)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, uint64(40), n) require.Equal(t, uint64(40), n)
n, err = cl.NonceAt(t.Ctx(), dp.Addresses.Alice, nil) n, err = cl.NonceAt(t.Ctx(), dp.Addresses.Alice, nil)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, uint64(32), n) require.Equal(t, uint64(33), n)
// Make more L1 blocks to get past the sequence window for the large range. // Make more L1 blocks to get past the sequence window for the large range.
// Do batch submit the previous L2 blocks. // Do batch submit the previous L2 blocks.
...@@ -148,7 +153,7 @@ func TestLargeL1Gaps(gt *testing.T) { ...@@ -148,7 +153,7 @@ func TestLargeL1Gaps(gt *testing.T) {
// Recheck nonce. Will fail if no batches where submitted // Recheck nonce. Will fail if no batches where submitted
n, err = cl.NonceAt(t.Ctx(), dp.Addresses.Alice, nil) n, err = cl.NonceAt(t.Ctx(), dp.Addresses.Alice, nil)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, uint64(32), n) // 16 valid blocks with txns. Get seq drift non-empty (32/2 => 16) & 8 forced empty require.Equal(t, uint64(33), n) // 16 valid blocks with txns. Get seq drift non-empty (32/2 => 16) & 7 forced empty
// Check that the verifier got the same result // Check that the verifier got the same result
verifier.ActL1HeadSignal(t) verifier.ActL1HeadSignal(t)
......
...@@ -89,7 +89,7 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) { ...@@ -89,7 +89,7 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) {
sequencer.ActL1HeadSignal(t) sequencer.ActL1HeadSignal(t)
// Make blocks up till the sequencer drift is about to surpass, but keep the old L1 origin // Make blocks up till the sequencer drift is about to surpass, but keep the old L1 origin
for sequencer.SyncStatus().UnsafeL2.Time+sd.RollupCfg.BlockTime < origin.Time()+sd.RollupCfg.MaxSequencerDrift { for sequencer.SyncStatus().UnsafeL2.Time+sd.RollupCfg.BlockTime <= origin.Time()+sd.RollupCfg.MaxSequencerDrift {
sequencer.ActL2KeepL1Origin(t) sequencer.ActL2KeepL1Origin(t)
makeL2BlockWithAliceTx() makeL2BlockWithAliceTx()
require.Equal(t, uint64(1), sequencer.SyncStatus().UnsafeL2.L1Origin.Number, "expected to keep old L1 origin") require.Equal(t, uint64(1), sequencer.SyncStatus().UnsafeL2.L1Origin.Number, "expected to keep old L1 origin")
......
...@@ -84,7 +84,11 @@ func (d *Sequencer) StartBuildingBlock(ctx context.Context, l1Origin eth.L1Block ...@@ -84,7 +84,11 @@ func (d *Sequencer) StartBuildingBlock(ctx context.Context, l1Origin eth.L1Block
// empty blocks (other than the L1 info deposit and any user deposits). We handle this by // empty blocks (other than the L1 info deposit and any user deposits). We handle this by
// setting NoTxPool to true, which will cause the Sequencer to not include any transactions // setting NoTxPool to true, which will cause the Sequencer to not include any transactions
// from the transaction pool. // from the transaction pool.
attrs.NoTxPool = uint64(attrs.Timestamp) >= l1Origin.Time+d.config.MaxSequencerDrift attrs.NoTxPool = uint64(attrs.Timestamp) > l1Origin.Time+d.config.MaxSequencerDrift
d.log.Debug("prepared attributes for new block",
"num", l2Head.Number+1, "time", uint64(attrs.Timestamp),
"origin", l1Origin, "origin_time", l1Origin.Time, "noTxPool", attrs.NoTxPool)
// And construct our fork choice state. This is our current fork choice state and will be // And construct our fork choice state. This is our current fork choice state and will be
// updated as a result of executing the block based on the attributes described above. // updated as a result of executing the block based on the attributes described above.
......
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