Skip to content

Commit

Permalink
scheduler: check for activation epoch (#2727)
Browse files Browse the repository at this point in the history
Adds a check for activation epoch to filter active validators before resolving duties.

category: bug
ticket: #2721
  • Loading branch information
dB2510 authored and xenowits committed Dec 12, 2023
1 parent 3f93927 commit 7812ec5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func delaySlotOffset(ctx context.Context, slot core.Slot, duty core.Duty, delayF

// resolveDuties resolves the duties for the slot's epoch, caching the results.
func (s *Scheduler) resolveDuties(ctx context.Context, slot core.Slot) error {
vals, err := resolveActiveValidators(ctx, s.eth2Cl, s.pubkeys, s.metricSubmitter)
vals, err := resolveActiveValidators(ctx, s.eth2Cl, s.pubkeys, s.metricSubmitter, slot.Epoch())
if err != nil {
return err
}
Expand Down Expand Up @@ -624,7 +624,7 @@ func newSlotTicker(ctx context.Context, eth2Cl eth2wrap.Client, clock clockwork.

// resolveActiveValidators returns the active validators (including their validator index) for the slot.
func resolveActiveValidators(ctx context.Context, eth2Cl eth2wrap.Client,
pubkeys []core.PubKey, submitter metricSubmitter,
pubkeys []core.PubKey, submitter metricSubmitter, epoch uint64,
) (validators, error) {
var e2pks []eth2p0.BLSPubKey
for _, pubkey := range pubkeys {
Expand Down Expand Up @@ -659,7 +659,9 @@ func resolveActiveValidators(ctx context.Context, eth2Cl eth2wrap.Client,

submitter(pubkey, val.Balance, val.Status.String())

if !val.Status.IsActive() {
// Check for active validators for the given epoch.
// The activation epoch needs to be checked in cases where this function is called before the epoch starts.
if !val.Status.IsActive() && val.Validator.ActivationEpoch != eth2p0.Epoch(epoch) {
continue
}

Expand Down

0 comments on commit 7812ec5

Please sign in to comment.