The enterRaffle function uses a nested loop structure to check for duplicate player entries. Each new player is compared against all existing players in the array, resulting in a computational complexity of (O(n^2)), where (n) is the number of players:
This inefficiency is further amplified by the way the players array is reset in the contract. Instead of truly deleting the array, the contract uses delete players;, which only resets the array elements to their default values but does not clear the array's length. This mechanism leads to an ever-growing array size, even though the actual active elements are reset:
Heightened Risk of DoS Attacks: The combination of inefficient duplicate checks and the improper reset method of the array significantly increases the risk of DoS attacks. An attacker can exploit these vulnerabilities to make the enterRaffle function practically unusable due to the high gas cost, effectively preventing legitimate participation.
Excessive Gas Costs: The quadratic complexity of the duplicate check, combined with an ever-growing array size, leads to prohibitively high gas costs, especially for large player arrays.
Scalability Concerns: The current implementation presents serious scalability issues, limiting the practical use of the contract for larger raffles and diminishing user experience due to potential transaction failures.
Implement Efficient Duplicate Checking: Use a mapping to keep track of whether an address has already entered the raffle, reducing the complexity of checking for duplicates to (O(1)) for each entry.
Proper Array Management: Modify the method of resetting the players array to actually clear its length, or consider alternative data structures for managing player entries.
Participant Entry Limits: Set a cap on the number of participants per raffle to control the size of the player array.
Batch Processing and Gas Optimization: If expecting a high volume of participants, consider batch processing entries and optimize the contract for gas efficiency.
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.