Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine external calls into one can save gas #211

Closed
code423n4 opened this issue Nov 15, 2021 · 1 comment
Closed

Combine external calls into one can save gas #211

code423n4 opened this issue Nov 15, 2021 · 1 comment
Labels
bug Something isn't working G (Gas Optimization) GovernorAlpha sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Handle

WatchPug

Vulnerability details

https://github.com/code-423n4/2021-11-vader/blob/429970427b4dc65e37808d7116b9de27e395ce0c/contracts/governance/GovernorAlpha.sol#L437-L445

for (uint256 i = 0; i < length; i++) {
    _queueOrRevert(
        proposal.targets[i],
        proposal.values[i],
        proposal.signatures[i],
        proposal.calldatas[i],
        eta
    );
}

https://github.com/code-423n4/2021-11-vader/blob/429970427b4dc65e37808d7116b9de27e395ce0c/contracts/governance/GovernorAlpha.sol#L466-L474

for (uint256 i = 0; i < length; i++) {
    timelock.executeTransaction{value: proposal.values[i]}(
        proposal.targets[i],
        proposal.values[i],
        proposal.signatures[i],
        proposal.calldatas[i],
        proposal.eta
    );
}

https://github.com/code-423n4/2021-11-vader/blob/429970427b4dc65e37808d7116b9de27e395ce0c/contracts/governance/GovernorAlpha.sol#L619-L627

for (uint256 i = 0; i < length; i++) {
    timelock.cancelTransaction(
        proposal.targets[i],
        proposal.values[i],
        proposal.signatures[i],
        proposal.calldatas[i],
        proposal.eta
    );
}

External call to timelock will be called each time in these for loops. They can be combined into batch external call by creating timelock.***Batch(...) function and call that function instead.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Nov 15, 2021
code423n4 added a commit that referenced this issue Nov 15, 2021
@SamSteinGG SamSteinGG added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Nov 25, 2021
@SamSteinGG
Copy link
Collaborator

Agreed but we don't want to change the timelock contract as this is forked from Comp and max actions are 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization) GovernorAlpha sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

3 participants