'enterRaffle' function might fail
'enterRaffle' function might fail if the list of players is too big
The smart contract will not allow new players to enter the raffle and the gas costs will increase for every new player because we use two 'for' loops to check for duplicates.
Manual Review
Modify the 'enterRaffle' function like this
uint256 private round; // We increase it after we choose the winner
mapping(address -> mapping(uint256 => bool)) public isPlayerInRound;
mapping (uint256 => uint256) public totalPlayersInRound;
function enterRaffle(address[] memory newPlayers) public payable {
require(msg.value == entranceFee * newPlayers.length, "PuppyRaffle: Must send enough to enter raffle");
for (uint256 i = 0; i < newPlayers.length; {
if(isPlayerInRound[newPlayers[i]][round] || newPlayers[i] == address(0)) revert("PuppyRaffle: Duplicate player");
isPlayerInRound[newPlayers[i]][round] = true;
unchecked {
++totalPlayersInRound[round];
++i;
}
}
emit RaffleEnter(newPlayers);
}
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.