Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Valid

rounding error leaves dust in the contract

Summary

When the ETH_REWARD is set to certain values (such as 101 ether and 1001 ether) and when the ether is divided among the FOR voters dust remains in the contract. Suspect that this has to do with how the rewardPerVoter is calculated.

Vulnerability Details

To recreate this, simply manually change the ETH_REWARD in the test file to 101 ether. And test: testVotePassesAndMoneyIsSent().
Can add an emit log_uint(address(booth).balance); to the test function to see the remaining dust.

Suspect that the cause is found on on line 207 of VoterBooth.sol: rewardPerVoter = Math.mulDiv(totalRewards, 1, totalVotes, Math.Rounding.Ceil);

Impact

Under certain circumstances will lead to dust remaining in the contract.

Tools Used

Manual and Fuzzing.

Recommendations

Consider a different rounding method.

Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

VotingBooth._distributeRewards(): Dust amount can still remain in contract

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.