From feb3a1af841e34b0bacb7be313808b35fb9f0546 Mon Sep 17 00:00:00 2001 From: Maurelian Date: Wed, 2 Oct 2024 14:42:48 -0400 Subject: [PATCH 1/3] feat: delete unused deploy functions --- .../scripts/deploy/Deploy.s.sol | 162 +----------------- 1 file changed, 1 insertion(+), 161 deletions(-) diff --git a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol index 01ef668c2073..f1a6af9a533a 100644 --- a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol @@ -603,27 +603,6 @@ contract Deploy is Deployer { require(initialized != 0); } - /// @notice Deploy the L1CrossDomainMessenger - function deployL1CrossDomainMessenger() public broadcast returns (address addr_) { - IL1CrossDomainMessenger messenger = IL1CrossDomainMessenger( - DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "L1CrossDomainMessenger", - _args: DeployUtils.encodeConstructor(abi.encodeCall(IL1CrossDomainMessenger.__constructor__, ())) - }) - ); - - // Override the `L1CrossDomainMessenger` contract to the deployed implementation. This is necessary - // to check the `L1CrossDomainMessenger` implementation alongside dependent contracts, which - // are always proxies. - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.L1CrossDomainMessenger = address(messenger); - ChainAssertions.checkL1CrossDomainMessenger({ _contracts: contracts, _vm: vm, _isProxy: false }); - - addr_ = address(messenger); - } - /// @notice Deploy the OptimismPortal function deployOptimismPortal() public broadcast returns (address addr_) { if (cfg.useInterop()) { @@ -672,34 +651,6 @@ contract Deploy is Deployer { ChainAssertions.checkOptimismPortal2({ _contracts: contracts, _cfg: cfg, _isProxy: false }); } - /// @notice Deploy the OptimismPortalInterop contract - function deployOptimismPortalInterop() public broadcast returns (address addr_) { - // Could also verify this inside DeployConfig but doing it here is a bit more reliable. - require( - uint32(cfg.respectedGameType()) == cfg.respectedGameType(), "Deploy: respectedGameType must fit into uint32" - ); - - addr_ = DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "OptimismPortalInterop", - _args: DeployUtils.encodeConstructor( - abi.encodeCall( - IOptimismPortalInterop.__constructor__, - (cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds()) - ) - ) - }); - save("OptimismPortal2", addr_); - - // Override the `OptimismPortal2` contract to the deployed implementation. This is necessary - // to check the `OptimismPortal2` implementation alongside dependent contracts, which - // are always proxies. - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.OptimismPortal2 = addr_; - ChainAssertions.checkOptimismPortal2({ _contracts: contracts, _cfg: cfg, _isProxy: false }); - } - /// @notice Deploy the L2OutputOracle function deployL2OutputOracle() public broadcast returns (address addr_) { IL2OutputOracle oracle = IL2OutputOracle( @@ -726,47 +677,7 @@ contract Deploy is Deployer { addr_ = address(oracle); } - /// @notice Deploy the OptimismMintableERC20Factory - function deployOptimismMintableERC20Factory() public broadcast returns (address addr_) { - IOptimismMintableERC20Factory factory = IOptimismMintableERC20Factory( - DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "OptimismMintableERC20Factory", - _args: DeployUtils.encodeConstructor(abi.encodeCall(IOptimismMintableERC20Factory.__constructor__, ())) - }) - ); - - // Override the `OptimismMintableERC20Factory` contract to the deployed implementation. This is necessary - // to check the `OptimismMintableERC20Factory` implementation alongside dependent contracts, which - // are always proxies. - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.OptimismMintableERC20Factory = address(factory); - ChainAssertions.checkOptimismMintableERC20Factory({ _contracts: contracts, _isProxy: false }); - - addr_ = address(factory); - } - - /// @notice Deploy the DisputeGameFactory - function deployDisputeGameFactory() public broadcast returns (address addr_) { - IDisputeGameFactory factory = IDisputeGameFactory( - DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "DisputeGameFactory", - _args: DeployUtils.encodeConstructor(abi.encodeCall(IDisputeGameFactory.__constructor__, ())) - }) - ); - - // Override the `DisputeGameFactory` contract to the deployed implementation. This is necessary to check the - // `DisputeGameFactory` implementation alongside dependent contracts, which are always proxies. - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.DisputeGameFactory = address(factory); - ChainAssertions.checkDisputeGameFactory({ _contracts: contracts, _expectedOwner: address(0) }); - - addr_ = address(factory); - } - + /// @notice Deploy the DelayedWETH. (Used in FPACOPS) function deployDelayedWETH() public broadcast returns (address addr_) { IDelayedWETH weth = IDelayedWETH( DeployUtils.create2AndSave({ @@ -844,77 +755,6 @@ contract Deploy is Deployer { addr_ = address(anchorStateRegistry); } - /// @notice Deploy the SystemConfig - function deploySystemConfig() public broadcast returns (address addr_) { - addr_ = DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "SystemConfig", - _args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfig.__constructor__, ())) - }); - } - - /// @notice Deploy the SystemConfigInterop contract - function deploySystemConfigInterop() public broadcast returns (address addr_) { - addr_ = DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "SystemConfigInterop", - _args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfigInterop.__constructor__, ())) - }); - save("SystemConfig", addr_); - - // Override the `SystemConfig` contract to the deployed implementation. This is necessary - // to check the `SystemConfig` implementation alongside dependent contracts, which - // are always proxies. - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.SystemConfig = addr_; - ChainAssertions.checkSystemConfig({ _contracts: contracts, _cfg: cfg, _isProxy: false }); - } - - /// @notice Deploy the L1StandardBridge - function deployL1StandardBridge() public broadcast returns (address addr_) { - IL1StandardBridge bridge = IL1StandardBridge( - DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "L1StandardBridge", - _args: DeployUtils.encodeConstructor(abi.encodeCall(IL1StandardBridge.__constructor__, ())) - }) - ); - - // Override the `L1StandardBridge` contract to the deployed implementation. This is necessary - // to check the `L1StandardBridge` implementation alongside dependent contracts, which - // are always proxies. - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.L1StandardBridge = address(bridge); - ChainAssertions.checkL1StandardBridge({ _contracts: contracts, _isProxy: false }); - - addr_ = address(bridge); - } - - /// @notice Deploy the L1ERC721Bridge - function deployL1ERC721Bridge() public broadcast returns (address addr_) { - IL1ERC721Bridge bridge = IL1ERC721Bridge( - DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "L1ERC721Bridge", - _args: DeployUtils.encodeConstructor(abi.encodeCall(IL1ERC721Bridge.__constructor__, ())) - }) - ); - - // Override the `L1ERC721Bridge` contract to the deployed implementation. This is necessary - // to check the `L1ERC721Bridge` implementation alongside dependent contracts, which - // are always proxies. - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.L1ERC721Bridge = address(bridge); - - ChainAssertions.checkL1ERC721Bridge({ _contracts: contracts, _isProxy: false }); - - addr_ = address(bridge); - } - /// @notice Transfer ownership of the address manager to the ProxyAdmin function transferAddressManagerOwnership() public broadcast { console.log("Transferring AddressManager ownership to IProxyAdmin"); From b2824c14772809e35a17d7bc765f206a4d5f7506 Mon Sep 17 00:00:00 2001 From: Maurelian Date: Wed, 2 Oct 2024 14:43:06 -0400 Subject: [PATCH 2/3] feat: Annotate functions used in FPACOPS scripts --- packages/contracts-bedrock/scripts/deploy/Deploy.s.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol index f1a6af9a533a..cdd8cd4236a2 100644 --- a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol @@ -624,7 +624,7 @@ contract Deploy is Deployer { ChainAssertions.checkOptimismPortal({ _contracts: contracts, _cfg: cfg, _isProxy: false }); } - /// @notice Deploy the OptimismPortal2 + /// @notice Deploy the OptimismPortal2 (used in FPACOPS) function deployOptimismPortal2() public broadcast returns (address addr_) { // Could also verify this inside DeployConfig but doing it here is a bit more reliable. require( @@ -705,7 +705,7 @@ contract Deploy is Deployer { addr_ = address(weth); } - /// @notice Deploy the PreimageOracle + /// @notice Deploy the PreimageOracle (Used in FPACOPS) function deployPreimageOracle() public broadcast returns (address addr_) { IPreimageOracle preimageOracle = IPreimageOracle( DeployUtils.create2AndSave({ @@ -724,6 +724,7 @@ contract Deploy is Deployer { } /// @notice Deploy Mips VM. Deploys either MIPS or MIPS2 depending on the environment + /// (Used in FPACOPS) function deployMips() public broadcast returns (address addr_) { addr_ = DeployUtils.create2AndSave({ _save: this, @@ -736,7 +737,7 @@ contract Deploy is Deployer { save("Mips", address(addr_)); } - /// @notice Deploy the AnchorStateRegistry + /// @notice Deploy the AnchorStateRegistry (Used in FPACOPS) function deployAnchorStateRegistry() public broadcast returns (address addr_) { IAnchorStateRegistry anchorStateRegistry = IAnchorStateRegistry( DeployUtils.create2AndSave({ From 85dc6c453cc571c9194a6a3e9dcc8563f3f07017 Mon Sep 17 00:00:00 2001 From: Maurelian Date: Wed, 2 Oct 2024 15:08:04 -0400 Subject: [PATCH 3/3] feat: Delete FPACOPS scripts This also allows us to delete several deployX() functions from Deploy.s.sol --- .../scripts/deploy/Deploy.s.sol | 87 ------ .../scripts/fpac/FPACOPS.s.sol | 242 --------------- .../scripts/fpac/FPACOPS2.s.sol | 287 ------------------ 3 files changed, 616 deletions(-) delete mode 100644 packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol delete mode 100644 packages/contracts-bedrock/scripts/fpac/FPACOPS2.s.sol diff --git a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol index cdd8cd4236a2..caf41f330eb6 100644 --- a/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol @@ -624,33 +624,6 @@ contract Deploy is Deployer { ChainAssertions.checkOptimismPortal({ _contracts: contracts, _cfg: cfg, _isProxy: false }); } - /// @notice Deploy the OptimismPortal2 (used in FPACOPS) - function deployOptimismPortal2() public broadcast returns (address addr_) { - // Could also verify this inside DeployConfig but doing it here is a bit more reliable. - require( - uint32(cfg.respectedGameType()) == cfg.respectedGameType(), "Deploy: respectedGameType must fit into uint32" - ); - - addr_ = DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "OptimismPortal2", - _args: DeployUtils.encodeConstructor( - abi.encodeCall( - IOptimismPortal2.__constructor__, - (cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds()) - ) - ) - }); - - // Override the `OptimismPortal2` contract to the deployed implementation. This is necessary - // to check the `OptimismPortal2` implementation alongside dependent contracts, which - // are always proxies. - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.OptimismPortal2 = addr_; - ChainAssertions.checkOptimismPortal2({ _contracts: contracts, _cfg: cfg, _isProxy: false }); - } - /// @notice Deploy the L2OutputOracle function deployL2OutputOracle() public broadcast returns (address addr_) { IL2OutputOracle oracle = IL2OutputOracle( @@ -677,66 +650,6 @@ contract Deploy is Deployer { addr_ = address(oracle); } - /// @notice Deploy the DelayedWETH. (Used in FPACOPS) - function deployDelayedWETH() public broadcast returns (address addr_) { - IDelayedWETH weth = IDelayedWETH( - DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "DelayedWETH", - _args: DeployUtils.encodeConstructor( - abi.encodeCall(IDelayedWETH.__constructor__, (cfg.faultGameWithdrawalDelay())) - ) - }) - ); - - // Override the `DelayedWETH` contract to the deployed implementation. This is necessary - // to check the `DelayedWETH` implementation alongside dependent contracts, which are - // always proxies. - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.DelayedWETH = address(weth); - ChainAssertions.checkDelayedWETH({ - _contracts: contracts, - _cfg: cfg, - _isProxy: false, - _expectedOwner: address(0) - }); - - addr_ = address(weth); - } - - /// @notice Deploy the PreimageOracle (Used in FPACOPS) - function deployPreimageOracle() public broadcast returns (address addr_) { - IPreimageOracle preimageOracle = IPreimageOracle( - DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: "PreimageOracle", - _args: DeployUtils.encodeConstructor( - abi.encodeCall( - IPreimageOracle.__constructor__, - (cfg.preimageOracleMinProposalSize(), cfg.preimageOracleChallengePeriod()) - ) - ) - }) - ); - addr_ = address(preimageOracle); - } - - /// @notice Deploy Mips VM. Deploys either MIPS or MIPS2 depending on the environment - /// (Used in FPACOPS) - function deployMips() public broadcast returns (address addr_) { - addr_ = DeployUtils.create2AndSave({ - _save: this, - _salt: _implSalt(), - _name: Config.useMultithreadedCannon() ? "MIPS2" : "MIPS", - _args: DeployUtils.encodeConstructor( - abi.encodeCall(IMIPS2.__constructor__, (IPreimageOracle(mustGetAddress("PreimageOracle")))) - ) - }); - save("Mips", address(addr_)); - } - /// @notice Deploy the AnchorStateRegistry (Used in FPACOPS) function deployAnchorStateRegistry() public broadcast returns (address addr_) { IAnchorStateRegistry anchorStateRegistry = IAnchorStateRegistry( diff --git a/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol b/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol deleted file mode 100644 index a68f0bf615f5..000000000000 --- a/packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol +++ /dev/null @@ -1,242 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.15; - -// Scripts -import { StdAssertions } from "forge-std/StdAssertions.sol"; -import "scripts/deploy/Deploy.s.sol"; - -// Libraries -import "src/dispute/lib/Types.sol"; - -// Interfaces -import { IProxy } from "src/universal/interfaces/IProxy.sol"; -import { IMIPS } from "src/cannon/interfaces/IMIPS.sol"; -import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol"; -import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; -import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol"; -import { IPermissionedDisputeGame } from "src/dispute/interfaces/IPermissionedDisputeGame.sol"; - -/// @notice Deploys the Fault Proof Alpha Chad contracts. -contract FPACOPS is Deploy, StdAssertions { - //////////////////////////////////////////////////////////////// - // ENTRYPOINTS // - //////////////////////////////////////////////////////////////// - - function deployFPAC(address _proxyAdmin, address _finalSystemOwner, address _superchainConfigProxy) public { - console.log("Deploying a fresh FPAC system and OptimismPortal2 implementation."); - - prankDeployment("ProxyAdmin", msg.sender); - prankDeployment("FinalSystemOwner", msg.sender); - prankDeployment("SuperchainConfigProxy", _superchainConfigProxy); - - // Deploy the proxies. - deployERC1967Proxy("DisputeGameFactoryProxy"); - deployERC1967Proxy("DelayedWETHProxy"); - deployERC1967Proxy("AnchorStateRegistryProxy"); - - // Deploy implementations. - deployDisputeGameFactory(); - deployDelayedWETH(); - deployAnchorStateRegistry(); - deployPreimageOracle(); - deployMips(); - - // Deploy the new `OptimismPortal` implementation. - deployOptimismPortal2(); - - // Initialize the proxies. - initializeDisputeGameFactoryProxy(); - initializeDelayedWETHProxy(); - initializeAnchorStateRegistryProxy(); - - // Deploy the Cannon Fault game implementation and set it as game ID = 0. - setCannonFaultGameImplementation({ _allowUpgrade: false }); - // Deploy the Permissioned Cannon Fault game implementation and set it as game ID = 1. - setPermissionedCannonFaultGameImplementation({ _allowUpgrade: false }); - - // Transfer ownership of the DisputeGameFactory to the FinalSystemOwner, and transfer the administrative rights - // of the DisputeGameFactoryProxy to the ProxyAdmin. - transferDGFOwnershipFinal({ _proxyAdmin: _proxyAdmin, _finalSystemOwner: _finalSystemOwner }); - transferWethOwnershipFinal({ _proxyAdmin: _proxyAdmin, _finalSystemOwner: _finalSystemOwner }); - transferAnchorStateOwnershipFinal({ _proxyAdmin: _proxyAdmin }); - - // Run post-deployment assertions. - postDeployAssertions({ _proxyAdmin: _proxyAdmin, _finalSystemOwner: _finalSystemOwner }); - - // Print overview - printConfigReview(); - } - - //////////////////////////////////////////////////////////////// - // HELPERS // - //////////////////////////////////////////////////////////////// - - /// @notice Initializes the DisputeGameFactoryProxy with the DisputeGameFactory. - function initializeDisputeGameFactoryProxy() internal broadcast { - console.log("Initializing DisputeGameFactoryProxy with DisputeGameFactory."); - - address dgfProxy = mustGetAddress("DisputeGameFactoryProxy"); - IProxy(payable(dgfProxy)).upgradeToAndCall( - mustGetAddress("DisputeGameFactory"), abi.encodeCall(IDisputeGameFactory.initialize, msg.sender) - ); - - // Set the initialization bonds for the FaultDisputeGame and PermissionedDisputeGame. - IDisputeGameFactory dgf = IDisputeGameFactory(dgfProxy); - dgf.setInitBond(GameTypes.CANNON, 0.08 ether); - dgf.setInitBond(GameTypes.PERMISSIONED_CANNON, 0.08 ether); - } - - function initializeDelayedWETHProxy() internal broadcast { - console.log("Initializing DelayedWETHProxy with DelayedWETH."); - - address wethProxy = mustGetAddress("DelayedWETHProxy"); - address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); - IProxy(payable(wethProxy)).upgradeToAndCall( - mustGetAddress("DelayedWETH"), - abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) - ); - } - - function initializeAnchorStateRegistryProxy() internal broadcast { - console.log("Initializing AnchorStateRegistryProxy with AnchorStateRegistry."); - address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); - ISuperchainConfig superchainConfig = ISuperchainConfig(superchainConfigProxy); - - IAnchorStateRegistry.StartingAnchorRoot[] memory roots = new IAnchorStateRegistry.StartingAnchorRoot[](2); - roots[0] = IAnchorStateRegistry.StartingAnchorRoot({ - gameType: GameTypes.CANNON, - outputRoot: OutputRoot({ - root: Hash.wrap(cfg.faultGameGenesisOutputRoot()), - l2BlockNumber: cfg.faultGameGenesisBlock() - }) - }); - roots[1] = IAnchorStateRegistry.StartingAnchorRoot({ - gameType: GameTypes.PERMISSIONED_CANNON, - outputRoot: OutputRoot({ - root: Hash.wrap(cfg.faultGameGenesisOutputRoot()), - l2BlockNumber: cfg.faultGameGenesisBlock() - }) - }); - - address asrProxy = mustGetAddress("AnchorStateRegistryProxy"); - IProxy(payable(asrProxy)).upgradeToAndCall( - mustGetAddress("AnchorStateRegistry"), - abi.encodeCall(IAnchorStateRegistry.initialize, (roots, superchainConfig)) - ); - } - - /// @notice Transfers admin rights of the `DisputeGameFactoryProxy` to the `ProxyAdmin` and sets the - /// `DisputeGameFactory` owner to the `FinalSystemOwner`. - function transferDGFOwnershipFinal(address _proxyAdmin, address _finalSystemOwner) internal broadcast { - IDisputeGameFactory dgf = IDisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy")); - - // Transfer the ownership of the DisputeGameFactory to the FinalSystemOwner. - dgf.transferOwnership(_finalSystemOwner); - - // Transfer the admin rights of the DisputeGameFactoryProxy to the ProxyAdmin. - IProxy prox = IProxy(payable(address(dgf))); - prox.changeAdmin(_proxyAdmin); - } - - /// @notice Transfers admin rights of the `DelayedWETHProxy` to the `ProxyAdmin` and sets the - /// `DelayedWETH` owner to the `FinalSystemOwner`. - function transferWethOwnershipFinal(address _proxyAdmin, address _finalSystemOwner) internal broadcast { - IDelayedWETH weth = IDelayedWETH(mustGetAddress("DelayedWETHProxy")); - - // Transfer the ownership of the DelayedWETH to the FinalSystemOwner. - weth.transferOwnership(_finalSystemOwner); - - // Transfer the admin rights of the DelayedWETHProxy to the ProxyAdmin. - IProxy prox = IProxy(payable(address(weth))); - prox.changeAdmin(_proxyAdmin); - } - - /// @notice Transfers admin rights of the `AnchorStateRegistryProxy` to the `ProxyAdmin`. - function transferAnchorStateOwnershipFinal(address _proxyAdmin) internal broadcast { - IAnchorStateRegistry asr = IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")); - - // Transfer the admin rights of the AnchorStateRegistryProxy to the ProxyAdmin. - IProxy prox = IProxy(payable(address(asr))); - prox.changeAdmin(_proxyAdmin); - } - - /// @notice Checks that the deployed system is configured correctly. - function postDeployAssertions(address _proxyAdmin, address _finalSystemOwner) internal view { - Types.ContractSet memory contracts = _proxiesUnstrict(); - contracts.OptimismPortal2 = mustGetAddress("OptimismPortal2"); - - // Ensure that `useFaultProofs` is set to `true`. - assertTrue(cfg.useFaultProofs()); - - // Ensure the contracts are owned by the correct entities. - address dgfProxyAddr = mustGetAddress("DisputeGameFactoryProxy"); - IDisputeGameFactory dgfProxy = IDisputeGameFactory(dgfProxyAddr); - assertEq(address(uint160(uint256(vm.load(dgfProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin); - ChainAssertions.checkDisputeGameFactory(contracts, _finalSystemOwner); - address wethProxyAddr = mustGetAddress("DelayedWETHProxy"); - assertEq(address(uint160(uint256(vm.load(wethProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin); - ChainAssertions.checkDelayedWETH(contracts, cfg, true, _finalSystemOwner); - - // Check the config elements in the deployed contracts. - ChainAssertions.checkOptimismPortal2(contracts, cfg, false); - - IPreimageOracle oracle = IPreimageOracle(mustGetAddress("PreimageOracle")); - assertEq(oracle.minProposalSize(), cfg.preimageOracleMinProposalSize()); - assertEq(oracle.challengePeriod(), cfg.preimageOracleChallengePeriod()); - - IMIPS mips = IMIPS(mustGetAddress("Mips")); - assertEq(address(mips.oracle()), address(oracle)); - - // Check the AnchorStateRegistry configuration. - IAnchorStateRegistry asr = IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")); - (Hash root1, uint256 l2BlockNumber1) = asr.anchors(GameTypes.CANNON); - (Hash root2, uint256 l2BlockNumber2) = asr.anchors(GameTypes.PERMISSIONED_CANNON); - assertEq(root1.raw(), cfg.faultGameGenesisOutputRoot()); - assertEq(root2.raw(), cfg.faultGameGenesisOutputRoot()); - assertEq(l2BlockNumber1, cfg.faultGameGenesisBlock()); - assertEq(l2BlockNumber2, cfg.faultGameGenesisBlock()); - - // Check the FaultDisputeGame configuration. - IFaultDisputeGame gameImpl = IFaultDisputeGame(payable(address(dgfProxy.gameImpls(GameTypes.CANNON)))); - assertEq(gameImpl.maxGameDepth(), cfg.faultGameMaxDepth()); - assertEq(gameImpl.splitDepth(), cfg.faultGameSplitDepth()); - assertEq(gameImpl.clockExtension().raw(), cfg.faultGameClockExtension()); - assertEq(gameImpl.maxClockDuration().raw(), cfg.faultGameMaxClockDuration()); - assertEq(gameImpl.absolutePrestate().raw(), bytes32(cfg.faultGameAbsolutePrestate())); - assertEq(address(gameImpl.weth()), wethProxyAddr); - assertEq(address(gameImpl.anchorStateRegistry()), address(asr)); - assertEq(address(gameImpl.vm()), address(mips)); - - // Check the security override yoke configuration. - IPermissionedDisputeGame soyGameImpl = - IPermissionedDisputeGame(payable(address(dgfProxy.gameImpls(GameTypes.PERMISSIONED_CANNON)))); - assertEq(soyGameImpl.proposer(), cfg.l2OutputOracleProposer()); - assertEq(soyGameImpl.challenger(), cfg.l2OutputOracleChallenger()); - assertEq(soyGameImpl.maxGameDepth(), cfg.faultGameMaxDepth()); - assertEq(soyGameImpl.splitDepth(), cfg.faultGameSplitDepth()); - assertEq(soyGameImpl.clockExtension().raw(), cfg.faultGameClockExtension()); - assertEq(soyGameImpl.maxClockDuration().raw(), cfg.faultGameMaxClockDuration()); - assertEq(soyGameImpl.absolutePrestate().raw(), bytes32(cfg.faultGameAbsolutePrestate())); - assertEq(address(soyGameImpl.weth()), wethProxyAddr); - assertEq(address(soyGameImpl.anchorStateRegistry()), address(asr)); - assertEq(address(soyGameImpl.vm()), address(mips)); - } - - /// @notice Prints a review of the fault proof configuration section of the deploy config. - function printConfigReview() internal view { - console.log(unicode"📖 FaultDisputeGame Config Overview (chainid: %d)", block.chainid); - console.log(" 0. Use Fault Proofs: %s", cfg.useFaultProofs() ? "true" : "false"); - console.log(" 1. Absolute Prestate: %x", cfg.faultGameAbsolutePrestate()); - console.log(" 2. Max Depth: %d", cfg.faultGameMaxDepth()); - console.log(" 3. Output / Execution split Depth: %d", cfg.faultGameSplitDepth()); - console.log(" 4. Clock Extension (seconds): %d", cfg.faultGameClockExtension()); - console.log(" 5. Max Clock Duration (seconds): %d", cfg.faultGameMaxClockDuration()); - console.log(" 6. L2 Genesis block number: %d", cfg.faultGameGenesisBlock()); - console.log(" 7. L2 Genesis output root: %x", uint256(cfg.faultGameGenesisOutputRoot())); - console.log(" 8. Proof Maturity Delay (seconds): ", cfg.proofMaturityDelaySeconds()); - console.log(" 9. Dispute Game Finality Delay (seconds): ", cfg.disputeGameFinalityDelaySeconds()); - console.log(" 10. Respected Game Type: ", cfg.respectedGameType()); - console.log(" 11. Preimage Oracle Min Proposal Size (bytes): ", cfg.preimageOracleMinProposalSize()); - console.log(" 12. Preimage Oracle Challenge Period (seconds): ", cfg.preimageOracleChallengePeriod()); - } -} diff --git a/packages/contracts-bedrock/scripts/fpac/FPACOPS2.s.sol b/packages/contracts-bedrock/scripts/fpac/FPACOPS2.s.sol deleted file mode 100644 index 0f372e752b87..000000000000 --- a/packages/contracts-bedrock/scripts/fpac/FPACOPS2.s.sol +++ /dev/null @@ -1,287 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.15; - -// Scripts -import { StdAssertions } from "forge-std/StdAssertions.sol"; -import "scripts/deploy/Deploy.s.sol"; - -// Libraries -import "src/dispute/lib/Types.sol"; - -// Interfaces -import { IProxy } from "src/universal/interfaces/IProxy.sol"; -import { IMIPS } from "src/cannon/interfaces/IMIPS.sol"; -import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol"; -import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; -import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol"; -import { IPermissionedDisputeGame } from "src/dispute/interfaces/IPermissionedDisputeGame.sol"; - -/// @notice Deploys new implementations of the FaultDisputeGame contract and its dependencies -/// assuming that the DisputeGameFactory contract does not need to be modified. Assumes -/// that the System Owner will update the DisputeGameFactory to point to these new -/// contracts at a later point in time. -contract FPACOPS2 is Deploy, StdAssertions { - //////////////////////////////////////////////////////////////// - // ENTRYPOINTS // - //////////////////////////////////////////////////////////////// - - /// @notice Deploys an updated FP system with new FaultDisputeGame contracts and new - /// DelayedWETH contracts. Deploys a new implementation of the - /// AnchorStateRegistry. Does not deploy a new DisputeGameFactory. System - /// Owner is responsible for updating implementations later. - /// @param _proxyAdmin Address of the ProxyAdmin contract to transfer ownership to. - /// @param _finalSystemOwner Address of the SystemOwner. - /// @param _superchainConfigProxy Address of the SuperchainConfig proxy contract. - /// @param _disputeGameFactoryProxy Address of the DisputeGameFactory proxy contract. - /// @param _anchorStateRegistryProxy Address of the AnchorStateRegistry proxy contract. - function deployFPAC2( - address _proxyAdmin, - address _finalSystemOwner, - address _superchainConfigProxy, - address _disputeGameFactoryProxy, - address _anchorStateRegistryProxy - ) - public - { - console.log("Deploying updated FP contracts."); - - // Prank required deployments. - prankDeployment("ProxyAdmin", msg.sender); - prankDeployment("FinalSystemOwner", msg.sender); - prankDeployment("SuperchainConfigProxy", _superchainConfigProxy); - prankDeployment("DisputeGameFactoryProxy", _disputeGameFactoryProxy); - prankDeployment("AnchorStateRegistryProxy", _anchorStateRegistryProxy); - - // Deploy the proxies. - deployERC1967Proxy("DelayedWETHProxy"); - deployERC1967Proxy("PermissionedDelayedWETHProxy"); - - // Deploy implementations. - deployDelayedWETH(); - deployAnchorStateRegistry(); - deployPreimageOracle(); - deployMips(); - - // Initialize the proxies. - initializeDelayedWETHProxy(); - initializePermissionedDelayedWETHProxy(); - - // Deploy the new game implementations. - deployCannonDisputeGame(); - deployPermissionedDisputeGame(); - - // Transfer ownership of DelayedWETH to ProxyAdmin. - transferWethOwnershipFinal({ _proxyAdmin: _proxyAdmin, _finalSystemOwner: _finalSystemOwner }); - transferPermissionedWETHOwnershipFinal({ _proxyAdmin: _proxyAdmin, _finalSystemOwner: _finalSystemOwner }); - - // Run post-deployment assertions. - postDeployAssertions({ _proxyAdmin: _proxyAdmin, _finalSystemOwner: _finalSystemOwner }); - - // Print overview. - printConfigReview(); - } - - //////////////////////////////////////////////////////////////// - // HELPERS // - //////////////////////////////////////////////////////////////// - - /// @notice Deploys the standard Cannon version of the FaultDisputeGame. - function deployCannonDisputeGame() internal broadcast { - console.log("Deploying CannonFaultDisputeGame implementation"); - - DeployUtils.create2AndSave({ - _save: this, - _name: "FaultDisputeGame", - _nick: "CannonFaultDisputeGame", - _args: DeployUtils.encodeConstructor( - abi.encodeCall( - IFaultDisputeGame.__constructor__, - ( - GameTypes.CANNON, - loadMipsAbsolutePrestate(), - cfg.faultGameMaxDepth(), - cfg.faultGameSplitDepth(), - Duration.wrap(uint64(cfg.faultGameClockExtension())), - Duration.wrap(uint64(cfg.faultGameMaxClockDuration())), - IBigStepper(mustGetAddress("Mips")), - IDelayedWETH(mustGetAddress("DelayedWETHProxy")), - IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")), - cfg.l2ChainID() - ) - ) - ), - _salt: _implSalt() - }); - } - - /// @notice Deploys the PermissionedDisputeGame. - function deployPermissionedDisputeGame() internal broadcast { - console.log("Deploying PermissionedDisputeGame implementation"); - - DeployUtils.create2AndSave({ - _save: this, - _name: "PermissionedDisputeGame", - _args: DeployUtils.encodeConstructor( - abi.encodeCall( - IPermissionedDisputeGame.__constructor__, - ( - GameTypes.PERMISSIONED_CANNON, - loadMipsAbsolutePrestate(), - cfg.faultGameMaxDepth(), - cfg.faultGameSplitDepth(), - Duration.wrap(uint64(cfg.faultGameClockExtension())), - Duration.wrap(uint64(cfg.faultGameMaxClockDuration())), - IBigStepper(mustGetAddress("Mips")), - IDelayedWETH(mustGetAddress("PermissionedDelayedWETHProxy")), - IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")), - cfg.l2ChainID(), - cfg.l2OutputOracleProposer(), - cfg.l2OutputOracleChallenger() - ) - ) - ), - _salt: _implSalt() - }); - } - - /// @notice Initializes the DelayedWETH proxy. - function initializeDelayedWETHProxy() internal broadcast { - console.log("Initializing DelayedWETHProxy with DelayedWETH."); - - address wethProxy = mustGetAddress("DelayedWETHProxy"); - address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); - IProxy(payable(wethProxy)).upgradeToAndCall( - mustGetAddress("DelayedWETH"), - abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) - ); - } - - /// @notice Initializes the permissioned DelayedWETH proxy. - function initializePermissionedDelayedWETHProxy() internal broadcast { - console.log("Initializing permissioned DelayedWETHProxy with DelayedWETH."); - - address wethProxy = mustGetAddress("PermissionedDelayedWETHProxy"); - address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); - IProxy(payable(wethProxy)).upgradeToAndCall( - mustGetAddress("DelayedWETH"), - abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) - ); - } - - /// @notice Transfers admin rights of the `DelayedWETHProxy` to the `ProxyAdmin` and sets the - /// `DelayedWETH` owner to the `FinalSystemOwner`. - function transferWethOwnershipFinal(address _proxyAdmin, address _finalSystemOwner) internal broadcast { - console.log("Transferring ownership of DelayedWETHProxy"); - - IDelayedWETH weth = IDelayedWETH(mustGetAddress("DelayedWETHProxy")); - - // Transfer the ownership of the DelayedWETH to the FinalSystemOwner. - weth.transferOwnership(_finalSystemOwner); - - // Transfer the admin rights of the DelayedWETHProxy to the ProxyAdmin. - IProxy prox = IProxy(payable(address(weth))); - prox.changeAdmin(_proxyAdmin); - } - - /// @notice Transfers admin rights of the permissioned `DelayedWETHProxy` to the `ProxyAdmin` - /// and sets the `DelayedWETH` owner to the `FinalSystemOwner`. - function transferPermissionedWETHOwnershipFinal( - address _proxyAdmin, - address _finalSystemOwner - ) - internal - broadcast - { - console.log("Transferring ownership of permissioned DelayedWETHProxy"); - - IDelayedWETH weth = IDelayedWETH(mustGetAddress("PermissionedDelayedWETHProxy")); - - // Transfer the ownership of the DelayedWETH to the FinalSystemOwner. - weth.transferOwnership(_finalSystemOwner); - - // Transfer the admin rights of the DelayedWETHProxy to the ProxyAdmin. - IProxy prox = IProxy(payable(address(weth))); - prox.changeAdmin(_proxyAdmin); - } - - /// @notice Checks that the deployed system is configured correctly. - function postDeployAssertions(address _proxyAdmin, address _finalSystemOwner) internal view { - Types.ContractSet memory contracts = _proxiesUnstrict(); - - // Ensure that `useFaultProofs` is set to `true`. - assertTrue(cfg.useFaultProofs()); - - // Verify that the DGF is owned by the ProxyAdmin. - address dgfProxyAddr = mustGetAddress("DisputeGameFactoryProxy"); - assertEq(address(uint160(uint256(vm.load(dgfProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin); - - // Verify that DelayedWETH is owned by the ProxyAdmin. - address wethProxyAddr = mustGetAddress("DelayedWETHProxy"); - assertEq(address(uint160(uint256(vm.load(wethProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin); - - // Verify that permissioned DelayedWETH is owned by the ProxyAdmin. - address soyWethProxyAddr = mustGetAddress("PermissionedDelayedWETHProxy"); - assertEq(address(uint160(uint256(vm.load(soyWethProxyAddr, Constants.PROXY_OWNER_ADDRESS)))), _proxyAdmin); - - // Run standard assertions for DGF and DelayedWETH. - ChainAssertions.checkDisputeGameFactory(contracts, _finalSystemOwner); - ChainAssertions.checkDelayedWETH(contracts, cfg, true, _finalSystemOwner); - ChainAssertions.checkPermissionedDelayedWETH(contracts, cfg, true, _finalSystemOwner); - - // Verify PreimageOracle configuration. - IPreimageOracle oracle = IPreimageOracle(mustGetAddress("PreimageOracle")); - assertEq(oracle.minProposalSize(), cfg.preimageOracleMinProposalSize()); - assertEq(oracle.challengePeriod(), cfg.preimageOracleChallengePeriod()); - - // Verify MIPS configuration. - IMIPS mips = IMIPS(mustGetAddress("Mips")); - assertEq(address(mips.oracle()), address(oracle)); - - // Grab ASR - IAnchorStateRegistry asr = IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")); - - // Verify FaultDisputeGame configuration. - address gameAddr = mustGetAddress("CannonFaultDisputeGame"); - IFaultDisputeGame gameImpl = IFaultDisputeGame(payable(gameAddr)); - assertEq(gameImpl.maxGameDepth(), cfg.faultGameMaxDepth()); - assertEq(gameImpl.splitDepth(), cfg.faultGameSplitDepth()); - assertEq(gameImpl.clockExtension().raw(), cfg.faultGameClockExtension()); - assertEq(gameImpl.maxClockDuration().raw(), cfg.faultGameMaxClockDuration()); - assertEq(gameImpl.absolutePrestate().raw(), bytes32(cfg.faultGameAbsolutePrestate())); - assertEq(address(gameImpl.weth()), wethProxyAddr); - assertEq(address(gameImpl.anchorStateRegistry()), address(asr)); - assertEq(address(gameImpl.vm()), address(mips)); - - // Verify security override yoke configuration. - address soyGameAddr = mustGetAddress("PermissionedDisputeGame"); - IPermissionedDisputeGame soyGameImpl = IPermissionedDisputeGame(payable(soyGameAddr)); - assertEq(soyGameImpl.proposer(), cfg.l2OutputOracleProposer()); - assertEq(soyGameImpl.challenger(), cfg.l2OutputOracleChallenger()); - assertEq(soyGameImpl.maxGameDepth(), cfg.faultGameMaxDepth()); - assertEq(soyGameImpl.splitDepth(), cfg.faultGameSplitDepth()); - assertEq(soyGameImpl.clockExtension().raw(), cfg.faultGameClockExtension()); - assertEq(soyGameImpl.maxClockDuration().raw(), cfg.faultGameMaxClockDuration()); - assertEq(soyGameImpl.absolutePrestate().raw(), bytes32(cfg.faultGameAbsolutePrestate())); - assertEq(address(soyGameImpl.weth()), soyWethProxyAddr); - assertEq(address(soyGameImpl.anchorStateRegistry()), address(asr)); - assertEq(address(soyGameImpl.vm()), address(mips)); - } - - /// @notice Prints a review of the fault proof configuration section of the deploy config. - function printConfigReview() internal view { - console.log(unicode"📖 FaultDisputeGame Config Overview (chainid: %d)", block.chainid); - console.log(" 0. Use Fault Proofs: %s", cfg.useFaultProofs() ? "true" : "false"); - console.log(" 1. Absolute Prestate: %x", cfg.faultGameAbsolutePrestate()); - console.log(" 2. Max Depth: %d", cfg.faultGameMaxDepth()); - console.log(" 3. Output / Execution split Depth: %d", cfg.faultGameSplitDepth()); - console.log(" 4. Clock Extension (seconds): %d", cfg.faultGameClockExtension()); - console.log(" 5. Max Clock Duration (seconds): %d", cfg.faultGameMaxClockDuration()); - console.log(" 6. L2 Genesis block number: %d", cfg.faultGameGenesisBlock()); - console.log(" 7. L2 Genesis output root: %x", uint256(cfg.faultGameGenesisOutputRoot())); - console.log(" 8. Proof Maturity Delay (seconds): ", cfg.proofMaturityDelaySeconds()); - console.log(" 9. Dispute Game Finality Delay (seconds): ", cfg.disputeGameFinalityDelaySeconds()); - console.log(" 10. Respected Game Type: ", cfg.respectedGameType()); - console.log(" 11. Preimage Oracle Min Proposal Size (bytes): ", cfg.preimageOracleMinProposalSize()); - console.log(" 12. Preimage Oracle Challenge Period (seconds): ", cfg.preimageOracleChallengePeriod()); - } -}