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

enterRaffle function efficiency

Summary

Nested for loop on line 86 in PuppyRaffle.sol [inefficient code]

Vulnerability Details

enterRaffle function is currently using a nested for loop to check if the address is a duplicate. See below (line 85-91 in PuppyRaffle.sol):

    // Check for duplicates
    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");
        }
    }
    emit RaffleEnter(newPlayers);

Impact

ineffiency, unecessary gas cost.

Tools Used

Manual inspection

Recommendations

Use a mapping to see if an address is already a participant.

Updates

Lead Judging Commences

Hamiltonite Lead Judge almost 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.