NFTBridge
60,000 USDC
View results
Submission Details
Severity: low
Invalid

Inefficient Gas Usage

While not as critical as the other issues, I noticed that the getWhiteListedCollections function was not optimized for gas efficiency. As the number of collections grew, the gas cost of this function would increase, potentially making it expensive to use.

Description: The function could become increasingly gas-intensive as the number of collections grows, making it prohibitively expensive to execute in some scenarios.

Location:getWhiteListedCollections function in ethereum/src/IStarklane.sol

Issue: The getWhiteListedCollections function iterates over all collections, which could be gas-inefficient as the number of collections grows. Also, resizing the array in assembly could lead to errors if not carefully handled.

Impact: High gas usage could make the contract prohibitively expensive to use, particularly for large-scale operations.

Tools used: Manual Review.

Recommendations: Optimize the getWhiteListedCollections function to minimize gas usage, possibly by using more efficient data structures or avoiding unnecessary iterations.

Potential changes: Optimize getWhiteListedCollections function for gas efficiency.

function getWhiteListedCollections() external view returns (address[] memory) {
uint256 nbElem = _collections.length;
uint256 whiteListedCount = 0;
// Count whitelisted collections first to preallocate memory
for (uint256 i = 0; i < nbElem; ++i) {
if (_whiteList[_collections[i]]) {
whiteListedCount++;
}
}
address[] memory ret = new address[](whiteListedCount);
uint256 offset = 0;
for (uint256 i = 0; i < nbElem; ++i) {
if (_whiteList[_collections[i]]) {
ret[offset] = _collections[i];
offset++;
}
}
return ret;
}
Updates

Lead Judging Commences

n0kto Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational / Gas

Please, do not suppose impacts, think about the real impact of the bug and check the CodeHawks documentation to confirm: https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity A PoC always helps to understand the real impact possible.

Support

FAQs

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