From b012e5f151d06640e7802f3f8779f73482907b94 Mon Sep 17 00:00:00 2001 From: Wazabie <48911235+Wazabie@users.noreply.github.com> Date: Wed, 23 Jul 2025 20:06:47 +0200 Subject: [PATCH 1/3] U13 to U16 template and example task Adding initial files --- src/improvements/template/U13_to_U16.sol | 219 ++++++++++++++++++ test/tasks/example/sep/019-u13-to-u16/.env | 1 + .../example/sep/019-u13-to-u16/config.toml | 49 ++++ 3 files changed, 269 insertions(+) create mode 100644 src/improvements/template/U13_to_U16.sol create mode 100644 test/tasks/example/sep/019-u13-to-u16/.env create mode 100644 test/tasks/example/sep/019-u13-to-u16/config.toml diff --git a/src/improvements/template/U13_to_U16.sol b/src/improvements/template/U13_to_U16.sol new file mode 100644 index 0000000000..fd34d7cec0 --- /dev/null +++ b/src/improvements/template/U13_to_U16.sol @@ -0,0 +1,219 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.15; + +import { + IOPContractsManager, + ISystemConfig, + IProxyAdmin +} from "@eth-optimism-bedrock/interfaces/L1/IOPContractsManager.sol"; + +import {Claim} from "@eth-optimism-bedrock/src/dispute/lib/Types.sol"; +import {VmSafe} from "forge-std/Vm.sol"; +import {stdToml} from "forge-std/StdToml.sol"; +import {LibString} from "solady/utils/LibString.sol"; + +import {console2 as console} from "forge-std/console2.sol"; + +import {OPCMTaskBase} from "src/improvements/tasks/types/OPCMTaskBase.sol"; +import {SuperchainAddressRegistry} from "src/improvements/SuperchainAddressRegistry.sol"; +import {Action} from "src/libraries/MultisigTypes.sol"; + +contract Upgrade_U12_to_U16 is OPCMTaskBase { + using stdToml for string; + using LibString for string; + + /// @notice Validator for final state + IStandardValidatorV400 public STANDARD_VALIDATOR_V400; + + /// @notice Address of the OPCM for U13, U14, U15 and U16 + /// @dev These addresses are set in the config.toml file. + address public OPCM_V200; + address public OPCM_V300; + address public OPCM_V400; + + /// @notice Struct to store inputs for OPCM.upgrade() function per L2 chain + struct OPCMUpgrade { + Claim absolutePrestate; + uint256 chainId; + string expectedValidationErrors; + } + + /// @notice Mapping from chain ID to upgrade parameters + mapping(uint256 => OPCMUpgrade) public upgrades; + + /// @notice Returns the storage write permissions + function _taskStorageWrites() internal view virtual override returns (string[] memory) { + string[] memory storageWrites = new string[](14); + storageWrites[0] = "ProxyAdminOwner"; + storageWrites[1] = "OPCM"; + storageWrites[2] = "SuperchainConfig"; + storageWrites[3] = "DisputeGameFactoryProxy"; + storageWrites[4] = "SystemConfigProxy"; + storageWrites[5] = "OptimismPortalProxy"; + storageWrites[6] = "AddressManager"; + storageWrites[7] = "L1CrossDomainMessengerProxy"; + storageWrites[8] = "L1StandardBridgeProxy"; + storageWrites[9] = "L1ERC721BridgeProxy"; + storageWrites[10] = "ProtocolVersions"; + storageWrites[11] = "OptimismMintableERC20FactoryProxy"; + storageWrites[12] = "PermissionedWETH"; + storageWrites[13] = "PermissionlessWETH"; + return storageWrites; + } + + /// @notice Returns an array of strings that refer to contract names in the address registry. + /// Contracts with these names are expected to have their balance changes during the task. + /// By default returns an empty array. Override this function if your task expects balance changes. + function _taskBalanceChanges() internal view virtual override returns (string[] memory) { + string[] memory balanceChanges = new string[](1); + balanceChanges[0] = "OptimismPortalProxy"; + // Not adding EthLockboxProxy because we do not perform balance checks on newly deployed contracts. + return balanceChanges; + } + + /// @notice Parses TOML and initializes contract state for upgrade + function _templateSetup(string memory taskConfigFilePath, address rootSafe) internal override { + super._templateSetup(taskConfigFilePath, rootSafe); + string memory tomlContent = vm.readFile(taskConfigFilePath); + + OPCMUpgrade[] memory parsedUpgrades = abi.decode(tomlContent.parseRaw(".opcmUpgrades"), (OPCMUpgrade[])); + for (uint256 i = 0; i < parsedUpgrades.length; i++) { + console.log("Adding upgrade - chainID: %s", parsedUpgrades[i].chainId); + console.logBytes32(Claim.unwrap(parsedUpgrades[i].absolutePrestate)); + console.log("Expected errors: %s", parsedUpgrades[i].expectedValidationErrors); + upgrades[parsedUpgrades[i].chainId] = parsedUpgrades[i]; + } + + // === OPCM for U13 === + OPCM_V200 = tomlContent.readAddress(".addresses.OPCMUpgradeV200"); + require(IOPContractsManager(OPCM_V200).version().eq("1.6.0"), "Incorrect OPCM"); + vm.label(OPCM_V200, "OPCMUpgradeV200"); + + // === Upgrade to U14 and U15 === + OPCM_V300 = tomlContent.readAddress(".addresses.OPCMUpgradeV300"); + require(IOPContractsManager(OPCM_V300).version().eq("1.9.0"), "Incorrect OPCM - expected version 1.9.0"); + vm.label(OPCM_V300, "OPCMUpgradeV300"); + + // === Upgrade to U16 === + OPCM_V400 = tomlContent.readAddress(".addresses.OPCMUpgradeV400"); + require(IOPContractsManager(OPCM_V400).version().eq("2.4.0"), "Incorrect OPCM - expected version 2.4.0"); + vm.label(OPCM_V400, "OPCMUpgradeV400"); + + // === Standard Validator for U16 === + STANDARD_VALIDATOR_V400 = IStandardValidatorV400(tomlContent.readAddress(".addresses.StandardValidatorV400")); + require(address(STANDARD_VALIDATOR_V400).code.length > 0, "ValidatorV400 not deployed"); + vm.label(address(STANDARD_VALIDATOR_V400), "StandardValidatorV400"); + } + + /// @notice Performs the atomic upgrade (U12 to U16) for all chains + function _build(address) internal override { + SuperchainAddressRegistry.ChainInfo[] memory chains = superchainAddrRegistry.getChains(); + IOPContractsManager.OpChainConfig[] memory opChainConfigs = + new IOPContractsManager.OpChainConfig[](chains.length); + + // === Upgrade to U13 === + for (uint256 i = 0; i < chains.length; i++) { + uint256 chainId = chains[i].chainId; + opChainConfigs[i] = IOPContractsManager.OpChainConfig({ + systemConfigProxy: ISystemConfig(superchainAddrRegistry.getAddress("SystemConfigProxy", chains[i].chainId)), + proxyAdmin: IProxyAdmin(superchainAddrRegistry.getAddress("ProxyAdmin", chains[i].chainId)), + absolutePrestate: upgrades[chainId].absolutePrestate + }); + } + + (bool success1,) = OPCM_V200.delegatecall(abi.encodeCall(IOPContractsManager.upgrade, (opChainConfigs))); + require(success1, "OPCMUpgradeV200: upgrade call failed in _build."); + + // === Upgrade to U14 === + for (uint256 i = 0; i < chains.length; i++) { + uint256 chainId = chains[i].chainId; + opChainConfigs[i] = IOPContractsManager.OpChainConfig({ + systemConfigProxy: ISystemConfig(superchainAddrRegistry.getAddress("SystemConfigProxy", chainId)), + proxyAdmin: IProxyAdmin(superchainAddrRegistry.getAddress("ProxyAdmin", chainId)), + absolutePrestate: upgrades[chainId].absolutePrestate + }); + } + + (bool success2,) = OPCM_V300.delegatecall(abi.encodeCall(IOPContractsManager.upgrade, (opChainConfigs))); + require(success2, "OPCMUpgradeV300: upgrade call failed in _build."); + + // === Upgrade to U15 === + for (uint256 i = 0; i < chains.length; i++) { + uint256 chainId = chains[i].chainId; + opChainConfigs[i] = IOPContractsManager.OpChainConfig({ + systemConfigProxy: ISystemConfig(superchainAddrRegistry.getAddress("SystemConfigProxy", chainId)), + proxyAdmin: IProxyAdmin(superchainAddrRegistry.getAddress("ProxyAdmin", chainId)), + absolutePrestate: upgrades[chainId].absolutePrestate + }); + } + + (bool success3,) = + OPCM_V300.delegatecall(abi.encodeWithSelector(IOPCMPrestateUpdate.updatePrestate.selector, opChainConfigs)); + require(success3, "OPCM.updatePrestate() failed"); + + // === Upgrade to U16 === + for (uint256 i = 0; i < chains.length; i++) { + uint256 chainId = chains[i].chainId; + opChainConfigs[i] = IOPContractsManager.OpChainConfig({ + systemConfigProxy: ISystemConfig(superchainAddrRegistry.getAddress("SystemConfigProxy", chainId)), + proxyAdmin: IProxyAdmin(superchainAddrRegistry.getAddress("ProxyAdmin", chainId)), + absolutePrestate: upgrades[chainId].absolutePrestate + }); + } + + // Delegatecall the OPCM.upgrade() function + (bool success4,) = + OPCM_V400.delegatecall(abi.encodeWithSelector(IOPContractsManager.upgrade.selector, opChainConfigs)); + require(success4, "OPCMUpgradeV400: Delegatecall failed in _build."); + } + + /// @notice Validates final post-upgrade state + function _validate(VmSafe.AccountAccess[] memory, Action[] memory, address) internal view override { + SuperchainAddressRegistry.ChainInfo[] memory chains = superchainAddrRegistry.getChains(); + for (uint256 i = 0; i < chains.length; i++) { + uint256 chainId = chains[i].chainId; + bytes32 expAbsolutePrestate = Claim.unwrap(upgrades[chainId].absolutePrestate); + string memory expErrors = upgrades[chainId].expectedValidationErrors; + address proxyAdmin = superchainAddrRegistry.getAddress("ProxyAdmin", chainId); + address sysCfg = superchainAddrRegistry.getAddress("SystemConfigProxy", chainId); + + IStandardValidatorV400.InputV400 memory input = IStandardValidatorV400.InputV400({ + proxyAdmin: proxyAdmin, + sysCfg: sysCfg, + absolutePrestate: expAbsolutePrestate, + l2ChainID: chainId + }); + + string memory errors = STANDARD_VALIDATOR_V400.validate({_input: input, _allowFailure: true}); + + require(errors.eq(expErrors), string.concat("Unexpected errors: ", errors, "; expected: ", expErrors)); + } + } + + /// @notice No code exceptions for this template + function _getCodeExceptions() internal view virtual override returns (address[] memory) { + return new address[](0); + } + + +} + +interface IOPCMPrestateUpdate { + function updatePrestate(IOPContractsManager.OpChainConfig[] memory _prestateUpdateInputs) external; +} + +/// @notice Final validator interface +interface IStandardValidatorV400 { + struct InputV400 { + address proxyAdmin; + address sysCfg; + bytes32 absolutePrestate; + uint256 l2ChainID; + } + + function validate(InputV400 memory _input, bool _allowFailure) external view returns (string memory); + + function mipsVersion() external pure returns (string memory); + + function systemConfigVersion() external pure returns (string memory); +} \ No newline at end of file diff --git a/test/tasks/example/sep/019-u13-to-u16/.env b/test/tasks/example/sep/019-u13-to-u16/.env new file mode 100644 index 0000000000..4998d8dea3 --- /dev/null +++ b/test/tasks/example/sep/019-u13-to-u16/.env @@ -0,0 +1 @@ +FORK_BLOCK_NUMBER=8826542 diff --git a/test/tasks/example/sep/019-u13-to-u16/config.toml b/test/tasks/example/sep/019-u13-to-u16/config.toml new file mode 100644 index 0000000000..c7bd1c55b5 --- /dev/null +++ b/test/tasks/example/sep/019-u13-to-u16/config.toml @@ -0,0 +1,49 @@ +templateName = "U13_to_U16" + + +[[l2chains]] +chainId = 7897 +name = "arena-z" + + +[[opcmUpgrades]] +chainId = 7897 +# prestates."1.6.1-rc.1 +# https://github.com/ethereum-optimism/superchain-registry/blob/d82a61168fd1d7ef522ed8e213ce23c853031495/validation/standard/standard-prestates.toml#L6 +absolutePrestate = "0x03eb07101fbdeaf3f04d9fb76526362c1eea2824e4c6e970bdb19675b72e4fc8" +expectedValidationErrors = "" + + +[addresses] +OPCMUpgradeV200 = "0x026b2F158255Beac46c1E7c6b8BbF29A4b6A7B76" # version 1.6.0 https://github.com/ethereum-optimism/superchain-registry/blob/212c60902834aba05d73d33bc2fcefc21fc3a7af/validation/standard/standard-versions-mainnet.toml#L140C26-L140C43 +# StandardValidatorV200 = "0xecabaeaa1d58261f1579232520c5b460ca58a164" # + +OPCMUpgradeV300 = "0x3a1f523a4bc09cd344a2745a108bb0398288094f" # version 1.9.0 https://github.com/ethereum-optimism/superchain-registry/blob/212c60902834aba05d73d33bc2fcefc21fc3a7af/validation/standard/standard-versions-mainnet.toml#L82 +# StandardValidatorV300 = "0xf989Df70FB46c581ba6157Ab335c0833bA60e1f0" # + +OPCMUpgradeV400 = "0x56ebc5c4870f5367b836081610592241ad3e0734" # version 2.4.0 https://github.com/ethereum-optimism/superchain-registry/blob/212c60902834aba05d73d33bc2fcefc21fc3a7af/validation/standard/standard-versions-mainnet.toml#L22 +StandardValidatorV400 = "0xbb43313d206a9b02032c749ca0828a07c962b4b5" # + + +[stateOverrides] +0x1Eb2fFc903729a0F03966B917003800b145F56E2 = [ + { key = "0x0000000000000000000000000000000000000000000000000000000000000005", value = 32 } +] + +0xDEe57160aAfCF04c34C887B5962D0a69676d3C8B = [ + { key = "0x0000000000000000000000000000000000000000000000000000000000000005", value = 46 } +] + +0xf64bc17485f0B4Ea5F06A96514182FC4cB561977 = [ + { key = "0x0000000000000000000000000000000000000000000000000000000000000005", value = 43 } +] + +# Override the SuperchainConfig implementation address. This is necessary to prevent an attempt to +# upgrade the SuperchainConfig by the wrong L1 ProxyAdmin owner. +0xC2Be75506d5724086DEB7245bd260Cc9753911Be = [ + {key = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc", value = "0x000000000000000000000000ce28685eb204186b557133766eca00334eb441e4"} +] +# 'isRC' flag on OPCM needs to be set here because 014-U16-opcm-upgrade-v400-op-ink sets it. +0x1ac76f0833bbfccc732cadcc3ba8a3bbd0e89c3d = [ + {key = "0x0000000000000000000000000000000000000000000000000000000000000001", value = "0x0000000000000000000000000000000000000000000000000000000000000000"} +] \ No newline at end of file From c11302c6aa0f58b8945160b6bcdf3ecaaf5f8e1a Mon Sep 17 00:00:00 2001 From: Wazabie <48911235+Wazabie@users.noreply.github.com> Date: Fri, 1 Aug 2025 19:10:36 +0200 Subject: [PATCH 2/3] Update SetRespectedGameTypeTemplate.sol --- .../template/SetRespectedGameTypeTemplate.sol | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/improvements/template/SetRespectedGameTypeTemplate.sol b/src/improvements/template/SetRespectedGameTypeTemplate.sol index baf09f5c57..e2c1060ec5 100644 --- a/src/improvements/template/SetRespectedGameTypeTemplate.sol +++ b/src/improvements/template/SetRespectedGameTypeTemplate.sol @@ -13,6 +13,8 @@ import {L2TaskBase} from "src/improvements/tasks/types/L2TaskBase.sol"; import {SuperchainAddressRegistry} from "src/improvements/SuperchainAddressRegistry.sol"; import {Action} from "src/libraries/MultisigTypes.sol"; +import {IAnchorStateRegistry} from "lib/optimism/packages/contracts-bedrock/interfaces/IAnchorStateRegistry.sol"; + /// @title SetRespectedGameTypeTemplate /// @notice This template is used to set the respected game type in the OptimismPortal2 contract /// for a given chain or set of chains. @@ -38,7 +40,7 @@ contract SetRespectedGameTypeTemplate is L2TaskBase { string[] memory storageWrites = new string[](3); storageWrites[0] = "DeputyGuardianModule"; storageWrites[1] = "Guardian"; - storageWrites[2] = "OptimismPortalProxy"; + storageWrites[2] = "AnchorStateRegistry"; return storageWrites; } @@ -62,8 +64,8 @@ contract SetRespectedGameTypeTemplate is L2TaskBase { SuperchainAddressRegistry.ChainInfo[] memory chains = superchainAddrRegistry.getChains(); for (uint256 i = 0; i < chains.length; i++) { uint256 chainId = chains[i].chainId; - address portalAddress = superchainAddrRegistry.getAddress("OptimismPortalProxy", chainId); - dgm.setRespectedGameType(IOptimismPortal2(payable(portalAddress)), cfg[chainId].gameType); + address asrAddress = superchainAddrRegistry.getAddress("AnchorStateRegistry", chainId); + dgm.setRespectedGameType(IAnchorStateRegistry(payable(asrAddress)), cfg[chainId].gameType); } } @@ -73,9 +75,10 @@ contract SetRespectedGameTypeTemplate is L2TaskBase { SuperchainAddressRegistry.ChainInfo[] memory chains = superchainAddrRegistry.getChains(); for (uint256 i = 0; i < chains.length; i++) { uint256 chainId = chains[i].chainId; - address portalAddress = superchainAddrRegistry.getAddress("OptimismPortalProxy", chainId); - IOptimismPortal2 portal = IOptimismPortal2(payable(portalAddress)); - assertEq(portal.respectedGameType().raw(), cfg[chainId].gameType.raw()); + address asrAddress = superchainAddrRegistry.getAddress("AnchorStateRegistry", chainId); + IAnchorStateRegistry asr = IAnchorStateRegistry(payable(asrAddress)); + assertEq(asr.respectedGameType().raw(), cfg[chainId].gameType.raw()); + } } From f7e6b29372101a0a129b93c3d54f735a74be97ea Mon Sep 17 00:00:00 2001 From: Wazabie <48911235+Wazabie@users.noreply.github.com> Date: Fri, 1 Aug 2025 19:12:50 +0200 Subject: [PATCH 3/3] Remove U13>U16 --- src/improvements/template/U13_to_U16.sol | 219 ------------------ test/tasks/example/sep/019-u13-to-u16/.env | 1 - .../example/sep/019-u13-to-u16/config.toml | 49 ---- 3 files changed, 269 deletions(-) delete mode 100644 src/improvements/template/U13_to_U16.sol delete mode 100644 test/tasks/example/sep/019-u13-to-u16/.env delete mode 100644 test/tasks/example/sep/019-u13-to-u16/config.toml diff --git a/src/improvements/template/U13_to_U16.sol b/src/improvements/template/U13_to_U16.sol deleted file mode 100644 index fd34d7cec0..0000000000 --- a/src/improvements/template/U13_to_U16.sol +++ /dev/null @@ -1,219 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.15; - -import { - IOPContractsManager, - ISystemConfig, - IProxyAdmin -} from "@eth-optimism-bedrock/interfaces/L1/IOPContractsManager.sol"; - -import {Claim} from "@eth-optimism-bedrock/src/dispute/lib/Types.sol"; -import {VmSafe} from "forge-std/Vm.sol"; -import {stdToml} from "forge-std/StdToml.sol"; -import {LibString} from "solady/utils/LibString.sol"; - -import {console2 as console} from "forge-std/console2.sol"; - -import {OPCMTaskBase} from "src/improvements/tasks/types/OPCMTaskBase.sol"; -import {SuperchainAddressRegistry} from "src/improvements/SuperchainAddressRegistry.sol"; -import {Action} from "src/libraries/MultisigTypes.sol"; - -contract Upgrade_U12_to_U16 is OPCMTaskBase { - using stdToml for string; - using LibString for string; - - /// @notice Validator for final state - IStandardValidatorV400 public STANDARD_VALIDATOR_V400; - - /// @notice Address of the OPCM for U13, U14, U15 and U16 - /// @dev These addresses are set in the config.toml file. - address public OPCM_V200; - address public OPCM_V300; - address public OPCM_V400; - - /// @notice Struct to store inputs for OPCM.upgrade() function per L2 chain - struct OPCMUpgrade { - Claim absolutePrestate; - uint256 chainId; - string expectedValidationErrors; - } - - /// @notice Mapping from chain ID to upgrade parameters - mapping(uint256 => OPCMUpgrade) public upgrades; - - /// @notice Returns the storage write permissions - function _taskStorageWrites() internal view virtual override returns (string[] memory) { - string[] memory storageWrites = new string[](14); - storageWrites[0] = "ProxyAdminOwner"; - storageWrites[1] = "OPCM"; - storageWrites[2] = "SuperchainConfig"; - storageWrites[3] = "DisputeGameFactoryProxy"; - storageWrites[4] = "SystemConfigProxy"; - storageWrites[5] = "OptimismPortalProxy"; - storageWrites[6] = "AddressManager"; - storageWrites[7] = "L1CrossDomainMessengerProxy"; - storageWrites[8] = "L1StandardBridgeProxy"; - storageWrites[9] = "L1ERC721BridgeProxy"; - storageWrites[10] = "ProtocolVersions"; - storageWrites[11] = "OptimismMintableERC20FactoryProxy"; - storageWrites[12] = "PermissionedWETH"; - storageWrites[13] = "PermissionlessWETH"; - return storageWrites; - } - - /// @notice Returns an array of strings that refer to contract names in the address registry. - /// Contracts with these names are expected to have their balance changes during the task. - /// By default returns an empty array. Override this function if your task expects balance changes. - function _taskBalanceChanges() internal view virtual override returns (string[] memory) { - string[] memory balanceChanges = new string[](1); - balanceChanges[0] = "OptimismPortalProxy"; - // Not adding EthLockboxProxy because we do not perform balance checks on newly deployed contracts. - return balanceChanges; - } - - /// @notice Parses TOML and initializes contract state for upgrade - function _templateSetup(string memory taskConfigFilePath, address rootSafe) internal override { - super._templateSetup(taskConfigFilePath, rootSafe); - string memory tomlContent = vm.readFile(taskConfigFilePath); - - OPCMUpgrade[] memory parsedUpgrades = abi.decode(tomlContent.parseRaw(".opcmUpgrades"), (OPCMUpgrade[])); - for (uint256 i = 0; i < parsedUpgrades.length; i++) { - console.log("Adding upgrade - chainID: %s", parsedUpgrades[i].chainId); - console.logBytes32(Claim.unwrap(parsedUpgrades[i].absolutePrestate)); - console.log("Expected errors: %s", parsedUpgrades[i].expectedValidationErrors); - upgrades[parsedUpgrades[i].chainId] = parsedUpgrades[i]; - } - - // === OPCM for U13 === - OPCM_V200 = tomlContent.readAddress(".addresses.OPCMUpgradeV200"); - require(IOPContractsManager(OPCM_V200).version().eq("1.6.0"), "Incorrect OPCM"); - vm.label(OPCM_V200, "OPCMUpgradeV200"); - - // === Upgrade to U14 and U15 === - OPCM_V300 = tomlContent.readAddress(".addresses.OPCMUpgradeV300"); - require(IOPContractsManager(OPCM_V300).version().eq("1.9.0"), "Incorrect OPCM - expected version 1.9.0"); - vm.label(OPCM_V300, "OPCMUpgradeV300"); - - // === Upgrade to U16 === - OPCM_V400 = tomlContent.readAddress(".addresses.OPCMUpgradeV400"); - require(IOPContractsManager(OPCM_V400).version().eq("2.4.0"), "Incorrect OPCM - expected version 2.4.0"); - vm.label(OPCM_V400, "OPCMUpgradeV400"); - - // === Standard Validator for U16 === - STANDARD_VALIDATOR_V400 = IStandardValidatorV400(tomlContent.readAddress(".addresses.StandardValidatorV400")); - require(address(STANDARD_VALIDATOR_V400).code.length > 0, "ValidatorV400 not deployed"); - vm.label(address(STANDARD_VALIDATOR_V400), "StandardValidatorV400"); - } - - /// @notice Performs the atomic upgrade (U12 to U16) for all chains - function _build(address) internal override { - SuperchainAddressRegistry.ChainInfo[] memory chains = superchainAddrRegistry.getChains(); - IOPContractsManager.OpChainConfig[] memory opChainConfigs = - new IOPContractsManager.OpChainConfig[](chains.length); - - // === Upgrade to U13 === - for (uint256 i = 0; i < chains.length; i++) { - uint256 chainId = chains[i].chainId; - opChainConfigs[i] = IOPContractsManager.OpChainConfig({ - systemConfigProxy: ISystemConfig(superchainAddrRegistry.getAddress("SystemConfigProxy", chains[i].chainId)), - proxyAdmin: IProxyAdmin(superchainAddrRegistry.getAddress("ProxyAdmin", chains[i].chainId)), - absolutePrestate: upgrades[chainId].absolutePrestate - }); - } - - (bool success1,) = OPCM_V200.delegatecall(abi.encodeCall(IOPContractsManager.upgrade, (opChainConfigs))); - require(success1, "OPCMUpgradeV200: upgrade call failed in _build."); - - // === Upgrade to U14 === - for (uint256 i = 0; i < chains.length; i++) { - uint256 chainId = chains[i].chainId; - opChainConfigs[i] = IOPContractsManager.OpChainConfig({ - systemConfigProxy: ISystemConfig(superchainAddrRegistry.getAddress("SystemConfigProxy", chainId)), - proxyAdmin: IProxyAdmin(superchainAddrRegistry.getAddress("ProxyAdmin", chainId)), - absolutePrestate: upgrades[chainId].absolutePrestate - }); - } - - (bool success2,) = OPCM_V300.delegatecall(abi.encodeCall(IOPContractsManager.upgrade, (opChainConfigs))); - require(success2, "OPCMUpgradeV300: upgrade call failed in _build."); - - // === Upgrade to U15 === - for (uint256 i = 0; i < chains.length; i++) { - uint256 chainId = chains[i].chainId; - opChainConfigs[i] = IOPContractsManager.OpChainConfig({ - systemConfigProxy: ISystemConfig(superchainAddrRegistry.getAddress("SystemConfigProxy", chainId)), - proxyAdmin: IProxyAdmin(superchainAddrRegistry.getAddress("ProxyAdmin", chainId)), - absolutePrestate: upgrades[chainId].absolutePrestate - }); - } - - (bool success3,) = - OPCM_V300.delegatecall(abi.encodeWithSelector(IOPCMPrestateUpdate.updatePrestate.selector, opChainConfigs)); - require(success3, "OPCM.updatePrestate() failed"); - - // === Upgrade to U16 === - for (uint256 i = 0; i < chains.length; i++) { - uint256 chainId = chains[i].chainId; - opChainConfigs[i] = IOPContractsManager.OpChainConfig({ - systemConfigProxy: ISystemConfig(superchainAddrRegistry.getAddress("SystemConfigProxy", chainId)), - proxyAdmin: IProxyAdmin(superchainAddrRegistry.getAddress("ProxyAdmin", chainId)), - absolutePrestate: upgrades[chainId].absolutePrestate - }); - } - - // Delegatecall the OPCM.upgrade() function - (bool success4,) = - OPCM_V400.delegatecall(abi.encodeWithSelector(IOPContractsManager.upgrade.selector, opChainConfigs)); - require(success4, "OPCMUpgradeV400: Delegatecall failed in _build."); - } - - /// @notice Validates final post-upgrade state - function _validate(VmSafe.AccountAccess[] memory, Action[] memory, address) internal view override { - SuperchainAddressRegistry.ChainInfo[] memory chains = superchainAddrRegistry.getChains(); - for (uint256 i = 0; i < chains.length; i++) { - uint256 chainId = chains[i].chainId; - bytes32 expAbsolutePrestate = Claim.unwrap(upgrades[chainId].absolutePrestate); - string memory expErrors = upgrades[chainId].expectedValidationErrors; - address proxyAdmin = superchainAddrRegistry.getAddress("ProxyAdmin", chainId); - address sysCfg = superchainAddrRegistry.getAddress("SystemConfigProxy", chainId); - - IStandardValidatorV400.InputV400 memory input = IStandardValidatorV400.InputV400({ - proxyAdmin: proxyAdmin, - sysCfg: sysCfg, - absolutePrestate: expAbsolutePrestate, - l2ChainID: chainId - }); - - string memory errors = STANDARD_VALIDATOR_V400.validate({_input: input, _allowFailure: true}); - - require(errors.eq(expErrors), string.concat("Unexpected errors: ", errors, "; expected: ", expErrors)); - } - } - - /// @notice No code exceptions for this template - function _getCodeExceptions() internal view virtual override returns (address[] memory) { - return new address[](0); - } - - -} - -interface IOPCMPrestateUpdate { - function updatePrestate(IOPContractsManager.OpChainConfig[] memory _prestateUpdateInputs) external; -} - -/// @notice Final validator interface -interface IStandardValidatorV400 { - struct InputV400 { - address proxyAdmin; - address sysCfg; - bytes32 absolutePrestate; - uint256 l2ChainID; - } - - function validate(InputV400 memory _input, bool _allowFailure) external view returns (string memory); - - function mipsVersion() external pure returns (string memory); - - function systemConfigVersion() external pure returns (string memory); -} \ No newline at end of file diff --git a/test/tasks/example/sep/019-u13-to-u16/.env b/test/tasks/example/sep/019-u13-to-u16/.env deleted file mode 100644 index 4998d8dea3..0000000000 --- a/test/tasks/example/sep/019-u13-to-u16/.env +++ /dev/null @@ -1 +0,0 @@ -FORK_BLOCK_NUMBER=8826542 diff --git a/test/tasks/example/sep/019-u13-to-u16/config.toml b/test/tasks/example/sep/019-u13-to-u16/config.toml deleted file mode 100644 index c7bd1c55b5..0000000000 --- a/test/tasks/example/sep/019-u13-to-u16/config.toml +++ /dev/null @@ -1,49 +0,0 @@ -templateName = "U13_to_U16" - - -[[l2chains]] -chainId = 7897 -name = "arena-z" - - -[[opcmUpgrades]] -chainId = 7897 -# prestates."1.6.1-rc.1 -# https://github.com/ethereum-optimism/superchain-registry/blob/d82a61168fd1d7ef522ed8e213ce23c853031495/validation/standard/standard-prestates.toml#L6 -absolutePrestate = "0x03eb07101fbdeaf3f04d9fb76526362c1eea2824e4c6e970bdb19675b72e4fc8" -expectedValidationErrors = "" - - -[addresses] -OPCMUpgradeV200 = "0x026b2F158255Beac46c1E7c6b8BbF29A4b6A7B76" # version 1.6.0 https://github.com/ethereum-optimism/superchain-registry/blob/212c60902834aba05d73d33bc2fcefc21fc3a7af/validation/standard/standard-versions-mainnet.toml#L140C26-L140C43 -# StandardValidatorV200 = "0xecabaeaa1d58261f1579232520c5b460ca58a164" # - -OPCMUpgradeV300 = "0x3a1f523a4bc09cd344a2745a108bb0398288094f" # version 1.9.0 https://github.com/ethereum-optimism/superchain-registry/blob/212c60902834aba05d73d33bc2fcefc21fc3a7af/validation/standard/standard-versions-mainnet.toml#L82 -# StandardValidatorV300 = "0xf989Df70FB46c581ba6157Ab335c0833bA60e1f0" # - -OPCMUpgradeV400 = "0x56ebc5c4870f5367b836081610592241ad3e0734" # version 2.4.0 https://github.com/ethereum-optimism/superchain-registry/blob/212c60902834aba05d73d33bc2fcefc21fc3a7af/validation/standard/standard-versions-mainnet.toml#L22 -StandardValidatorV400 = "0xbb43313d206a9b02032c749ca0828a07c962b4b5" # - - -[stateOverrides] -0x1Eb2fFc903729a0F03966B917003800b145F56E2 = [ - { key = "0x0000000000000000000000000000000000000000000000000000000000000005", value = 32 } -] - -0xDEe57160aAfCF04c34C887B5962D0a69676d3C8B = [ - { key = "0x0000000000000000000000000000000000000000000000000000000000000005", value = 46 } -] - -0xf64bc17485f0B4Ea5F06A96514182FC4cB561977 = [ - { key = "0x0000000000000000000000000000000000000000000000000000000000000005", value = 43 } -] - -# Override the SuperchainConfig implementation address. This is necessary to prevent an attempt to -# upgrade the SuperchainConfig by the wrong L1 ProxyAdmin owner. -0xC2Be75506d5724086DEB7245bd260Cc9753911Be = [ - {key = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc", value = "0x000000000000000000000000ce28685eb204186b557133766eca00334eb441e4"} -] -# 'isRC' flag on OPCM needs to be set here because 014-U16-opcm-upgrade-v400-op-ink sets it. -0x1ac76f0833bbfccc732cadcc3ba8a3bbd0e89c3d = [ - {key = "0x0000000000000000000000000000000000000000000000000000000000000001", value = "0x0000000000000000000000000000000000000000000000000000000000000000"} -] \ No newline at end of file