-
Notifications
You must be signed in to change notification settings - Fork 11
Celo op-deployer v5.0.0 #422
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: celo-contracts/v5.0.0
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ import { IPermissionedDisputeGame } from "interfaces/dispute/IPermissionedDisput | |
| import { ISuperFaultDisputeGame } from "interfaces/dispute/ISuperFaultDisputeGame.sol"; | ||
| import { ISuperPermissionedDisputeGame } from "interfaces/dispute/ISuperPermissionedDisputeGame.sol"; | ||
| import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol"; | ||
| import { IHasSuperchainConfig } from "interfaces/L1/IHasSuperchainConfig.sol"; | ||
| import { IProtocolVersions } from "interfaces/L1/IProtocolVersions.sol"; | ||
| import { IOptimismPortal2 as IOptimismPortal } from "interfaces/L1/IOptimismPortal2.sol"; | ||
| import { IOptimismPortalInterop } from "interfaces/L1/IOptimismPortalInterop.sol"; | ||
|
|
@@ -732,10 +733,11 @@ contract OPContractsManagerUpgrader is OPContractsManagerBase { | |
|
|
||
| /// @notice Upgrades a set of chains to the latest implementation contracts | ||
| /// @param _opChainConfigs Array of OpChain structs, one per chain to upgrade | ||
| /// @param _upgradeSuperchainConfig Flag to indicate if superchainConfig should be upgraded | ||
| /// @dev This function is intended to be DELEGATECALLed by an address that is the common owner of every chain in | ||
| /// `_opChainConfigs`'s ProxyAdmin. | ||
| /// @dev This function requires that each chain's superchainConfig is already upgraded. | ||
| function upgrade(OPContractsManager.OpChainConfig[] memory _opChainConfigs) external virtual { | ||
| function upgrade(OPContractsManager.OpChainConfig[] memory _opChainConfigs, bool _upgradeSuperchainConfig) external virtual { | ||
| // Grab the implementations. | ||
| OPContractsManager.Implementations memory impls = getImplementations(); | ||
|
|
||
|
|
@@ -745,11 +747,17 @@ contract OPContractsManagerUpgrader is OPContractsManagerBase { | |
| uint256 l2ChainId = _opChainConfigs[i].systemConfigProxy.l2ChainId(); | ||
|
|
||
| // Grab the SuperchainConfig. | ||
| ISuperchainConfig superchainConfig = _opChainConfigs[i].systemConfigProxy.superchainConfig(); | ||
| ISuperchainConfig celoSuperchainConfig = _opChainConfigs[i].systemConfigProxy.superchainConfig(); | ||
| ISuperchainConfig superchainConfig = IHasSuperchainConfig(address(celoSuperchainConfig)).superchainConfig(); | ||
|
|
||
| // SuperchainConfig should be in older version than impl on Celo L1. | ||
| if (!SemverComp.lt(superchainConfig.version(), ISuperchainConfig(impls.superchainConfigImpl).version())) { | ||
| revert OPContractsManagerUpgrader_SuperchainConfigMismatch(); | ||
| { | ||
| if (!SemverComp.lt(superchainConfig.version(), ISuperchainConfig(impls.superchainConfigImpl).version())) { | ||
| revert OPContractsManagerUpgrader_SuperchainConfigMismatch(); | ||
| } else if (_upgradeSuperchainConfig) { | ||
|
Comment on lines
+755
to
+757
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This version gate runs on every iteration and requires Useful? React with 👍 / 👎. |
||
| // Celo: some chains (like Celo Mainnet) follow external superchain config that is not desired to be upgraded | ||
| __upgradeSuperchainConfig(superchainConfig, _opChainConfigs[i].proxyAdmin); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
|
|
||
| // Do the chain upgrade. | ||
|
|
@@ -898,12 +906,16 @@ contract OPContractsManagerUpgrader is OPContractsManagerBase { | |
| } | ||
| } | ||
|
|
||
| function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig, IProxyAdmin _superchainProxyAdmin) external { | ||
| __upgradeSuperchainConfig(_superchainConfig, _superchainProxyAdmin); | ||
| } | ||
|
|
||
| /// @notice Upgrades the SuperchainConfig contract. | ||
| /// @param _superchainConfig The SuperchainConfig contract to upgrade. | ||
| /// @param _superchainProxyAdmin The ProxyAdmin contract to use for the upgrade. | ||
| /// @dev This function is intended to be DELEGATECALLed by the superchainConfig's ProxyAdminOwner. | ||
| /// @dev This function will revert if the SuperchainConfig is already at or above the target version. | ||
| function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig, IProxyAdmin _superchainProxyAdmin) external { | ||
| function __upgradeSuperchainConfig(ISuperchainConfig _superchainConfig, IProxyAdmin _superchainProxyAdmin) internal { | ||
| // Only upgrade the superchainConfig if the current version is less than the target version. | ||
| if ( | ||
| SemverComp.gte( | ||
|
|
@@ -2031,13 +2043,14 @@ contract OPContractsManager is ISemver { | |
|
|
||
| /// @notice Upgrades a set of chains to the latest implementation contracts | ||
| /// @param _opChainConfigs Array of OpChain structs, one per chain to upgrade | ||
| /// @param _upgradeSuperchainConfig Flag to indicate if superchainConfig should be upgraded | ||
| /// @dev This function is intended to be DELEGATECALLed by an address that is the common owner of every chain in | ||
| /// `_opChainConfigs`'s ProxyAdmin. | ||
| /// @dev This function requires that each chain's superchainConfig is already upgraded. | ||
| function upgrade(OpChainConfig[] memory _opChainConfigs) external virtual { | ||
| function upgrade(OpChainConfig[] memory _opChainConfigs, bool _upgradeSuperchainConfig) external virtual { | ||
| if (address(this) == address(thisOPCM)) revert OnlyDelegatecall(); | ||
|
|
||
| bytes memory data = abi.encodeCall(OPContractsManagerUpgrader.upgrade, (_opChainConfigs)); | ||
| bytes memory data = abi.encodeCall(OPContractsManagerUpgrader.upgrade, (_opChainConfigs, _upgradeSuperchainConfig)); | ||
| _performDelegateCall(address(opcmUpgrader), data); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ import { IAnchorStateRegistry } from "interfaces/dispute/IAnchorStateRegistry.so | |
| import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol"; | ||
| import { IL1CrossDomainMessenger } from "interfaces/L1/IL1CrossDomainMessenger.sol"; | ||
| import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol"; | ||
| import { IHasSuperchainConfig } from "interfaces/L1/IHasSuperchainConfig.sol"; | ||
| import { IOptimismMintableERC20Factory } from "interfaces/universal/IOptimismMintableERC20Factory.sol"; | ||
| import { IL1StandardBridge } from "interfaces/L1/IL1StandardBridge.sol"; | ||
| import { IL1ERC721Bridge } from "interfaces/L1/IL1ERC721Bridge.sol"; | ||
|
|
@@ -232,6 +233,10 @@ contract OPContractsManagerStandardValidator is ISemver { | |
| return _errors; | ||
| } | ||
|
|
||
| function celoSuperchainConfig(address _celoSuperchainConfig) internal view returns (ISuperchainConfig) { | ||
| return IHasSuperchainConfig(_celoSuperchainConfig).superchainConfig(); | ||
| } | ||
|
|
||
| /// @notice Asserts that the SystemConfig contract is valid. | ||
| function assertValidSystemConfig( | ||
| string memory _errors, | ||
|
|
@@ -261,13 +266,31 @@ contract OPContractsManagerStandardValidator is ISemver { | |
| _errors = internalRequire(_sysCfg.operatorFeeScalar() == 0, "SYSCON-110", _errors); | ||
| _errors = internalRequire(_sysCfg.operatorFeeConstant() == 0, "SYSCON-120", _errors); | ||
| _errors = internalRequire(getProxyAdmin(address(_sysCfg)) == _admin, "SYSCON-130", _errors); | ||
| _errors = internalRequire(_sysCfg.superchainConfig() == superchainConfig, "SYSCON-140", _errors); | ||
| _errors = internalRequire(celoSuperchainConfig(address(_sysCfg.superchainConfig())) == superchainConfig, "SYSCON-140", _errors); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This now assumes Useful? React with 👍 / 👎. |
||
|
|
||
| // CGT prevents Lockbox | ||
| if (_sysCfg.isCustomGasToken()) { | ||
| _errors = internalRequire(!_sysCfg.isFeatureEnabled(Features.ETH_LOCKBOX), "SYSCON-150", _errors); | ||
| } | ||
|
|
||
| // Celo extra validation: custom gas token | ||
| (address address_, uint8 decimals_) = _sysCfg.gasPayingToken(); | ||
| address expected_; | ||
| string memory name_; | ||
| if (address(_sysCfg) == address(0x760a5F022C9940f4A074e0030be682F560d29818)) { | ||
| // sepolia | ||
| expected_ = address(0x3C7011fD5e6Aed460cAa4985cF8d8Caba435b092); | ||
| name_ = "Celo"; | ||
| } else if (address(_sysCfg) == address(0x89E31965D844a309231B1f17759Ccaf1b7c09861)) { | ||
| // mainnet | ||
| expected_ = address(0x057898f3C43F129a17517B9056D23851F124b19f); | ||
| name_ = "Celo native asset"; | ||
| } | ||
| _errors = internalRequire(address_ == expected_, "SYSCON-CEL-10", _errors); | ||
| _errors = internalRequire(decimals_ == 18, "SYSCON-CEL-20", _errors); | ||
| _errors = internalRequire(LibString.eq(_sysCfg.gasPayingTokenName(), name_) , "SYSCON-CEL-30", _errors); | ||
| _errors = internalRequire(LibString.eq(_sysCfg.gasPayingTokenSymbol(), "CELO") , "SYSCON-CEL-40", _errors); | ||
|
|
||
| return _errors; | ||
| } | ||
|
|
||
|
|
@@ -421,6 +444,16 @@ contract OPContractsManagerStandardValidator is ISemver { | |
| _errors = internalRequire(address(_portal.systemConfig()) == address(_sysCfg), "PORTAL-40", _errors); | ||
| _errors = internalRequire(_portal.l2Sender() == Constants.DEFAULT_L2_SENDER, "PORTAL-80", _errors); | ||
| _errors = internalRequire(getProxyAdmin(address(_portal)) == _admin, "PORTAL-90", _errors); | ||
|
|
||
| // Celo extra validation: celo superchain config vs external superchain config | ||
| address celoSuperchainConfig_ = address(_portal.superchainConfig()); | ||
| _errors = internalRequire( | ||
| _portal.guardian() != superchainConfig.guardian(), "PORTAL-CEL-10", _errors | ||
| ); // True only for Celo Mainnet | ||
| _errors = internalRequire( | ||
| _portal.guardian() == ISuperchainConfig(celoSuperchainConfig_).guardian(), "PORTAL-CEL-20", _errors | ||
| ); // True for Celo Mainnet & Celo Testnets | ||
|
|
||
| return _errors; | ||
| } | ||
|
|
||
|
|
@@ -451,7 +484,7 @@ contract OPContractsManagerStandardValidator is ISemver { | |
| _errors = internalRequire(_lockbox.systemConfig() == _sysCfg, "LOCKBOX-40", _errors); | ||
| _errors = internalRequire(_lockbox.authorizedPortals(_portal), "LOCKBOX-50", _errors); | ||
| // Lockbox is not compatible with CGT | ||
| _errors = internalRequire(!_sysCfg.isCustomGasToken(), "LOCKBOX-60", _errors); | ||
| _errors = internalRequire(!_sysCfg.isCustomGasToken(), "LOCKBOX-CEL-10", _errors); | ||
| return _errors; | ||
| } | ||
|
|
||
|
|
||
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.
This loop checks that
superchainConfig.version() < targetfor every chain, then conditionally upgrades SuperchainConfig inside the same loop. If multiple entries reference the same underlying SuperchainConfig and_upgradeSuperchainConfigis enabled, the first iteration upgrades it and the next iteration fails this< targetcheck, reverting the whole batched chain upgrade.Useful? React with 👍 / 👎.