Skip to content
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

Fix Attester Slashing Validation In Gossip #12295

Merged
merged 10 commits into from
Apr 17, 2023
Merged

Conversation

nisdas
Copy link
Member

@nisdas nisdas commented Apr 17, 2023

What type of PR is this?

Bug Fix

What does this PR do? Why is it needed?

Fixes a missing check for slashable validators in our gossip pipeline. This adds in the check and also adds in
a respective regression check for it.

Which issues(s) does this PR fix?

N.A

Other notes for review

@nisdas nisdas added Ready For Review A pull request ready for code review Networking P2P related items labels Apr 17, 2023
@nisdas nisdas requested a review from a team as a code owner April 17, 2023 13:46
@@ -50,7 +51,7 @@ func (s *Service) validateAttesterSlashing(ctx context.Context, pid peer.ID, msg
if err != nil {
return pubsub.ValidationIgnore, err
}
if err := blocks.VerifyAttesterSlashing(ctx, headState, slashing); err != nil {
if _, err := blocks.ProcessAttesterSlashing(ctx, headState, slashing, v.SlashValidator); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mutates a beacon state and slashes a validator in vain, since the function VerifyAttesterSlashing anyway is called in a few other places (like RPC methods) and in particular is called within ProcessAttesterSlashing I believe that the right thing to do would be to perform the extra check within VerifyAttesterSlashing and if performance is an issue, this function can be refactored to return the validators that need to be slashed in the state (so that ProcessAttesterSlashing can use them)

@@ -53,7 +57,20 @@ func (s *Service) validateAttesterSlashing(ctx context.Context, pid peer.ID, msg
if err := blocks.VerifyAttesterSlashing(ctx, headState, slashing); err != nil {
return pubsub.ValidationReject, err
}

slashedVals := blocks.SlashableAttesterIndices(slashing)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to move this up a little and check if slashedVals == nil then you can return the nil message error above and avoid the double check for nil

return pubsub.ValidationIgnore, err
}
if helpers.IsSlashableValidator(val.ActivationEpoch(), val.WithdrawableEpoch(), val.Slashed(), slots.ToEpoch(headState.Slot())) {
isSlashable = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to break the loop here?

@prylabs-bulldozer prylabs-bulldozer bot merged commit e2386cf into develop Apr 17, 2023
@delete-merged-branch delete-merged-branch bot deleted the fixGossipChecks branch April 17, 2023 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Networking P2P related items Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants