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

eip-7251: Updated slash_validator #13976

Merged
merged 1 commit into from
May 9, 2024
Merged

Conversation

prestonvanloon
Copy link
Member

What type of PR is this?

Feature

What does this PR do? Why is it needed?

This PR comes with some minor refactoring.

  • tests in beacon-chain/core/validators are blackbox tests
  • instead of requiring switch statements from the caller, the correct parameters are derived from within slash_validator using the state version.

Part of #13903

Which issues(s) does this PR fix?

Tracking @ #13849

Other notes for review

https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/electra/beacon-chain.md#updated-slash_validator

return nil, errors.Wrap(err, "could not get slashing parameters per version")
}

slashingPenalty := validator.EffectiveBalance / slashingQuotient
Copy link
Contributor

Choose a reason for hiding this comment

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

safe math here? just to be careful

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 64dcaa8 for all divisions in this method

Tests for updated slash_validator
)

// SlashingParamsPerVersion returns the slashing parameters for the given state version.
func SlashingParamsPerVersion(v int) (slashingQuotient, proposerRewardQuotient, whistleblowerRewardQuotient uint64, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

It could be dangerous if someone messes up the order of the return variables. However, there are more dangerous things out there...

@prestonvanloon prestonvanloon added this pull request to the merge queue May 9, 2024
Merged via the queue into develop with commit f3dd75a May 9, 2024
17 checks passed
@prestonvanloon prestonvanloon deleted the eip-7251-slash-validator branch May 9, 2024 21:02
ErnestK pushed a commit to ErnestK/prysm that referenced this pull request May 19, 2024
nisdas pushed a commit that referenced this pull request Jul 4, 2024
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants