From 7c62b8968463d09685175085467e1555e6fa27b4 Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Mon, 20 Jan 2025 14:26:17 +1000 Subject: [PATCH] refactor: Remove unnecessary slot variable and optimize epoch handling --- pkg/cannon/cannon.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/cannon/cannon.go b/pkg/cannon/cannon.go index e915ec4f..23fc4355 100644 --- a/pkg/cannon/cannon.go +++ b/pkg/cannon/cannon.go @@ -700,8 +700,6 @@ func (c *Cannon) startDeriverWhenReady(ctx context.Context, d deriver.EventDeriv continue } - slot := c.beacon.Node().Wallclock().Slots().Current() - fork, err := spec.ForkEpochs.GetByName(d.ActivationFork()) if err != nil { c.log.WithError(err).Errorf("unknown activation fork: %s", d.ActivationFork()) @@ -713,10 +711,10 @@ func (c *Cannon) startDeriverWhenReady(ctx context.Context, d deriver.EventDeriv continue } - if !fork.Active(phase0.Slot(slot.Number()), spec.SlotsPerEpoch) { - // Sleep until the next epochl and then retrty - currentEpoch := c.beacon.Metadata().Wallclock().Epochs().Current() + // Sleep until the next epochl and then retrty + currentEpoch := c.beacon.Metadata().Wallclock().Epochs().Current() + if !fork.Active(phase0.Epoch(currentEpoch.Number())) { activationForkEpoch := c.beacon.Node().Wallclock().Epochs().FromNumber(uint64(fork.Epoch)) sleepFor := time.Until(activationForkEpoch.TimeWindow().End())