Closed code423n4 closed 2 years ago
kenzo
By putting the bool variables declared in Auction one after the other, solidity will pack them and save gas in deployment.
Around 13000 gas can be saved.
Relevant lines: https://github.com/code-423n4/2021-09-defiProtocol/blob/52b74824c42acbcd64248f68c40128fe3a82caf6/contracts/contracts/Auction.sol#L16:#L21 Running hardhat with a test file, for deployment of Auction I see normal price of 1547504, and after packing together 1534543.
Manual analysis, hardhat, hardhat-gas-reporter.
Declare the bool variables together:
bool public override initialized; bool public override auctionOngoing; bool public override hasBonded;
Duplicate of #109
Handle
kenzo
Vulnerability details
By putting the bool variables declared in Auction one after the other, solidity will pack them and save gas in deployment.
Impact
Around 13000 gas can be saved.
Proof of Concept
Relevant lines: https://github.com/code-423n4/2021-09-defiProtocol/blob/52b74824c42acbcd64248f68c40128fe3a82caf6/contracts/contracts/Auction.sol#L16:#L21 Running hardhat with a test file, for deployment of Auction I see normal price of 1547504, and after packing together 1534543.
Tools Used
Manual analysis, hardhat, hardhat-gas-reporter.
Recommended Mitigation Steps
Declare the bool variables together: