diff --git a/pkg/exporter/consensus/beacon/state/fork_epoch.go b/pkg/exporter/consensus/beacon/state/fork_epoch.go index 7220715..d9160de 100644 --- a/pkg/exporter/consensus/beacon/state/fork_epoch.go +++ b/pkg/exporter/consensus/beacon/state/fork_epoch.go @@ -14,7 +14,7 @@ type ForkEpoch struct { // Active returns true if the fork is active at the given slot. func (f *ForkEpoch) Active(slot, slotsPerEpoch phase0.Slot) bool { - return phase0.Epoch(int(slot)/int(slotsPerEpoch)) > f.Epoch + return phase0.Epoch(int(slot)/int(slotsPerEpoch)) >= f.Epoch } // ForkEpochs is a list of forks that activate at specific epochs. diff --git a/pkg/exporter/consensus/jobs/beacon.go b/pkg/exporter/consensus/jobs/beacon.go index fa38b77..6ff94d2 100644 --- a/pkg/exporter/consensus/jobs/beacon.go +++ b/pkg/exporter/consensus/jobs/beacon.go @@ -210,14 +210,14 @@ func (b *Beacon) Start(ctx context.Context) error { select { case <-ctx.Done(): return ctx.Err() - case <-time.After(time.Second * 5): + case <-time.After(time.Second * 60): b.tick(ctx) } } } func (b *Beacon) tick(ctx context.Context) { - + b.updateFinalizedCheckpoint(ctx) } func (b *Beacon) setupSubscriptions(ctx context.Context) error { @@ -233,7 +233,14 @@ func (b *Beacon) setupSubscriptions(ctx context.Context) error { return err } - if _, err := b.beaconNode.OnFinalizedCheckpoint(ctx, b.handleFinalizedCheckpointEvent); err != nil { + if _, err := b.beaconNode.OnFinalizedCheckpoint(ctx, func(ctx context.Context, ev *v1.FinalizedCheckpointEvent) error { + // Sleep for 3 seconds to allow the beacon node to process the finalized checkpoint. + time.Sleep(3 * time.Second) + + b.updateFinalizedCheckpoint(ctx) + + return nil + }); err != nil { return err }