Port UUPSProxy to support Solidity 0.5.x

I’m trying to use the latest UUPSProxy to replace the transparent proxy for some of our old contracts, which is written in Solidity 0.5.

Wondering if anyone has done that, or have any recommendations? I’m thinking to just port over the UUPSProxy related contracts. Any suggestions?

Hi @maxweng. Are you using the Upgrades Plugins? You can switch to UUPS proxies by just changing the options when you depoy the proxy.

You will need to port the UUPSUpgradeable contract to 0.5, but it should be small changes.

Yes, I’m using the upgrade plugin. And seems like there’s one issue when trying to port over UUPSUpgradeable.

If I understand it correctly, the new proxy uses a storage layout called Diamond Storage. It takes advantage of a new Solidity feature supported from v0.6.4, that allows creating pointers to structs in arbitrary places in contract storage. Here’s the actual code I’m talking about: https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/aeb86bf4f438e0fedb5eecc3dd334fd6544ab1f6/contracts/utils/StorageSlotUpgradeable.sol#L53

So, wondering if I change the implementation mentioned above, will it destroy UUPSProxy, or it doesn’t matter as it’s just a utility thing.

This pattern is not called Diamond Storage.

It’s true that this feature is only available since Solidity 0.6.4. It would be fine to replace the use of this feature with a getter and setter like we used to do:

1 Like