Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Sep 21, 2024
1 parent cc0335e commit ff5965a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions op-e2e/actions/helpers/l2_batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,6 @@ func (s *L2Batcher) Buffer(t Testing) error {
type BlockModifier = func(block *types.Block)

func (s *L2Batcher) BufferWithOpts(t Testing, opts ...BlockModifier) error {
block, err := s.l2.BlockByNumber(t.Ctx(), big.NewInt(int64(s.L2BufferedBlock.Number+1)))
require.NoError(t, err, "need l2 block %d from sync status", s.l2SubmittedBlock.Number+1)
for _, f := range opts {
f(block)
}
return s.BufferBlock(t, block)
}

func (s *L2Batcher) BufferBlock(t Testing, block *types.Block) error {
if s.l2Submitting { // break ongoing submitting work if necessary
s.L2ChannelOut = nil
s.l2Submitting = false
Expand Down Expand Up @@ -198,15 +189,25 @@ func (s *L2Batcher) BufferBlock(t Testing, block *types.Block) error {
return nil
}
}

block, err := s.l2.BlockByNumber(t.Ctx(), big.NewInt(int64(s.L2BufferedBlock.Number+1)))
require.NoError(t, err, "need l2 block %d from sync status", s.l2SubmittedBlock.Number+1)
if block.ParentHash() != s.L2BufferedBlock.Hash {
s.log.Error("detected a reorg in L2 chain vs previous submitted information, resetting to safe head now", "safe_head", syncStatus.SafeL2)
s.l2SubmittedBlock = syncStatus.SafeL2
s.L2BufferedBlock = syncStatus.SafeL2
s.L2ChannelOut = nil
}

// Apply modifications to the block
for _, f := range opts {
f(block)
}

// Create channel if we don't have one yet
if s.L2ChannelOut == nil {
var ch ChannelOutIface
var err error
if s.l2BatcherCfg.GarbageCfg != nil {
ch, err = NewGarbageChannelOut(s.l2BatcherCfg.GarbageCfg)
} else {
Expand Down

0 comments on commit ff5965a

Please sign in to comment.