The recordVote function in the veRAACToken.sol contract updates the _hasVotedOnProposal[voter][proposalId] state variable before confirming that the getVotingPower(voter) operation succeeds. This could lead to state inconsistencies if getVotingPower(voter) reverts, as the voter would be marked as having voted even though the vote was not successfully recorded.
The recordVote function sets the _hasVotedOnProposal[voter][proposalId] flag to true before calling getVotingPower(voter). If getVotingPower(voter) reverts (e.g., due to an internal error or unexpected state), the voter will be marked as having voted, even though the vote was not successfully recorded. This could lead to the following issues:
State Inconsistency: The _hasVotedOnProposal flag will be set to true even if the vote was not recorded, preventing the voter from retrying the vote.
Gas Wastage: Gas spent on updating the _hasVotedOnProposal flag will be wasted if getVotingPower(voter) reverts.
User Experience: Voters may be confused if they are marked as having voted but their vote was not recorded, leading to frustration or mistrust in the system.
Manual Review
Update the recordVote function to set the _hasVotedOnProposal[voter][proposalId] flag after confirming that getVotingPower(voter) succeeds. This ensures that the state is only updated if the vote is successfully recorded.
Here is the corrected implementation:
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.