Proxy Contracts Forwarding Calls To Zero Address Despite Initialization

I’m attempting to integrate a codebase with the Openzeppelin truffle upgrades plugin. The codebase uses a factory contract to generate minimal proxies that point to proxy contracts. Contract deployment through the factory works, however when interacting with the deployed proxies, all calls get forwarded to the all 0 address.

This is the factory contract which is used to deploy minimal proxies for Cash.sol and Bond.sol. Here is my migration script.

This is an example transaction to an instance of Cash.sol deployed through the factory if you go to the internal transactions you’ll notice delegatecalls being sent to the all 0 address. Originally I thought it might’ve been an issue with the contract being deployed through the factory not properly being initialized, so i modified the factory contract to explicitly call the initialize function but this also did not work.

Apologies for the annoying formats of links, but attempting to post more than 2 links as a new user in a single post gives me a warning that prevents me from submitting the post.

Let me know if I need to provide any more information. Thanks!

1 Like

Hey there!

It sounds like the problem is in the double proxy setup you’re using. If I understand correctly from your description, your minimal proxies point at another proxy. If that is the case, the issue is that the (non-minimal) proxy attemps to retrieve its implementation address from storage, but while this address is kept in the storage of the proxy, it will actually be reading from the storage of the minimal proxy.

When contract A delegates to contract B, the code of B runs in the context of A, where context includes storage.

This is the reason why this kind of double proxy setup doesn’t work.

2 Likes

You can have a try following this doc to use proxy: https://docs.openzeppelin.com/learn/upgrading-smart-contracts#upgrading-a-contract-via-plugins

2 Likes