Hi, I’m trying to design a contract factory, and I want to adopt EIP1167 meanwhile make the contract upgradable (1 update can impact all cloned contracts).
I’m not sure if I get it correctly, but if I want to achieve this, it seems like I need 2 proxies: The first one which user deploy and interact with is the Minimal Proxy, and the “implementation address” of the minimal proxy is actually another upgradable proxy, which relay call to the implementation contract. Does this architecture sounds okay?
Thanks for helping!
1 Like
Hi @antoncoding,
Welcome to the community forum
If I understand correctly, you want to use a factory to create the following:
Minimal Proxy -> Upgradeable Proxy -> Logic contract
Unfortunately we can’t do two delegate calls.
You may want to look at Dharma’s upgrade pattern using Beacon contracts, developed by 0age.
1 Like
Hey @antoncoding,
Andy is correct (as always!). You cannot chain two delegatecall-based proxies. Let’s say you have the EIP1167 proxy, pointing to an upgradeable proxy (UP), pointing to your logic contract (LC).
You make a call to EIP1167. EIP1167 makes a DELEGATECALL
to UP, which means that, when UP executes, all operations are made in the context of EIP1167. This implies that, when UP attempts to SLOAD
the LC address from its storage, it will actually be reading from EIP1167’s storage, which is empty, so won’t be able to call LC.
As Andy mentioned, Dharma’s beacon implementation is an elegant solution for this. We have received several requests for implementing such a pattern, so we’ll try to tackle this in the upcoming months.
Cheers!
2 Likes
@abcoathup @spalladino Thanks for the reply! It make much more sense now. I’ll look into the Beacon contracts implementation and see what can I learn from there.
We will think more about if we really want to make this contract upgradable, it looks like a huge effort.
1 Like