PuppyRaffle::enterRaffle, wasting gas on reverted transactionsDescription: PuppyRaffle::enterRaffle pushes every address in newPlayers into the players storage array before verifying that no duplicates exist. If a duplicate is found, the transaction reverts and all state changes are rolled back, but the gas spent on those writes is not refunded to the caller. Each players.push() on a fresh storage slot costs gas, so a call carrying a duplicate near the end of a large array pays for every preceding write before the check ever runs.
Impact: Callers submitting an array containing a duplicate pay for storage writes that are discarded. With 50 new players and a duplicate in the last position, unnecessary gas is consumed before the revert. The contract itself is not harmed, but the cost falls entirely on the user.
Recommended Mitigation: Validate before writing, so that a rejected call reverts before any storage is touched.
Note: the rewritten check covers both cases the original relied on: duplicates between the new entries and the existing players, and duplicates within newPlayers itself.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.