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

Minimize Storage Slots (Auction.sol) #46

Open
code423n4 opened this issue Oct 9, 2021 · 2 comments
Open

Minimize Storage Slots (Auction.sol) #46

code423n4 opened this issue Oct 9, 2021 · 2 comments
Labels
bug Warden finding G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

ye0lde

Vulnerability details

Impact

It is possible to minimize the number of storage slots used by rearranging the state variables in a more efficient way.

Proof of Concept

In Auction.sol:
https://github.com/code-423n4/2021-10-defiprotocol/blob/7ca848f2779e2e64ed0b4756c02f0137ecd73e50/contracts/contracts/Auction.sol#L16-L28

Tools Used

Visual Studio Code, Remix

Recommended Mitigation Steps

Arrange the bool and address variables such that they fit into the same slot.
For example:

uint256 private constant BASE = 1e18;
uint256 private constant ONE_DAY = 4 * 60 * 24; // one day in blocks

bool public override auctionOngoing;
bool public override hasBonded;
bool public override initialized;
address public override auctionBonder;

uint256 public override auctionStart;
code423n4 added a commit that referenced this issue Oct 9, 2021
@frank-beard frank-beard added duplicate Another warden found this issue sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Nov 6, 2021
@frank-beard
Copy link
Collaborator

#55

@GalloDaSballo
Copy link
Collaborator

Packing boolean will save storage

@GalloDaSballo GalloDaSballo removed the duplicate Another warden found this issue label Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Warden finding G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants