The vote()
function logic is flawed. When the allowList
contains 3 different addresses, _distributeRewards() is called by submitting 1 true and 1 false vote. In a real-life scenario, it would be up to the third voter to decide whether or not the vote passes.
When there are 3 different voters, quorum is already reached when there are 2 submitted votes:
2 * 100 / allowListLength = 66.67 (which is >= 51).
This can be tested with this snippet:
s_votingComplete
is set to true, so further votes are impossible.
The function _distributeRewards()
is then called, returning the contract balance of 1 ether to the s_creator
. This happens because the totalVotesAgainst >= totalVotesFor
condition is met (1 vote for, 1 vote against). This behaviour is not expected when using the contract.
Foundry
This problem can be fixed by implementing an additional safety check on line 156, for example:
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.