Commit 901d20aa authored by zhiqiangxu's avatar zhiqiangxu Committed by GitHub

call BuildingPayload once (#9884)

parent 763fda7f
......@@ -132,10 +132,11 @@ 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)
}
......@@ -143,8 +144,6 @@ func (d *Sequencer) PlanNextSequencerAction() time.Duration {
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 {
......
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