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

New upgrade() method #13078

Open
Tracked by #13069
maurelian opened this issue Nov 25, 2024 · 0 comments
Open
Tracked by #13069

New upgrade() method #13078

maurelian opened this issue Nov 25, 2024 · 0 comments

Comments

@maurelian
Copy link
Contributor

maurelian commented Nov 25, 2024

As part of the release process, the associated implementation contracts and a new OPCM, will be deployed.

The Upgrade Controller (which MUST be a Safe), will DELEGATECALL the OPCM.upgrade() function,
providing the address of the SuperchainProxyAdmin and a list of the SystemConfig contracts for the
OP Chains to be upgraded.

Thus the high level logic for upgrading a contract should be roughly as follows:

// Some upgrades will not require any new values
struct NewChainConfig {
  address newValues;
  address disputeGameBlueprint;
}

Addresses immutable implementations;

constructor(Addresses _implementations) {
  implementations = _implementations;
}

/// @notice This function is intended to be DELEGATECALLed by the chain's Upgrade Controller, therefore it
///         must not read or write from storage, and should receive all required data as calldata.
function upgrade(SuperchainProxyAdmin _admin, ISystemConfig[] _systemConfigs, NewChainConfig[] _newConfigs) public {
  for(uint i=0; i< systemConfigs.length; i++) {
    // Read the `Addresses` struct from each `SystemConfig` in the `systemConfigs` mapping.
    // For each entry in the `Addresses` struct:
      // 1. Call the appropriate `SuperchainProxyAdmin.upgradeAndCall()` function to reset the initialized slot.
      // 2. Call the appropriate `SuperchainProxyAdmin.upgradeAndCall()` function to update the
      //    implementation and call `upgrade()` on the contract.
      // 3. For non-MCP compliant dispute game contracts, call `setImplementation()` and update the `AnchorStateRegistry`.
  }
  // run safety assertions to validate the upgrade
}

To enumerate the full flow:

  1. Deploy new OPCM contract, which contains:
    1. deploy() and upgrade() methods to deploy new chains and ugprade existing chains
    2. immutables pointing to all new implementation contracts and shared config (e.g. a new contract).
  2. For each new implementation an upgrade call will be executed via the SuperchainProxyAdmin
  3. A Safe will DELEGATECALL to the OPCM.upgrade() method, which MUST be pure for safety purposes.
  4. A two step upgrade is used where the first upgrade is to an InitializerResetter which resets
    the initialized value, then the implementation is updated to the final address and upgrade()
    is called.

Notes:

  • We should identify measures for ensuring the OPCM is nearly stateless, and the upgrade() function
    should not read or write from its own storage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant