diff --git a/pkg/sentry/ethereum/beacon.go b/pkg/sentry/ethereum/beacon.go index b0c5422e..8a5b744c 100644 --- a/pkg/sentry/ethereum/beacon.go +++ b/pkg/sentry/ethereum/beacon.go @@ -85,6 +85,20 @@ func (b *BeaconNode) checkForReadyPublish(ctx context.Context) error { return errors.Wrap(err, "metadata service is not ready") } + status := b.beacon.GetStatus(ctx) + if status == nil { + return errors.New("failed to get beacon node status") + } + + syncState := status.SyncState() + if syncState == nil { + return errors.New("missing beacon node status sync state") + } + + if syncState.IsSyncing { + return errors.New("beacon node is syncing") + } + for _, callback := range b.onReadyCallbacks { if err := callback(ctx); err != nil { b.log.WithError(err).Error("failed to run on ready callback") diff --git a/pkg/sentry/sentry.go b/pkg/sentry/sentry.go index 5bd751d9..d5bf97ad 100644 --- a/pkg/sentry/sentry.go +++ b/pkg/sentry/sentry.go @@ -203,6 +203,16 @@ func (s *Sentry) syncClockDrift(ctx context.Context) error { } func (s *Sentry) handleNewDecoratedEvent(ctx context.Context, event *xatu.DecoratedEvent) error { + status := s.beacon.Node().GetStatus(ctx) + if status == nil { + return nil + } + + syncState := status.SyncState() + if syncState == nil || syncState.IsSyncing { + return nil + } + for _, sink := range s.sinks { if err := sink.HandleNewDecoratedEvent(ctx, event); err != nil { s.log.WithError(err).WithField("sink", sink.Type()).Error("Failed to send event to sink")