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

Update correlation penalty for EIP-7251 #14456

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

terencechain
Copy link
Member

This PR fixes an issue in the correlation penalty computation that caused a zero penalty for 32 ETH validators and a non-zero penalty for 2048 ETH validators under certain slashed balances, leading to an imbalance. The fix ensures penalties are computed per effective balance increment, preventing overflow and balancing penalties for different validator sizes.

Reference: ethereum/consensus-specs#3882

@terencechain terencechain added the Electra electra hardfork label Sep 18, 2024
@terencechain terencechain force-pushed the update-correlation-penalty branch 15 times, most recently from 6d89f55 to 9fb665c Compare September 25, 2024 19:01
@terencechain terencechain marked this pull request as ready for review September 25, 2024 19:01
@terencechain terencechain requested a review from a team as a code owner September 25, 2024 19:01
// Modified in Electra:EIP7251
var penaltyPerEffectiveBalanceIncrement uint64
if st.Version() == version.Electra {
penaltyPerEffectiveBalanceIncrement = minSlashing / (totalBalance / increment)
Copy link
Contributor

Choose a reason for hiding this comment

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

can (totalBalance / increment) ever be 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, I dont think it can

penaltyNumerator := val.EffectiveBalance() / increment * minSlashing
penalty := penaltyNumerator / totalBalance * increment
var penalty uint64
if st.Version() == version.Electra {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we do st.Version() >= version.Electra? might not change next hard fork


// Modified in Electra:EIP7251
var penaltyPerEffectiveBalanceIncrement uint64
if st.Version() == version.Electra {
Copy link
Contributor

Choose a reason for hiding this comment

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

The future me wants this :)

Suggested change
if st.Version() == version.Electra {
if st.Version() >= version.Electra {

@terencechain terencechain added this pull request to the merge queue Oct 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Electra electra hardfork
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants