Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgradeability for TeleporterUpgradeable and TeleporterOwnerUpgradeable #397

Merged
merged 53 commits into from
Jul 25, 2024

Conversation

minghinmatthewlam
Copy link

@minghinmatthewlam minghinmatthewlam commented Jun 7, 2024

Why this should be merged

Fixes #420 #414

How this works

Makes it so the utility contracts are upgradeable, and can have easy non-upgradeable extensions that derive off these contracts in future issue.

How this was tested

CI

How is this documented

Copy link

Upgradeability POC

Generated at commit: a322c6a3cb9475a59e831c3153e830a978fdc145

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
0
0
0
2
14
16
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

.gitmodules Show resolved Hide resolved
@minghinmatthewlam minghinmatthewlam marked this pull request as ready for review July 8, 2024 21:44
@minghinmatthewlam minghinmatthewlam requested a review from a team as a code owner July 8, 2024 21:44
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why this ABI binding changed despite the contract being untouched?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's just the IPFS hash of the deployed byte code that changed, but still seems odd since nothing else was modified as far as I can tell.

internal
onlyInitializing
{
__ReentrancyGuard_init();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my own understanding, do you know why ContextUpgradeable doesn't have a __ContextUpgradeable_init function to be called here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ContextUPgradeable has no state to initialize with so the init functions are empty

    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, should we include calls to that here for completeness? In the event that state is added to those contracts in a future version I image we'd want to call it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need to follow up this. If you include the Context init call, for new versions we'd need to check through the inheritance hierarchy to make sure there's no duplicates of initialize calls anyways. Likely if called, we can call the init_unchained call. Also was looking at OZ's OwnableUpgradeable which also inherits ContextUpgradeable but they do not call the Context init function, so might ask OZ about that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

following convention in #397 (comment) to call init instead of unchained when not needed, went forward to call Context_init as well for completeness, and no duplicate initializations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related OZ issue with their upgradeable contract transpiler not always calling the init functions of parent contracts OpenZeppelin/openzeppelin-contracts#4690

@michaelkaplan13
Copy link
Collaborator

Bumping this comment that may have fallen through the cracks: #397 (comment)

Copy link
Contributor

@feuGeneA feuGeneA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to call _disableInitializers() somewhere? https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializing_the_implementation_contract

Do we plan to integrate OZ's Upgrades Plugins? In particular, the "upgrade safety validations" sound helpful.

Copy link
Contributor

@geoff-vball geoff-vball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once Gene's comments are addressed

@minghinmatthewlam
Copy link
Author

minghinmatthewlam commented Jul 24, 2024

Do we need to call _disableInitializers() somewhere? https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializing_the_implementation_contract

Do we plan to integrate OZ's Upgrades Plugins? In particular, the "upgrade safety validations" sound helpful.

I deferred the _disableInitializer to the non-upgradeable extensions Issue/PR, but yes they should be added to constructors of upgradeable contracts.

Also I agree that now we have upgradeable contracts, integrating the plugin will be beneficial especially after moving to mono-repo structure. Can you create a separate issue for it @feuGeneA

@minghinmatthewlam minghinmatthewlam merged commit 556103f into main Jul 25, 2024
14 checks passed
@minghinmatthewlam minghinmatthewlam deleted the upgradeable-poc-merge branch July 25, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants