Skip to content

Commit

Permalink
GetValidatorPerformance only return its status info if the validator …
Browse files Browse the repository at this point in the history
…is active (#5568)

* Task #1
* First commit
* Fix
* Clean
* Clean
* Clean
* Merge branch 'master' into only-active-validators-log
* Fix
* Clean
* Fix
* Fix
* Fix
* Fix
* Merge branch 'master' into only-active-validators-log
  • Loading branch information
ShawkiS authored Apr 23, 2020
1 parent 2f21249 commit 49ca075
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion beacon-chain/rpc/beacon/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,9 @@ func (bs *Server) GetValidatorPerformance(

headState, err := bs.HeadFetcher.HeadState(ctx)
if err != nil {
return nil, status.Error(codes.Internal, "Could not get head state")
return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err)
}

// Convert the list of validator public keys to list of validator indices.
// Also track missing validators using public keys.
for _, key := range req.PublicKeys {
Expand All @@ -815,6 +816,14 @@ func (bs *Server) GetValidatorPerformance(
missingValidators = append(missingValidators, key)
continue
}
val, err := headState.ValidatorAtIndex(idx)
if err != nil {
return nil, status.Errorf(codes.Internal, "could not get validator: %v", err)
}
currentEpoch := helpers.CurrentEpoch(headState)
if !helpers.IsActiveValidator(val, currentEpoch) {
continue
}
if idx >= uint64(len(validatorSummary)) {
// Not listed in validator summary yet; treat it as missing.
missingValidators = append(missingValidators, key)
Expand Down

0 comments on commit 49ca075

Please sign in to comment.