The castVote function in the Governance contract allows users to cast votes on proposals that have already been cancelled. This can lead to unnecessary gas costs for users who may not be aware that the proposal they are voting on is no longer valid.
In the castVote function, there is no check to prevent voting on proposals that have been cancelled. The relevant code snippet is as follows:
Users can incur gas costs when attempting to vote on proposals that have been cancelled, leading to a poor user experience and potential financial loss. This could also lead to confusion regarding the status of proposals and the voting process.
Manual code review
To mitigate this issue, a check should be added to the castVote function to ensure that the proposal has not been cancelled before allowing a vote to be cast. The updated code snippet could look like this:
This check should be added after verifying that the proposal exists and before checking the voting time constraints.
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.