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

Fix denominator constraint #256

Merged
merged 3 commits into from
Jul 9, 2018
Merged

Fix denominator constraint #256

merged 3 commits into from
Jul 9, 2018

Conversation

lazovicff
Copy link
Contributor

@lazovicff lazovicff commented Jul 1, 2018

Fixed a bug where user was able to pass denominator smaller than the correct value, therefore maximizing his reward and draining reward pot.

@lazovicff lazovicff self-assigned this Jul 2, 2018
@lazovicff lazovicff changed the title Fix/denominator constraint Fix denominator constraint Jul 2, 2018
@elenadimitrova elenadimitrova requested a review from area July 3, 2018 08:54
Copy link
Member

@area area left a comment

Choose a reason for hiding this comment

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

Only a few niggles, otherwise fine as far as I can see. Great job again on realising this needed doing in the first place, though.

"colony-reward-payout-invalid-parametar-numerator",
"colony-reward-payout-invalid-parametar-denominator"
"colony-reward-payout-invalid-parametar-denominator",
Copy link
Member

Choose a reason for hiding this comment

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

The word is 'parameter' 😄

@@ -313,7 +313,7 @@ contract("All", accounts => {
});

it("when working with reward payouts", async () => {
const totalReputation = toBN(350 * 1e18);
const totalReputation = toBN(300 * 1e18);
Copy link
Member

Choose a reason for hiding this comment

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

You've changed this to be accurate, but I don't think this variable is used anywhere in the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are passing it to claimRewardPayout

@@ -253,5 +253,9 @@ export function bnSqrt(bn) {
.add(a)
.div(web3Utils.toBN(2));
}
// Do we need while loop? Not sure how precise the formula above is
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe the loop is needed (though obviously the addition is). I believe you could also replace the addition with b = b.addn(1).

const blockTimestamp = await currentBlockTime();

const info = await colony.getRewardPayoutInfo(payoutId);
assert.equal(info[1].toString(), userTokens.toString());
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we're not checking info[0]? We could compare it to colonyNetwork.getReputationRootHash(), right? (Although without going through all the mining setup, I suppose that's going to just be 0x0, which might be the reason you've skipped it?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, i thought i can add it when we add proofs (which will require mining process), but i guess we can do it now

@area area merged commit b333ae5 into JoinColony:develop Jul 9, 2018
@elenadimitrova elenadimitrova deleted the fix/denominator-constraint branch July 9, 2018 14:49
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.

3 participants