-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add function to prepare proxy upgrade #54
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Proxy upgrades of contracts are performed in two stages: 1. Deploy new implementation contract. 2. Upgrade version of implementation in the Proxy contract. For upgradable contracts that were already deployed and ownership transferred to the governance we cannot simply run `upgradeProxy` as the governance is a multisig. Here we introduce a solution that will help us execute the upgrade in setup used across our projects: 1. Deploy new implementation contract. 2. Prepare transaction for the Governance to execute. The solution is based on Open Zeppelin's [upgradeProxy](https://github.com/OpenZeppelin/openzeppelin-upgrades/blob/49e7ae93ee9be1d6f586517890a83634dea29ebc/packages/plugin-hardhat/src/upgrade-proxy.ts) function, with the difference that the upgrade implementation transaction is prepared but not executed. Implementation upgrade is executed through ProxyAdmin contract which can exist in two versions: V4 and V5. Currently our new contracts are deployed with version V5, but for older deployments we still support V5. The difference between these two version is in the upgrade function that is called on the ProxyAdmin. In V4 there were two separate functions `upgradeAndCall` and `upgrade` which were called depending if the callback should be executed. In V5 there is just `upgradeAndCall` function, which allows empty calldata. This is based on https://github.com/OpenZeppelin/openzeppelin-upgrades/blob/49e7ae93ee9be1d6f586517890a83634dea29ebc/packages/plugin-hardhat/src/upgrade-proxy.ts#L62C45-L103
nkuba
added a commit
to thesis/acre
that referenced
this pull request
Aug 9, 2024
These are upgrade scripts for stBTC and MezoAllocator contracts that will be executed on Sepolia and Mainnet. The solution is using proxy upgrade helpers function that will deploy implementation contract and prepare transaction that will be executed by the governance to upgrade the implementation on the proxy contract. It requires changes from keep-network/hardhat-helpers#54 which branch is set in package.json as version of the package. We need to update the version of `keep-network/hardhat-helpers` dependency once it is released.
jagodarybacka
approved these changes
Aug 9, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO looks good, if you have already tested on the fork I think we are good to merge? Or go we want to wait until we will attempt the upgrade on Sepolia?
nkuba
added a commit
to thesis/acre
that referenced
this pull request
Aug 9, 2024
This is a version that includes the proxy upgrade preparation helpers keep-network/hardhat-helpers#54
nkuba
added a commit
to thesis/acre
that referenced
this pull request
Aug 9, 2024
These are upgrade scripts for stBTC and MezoAllocator contracts that will be executed on Sepolia and Mainnet. The solution is using proxy upgrade helpers function that will deploy implementation contract and prepare transaction that will be executed by the governance to upgrade the implementation on the proxy contract. It requires changes from keep-network/hardhat-helpers#54 which branch is set in package.json as version of the package. We need to update the version of `keep-network/hardhat-helpers` dependency once it is released.
nkuba
added a commit
to thesis/acre
that referenced
this pull request
Aug 9, 2024
This is a version that includes the proxy upgrade preparation helpers keep-network/hardhat-helpers#54
jagodarybacka
added a commit
to thesis/acre
that referenced
this pull request
Aug 9, 2024
…698) These are upgrade scripts for stBTC and MezoAllocator contracts that will be executed on Sepolia and Mainnet. The solution is using proxy upgrade helpers function that will deploy implementation contract and prepare transaction that will be executed by the governance to upgrade the implementation on the proxy contract. It requires changes from keep-network/hardhat-helpers#54 which branch is set in package.json as version of the package. We need to update the version of `keep-network/hardhat-helpers` dependency once it is released.
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proxy upgrades of contracts are performed in two stages:
For upgradable contracts that were already deployed and ownership transferred to the governance, we cannot simply run
upgradeProxy
as the governance is a multi-sig.Here we introduce a solution that will help us execute the upgrade in setup used across our projects:
The solution is based on Open Zeppelin's upgradeProxy function, with the difference that the upgrade implementation transaction is prepared but not executed.
ProxyAdmin V4 vs V5
Implementation upgrade is executed through ProxyAdmin contract which can exist in two versions: V4 and V5.
Currently, our new contracts are deployed with version V5, but for older deployments we still support V4.
The difference between these two versions is in the upgrade function that is called on the ProxyAdmin.
In V4 there were two separate functions
upgradeAndCall
andupgrade
which were called depending on if the callback should be executed.In V5 there is just an
upgradeAndCall
function, which allows empty call data.We introduced a switch statement to differentiate the flow based on Open Zeppelin's library.