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

Open
c4-bot-5 opened this issue Dec 8, 2023 · 6 comments
Open

Gas Optimizations #274

c4-bot-5 opened this issue Dec 8, 2023 · 6 comments
Labels
bug Something isn't working G (Gas Optimization) G-01 selected for report This submission will be included/highlighted in the audit report sufficient quality report This report is of sufficient quality

Comments

@c4-bot-5
Copy link
Contributor

c4-bot-5 commented Dec 8, 2023

See the markdown file with the details of this report here.

@c4-bot-5 c4-bot-5 added bug Something isn't working G (Gas Optimization) labels Dec 8, 2023
c4-bot-5 added a commit that referenced this issue Dec 8, 2023
c4-bot-3 added a commit that referenced this issue Dec 8, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as sufficient quality report

@c4-pre-sort c4-pre-sort added the sufficient quality report This report is of sufficient quality label Dec 10, 2023
@0xA5DF
Copy link

0xA5DF commented Dec 16, 2023

G10 in bot findings
G13 is false (Ocean doesn't implement ERC721)

G4 is false

// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;


contract TestConstant{

    uint constant MAX_UINT256  = type(uint256).max;
    // gas cost: 149
    function control() public returns (uint256) { 
         return type(uint256).max;
    }

    // gas cost: 171
    function test() public returns (uint256) {
        return MAX_UINT256;
    }
}

G12 is false

// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;


contract TestIndexed{

    event Unindexed(address a, uint b, bool c);
    event Indexed(address indexed a, uint b, bool c);


    function control() public returns (uint256) {
        address a = address(0);
        emit Unindexed(a,0, false);
         return 0;
    }

    
    function test() public returns (uint256) {
        address a = address(0);
        emit Indexed(a,0, false);
         return 0;
    }
}

As for G6 - the savings seem to actually be ~450 per instance (when optimization is turned on), and I'm not sure it'd work for every case there

@c4-judge
Copy link
Contributor

0xA5DF marked the issue as selected for report

@c4-judge c4-judge added the selected for report This submission will be included/highlighted in the audit report label Dec 17, 2023
@c3phas
Copy link

c3phas commented Dec 19, 2023

G-01: Invalid the compiler is set to use 0.8.20
G-02: OOS - reported by bot
G-03: Invalid - currently we have 1 SLOAD + 1 SSTORE , if we cache we still end up with 1 SLOAD + 1 SSTORE(should actually cost more for the local variable initialization)
G-04: False - judge found this too

The judge has already identified other invalid so not going to repeat them

@0xA5DF
Copy link

0xA5DF commented Dec 19, 2023

G-02: OOS - reported by bot

Bot reported only on division, this is about subtraction.
The rest were indeed marked as invalid, see the judging sheet

@C4-Staff C4-Staff added the G-01 label Dec 21, 2023
@thebrittfactor
Copy link
Contributor

Just a note that C4 is excluding the invalid entries from the official report.

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) G-01 selected for report This submission will be included/highlighted in the audit report sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

7 participants