diff --git a/beacon-chain/rpc/validator/assignments.go b/beacon-chain/rpc/validator/assignments.go index b941b84277b8..88a7667688ec 100644 --- a/beacon-chain/rpc/validator/assignments.go +++ b/beacon-chain/rpc/validator/assignments.go @@ -57,25 +57,30 @@ func (vs *Server) GetDuties(ctx context.Context, req *ethpb.DutiesRequest) (*eth } idx, ok := s.ValidatorIndexByPubkey(bytesutil.ToBytes48(pubKey)) - if !ok { - // If the validator isn't in the beacon state, assume it is not active. - continue - } - ca, ok := committeeAssignments[idx] - if ok { - assignment.Committee = ca.Committee - assignment.Status = vs.assignmentStatus(idx, s) - assignment.ValidatorIndex = idx - assignment.PublicKey = pubKey - assignment.AttesterSlot = ca.AttesterSlot - assignment.ProposerSlots = proposerIndexToSlots[idx] - assignment.CommitteeIndex = ca.CommitteeIndex - committeeIDs = append(committeeIDs, ca.CommitteeIndex) - } - // Save the next epoch assignments. - ca, ok = nextCommitteeAssignments[idx] if ok { - nextCommitteeIDs = append(nextCommitteeIDs, ca.CommitteeIndex) + ca, ok := committeeAssignments[idx] + if ok { + assignment.Committee = ca.Committee + assignment.Status = vs.assignmentStatus(idx, s) + assignment.ValidatorIndex = idx + assignment.PublicKey = pubKey + assignment.AttesterSlot = ca.AttesterSlot + assignment.ProposerSlots = proposerIndexToSlots[idx] + assignment.CommitteeIndex = ca.CommitteeIndex + committeeIDs = append(committeeIDs, ca.CommitteeIndex) + } + // Save the next epoch assignments. + ca, ok = nextCommitteeAssignments[idx] + if ok { + nextCommitteeIDs = append(nextCommitteeIDs, ca.CommitteeIndex) + } + + } else { + vStatus, _, err := vs.retrieveStatusFromState(ctx, pubKey, s) + if err != nil { + return nil, status.Errorf(codes.Internal, "Could not retrieve status from state: %v", err) + } + assignment.Status = vStatus } validatorAssignments = append(validatorAssignments, assignment) } diff --git a/validator/client/validator.go b/validator/client/validator.go index bb31b08af46b..53921b18ff9d 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -295,15 +295,15 @@ func (v *validator) UpdateDuties(ctx context.Context, slot uint64) error { alreadySubscribed := make(map[[64]byte]bool) for _, duty := range v.duties.Duties { - if duty.Status != ethpb.ValidatorStatus_ACTIVE { - continue - } - 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,