Upgradability Repo Structure #183
Replies: 3 comments 2 replies
-
Small comment on enum Initializable {
Allowed,
Disabled
} I'm still thinking through everything else, but wanted to write this down before I forgot. |
Beta Was this translation helpful? Give feedback.
-
Would we need |
Beta Was this translation helpful? Give feedback.
-
Assuming, under Option 2, that both the upgradeable and non-upgradeable versions satisfy the same interface, a single test suite could be used for both. |
Beta Was this translation helpful? Give feedback.
-
Context
Currently in teleporter and avalanche-interchain-token-transfer we have non-upgradeable contracts. However, we plan on adding upgradability to the Avalanche ICTT, this means contract changes required to make them upgrade compatible.
Upgrade Contract Changes
Repo Structure
Option 1: Non-upgradeable Extension
The core of the contracts would be upgrade compatible, and the non-upgradeable versions of the contracts would simply inherit from the upgradeable version and call their initialize function.
Pros:
Cons:
_disableInitiailizers
in the constructor of the upgradeable contract for security purposes. To work around this for the non-upgradeable contract extensions, we can take an additional constructor parameter for upgradeable versions likebool disableInitializers
.TeleporterUpgradeable
incur extra costs unnecessarily.Option 2 Separate Non-upgradeable vs Upgradeable Contracts
Pros:
TeleporterUpgradeable
is a utility contract for building Teleporter dApp, not optimal to provide a non-upgradeable version that costs higher gas than needed.Cons:
More code duplication
Proposal
Proposal is for Avalanche ICTT to use the upgradeable extension in Option 1 for non-upgradeable versions. The primary reason is that any contract change would need to be done in both contracts in option 2, and would need to make sure it’s done correctly. On top of that, since they are completely separate contracts, we should have unit test coverage for both contracts. Whereas for Option 1 with inheritance, code changes automatically apply to both contracts, and test coverage is more likely to cover both contracts.
Also this approach makes more sense if we’d like to push the upgradeable version as the standard, while still providing support for non-upgradeable versions.
The initial workaround for disableInitializer can be to take in an extra parameter in the constructor to specify to disable or not.
Next question is whether we upgrade to OZ v5 and Solidity ^0.8.20 with namespaced storage, use namespaced storage with OZ v4, or just use gap state variables with OZ v4. Proposal option is OZv5 and Solidity ^0.8.20, with the assumption that the audit timeline is August. Reasons being:
Teleporter utility contracts had more considerations for splitting the contracts, but at this point don’t feel it’s worth the tradeoff in terms of managing both non-upgradeable and upgradeable versions, with possible higher priority tasks.
Next steps:
Beta Was this translation helpful? Give feedback.
All reactions