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

Unnecessary SLOADs in Auction #33

Open
code423n4 opened this issue Oct 9, 2021 · 1 comment
Open

Unnecessary SLOADs in Auction #33

code423n4 opened this issue Oct 9, 2021 · 1 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")

Comments

@code423n4
Copy link
Contributor

Handle

pants

Vulnerability details

The functions Auction.bondForRebalance(), Auction.settleAuction(), Auction.bondBurn() and Auction.withdrawBounty() read values from storage multiple times instead of caching them in local variables:

  • Auction.bondForRebalance() reads bondAmount twice.
  • Auction.settleAuction() reads bondBlock twice, basket 8 times and factory twice.
  • Auction.bondBurn() reads basket twice and bondAmount twice.
  • Auction.withdrawBounty() reads bounty.token twice and bounty.amount twice.

Impact

Storage reads are much more expensive than reading local variables.

Tool Used

Manual code review.

Recommended Mitigation Steps

Read these values from storage once, cache them in local variables and then read them again from the local variables.

code423n4 added a commit that referenced this issue Oct 9, 2021
@frank-beard frank-beard added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Nov 6, 2021
@GalloDaSballo
Copy link
Collaborator

Agree that caching these values in memory would save gas
I appreciate the warden listing the isntances

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