Skip to content

Commit

Permalink
ignore not yet participating validators in duty execution
Browse files Browse the repository at this point in the history
  • Loading branch information
olegshmuelov committed Dec 2, 2024
1 parent f668abe commit ba06e7e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
17 changes: 17 additions & 0 deletions operator/duties/attester.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,23 @@ func (h *AttesterHandler) toGenesisSpecDuty(duty *eth2apiv1.AttesterDuty, role g

func (h *AttesterHandler) shouldExecute(duty *eth2apiv1.AttesterDuty) bool {
currentSlot := h.network.Beacon.EstimatedCurrentSlot()
currentEpoch := h.network.Beacon.EstimatedEpochAtSlot(currentSlot)

v, exists := h.validatorProvider.Validator(duty.PubKey[:])
if !exists {
h.logger.Warn("validator not found", fields.Validator(duty.PubKey[:]))
return false
}

if v.MinParticipationEpoch() > currentEpoch {
h.logger.Debug("validator not yet participating",
fields.Validator(duty.PubKey[:]),
zap.Uint64("min_participation_epoch", uint64(v.MinParticipationEpoch())),
zap.Uint64("current_epoch", uint64(currentEpoch)),
)
return false
}

// execute task if slot already began and not pass 1 epoch
var attestationPropagationSlotRange = phase0.Slot(h.network.Beacon.SlotsPerEpoch())
if currentSlot >= duty.Slot && currentSlot-duty.Slot <= attestationPropagationSlotRange {
Expand Down
1 change: 1 addition & 0 deletions operator/duties/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type ExecutionClient interface {
type ValidatorProvider interface {
ParticipatingValidators(epoch phase0.Epoch) []*types.SSVShare
SelfParticipatingValidators(epoch phase0.Epoch) []*types.SSVShare
Validator(pubKey []byte) (*types.SSVShare, bool)
}

// ValidatorController represents the component that controls validators via the scheduler
Expand Down
17 changes: 17 additions & 0 deletions operator/duties/sync_committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,23 @@ func (h *SyncCommitteeHandler) toSpecDuty(duty *eth2apiv1.SyncCommitteeDuty, slo

func (h *SyncCommitteeHandler) shouldExecute(duty *eth2apiv1.SyncCommitteeDuty, slot phase0.Slot) bool {
currentSlot := h.network.Beacon.EstimatedCurrentSlot()
currentEpoch := h.network.Beacon.EstimatedEpochAtSlot(currentSlot)

v, exists := h.validatorProvider.Validator(duty.PubKey[:])
if !exists {
h.logger.Warn("validator not found", fields.Validator(duty.PubKey[:]))
return false
}

if v.MinParticipationEpoch() > currentEpoch {
h.logger.Debug("validator not yet participating",
fields.Validator(duty.PubKey[:]),
zap.Uint64("min_participation_epoch", uint64(v.MinParticipationEpoch())),
zap.Uint64("current_epoch", uint64(currentEpoch)),
)
return false
}

// execute task if slot already began and not pass 1 slot
if currentSlot == slot {
return true
Expand Down
7 changes: 5 additions & 2 deletions protocol/v2/types/ssvshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ func (s *SSVShare) IsAttesting(epoch phase0.Epoch) bool {
}

func (s *SSVShare) IsParticipating(epoch phase0.Epoch) bool {
participating := s.minParticipationEpoch == 0 || s.minParticipationEpoch <= epoch
return !s.Liquidated && s.IsAttesting(epoch) && participating
return !s.Liquidated && s.IsAttesting(epoch)
}

func (s *SSVShare) SetFeeRecipient(feeRecipient bellatrix.ExecutionAddress) {
Expand Down Expand Up @@ -90,6 +89,10 @@ func (s *SSVShare) SetMinParticipationEpoch(epoch phase0.Epoch) {
s.minParticipationEpoch = epoch
}

func (s *SSVShare) MinParticipationEpoch() phase0.Epoch {
return s.minParticipationEpoch
}

func (s *SSVShare) OperatorIDs() []spectypes.OperatorID {
ids := make([]spectypes.OperatorID, len(s.Committee))
for i, v := range s.Committee {
Expand Down

0 comments on commit ba06e7e

Please sign in to comment.