Skip to content

Commit

Permalink
call BuildingPayload once (#9884)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqiangxu authored Mar 25, 2024
1 parent 763fda7 commit 901d20a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions op-node/rollup/driver/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,18 @@ func (d *Sequencer) CancelBuildingBlock(ctx context.Context) {

// PlanNextSequencerAction returns a desired delay till the RunNextSequencerAction call.
func (d *Sequencer) PlanNextSequencerAction() time.Duration {
buildingOnto, buildingID, safe := d.engine.BuildingPayload()
// If the engine is busy building safe blocks (and thus changing the head that we would sync on top of),
// then give it time to sync up.
if onto, _, safe := d.engine.BuildingPayload(); safe {
d.log.Warn("delaying sequencing to not interrupt safe-head changes", "onto", onto, "onto_time", onto.Time)
if safe {
d.log.Warn("delaying sequencing to not interrupt safe-head changes", "onto", buildingOnto, "onto_time", buildingOnto.Time)
// approximates the worst-case time it takes to build a block, to reattempt sequencing after.
return time.Second * time.Duration(d.rollupCfg.BlockTime)
}

head := d.engine.UnsafeL2Head()
now := d.timeNow()

buildingOnto, buildingID, _ := d.engine.BuildingPayload()

// We may have to wait till the next sequencing action, e.g. upon an error.
// If the head changed we need to respond and will not delay the sequencing.
if delay := d.nextAction.Sub(now); delay > 0 && buildingOnto.Hash == head.Hash {
Expand Down

0 comments on commit 901d20a

Please sign in to comment.