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

About the gas savings for this library #22

Open
zhiqiangxu opened this issue Feb 16, 2024 · 2 comments
Open

About the gas savings for this library #22

zhiqiangxu opened this issue Feb 16, 2024 · 2 comments

Comments

@zhiqiangxu
Copy link

zhiqiangxu commented Feb 16, 2024

By doing so, the gas cost of creating parametrizable clones is reduced, since there's no need to store the parameters in storage, which you need to do with EIP-1167. The cost of using such clones is also reduced, since storage loads are replaced with calldata reading, which is far cheaper.

I don't think the gas savings should compare with storage loads since immutable data are not loaded from storage in the first place, it's loaded from code, so it should compare with that of codecopy, which will be more or less the same in both cases.

IMO the essential advantage this library provides is: it allows to parameterize the immutable data at the clone time instead of at deploy time of implementation contract in the case of EIP-1167.

@wighawag
Copy link
Owner

I don't think the gas savings should compare with storage loads since immutable data are not loaded from storage in the first place, it's loaded from code, so it should compare with that of codecopy, which will be more or less the same in both cases.

This is in comparison to a normal proxy clone
Remember that with clone, implementation code is all the same, so any immutable are also same and so not parametrizable.

As such with such normal clone you would have to parametrize by using storage for which you have to pay the initialisation storage cost and each storage read . With clones-with-immutable-args you do not need to write to storage as you can inject immutable in the proxy and pay only calldata for read

Maybe we could word it differently to make this clearer ?

@zhiqiangxu
Copy link
Author

Yeah, it definitely helps if the comparison is more explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants