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 #110

Closed
code423n4 opened this issue May 19, 2022 · 1 comment
Closed

Gas Optimizations #110

code423n4 opened this issue May 19, 2022 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization) sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Using "> 0" is less consuming than != 0 for uint in requirements :

The mint function in : https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol contract at the totalsupply check it checks using not equal to instead of if greater than for 0 checks and this is way more gas onsuming,

see :

Using :

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	30113 gas
transaction cost	26185 gas 
execution cost	26185 gas 

Using :

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	30110 gas
transaction cost	26182 gas 
execution cost	26182 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 duplicate This issue or pull request already exists sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue labels May 25, 2022
@dmvt
Copy link
Collaborator

dmvt commented Jul 8, 2022

Grouping this with the warden’s gas report, #109

@dmvt dmvt closed this as completed Jul 8, 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 duplicate This issue or pull request already exists 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