-
Notifications
You must be signed in to change notification settings - Fork 996
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: Update correlation penalty computation #3882
Conversation
Lgtm! Besides fixing the overflow and the issue of penalties not being uniform between 32 and 2048 validators (and anything in between), I think it's quite nice that it makes the penalty computation more precise, resulting in penalties being actually linear in the slashed amount rather than a step function. About this, one note to other reviewers is that penalties are now actually in Gwei, rather than increasing in 1 ETH increments. @mkalinin Maybe you could link the notebook? |
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.
looks great!
AFAICT this is mathematically equivalent to the bellatrix spec if we are working over say R (real numbers)
and the issue arises due to working over the integers (both the issues with actual penalty amounts at the extremes and also the overflow)
this PR seems to handle it well
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.
the change looks good to me! lodestar tracks everything in increment value so not likely to face the overflow issue just fyi
Fixes an issue in the correlation penalty computation that under certain total slashed balances (
sum(state.slashings)
) lead to zero penalty for 32 ETH validators and non-zero penalty for 2048 ETH validators, and as a result imbalance between the penalty for 64 x 32 ETH (= 0) and 1 x 2048 ETH (> 0) validators. It also fixes potential overflow in the same computation.Many thanks to Pavel for finding the issue.
Many thanks to @fradamt for co-authoring the fix.
Problem
If validator effective_balance = 2048 ETH and > 30.024M ETH is slashed, the overflow can occur in the first line of the following code :
The cause of the imbalance problem is in the integer division in the second line of the above code.
Whenever
validator.effective_balance // increment * adjusted_total_slashing_balance < total_balance
the penalty would be zero. Let us use real numbers for effective balance to highlight the discrepancy:Obviously, for 32 ETH validator to experience non-zero penalty the
adjusted_total_slashing_balance
value should be 64 times higher than in the 2048 ETH case. Which is also illustrated by the following plot:Fix
The idea of the fix is to compute penalty per EB increment in a way that never overflows and then multiply it by a number of increments to alleviate the imbalance between 64 x 32 ETH and 1 x 2048 ETH validators:
Analysis
Notebook with more details can be found here.
The fix has the following effects: