In the PuppyRaffle contract, the functions _isActivePlayer and getActivePlayerIndex use unbounded loops to iterate over the entire players array. Since the array length is continuously increased with new players being added and never reset or reduced in size, these loops become increasingly inefficient over time:
Gas Limit Exceeded: As the players array continually grows, the gas required for these functions to execute increases. Eventually, this may lead to exceeding the block gas limit, causing transaction failures.
Denial of Service (DoS): The ever-increasing cost of these functions can render the contract unusable over time, as even basic operations involving player lookup become prohibitively expensive.
Scalability and Usability Issues: The lack of scalability due to the unbounded loops and growing array size significantly impacts the contract's performance and usability, deterring users from interacting with it.
Implement Array Size Management: Reset or limit the size of the players array to prevent unbounded growth. This could involve resetting the array after each raffle draw or implementing a maximum player limit.
Opt for Efficient Data Structures: Utilize mappings or other more efficient data structures for tracking players, which can reduce or eliminate the need for looping through large arrays.
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.