function rebuildCache() public {
bytes32[] memory requiredAddresses = resolverAddressesRequired();
// The resolver must call this function whenever it updates its state
for (uint256 i = 0; i < requiredAddresses.length; i++) {
bytes32 name = requiredAddresses[i];
// Note: can only be invoked once the resolver has all the targets needed added
address destination = resolver.getAddress(name);
if (destination != address(0)) {
addressCache[name] = destination;
} else {
delete addressCache[name];
}
emit CacheUpdated(name, destination);
}
}
Handle
WatchPug
Vulnerability details
The for loop in
rebuildCache()
will cost more gas ifremoveOperator()
wont decreaseoperators.length
.https://github.com/code-423n4/2021-11-nested/blob/f646002b692ca5fa3631acfff87dda897541cf41/contracts/MixinOperatorResolver.sol#L29-L43
https://github.com/code-423n4/2021-11-nested/blob/f646002b692ca5fa3631acfff87dda897541cf41/contracts/NestedFactory.sol#L78-L86
Recommendation
Change to: