BriVault

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

Calldata must be used instead of Memory in `setCountry::BriVault`

Root + Impact : setCountry::BriVault function is using memory instead of calldata which will save gas fee

Description

  • The function setCountry have string[48] memory countries which is consuming extra gas fee.

  • The function is not modifing the countries string array and is only reading from the array .

  • Hence, it's a waste of gas to use memory where the function only reading and is also not used anywhere in the contract, hence should also be made external with this .

contract BriVault is ERC4626, Ownable {
...
@> function setCountry(string[48] memory countries) public onlyOwner {
for (uint256 i = 0; i < countries.length; ++i) {
teams[i] = countries[i];
}
emit CountriesSet(countries);
}
...
}

Risk

Likelihood: Low

Impact: Low/Gas

Recommended Mitigation

  • Change memory->calldata and also change the visbility specifier to external.

contract BriVault is ERC4626, Ownable {
...
- function setCountry(string[48] memory countries) public onlyOwner {
+ function setCountry(string[48] calldata countries) external onlyOwner {
for (uint256 i = 0; i < countries.length; ++i) {
teams[i] = countries[i];
}
emit CountriesSet(countries);
}
...
}
Updates

Appeal created

bube Lead Judge 19 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!