Skip to content

Commit

Permalink
Undo validator client changes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKiwi committed Apr 19, 2020
1 parent e402645 commit 4385181
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions validator/client/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,6 @@ func (v *validator) UpdateDuties(ctx context.Context, slot uint64) error {
alreadySubscribed := make(map[[64]byte]bool)

for _, duty := range v.duties.Duties {
if v.emitAccountMetrics {
fmtKey := fmt.Sprintf("%#x", duty.PublicKey[:])
validatorStatusesGaugeVec.WithLabelValues(fmtKey).Set(float64(duty.Status))
}

if duty.Status != ethpb.ValidatorStatus_ACTIVE {
continue
}

lFields := logrus.Fields{
"pubKey": fmt.Sprintf("%#x", bytesutil.Trunc(duty.PublicKey)),
"validatorIndex": duty.ValidatorIndex,
Expand All @@ -312,30 +303,37 @@ func (v *validator) UpdateDuties(ctx context.Context, slot uint64) error {
"status": duty.Status,
}

attesterSlot := duty.AttesterSlot
committeeIndex := duty.CommitteeIndex

if len(duty.ProposerSlots) > 0 {
lFields["proposerSlots"] = duty.ProposerSlots
if v.emitAccountMetrics {
fmtKey := fmt.Sprintf("%#x", duty.PublicKey[:])
validatorStatusesGaugeVec.WithLabelValues(fmtKey).Set(float64(duty.Status))
}
lFields["attesterSlot"] = attesterSlot

alreadySubscribedKey := validatorSubscribeKey(attesterSlot, committeeIndex)
if _, ok := alreadySubscribed[alreadySubscribedKey]; ok {
continue
}
if duty.Status == ethpb.ValidatorStatus_ACTIVE {
attesterSlot := duty.AttesterSlot
committeeIndex := duty.CommitteeIndex

aggregator, err := v.isAggregator(ctx, duty.Committee, attesterSlot, bytesutil.ToBytes48(duty.PublicKey))
if err != nil {
return errors.Wrap(err, "could not check if a validator is an aggregator")
}
if aggregator {
alreadySubscribed[alreadySubscribedKey] = true
if len(duty.ProposerSlots) > 0 {
lFields["proposerSlots"] = duty.ProposerSlots
}
lFields["attesterSlot"] = attesterSlot

alreadySubscribedKey := validatorSubscribeKey(attesterSlot, committeeIndex)
if _, ok := alreadySubscribed[alreadySubscribedKey]; ok {
continue
}

aggregator, err := v.isAggregator(ctx, duty.Committee, attesterSlot, bytesutil.ToBytes48(duty.PublicKey))
if err != nil {
return errors.Wrap(err, "could not check if a validator is an aggregator")
}
if aggregator {
alreadySubscribed[alreadySubscribedKey] = true
}
subscribeSlots = append(subscribeSlots, attesterSlot)
subscribeCommitteeIDs = append(subscribeCommitteeIDs, committeeIndex)
subscribeIsAggregator = append(subscribeIsAggregator, aggregator)
log.WithFields(lFields).Info("New assignment")
}
subscribeSlots = append(subscribeSlots, attesterSlot)
subscribeCommitteeIDs = append(subscribeCommitteeIDs, committeeIndex)
subscribeIsAggregator = append(subscribeIsAggregator, aggregator)
log.WithFields(lFields).Info("New assignment")
}

// Notify beacon node to subscribe to the attester and aggregator subnets for the next epoch.
Expand Down

0 comments on commit 4385181

Please sign in to comment.