The userToCountry mapping stores team names as strings, which is extremely gas-inefficient. Storing the uint256 country index instead would save ~15,000 gas per user on join and ~20,000 gas per withdrawal.
Normal behavior for efficient storage expects using the smallest data type that can represent the needed information. Since teams are already indexed 0-47, storing the index is sufficient.
The current implementation stores the entire team name string for each user, requiring expensive string storage operations and complex string comparison using keccak256 hashing during withdrawals.
Likelihood:
Every user calling joinEvent() incurs string storage cost
Every winner calling withdraw() incurs string comparison cost
With thousands of users, costs compound to millions of gas wasted
Impact:
Each user wastes ~15,000 extra gas joining event
Each winner wastes ~20,000 extra gas on withdrawal
Protocol becomes significantly more expensive than necessary
Poor user experience due to high transaction costs
Makes protocol less competitive vs alternatives
Limits adoption due to cost barriers
Estimated Gas Savings:
~15,000 gas per joinEvent() call
~20,000 gas per withdraw() call
With 1000 users: saves ~15,000,000 gas on joins + variable on withdrawals
Gas optimizations are invalid according to the CodeHawks documentation.
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.