-
Notifications
You must be signed in to change notification settings - Fork 46
design doc for the ocpm superchain upgrade fix #310
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Maurelian <[email protected]>
Co-authored-by: Maurelian <[email protected]>
Co-authored-by: Maurelian <[email protected]>
- The SuperchainConfig's implementation is Impl0 | ||
- The OPCM has stored Impl1 as the implementation to upgrade to | ||
|
||
If ChainA's proxyAdmin (also the SuperchainConfig's ProxyAdmin) calls the OPCM's `upgrade()` function, the check above (if (superchainProxyAdmin.getProxyImplementation(address(superchainConfig)) != impls.superchainConfigImpl)) will be true and it will upgrade the SuperchainConfig to Impl1 and also upgrade ChainA's L1 contracts. |
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.
We say ProxyAdmin a lot in this section, but is it correct that really it's the ProxyAdmin Owner that matter?
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.
fixed
- The OPCM's `upgrade()` function is called and the SuperchainConfig's implementation is upgraded to Impl2 | ||
- A new chain, ChainC comes in or is behind and has to use the old OPCM first | ||
|
||
When it calls the OPCM's `upgrade()` function, the check above (if (superchainProxyAdmin.getProxyImplementation(address(superchainConfig)) != impls.superchainConfigImpl)) will be true and it will attempt to upgrade the SuperchainConfig which will fail since it's ProxyAdmin will not be the SuperchainConfig's ProxyAdmin. |
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.
Nit, implicit here is that ChainC has a different ProxyAdmin Owner (PAO)—let's state that explicitly for clarity
We should also explain what happens when ChainC has the same PAO
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.
added
A proposed solution for this is to change the check: | ||
- Create a variable `bool isSuperchainUpgraded` in the OPCMUpgrader contract. | ||
- When `OPCM.upgrade()` is called, it delegates call to `OPCMUpgrader.upgrade()` as usual. | ||
- `OPCMUpgrader.upgrade()` calls back into itself (to be able to access it's storage) and checks if the superchainConfig is already upgraded by checking the `isSuperchainUpgraded` variable. | ||
- If it is not upgraded, it calls back into itself once more to set the `isSuperchainUpgraded` variable to true and then upgrade the superchainConfig. | ||
- If it is already upgraded, it will skip the upgrade and continue execution. | ||
|
||
While at it, it is proposed to also add support for different superchainConfigs i.e different Superchains. We can easily do this by replacing the `isSuperchainUpgraded` variable with a mapping `mapping(ISuperchainConfig superchainConfig => bool isSuperchainUpgraded)`. This way we can check which superchainConfig is being upgraded and set the `isSuperchainUpgraded` variable to true for that superchainConfig while also preventing the same superchainConfig from being upgraded again. |
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.
Hmm the control flow here feels a bit confusing and error prone. Is there a solution where we add inputs so the caller can simply specify whether they want to try upgrading the superchainConfig, with the following logic:
- Add
bool shouldUpgradeSuperchainConfig
as an input to theupgrade
method` - If
isRc == false
, this input value MUST be true. Revert if this condition is violated - Otherwise, proceed to do the upgrade as normal and try upgrading superchainConfig when requested
- Note: Downside here is that chains with their own superchainConfig must remember to manually pass in
true
for this new bool
Alternatively, can we just make the (superchainProxyAdmin.getProxyImplementation(address(superchainConfig)) != impls.superchainConfigImpl))
check smarter to do a greater than/less than semver comparison instead of strict inequality?
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.
Yeah but we want to try not changing the interface at all
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.
Got it, so would it be fair to say there's two solutions here:
- Short term patches for the existing OPCM where we don't want to change the interface
- Longer term solution (i.e. for all future OPCMs) where we are ok with breaking the interface to simplify things. In these future OPCMs, we can read the PAO from any contract, therefore we can keep the interfaces the same and just have smarter internal logic about when to upgrade?
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.
yes exactly
} | ||
``` | ||
|
||
## Requirements and Expected behaviour |
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.
We should remove this section since we added a similar one above.
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.
done
Co-authored-by: Maurelian <[email protected]>
Co-authored-by: Maurelian <[email protected]>
|
||
## Proposed Solution | ||
|
||
A proposed solution for this is to change the check to version comparisons. We can hardcode an expected version for the SuperchainConfig and compare it to the actual version. If the actual version is equal to the expected version, we can upgrade the SuperchainConfig. Otherwise we continue the execution. |
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.
To clarify, which of the following will be the upgrade condition
- The current
superchainConfig.version()
value is equal to the previous OR - The current
superchainConfig.version()
value is not equal to the current
?
} | ||
} | ||
``` | ||
- It is also important to note that for any superchain asides the one with its superchainConfig hardcoded in the OPCM, in order to upgrade the superchainConfig, one of it's L1 chains which has the same ProxyAdmin as the SuperchainConfig's ProxyAdmin will need to be upgraded in the same transaction i.e the `OpChainConfig` should not be empty. This is because if the `OpChainConfig` is empty, the function defaults to using a hardcoded superchainConfig and superchainProxyAdmin. |
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.
I think that this is very important. It means that:
- we do not support a SuperchainConfig having a ProxyAdmin which is not also the owner of an OP Chain
- it is not possible to upgrade a SuperchainConfig without upgrading at least one OP Chain.
design doc for the ocpm superchain upgrade fix