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

Gas optimization: Struct layout #327

Closed
code423n4 opened this issue Dec 1, 2021 · 2 comments
Closed

Gas optimization: Struct layout #327

code423n4 opened this issue Dec 1, 2021 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Handle

gzeon

Vulnerability details

Impact

AuctionData struct can be repacked to save some storage slot. e.g.

  1. Put active and finalized together to save 1 slot
  2. Use uint120 for startingTime and endingTime to save 2 slot when packed with active and finalized
struct AuctionData {
  uint256 fullRequirement;
  uint256 maxCommitments;
  uint256 commitments;
  uint256 maltPurchased;
  uint256 startingPrice;
  uint256 endingPrice;
  uint256 finalPrice;
  uint256 pegPrice;
  uint120 startingTime;
  uint120 endingTime;
  bool active;
  bool finalized;
  uint256 preAuctionReserveRatio;
  uint256 claimableTokens;
  uint256 finalBurnBudget;
  uint256 finalPurchased;
  mapping(address => AccountCommitment) accountCommitments;
}

https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/Auction.sol#L26

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Dec 1, 2021
code423n4 added a commit that referenced this issue Dec 1, 2021
@0xScotch 0xScotch added the duplicate This issue or pull request already exists label Dec 9, 2021
@0xScotch
Copy link
Collaborator

0xScotch commented Dec 9, 2021

#38

@0xScotch 0xScotch closed this as completed Dec 9, 2021
@GalloDaSballo
Copy link
Collaborator

Duplicate of #38

@GalloDaSballo GalloDaSballo marked this as a duplicate of #38 Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

3 participants