diff --git a/services/controller/standard/events.go b/services/controller/standard/events.go index 8f80974..fc3ca8d 100644 --- a/services/controller/standard/events.go +++ b/services/controller/standard/events.go @@ -207,9 +207,13 @@ func (s *Service) refreshSyncCommitteeDutiesForEpochPeriod(ctx context.Context, // Work out start and end epoch for the period. period := uint64(epoch) / s.epochsPerSyncCommitteePeriod firstEpoch := s.firstEpochOfSyncPeriod(period) - firstSlot := s.chainTimeService.FirstSlotOfEpoch(firstEpoch) + // If we are in the sync committee that starts at slot x we need to generate a message during slot x-1 + // for it to be included in slot x, hence -1. + firstSlot := s.chainTimeService.FirstSlotOfEpoch(firstEpoch) - 1 lastEpoch := s.firstEpochOfSyncPeriod(period+1) - 1 - lastSlot := s.chainTimeService.FirstSlotOfEpoch(lastEpoch+1) - 1 + // If we are in the sync committee that ends at slot x we do not generate a message during slot x-1 + // as it will never be included, hence -1. + lastSlot := s.chainTimeService.FirstSlotOfEpoch(lastEpoch+1) - 2 // First thing we do is cancel all scheduled sync committee message jobs. for slot := firstSlot; slot <= lastSlot; slot++ { diff --git a/services/controller/standard/synccommitteemessenger.go b/services/controller/standard/synccommitteemessenger.go index ade02a9..38dc6b7 100644 --- a/services/controller/standard/synccommitteemessenger.go +++ b/services/controller/standard/synccommitteemessenger.go @@ -40,9 +40,13 @@ func (s *Service) scheduleSyncCommitteeMessages(ctx context.Context, period := uint64(epoch) / s.epochsPerSyncCommitteePeriod firstEpoch := s.firstEpochOfSyncPeriod(period) - firstSlot := s.chainTimeService.FirstSlotOfEpoch(firstEpoch) + // If we are in the sync committee that starts at slot x we need to generate a message during slot x-1 + // for it to be included in slot x, hence -1. + firstSlot := s.chainTimeService.FirstSlotOfEpoch(firstEpoch) - 1 lastEpoch := s.firstEpochOfSyncPeriod(period+1) - 1 - lastSlot := s.chainTimeService.FirstSlotOfEpoch(lastEpoch+1) - 1 + // If we are in the sync committee that ends at slot x we do not generate a message during slot x-1 + // as it will never be included, hence -1. + lastSlot := s.chainTimeService.FirstSlotOfEpoch(lastEpoch+1) - 2 started := time.Now() log.Trace().Uint64("period", period).Uint64("first_epoch", uint64(firstEpoch)).Uint64("last_epoch", uint64(lastEpoch)).Msg("Scheduling sync committee messages")