reward calculation error in VotingBooth smart contract caused by a Denomination Error
In the VotingBooth::_distributeRewards function, if the proposal passed, the rewardPerVoter calculation employed an invalid denominator, specifically using totalVotes to distribute rewards among the For voters. This resulted in unequal distribution, as the denominator considered users who voted Against the proposal as well. Consequently, this miscalculation has financial implications on both the smart contract and its users. The division of totalRewards by totalVotes caused the rewardPerVoter value to be inaccurately calculated.
Wrong distribution of rewards for the For Voters
funds get stuck forever in the smart contracts
Manual Review, Foundry.
Add the above function to VotingBoothTest.t.sol and run it with forge test --mt testIncorrectRewardCalculation -vvvvv
it is advised to correct the calculation logic in the VotingBooth::_distributeRewards function to use an appropriate denominator, ensuring that only relevant votes are considered in the rewardPerVoter calculation when proposal passed.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.