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

R4R: Cap(clip) reward to remaining coins in AllocateTokens #3726

Merged
merged 1 commit into from
Feb 27, 2019

Conversation

jaekwon
Copy link
Contributor

@jaekwon jaekwon commented Feb 25, 2019

Related to #3722

OUTSTANDING TODO: pull out #3722's test into its own test that would fail without these changes.

// 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)
Copy link
Contributor

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.

@alexanderbez
Copy link
Contributor

CI is failing and if we do decide to go with this approach, it should have a pending log entry.

@cwgoes
Copy link
Contributor

cwgoes commented Feb 25, 2019

Complementary fix with truncation: #3728

@codecov
Copy link

codecov bot commented Feb 25, 2019

Codecov Report

❗ No coverage uploaded for pull request base (develop@e78a6da). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff             @@
##             develop    #3726   +/-   ##
==========================================
  Coverage           ?   61.46%           
==========================================
  Files              ?      189           
  Lines              ?    14057           
  Branches           ?        0           
==========================================
  Hits               ?     8640           
  Misses             ?     4876           
  Partials           ?      541

@cwgoes cwgoes added this to the v0.33.0 (Launch) milestone Feb 25, 2019
@cwgoes cwgoes mentioned this pull request Feb 25, 2019
5 tasks
Copy link
Contributor

@cwgoes cwgoes left a 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

@alexanderbez
Copy link
Contributor

ACK pending PENDING.md

I thought we were going with #3728?

@cwgoes
Copy link
Contributor

cwgoes commented Feb 26, 2019

ACK pending PENDING.md

I thought we were going with #3728?

They're complementary, the additional defensive coding is fine I think.

@jackzampolin
Copy link
Member

This is failing tests and needs a rebase.

Copy link
Member

@jackzampolin jackzampolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@cwgoes cwgoes merged commit 7e08b62 into develop Feb 27, 2019
@cwgoes cwgoes deleted the jae/distr_allocation_bug branch February 27, 2019 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants