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

Add function to prepare proxy upgrade #54

Merged
merged 2 commits into from
Aug 9, 2024

Commits on Aug 9, 2024

  1. 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
    nkuba committed Aug 9, 2024
    Configuration menu
    Copy the full SHA
    3c6a27c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1fb3e1b View commit details
    Browse the repository at this point in the history