-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
feat: update correlation penalty computation #7071
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #7071 +/- ##
============================================
- Coverage 50.82% 48.93% -1.90%
============================================
Files 597 597
Lines 39789 39809 +20
Branches 2059 2055 -4
============================================
- Hits 20224 19481 -743
- Misses 19565 20287 +722
- Partials 0 41 +41 |
Performance Report✔️ no performance regression detected Full benchmark results
|
spec tests failing |
New slashing penalty calculation preserves every digit in gwei whereas old calculation is rounded to the nearest 1ETH. So this change doesn't retrofit pre-electra forks and will need to wait for next release of spec test in order to test the correctness of this PR. Will convert to draft for now |
2eb3e38
to
e07ed10
Compare
const penalties: number[] = []; | ||
|
||
const penaltiesByEffectiveBalanceIncrement = new Map<number, number>(); | ||
for (const index of cache.indicesToSlash) { | ||
const effectiveBalanceIncrement = effectiveBalanceIncrements[index]; | ||
let penalty = penaltiesByEffectiveBalanceIncrement.get(effectiveBalanceIncrement); | ||
if (penalty === undefined) { | ||
const penaltyNumeratorByIncrement = effectiveBalanceIncrement * adjustedTotalSlashingBalanceByIncrement; | ||
penalty = Math.floor(penaltyNumeratorByIncrement / totalBalanceByIncrement) * increment; | ||
if (fork < ForkSeq.electra) { |
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.
any reason why the check is reversed here?
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.
any reason why the check is reversed here?
No particular reason. I don't think there is a convention for fork check to be >= ForkSeq.electra
vs < ForkSeq.electra
.
Several places use <
see:
if (fork < ForkSeq.electra) { |
if (fork < ForkSeq.electra) { |
if (fork < ForkSeq.electra) { |
* Update slashing calculation to be more aligned with spec style * Update calculation * Lint * Fix rounding issue * Update calculation * Enable slashing spec test * lint
🎉 This PR is included in v1.23.0 🎉 |
ethereum/consensus-specs#3882 proposes to reformat slashing penalty calculation due to overflow issue.
Lodestar does not have such issue as we've already been tracking everything in increments.
This PR restyle the calculation to be more in line with the spec.
Although spec change supposedly will be live for devnet-4, we can make the code change now for devnet-3 since no functional difference.