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

0 stars 0 forks source link

Pack together bool variables in Auction #55

Closed code423n4 closed 2 years ago

code423n4 commented 3 years ago

Handle

kenzo

Vulnerability details

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-10-defiprotocol/blob/main/contracts/contracts/Auction.sol#L16:#L28

Tools Used

Manual analysis, hardhat, hardhat-gas-reporter.

Recommended Mitigation Steps

Declare the bool variables together:

  bool public override initialized;
  bool public override auctionOngoing;
  bool public override hasBonded;
GalloDaSballo commented 2 years ago

Duplicate of #46