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

Merged
merged 2 commits into from
Oct 16, 2024
Merged

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 from c059a20 to 5f54320 Compare September 18, 2024 01:38
@prestonvanloon prestonvanloon self-requested a review September 23, 2024 15:38
@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

@terencechain terencechain force-pushed the update-correlation-penalty branch from 9fb665c to 2ecf5cb Compare September 30, 2024 13:46
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 {

james-prysm
james-prysm previously approved these changes Oct 1, 2024
@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
@terencechain terencechain force-pushed the update-correlation-penalty branch from dccb780 to e541901 Compare October 16, 2024 20:57
@terencechain terencechain force-pushed the update-correlation-penalty branch from e541901 to b196f21 Compare October 16, 2024 20:57
@james-prysm james-prysm enabled auto-merge October 16, 2024 20:58
@james-prysm james-prysm added this pull request to the merge queue Oct 16, 2024
Merged via the queue into develop with commit ffc443b Oct 16, 2024
18 checks passed
@james-prysm james-prysm deleted the update-correlation-penalty branch October 16, 2024 22:10
@kasey kasey added the changelog/changed Changelog Section: Changed label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/changed Changelog Section: Changed Electra electra hardfork
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants