code-423n4 / 2021-12-defiprotocol-findings

0 stars 0 forks source link

Gas Optimization: Struct layout #133

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

gzeon

Vulnerability details

Impact

Pack variables into less storage slot. https://github.com/code-423n4/2021-12-defiprotocol/blob/205d3766044171e325df6a8bf2e79b37856eece1/contracts/contracts/interfaces/IAuction.sol#L8

    struct Bounty {
        address token;
        bool active;
        uint256 amount;
    }

https://github.com/code-423n4/2021-12-defiprotocol/blob/205d3766044171e325df6a8bf2e79b37856eece1/contracts/contracts/interfaces/IFactory.sol#L6

    struct Bounty {
        address token;
        bool active;
        uint256 amount;
    }
    struct Proposal {
        uint256 licenseFee;
        uint256 maxSupply;
        address proposer;
        address basket;
        address[] tokens;
        uint256[] weights;
        string tokenName;
        string tokenSymbol;
    }
0xleastwood commented 2 years ago

You can't pack address and bool types together