-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function to prepare proxy upgrade
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
- Loading branch information
Showing
1 changed file
with
138 additions
and
0 deletions.
There are no files selected for viewing
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