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 Optimizations #15

Open
code423n4 opened this issue Feb 26, 2022 · 2 comments
Open

Gas Optimizations #15

code423n4 opened this issue Feb 26, 2022 · 2 comments
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

  1. If use Offer memory offer and return offer is cheaper.
  1. Use delete instead of set the default value (false or 0)
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Feb 26, 2022
code423n4 added a commit that referenced this issue Feb 26, 2022
@HardlyDifficult
Copy link
Collaborator

Thanks for the feedback.

  1. We decided to keep returning the unpacked version because this approach shields consumers from the slot packing strategy we use, and allows us to potentially make other additions or changes to the struct without impacting the external ABI. Ideally we would be more consistent here and do the same when returning the ReserveAuction struct - however there is a 3rd party contract which has already created a dependency on the current ABI.

  2. We agree with this change as it improves readability and will switch to delete pendingWithdrawals[user] here.

@alcueca
Copy link
Collaborator

alcueca commented Mar 17, 2022

Wouldn't it be cheaper to do Offer memory offer = and then return (offer.buyer, offer.expiration, offer.amount)? The slot is warm, but still you should save about 300 gas.

Score: 300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

3 participants