-
Notifications
You must be signed in to change notification settings - Fork 46
⛽ Gas Optimizations #14
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
base: master
Are you sure you want to change the base?
⛽ Gas Optimizations #14
Conversation
|
do you need unchecked here?
|
@z0r0z , This unchecked block was carried over from the current implementation. The potential overflows that might be problematic would be:
and
Basically for the overflow to happen we would need From EIP-170, we know that the otherwise, the create instruction should fail:
So combing everything so far, we should have in case of an overflow as a rough estimate: This would mean the memory has been expanded quite a lot, plugging the lower band in the memory expansion cost function would roughly give us So the memory expansion gas cost would be astronomically high. Based on these calculations the function call would run out of gas before it would overflow. |
|
I am under the impression that |
This reverts commit 9b3f1f8.
|
anything blocking this? I'm wanting to deploy a clone soon and these changes look helpful |
|
@wysenynja believe solady's clone has these updates + others baked in |
This PR applies some gas optimizations to
ClonesWithImmutableArgs.solandClone.sol.ClonesWithImmutableArgs.solhas been rewritten to optimize gas and also consolidate all theassemblyblocks.Clone.solinclude using more assembly for_getArgUint256Arraymethod and also together withClonesWithImmutableArgs.soledits, we are assuming the 2 bytes at the end of the clone/proxy contract is the data length plus 2. In this way we would save subtracting 2 inClonesWithImmutableArgs.soland adding it back inClone.solto calculate the extra data offset in the calldata.In the 1st commit 30958a4d3a39c31293353dee7c41519df9ca133b, we update the
.gas-snapshotsince it was not previously updated.Here is the result of running
forge snapshot ...with the new optimization edits: