code-423n4 / 2023-11-shellprotocol-findings

7 stars 7 forks source link

Gas Optimizations #274

Open c4-bot-5 opened 9 months ago

c4-bot-5 commented 9 months ago

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

c4-pre-sort commented 9 months ago

raymondfam marked the issue as sufficient quality report

0xA5DF commented 9 months ago

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 commented 9 months ago

0xA5DF marked the issue as selected for report

c3phas commented 8 months ago

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 commented 8 months ago

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

thebrittfactor commented 8 months ago

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