-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Account for Rounding Errors in Distribution Calculations #4094
Conversation
Codecov Report
@@ Coverage Diff @@
## release/v0.34.0 #4094 +/- ##
===================================================
- Coverage 60.02% 59.99% -0.04%
===================================================
Files 212 212
Lines 15121 15129 +8
===================================================
Hits 9077 9077
- Misses 5421 5429 +8
Partials 623 623 |
Passes |
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.
Sim 2 passes for me on this branch
All seeds passed! |
currentStake := val.TokensFromShares(del.GetShares()) | ||
if stake.GT(currentStake) { | ||
panic(fmt.Sprintf("calculated final stake for delegator %s greater than current stake: %s, %s", | ||
del.GetDelegatorAddr(), stake, currentStake)) | ||
// account for rounding errors due to stake being multiplied by slash fractions |
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.
Why would these rounding errors lead to stake
being too high, if we round up the slash fractions?
updatedFraction := sdk.OneDec().Sub(currentMultiplicand.Mul(newMultiplicand)) | ||
|
||
// using MulTruncate here conservatively increases the slashing amount | ||
updatedFraction := sdk.OneDec().Sub(currentMultiplicand.MulTruncate(newMultiplicand)) |
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.
++, this looks fine to me - this should lead to more slashing, see comment above
closes: #4088
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
Wrote tests
Updated relevant documentation (
docs/
)Added a relevant changelog entry:
sdkch add [section] [stanza] [message]
rereviewed
Files changed
in the github PR explorerFor Admin Use: