Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: low
Invalid

[L-2] there should be a break statement after the chain has been found and removed in the for loop in removeWhitelistedChain::SDLPoolCCIPControllerPrimary

Description:

function removeWhitelistedChain(uint64 _chainSelector) external onlyOwner {
if (whitelistedDestinations[_chainSelector] == address(0)) revert InvalidDestination();
emit ChainRemoved(_chainSelector, whitelistedDestinations[_chainSelector]);
for (uint256 i = 0; i < whitelistedChains.length; ++i) {
if (whitelistedChains[i] == _chainSelector) {
whitelistedChains[i] = whitelistedChains[whitelistedChains.length - 1];
whitelistedChains.pop();
}
}
delete whitelistedDestinations[_chainSelector];
}

In the current implementation, the loop continues even after finding and removing the target _chainSelector. Once the matching element is found and removed, there's no need to continue iterating through the array. Adding a break statement can exit the loop early, saving gas

function removeWhitelistedChain(uint64 _chainSelector) external onlyOwner {
if (whitelistedDestinations[_chainSelector] == address(0)) revert InvalidDestination();
emit ChainRemoved(_chainSelector, whitelistedDestinations[_chainSelector]);
for (uint256 i = 0; i < whitelistedChains.length; ++i) {
if (whitelistedChains[i] == _chainSelector) {
whitelistedChains[i] = whitelistedChains[whitelistedChains.length - 1];
whitelistedChains.pop();
break; // Exit the loop as we've already found and removed the chain
}
}
delete whitelistedDestinations[_chainSelector];
}
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

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