-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
G (Gas Optimization)bugSomething isn't workingSomething isn't workingsponsor acknowledgedTechnically the issue is correct, but we're not going to resolve it for XYZ reasonsTechnically the issue is correct, but we're not going to resolve it for XYZ reasons
Description
Handle
pants
Vulnerability details
You can cache the array length to save length access gas cost at every iteration.
The following (bad) form appears at GovernorAlpha.sol line 571 and LinearVesting.sol line 72.
GovernorAlpha.sol example:
for (uint256 i = 0; i < _targets.length; i++) {
if (_targets[i] == address(this)) {
revert(
"GovernorAlpha::veto: council cannot veto on proposal having action with address(this) as target"
);
}
}
Change it to:
uint256 len = _targets.length;
for (uint256 i = 0; i < len; i++) {
if (_targets[i] == address(this)) {
revert(
"GovernorAlpha::veto: council cannot veto on proposal having action with address(this) as target"
);
}
}
Metadata
Metadata
Assignees
Labels
G (Gas Optimization)bugSomething isn't workingSomething isn't workingsponsor acknowledgedTechnically the issue is correct, but we're not going to resolve it for XYZ reasonsTechnically the issue is correct, but we're not going to resolve it for XYZ reasons