Description:
The initializeDeck() function in the TwentyOne contract uses a loop to populate a player's deck with all cards from a standard deck (1 to 52). This approach incurs significant gas costs because:
Storage writes (e.g., availableCards[player].push(i)) are among the most expensive operations in Solidity.
Each iteration of the loop performs a write operation, which is executed 52 times, leading to excessive gas consumption.
Impact:
Increased Gas Costs for Users:
Players or game operators will pay significantly more gas every time the deck is initialized, reducing user satisfaction and scalability.
Proof of Concept:
Recommended Mitigation:
Consider using immutable deck variable instead of using list each initializations :
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.