BriVault

First Flight #52
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: high
Invalid

Static array limits flexibility and increases gas in team setup

Root + Impact

Static array (string[48]) limits flexibility and causes gas inefficiency

Description

=> the contract should store tournament teams in a way that supports different tournament sizes for example, 16, 32, or 64 teams without changing the source code

=> the contract currently uses a fixed-size static array string[48] public teams; This enforces a hard limit of 48 teams wastes storage for unused slots and increases gas cost during setCountry() since it must loop through all 48 indexes even if fewer teams are used

Risk

Likelihood:

  • This occurs every time the contract is deployed for a tournament that doesn’t have exactly 48 teams (which is almost always

  • Gas inefficiency also occurs in every call to setCountry() since the loop runs through all 48 indexes, even when many are empty

Impact:

  • Causes unnecessary gas consumption for both deployment and setup

  • Prevents contract reuse for tournaments with a different number of teams

Proof of Concept

string[48] public teams;
function setCountry(string[48] memory countries) public onlyOwner {
for (uint256 i = 0; i < countries.length; ++i) {
teams[i] = countries[i];
}
}

Recommended Mitigation

- string[48] public teams;
+ string[] public teams;
+ function setCountry(string[] memory countries) public onlyOwner {
+ delete teams; // clear previous list
+ for (uint256 i = 0; i < countries.length; ++i) {
+ teams.push(countries[i]);
+ }
+ emit CountriesSet(countries);
+ }
Updates

Appeal created

bube Lead Judge 20 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Gas optimizations

Gas optimizations are invalid according to the CodeHawks documentation.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!