clones-with-immutable-args
clones-with-immutable-args copied to clipboard
About the gas savings for this library
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.
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 ?
Yeah, it definitely helps if the comparison is more explicit.