From 72c71f6a81de2c5e80c14b0d8543f589555a1eaa Mon Sep 17 00:00:00 2001 From: Andrew Davis <1709934+Savid@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:47:12 +1000 Subject: [PATCH] fix(sentry): capture finalized checkpoint events --- pkg/sentry/sentry.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pkg/sentry/sentry.go b/pkg/sentry/sentry.go index 4760cb5c..9a3ff25b 100644 --- a/pkg/sentry/sentry.go +++ b/pkg/sentry/sentry.go @@ -329,6 +329,35 @@ func (s *Sentry) Start(ctx context.Context) error { return s.handleNewDecoratedEvent(ctx, decoratedEvent) }) + s.beacon.Node().OnFinalizedCheckpoint(ctx, func(ctx context.Context, finalizedCheckpoint *eth2v1.FinalizedCheckpointEvent) error { + s.log.WithField("finalized_checkpoint", finalizedCheckpoint).Debug("Finalized checkpoint") + + now := time.Now().Add(s.clockDrift) + + meta, err := s.createNewClientMeta(ctx) + if err != nil { + return err + } + + event := v1.NewEventsFinalizedCheckpoint(s.log, finalizedCheckpoint, now, s.beacon, s.duplicateCache.BeaconETHV1EventsFinalizedCheckpoint, meta) + + ignore, err := event.ShouldIgnore(ctx) + if err != nil { + return err + } + + if ignore { + return nil + } + + decoratedEvent, err := event.Decorate(ctx) + if err != nil { + return err + } + + return s.handleNewDecoratedEvent(ctx, decoratedEvent) + }) + if err := s.startForkChoiceSchedule(ctx); err != nil { return err }