diff --git a/op-e2e/system_test.go b/op-e2e/system_test.go index 8c7439f804f35..f90da1a923cdf 100644 --- a/op-e2e/system_test.go +++ b/op-e2e/system_test.go @@ -566,7 +566,7 @@ func TestSystemMockP2P(t *testing.T) { require.Nil(t, err, "Sending L2 tx to sequencer") // Wait for tx to be mined on the L2 sequencer chain - receiptSeq, err := waitForTransaction(tx.Hash(), l2Seq, 3*time.Duration(sys.RollupConfig.BlockTime)*time.Second) + receiptSeq, err := waitForTransaction(tx.Hash(), l2Seq, 6*time.Duration(sys.RollupConfig.BlockTime)*time.Second) require.Nil(t, err, "Waiting for L2 tx on sequencer") // Wait until the block it was first included in shows up in the safe chain on the verifier diff --git a/op-node/rollup/driver/conf_depth.go b/op-node/rollup/driver/conf_depth.go index 2f2557e762b7a..0357606e919fa 100644 --- a/op-node/rollup/driver/conf_depth.go +++ b/op-node/rollup/driver/conf_depth.go @@ -6,7 +6,6 @@ import ( "github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/common" ) // confDepth is an util that wraps the L1 input fetcher used in the pipeline, @@ -33,7 +32,10 @@ func (c *confDepth) L1BlockRefByNumber(ctx context.Context, num uint64) (eth.L1B // Don't apply the conf depth is l1Head is empty (as it is during the startup case before the l1State is initialized). l1Head := c.l1Head() - if num == 0 || c.depth == 0 || num+c.depth <= l1Head.Number || l1Head.Hash == (common.Hash{}) { + if l1Head == (eth.L1BlockRef{}) { + return c.L1Fetcher.L1BlockRefByNumber(ctx, num) + } + if num == 0 || c.depth == 0 || num+c.depth <= l1Head.Number { return c.L1Fetcher.L1BlockRefByNumber(ctx, num) } return eth.L1BlockRef{}, ethereum.NotFound diff --git a/op-node/rollup/driver/l1_state.go b/op-node/rollup/driver/l1_state.go index 9b845ebb82640..a886cc4b08603 100644 --- a/op-node/rollup/driver/l1_state.go +++ b/op-node/rollup/driver/l1_state.go @@ -63,14 +63,20 @@ func (s *L1State) HandleNewL1FinalizedBlock(finalized eth.L1BlockRef) { s.l1Finalized = finalized } +// L1Head returns either the stored L1 head or an empty block reference +// if the L1 Head has not been initialized yet. func (s *L1State) L1Head() eth.L1BlockRef { return s.l1Head } +// L1Safe returns either the stored L1 safe block or an empty block reference +// if the L1 safe block has not been initialized yet. func (s *L1State) L1Safe() eth.L1BlockRef { return s.l1Safe } +// L1Finalized returns either the stored L1 finalized block or an empty block reference +// if the L1 finalized block has not been initialized yet. func (s *L1State) L1Finalized() eth.L1BlockRef { return s.l1Finalized } diff --git a/op-node/rollup/driver/state.go b/op-node/rollup/driver/state.go index 8472876d157ad..d86bcff59a2bb 100644 --- a/op-node/rollup/driver/state.go +++ b/op-node/rollup/driver/state.go @@ -134,8 +134,13 @@ func (s *Driver) createNewL2Block(ctx context.Context) error { l2Safe := s.derivation.SafeL2Head() l2Finalized := s.derivation.Finalized() + l1Head := s.l1State.L1Head() + if l1Head == (eth.L1BlockRef{}) { + return derive.NewTemporaryError(errors.New("L1 Head in L1 State is not initizalited yet")) + } + // Figure out which L1 origin block we're going to be building on top of. - l1Origin, err := s.l1OriginSelector.FindL1Origin(ctx, s.l1State.L1Head(), l2Head) + l1Origin, err := s.l1OriginSelector.FindL1Origin(ctx, l1Head, l2Head) if err != nil { s.log.Error("Error finding next L1 Origin", "err", err) return err @@ -261,9 +266,8 @@ func (s *Driver) eventLoop() { case <-l2BlockCreationReqCh: s.snapshot("L2 Block Creation Request") - l1Head := s.l1State.L1Head() if !s.idleDerivation { - s.log.Warn("not creating block, node is deriving new l2 data", "head_l1", l1Head) + s.log.Warn("not creating block, node is deriving new l2 data", "head_l1", s.l1State.L1Head()) break } ctx, cancel := context.WithTimeout(ctx, 20*time.Minute)