New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GetValidatorPerformance only return its status info if the validator is active #5568
GetValidatorPerformance only return its status info if the validator is active #5568
Conversation
Please fix build
|
return nil, errors.Wrap(err, "could not get validator") | ||
} | ||
if !helpers.IsActiveValidator(val) { | ||
// If the validator isn't active, no need to get its performance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the comment here is necessary. It's pretty self explanatory imo
Please also add a description to the PR |
@prestonvanloon Okay will fix it, I saw two exapmples: one passing currentEpoch as What shall I pass in our current example? @terencechain okay will remove it |
if err != nil { | ||
return nil, status.Error(codes.Internal, "Could not get head state") | ||
} | ||
headState, err := bs.HeadFetcher.HeadState(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use gofmt
here the indentation is off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
val, err := headState.ValidatorAtIndex(idx) | ||
currentEpoch := helpers.CurrentEpoch(headState) | ||
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "could not get validator: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix the error here
could not get current epoch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, why that is happening I saw this code working in other places?
Is the way I am getting it wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok so your order of code here is vulnerable to errors here. if you look at
idx, ok := headState.ValidatorIndexByPubkey(pubkeyBytes)
you need to handle the case where the index doesn't exist.
so immediately after that you need to do:
if !ok {
missingValidators = append(missingValidators, key)
continue
}
Then doing this:
val, err := headState.ValidatorAtIndex(idx)
currentEpoch := helpers.CurrentEpoch(headState)
if err != nil {
is wrong you need to handle the error first
val, err := headState.ValidatorAtIndex(idx)
if err != nil {
return nil, status.Errorf(codes.Internal, "could not get validator: %v", err)
}
currentEpoch := helpers.CurrentEpoch(headState)
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, status.Errorf(codes.Internal, "could not get head state: %v", err) | |
return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err) |
This is a server error returned to our rpc clients, so it should be capitalized.
Codecov Report
@@ Coverage Diff @@
## master #5568 +/- ##
=======================================
Coverage 27.46% 27.46%
=======================================
Files 239 239
Lines 20771 20771
=======================================
Hits 5705 5705
Misses 14070 14070
Partials 996 996 |
Hi @ShawkiS would also recommend always adding a PR description and a good title that gives us enough context about why this is needed (if it solves an open issue, type |
Hey @rauljordan, okay will make sure to do that next time because it seems that I can't edit the description now, yeah that's better I changed the name. Does it seem that I can't set a label? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShawkiS Please add in a proper title with a PR description.
Resolves #5485
Description
Write why you are making the changes in this pull request:
The problem here is that the user has 5 validator keys. Only 2 of these are active. The feature request is to only log "previous epoch voting summary" for activated validators as this log is not helpful for pending ones. A pending validator had no duties in the last epoch and there is really nothing to report on their performance.
Write a summary of the changes you are making:
This PR changes one file that is
rpc/beacon/validators.go
and it adds a condition to the GetValidatorPerformance to make sure it only returns its status info if the validator is active