From 49ca0751b6e37387b6df5a56d68980f93ccf377b Mon Sep 17 00:00:00 2001 From: Shawki Sukkar <57439827+ShawkiS@users.noreply.github.com> Date: Thu, 23 Apr 2020 09:11:13 +0300 Subject: [PATCH] GetValidatorPerformance only return its status info if the validator 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 --- beacon-chain/rpc/beacon/validators.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/beacon-chain/rpc/beacon/validators.go b/beacon-chain/rpc/beacon/validators.go index 6f3fb8093618..aaf763019c02 100644 --- a/beacon-chain/rpc/beacon/validators.go +++ b/beacon-chain/rpc/beacon/validators.go @@ -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 { @@ -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)