The LikeRegistry contract uses a mapping (matches) that stores arrays of addresses for each user’s matches. Repeated matches cause these arrays to grow indefinitely, increasing gas costs for the getMatches function and risking transaction failures due to block gas limits. Over time, this makes the contract increasingly inefficient and potentially unusable.
Contract: LikeRegistry.sol
Mapping: matches[address] (stores address[])
Unbounded Array Growth:
Every time a mutual "like" occurs, both users’ addresses are appended to each other’s matches array.
There is no mechanism to limit the size of these arrays (e.g., removing old matches).
Gas Costs:
Reading large arrays via getMatches becomes prohibitively expensive as the array grows.
Transactions that interact with the array (e.g., iterating over matches) may exceed block gas limits.
Gas Inefficiency: The getMatches function’s gas cost scales linearly with the number of matches, making it expensive for long-term users.
Denial of Service (DoS): Applications or users calling getMatches may encounter out-of-gas errors for large arrays.
Storage Bloat: The contract’s storage usage grows indefinitely, increasing blockchain bloat.
Expected: The matches array should have a manageable size, and getMatches should remain gas-efficient.
Actual: The matches array grows linearly, and getMatches gas costs increase proportionally.
Replace the array with a mapping to track matches more efficiently:
Match Expiry: Automatically remove old matches after a certain period.
Event-Based Tracking: Emit events for matches and let off-chain systems track them (reduces on-chain storage).
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
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.