Skip to content

Commit a804cb2

Browse files
fix(taiko-client): reduce slot required for updating lookahead (#19526)
Co-authored-by: David <[email protected]>
1 parent 827cd89 commit a804cb2

File tree

1 file changed

+49
-19
lines changed

1 file changed

+49
-19
lines changed

packages/taiko-client/driver/driver.go

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -457,26 +457,56 @@ func (d *Driver) cacheLookaheadLoop() {
457457
// once per epoch, since we push the next operator as the current range when we check.
458458
// so, this means we should use a reliable slot past 0 where the operator has no possible
459459
// way to change. mid-epooch works, so we use slot 16.
460-
if lookahead == nil || lookahead.LastEpochUpdated < currentEpoch && slotInEpoch >= 15 {
461-
log.Info(
462-
"Pushing into window for current epoch",
463-
"epoch", currentEpoch,
464-
"currentSlot", currentSlot,
465-
"slotInEpoch", slotInEpoch,
466-
"currOp", currOp.Hex(),
467-
"nextOp", nextOp.Hex(),
468-
)
469-
opWin.Push(currentEpoch, currOp, nextOp)
460+
if lookahead == nil || lookahead.LastEpochUpdated < currentEpoch && slotInEpoch >= 2 {
461+
if currOp == d.PreconfOperatorAddress && nextOp == d.PreconfOperatorAddress {
462+
log.Info(
463+
"Pushing into window for current epoch as current and next operator",
464+
"epoch", currentEpoch,
465+
"currentSlot", currentSlot,
466+
"slotInEpoch", slotInEpoch,
467+
"currOp", currOp.Hex(),
468+
"nextOp", nextOp.Hex(),
469+
)
470+
opWin.Push(currentEpoch, currOp, nextOp)
470471

471-
// Push next epoch into window.
472-
log.Info(
473-
"Pushing into window for next epoch",
474-
"epoch", currentEpoch+1,
475-
"currentSlot", currentSlot,
476-
"slotInEpoch", slotInEpoch,
477-
"currOp", nextOp.Hex(), // currOp becomes nextOp at next epoch
478-
)
479-
opWin.Push(currentEpoch+1, nextOp, common.Address{}) // We don't know next-next-op, safe to leave zero
472+
log.Info(
473+
"Pushing into window for next epoch as current operator",
474+
"epoch", currentEpoch+1,
475+
"currentSlot", currentSlot,
476+
"slotInEpoch", slotInEpoch,
477+
"currOp", nextOp.Hex(),
478+
)
479+
opWin.Push(currentEpoch+1, nextOp, common.Address{}) // next next op is safe to leave 0
480+
} else if currOp == d.PreconfOperatorAddress {
481+
log.Info(
482+
"Pushing into window for current epoch as current operator",
483+
"epoch", currentEpoch,
484+
"currentSlot", currentSlot,
485+
"slotInEpoch", slotInEpoch,
486+
"currOp", currOp.Hex(),
487+
"nextOp", nextOp.Hex(),
488+
)
489+
opWin.Push(currentEpoch, currOp, common.Address{})
490+
} else if nextOp == d.PreconfOperatorAddress {
491+
log.Info(
492+
"Pushing into window for current epoch as next operator",
493+
"epoch", currentEpoch,
494+
"currentSlot", currentSlot,
495+
"slotInEpoch", slotInEpoch,
496+
"currOp", currOp.Hex(),
497+
"nextOp", nextOp.Hex(),
498+
)
499+
opWin.Push(currentEpoch, common.Address{}, nextOp)
500+
501+
log.Info(
502+
"Pushing into window for next epoch as current operator",
503+
"epoch", currentEpoch+1,
504+
"currentSlot", currentSlot,
505+
"slotInEpoch", slotInEpoch,
506+
"currOp", nextOp.Hex(),
507+
)
508+
opWin.Push(currentEpoch+1, nextOp, common.Address{}) // next next op is safe to leave 0
509+
}
480510

481511
var (
482512
currRanges = opWin.SequencingWindowSplit(d.PreconfOperatorAddress, true)

0 commit comments

Comments
 (0)