-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
R4R: Cap(clip) reward to remaining coins in AllocateTokens #3726
Conversation
// ref https://github.com/cosmos/cosmos-sdk/issues/2525#issuecomment-430838701 | ||
powerFraction := sdk.NewDec(vote.Validator.Power).Quo(sdk.NewDec(totalPower)) | ||
reward := feesCollected.MulDec(voteMultiplier).MulDec(powerFraction) | ||
reward = reward.Cap(remaining) |
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.
Hmm is this the best way to fix? If this is necessary, it seems like our multiplication somewhere rounds up where it ought to always floor, so instead I wonder if we should change the multiplication (MulDec
maybe) to always floor, or add a version that does and use it here.
CI is failing and if we do decide to go with this approach, it should have a pending log entry. |
Complementary fix with truncation: #3728 |
Codecov Report
@@ Coverage Diff @@
## develop #3726 +/- ##
==========================================
Coverage ? 61.46%
==========================================
Files ? 189
Lines ? 14057
Branches ? 0
==========================================
Hits ? 8640
Misses ? 4876
Partials ? 541 |
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.
ACK pending PENDING.md
I thought we were going with #3728? |
They're complementary, the additional defensive coding is fine I think. |
This is failing tests and needs a rebase. |
0dd3a35
to
85e3a6a
Compare
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.
👍 LGTM
Related to #3722
OUTSTANDING TODO: pull out #3722's test into its own test that would fail without these changes.