The setCountry() function uses memory parameter type which copies the entire 48-element array into memory, wasting significant gas when a calldata reference would be sufficient.
Normal behavior for external functions that don't modify parameters expects using calldata to avoid unnecessary memory allocation and copying operations.
The current implementation copies the entire string array from calldata to memory even though the function only reads the values to copy them to storage. This wastes gas on the copy operation.
Likelihood:
Every call to setCountry() incurs this cost
Function is called at least once per tournament setup
May be called multiple times if teams need updating
Impact:
Wastes approximately 20,000-50,000 gas per call
Unnecessary cost for contract owner during setup
Makes contract deployment and configuration more expensive
Compounds with other gas inefficiencies
Additional optimization: Change public to external since this function is never called internally, saving additional gas on function selector matching.
Estimated Gas Savings: ~20,000-50,000 gas per setCountry() call
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.