-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Optimize ERC1167 proxy creation code by 1 opcode #3329
Conversation
This is a tiny optimization so it has low priority for us, but I don't see a reason not to merge it. Can you confirm if minimal proxies deployed with this new code are still detected as minimal proxies by Etherscan? |
It's completely understandable that a 3 gas optimization is not your priority. I've verified that etherscan recognizes proxies deployed with the adjusted bytecode as minimal proxies: https://ropsten.etherscan.io/address/0x6d91057e495b2fe6ba421ed7117bde6453c61516#code (creator address is a contract which has the adjusted internal |
Nice. Thanks.
You can add an entry in the topmost "Unreleased" section in CHANGELOG.md. Just a short description, follow a similar format than the rest. |
Changelog entry added and merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good to me.
@Philogy We ended up reverting this change, we realized it was a breaking change of the way deterministic addresses are computed and this has the risk of breaking upgradeable contracts. The risk is not worth taking for such a small improvement. |
Fixes: None (No issue created beforehand)
Description
The existing proxy creation bytecode was a total of 55 bytes:
3d602d80600a3d3981f3
10 bytes, responsible for returning the remaining 45 byte ERC1167 proxy code, equivalent to the constructor in solidity363d3d373d3d3d363d73????????????????????????????????????????5af43d82803e903pd91602b57fd5bf3
45 bytes, standard ERC1167 proxy bytecodeLooking at the execution of the constructor code one notices that one value always remains, unused on the stack at the end of execution (stack after op depicted in the square brackets; left -> right, top -> bottom):
By rearranging the opcodes slightly, one opcode can be removed, resulting in a smaller, 9-byte constructor
602d8060093d393df3
:The
proxy/Clones.sol
library'sclone
,cloneDeterministic
andpredictDeterministicAddress
methods are then adjusted for the smaller code. The total creation bytecode is then 54 bytes instead of the current 55 bytes.PR Checklist