getUserMemorabiliaDetailed() wastes gas and iterates through non-existent collectionsDescription
The getUserMemorabiliaDetailed() function iterates through collection IDs starting from 1, but memorabilia collections actually start at ID 100 (nextCollectionId = 100). Collection IDs 1-3 are reserved for pass types (GENERAL_PASS, VIP_PASS, BACKSTAGE_PASS), and IDs 4-99 do not exist as collections.
This causes the function to unnecessarily iterate through 99 non-memorabilia collection IDs before reaching the actual memorabilia starting at ID 100.
Impact
Gas Waste: The function iterates through 99 non-existent collection IDs (1-99) on every call, performing unnecessary storage reads and operations
Inefficiency: For each of the 99 iterations, the function reads collections[cId].currentItemId which returns 0 for non-existent collections, skipping the inner loop but still consuming gas
Incorrect Logic: The function conflates pass IDs (1-3) with memorabilia collection IDs (≥100), violating the intended separation
While this is primarily a gas efficiency issue, it demonstrates a fundamental misunderstanding of the collection ID structure in the codebase.
Proof of Concept
Gas waste calculation:
If nextCollectionId = 105 (5 memorabilia collections created)
Function iterates 104 times (1 to 104)
Only 5 iterations (100-104) are meaningful
99 iterations (1-99) are wasted
Mitigation
Start the iteration from 100 to skip non-memorabilia IDs:
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.