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

Gas Optimizations #109

Open
code423n4 opened this issue May 19, 2022 · 2 comments
Open

Gas Optimizations #109

code423n4 opened this issue May 19, 2022 · 2 comments
Labels
bug Something isn't working G (Gas Optimization) sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

The contract : https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol at function checks if the msg.sender is the operator using if condition instead of modifier,
this consumes gas more than using a modifier

see :

function mint(address _to, uint256 _amount) external {
        require(totalSupply() != 0, "Not initialised");

        if (msg.sender != operator) {
            // dont error just return. if a shutdown happens, rewards on old system
            // can still be claimed, just wont mint cvx
            return;
        }

consumed :

gas	30114 gas
transaction cost	26186 gas 
execution cost	26186 gas 

Using :

modifier isOperator() {
    require(msg.sender == operator,"not operator");
}

function mint(address _to, uint256 _amount) isOperator external {
        require(totalSupply() != 0, "Not initialised");

       
        }

consumed :

gas	30113 gas
transaction cost	26185 gas 
execution cost	26185 gas 
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels May 19, 2022
code423n4 added a commit that referenced this issue May 19, 2022
@0xMaharishi 0xMaharishi added invalid This doesn't seem right sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue labels May 25, 2022
@0xMaharishi
Copy link

Incorrect as we don't want to revert. Also, only saves ONE gas

@dmvt
Copy link
Collaborator

dmvt commented Jul 4, 2022

Technically accurate. Letting it stand, although the value is low to non-existent.

@dmvt dmvt removed the invalid This doesn't seem right label Jul 4, 2022
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) sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

3 participants