Reuse Upgrade-Safety Checks For Implementation Contracts Used In Diamond Pattern

Hello! I am a huge fan of how upgradeProxy and deployProxy comes with many extremely useful safety checks built-in. However, I am using the diamond pattern (EIP-2535) and thus I can't use these 2 methods as is. Is there a way use these methods to instead only check if two implementation contracts are "compatible" with each other and skip the actual deployment? (Actually, deploying the implementation contract for me would be okay. Just deploying the proxy is unnecessary for me).

For example, suppose I have existing diamond contract D that points to facet contracts (i.e. implementation contracts) F1, F2, F3, ... and I want to upgrade F1 to F1'. I would love to be able to reuse OZ's upgrade-safety checks before I deploy F1' and change the D->F1 link to D->F1' link. E.g. a does a method like validateUpgradeSafety(oldImplAddress, newImplContractAbiAndBytecode) exist? Or perhaps there is a relatively straightforward way for me to extract this functionality out from the current OZ repo?

Thank you!

1 Like

There are several ways in which you can run upgrade safety validations by themselves:

These include validations of regular Solidity storage layouts, storage gaps, and namespaced storage.

Note that these do not by default validate diamond storage, but you should be able to add annotations to the structs in your implementations according to this comment which will cause those structs to be included in namespace validations when running any of the above.

1 Like