Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Gas optimization in the double loop in the enterRaffle function

Reference

L86 to L90 of PuppyRaffle.sol

for (uint256 i = 0; i < players.length - 1; i++) { for (uint256 j = i + 1; j < players.length; j++) { require(players[i] != players[j], "PuppyRaffle: Duplicate player"); } }

Summary

The nested raffle in the reference above would cause a considerable amount of gas, especially when the array gets very long.

Recommendation

Consider using the if operation together with mappings to check for this duplicate.

Vulnerability Details

Impact

Tools Used

Manual Review

Updates

Lead Judging Commences

Hamiltonite Lead Judge about 2 years ago
Submission Judgement Published
Invalidated
Reason: Gas optimizations

Support

FAQs

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

Give us feedback!