Skip to content

Commit

Permalink
feat(cannon): Add additonal logging for derviers waiting to be activated
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Jan 12, 2024
1 parent f983937 commit 0853184
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions pkg/cannon/cannon.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,31 @@ func (c *Cannon) startDeriverWhenReady(ctx context.Context, d deriver.EventDeriv

if !fork.Active(phase0.Slot(slot.Number()), spec.SlotsPerEpoch) {
// Sleep until the next epochl and then retrty
c.log.Debug("Derived epoch is not active yet, sleeping until next epoch")
currentEpoch := c.beacon.Metadata().Wallclock().Epochs().Current()

epoch := c.beacon.Metadata().Wallclock().Epochs().Current()
activationForkEpoch := c.beacon.Node().Wallclock().Epochs().FromNumber(uint64(fork.Epoch))

time.Sleep(time.Until(epoch.TimeWindow().End()))
sleepFor := time.Until(activationForkEpoch.TimeWindow().End())

if activationForkEpoch.Number()-currentEpoch.Number() > 100000 {
// If the fork epoch is over 100k epochs away we are most likely dealing with a
// placeholder fork epoch. We should sleep until the end of the current fork epoch and then
// wait for the spec to refresh. This gives the beacon node a chance to give us the real
// fork epoch once its scheduled.
sleepFor = time.Until(currentEpoch.TimeWindow().End())
}

c.log.
WithField("current_epoch", currentEpoch.Number()).
WithField("activation_fork_name", d.ActivationFork()).
WithField("activation_fork_epoch", fork.Epoch).
WithField("estimated_time_until_fork", time.Until(
activationForkEpoch.TimeWindow().Start(),
)).
WithField("check_again_in", sleepFor).
Warn("Deriver required fork is not active yet")

time.Sleep(sleepFor)

continue
}
Expand Down

0 comments on commit 0853184

Please sign in to comment.