Beginner FriendlyFoundryGameFi
100 EXP
View results
Submission Details
Severity: medium
Invalid

In `MartenitsaVoting` contract same `users` cannot participate in voting for next time `martenitsa` tokens listed on the marketplace.

Description: The contract allows the users to participate in voting for martenitsa tokens listed on the marketplace (only producers can add their MartenitsaTokens for voting). After the voting period ends, the owner can announce the winner based on the number of votes, and the winner receives a HealthToken as a reward. However, In MartenitsaVoting::announceWinner the function does not delete the hasVoted mapping users because of that the previous voting participant remains always saved in the hasVoted mapping that's why next time when the voting for martenitsa tokens start the previous users cannot participate in the this voting listed on the marketplace.

Impact: The previous users can not participate in the future voting tokens listed on the marketplace because this protocol is no longer usable.

Proof Of Concept: Paste this test to your test folder and run the test.

function test_sameUserCannotParticipateInNextVoting() public {
// First voting is started for bracelet
vm.startPrank(chasy);
martenitsaToken.createMartenitsa("bracelet");
marketplace.listMartenitsaForSale(0, 1 wei);
vm.stopPrank();
vm.prank(bob);
voting.voteForMartenitsa(0);
vm.warp(block.timestamp + 1 days + 1);
vm.recordLogs();
voting.announceWinner();
Vm.Log[] memory entries = vm.getRecordedLogs();
address winner = address(uint160(uint256(entries[0].topics[2])));
assert(winner == chasy);
//Second voting is started
vm.warp(block.timestamp);
voting.startVoting();
vm.startPrank(jack);
martenitsaToken.createMartenitsa("bracelet");
marketplace.listMartenitsaForSale(1, 1 wei);
vm.stopPrank();
// previous voting user bob not able to vote in this time voting
vm.prank(bob);
vm.expectRevert("You have already voted");
voting.voteForMartenitsa(1);
vm.warp(block.timestamp + 1 days + 1);
vm.recordLogs();
voting.announceWinner();
}

Recommendation: Delete all the participants from the hasVoted mapping so that next time same user can participate in voting for martenitsa tokens listed on the marketplace.

Updates

Lead Judging Commences

bube Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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