github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/test/kontrol/deployment/DeploymentSummary.t.sol (about) 1 // SPDX-License-Identifier: MIT 2 pragma solidity 0.8.15; 3 4 // Libraries 5 import { Constants } from "src/libraries/Constants.sol"; 6 import { Predeploys } from "src/libraries/Predeploys.sol"; 7 8 // Target contract dependencies 9 import { L2OutputOracle } from "src/L1/L2OutputOracle.sol"; 10 import { SystemConfig } from "src/L1/SystemConfig.sol"; 11 import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; 12 import { OptimismPortal } from "src/L1/OptimismPortal.sol"; 13 import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol"; 14 import { DeploymentSummary } from "../proofs/utils/DeploymentSummary.sol"; 15 import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol"; 16 import { L1StandardBridge } from "src/L1/L1StandardBridge.sol"; 17 import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 18 import { LegacyMintableERC20 } from "src/legacy/LegacyMintableERC20.sol"; 19 20 // Tests 21 import { L1CrossDomainMessenger_Test } from "test/L1/L1CrossDomainMessenger.t.sol"; 22 import { OptimismPortal_Test } from "test/L1/OptimismPortal.t.sol"; 23 import { L1ERC721Bridge_Test, TestERC721 } from "test/L1/L1ERC721Bridge.t.sol"; 24 import { 25 L1StandardBridge_Getter_Test, 26 L1StandardBridge_Initialize_Test, 27 L1StandardBridge_Pause_Test 28 } from "test/L1/L1StandardBridge.t.sol"; 29 30 /// @dev Contract testing the deployment summary correctness 31 contract DeploymentSummary_TestOptimismPortal is DeploymentSummary, OptimismPortal_Test { 32 /// @notice super.setUp is not called on purpose 33 function setUp() public override { 34 // Recreate Deployment Summary state changes 35 DeploymentSummary deploymentSummary = new DeploymentSummary(); 36 deploymentSummary.recreateDeployment(); 37 38 // Set summary addresses 39 optimismPortal = OptimismPortal(payable(optimismPortalProxyAddress)); 40 superchainConfig = SuperchainConfig(superchainConfigProxyAddress); 41 l2OutputOracle = L2OutputOracle(l2OutputOracleProxyAddress); 42 systemConfig = SystemConfig(systemConfigProxyAddress); 43 44 // Set up utilized addresses 45 depositor = makeAddr("depositor"); 46 alice = makeAddr("alice"); 47 bob = makeAddr("bob"); 48 vm.deal(alice, 10000 ether); 49 vm.deal(bob, 10000 ether); 50 } 51 52 /// @dev Skips the first line of `super.test_constructor_succeeds` because 53 /// we're not exercising the `Deploy` logic in these tests. However, 54 /// the remaining assertions of the test are important to check 55 function test_constructor_succeeds() external override { 56 // OptimismPortal opImpl = OptimismPortal(payable(deploy.mustGetAddress("OptimismPortal"))); 57 OptimismPortal opImpl = OptimismPortal(payable(optimismPortalAddress)); 58 assertEq(address(opImpl.L2_ORACLE()), address(0)); 59 assertEq(address(opImpl.l2Oracle()), address(0)); 60 assertEq(address(opImpl.SYSTEM_CONFIG()), address(0)); 61 assertEq(address(opImpl.systemConfig()), address(0)); 62 assertEq(address(opImpl.superchainConfig()), address(0)); 63 assertEq(opImpl.l2Sender(), Constants.DEFAULT_L2_SENDER); 64 } 65 66 /// @dev Skips the first line of `super.test_initialize_succeeds` because 67 /// we're not exercising the `Deploy` logic in these tests. However, 68 /// the remaining assertions of the test are important to check 69 function test_initialize_succeeds() external override { 70 // address guardian = deploy.cfg().superchainConfigGuardian(); 71 address guardian = superchainConfig.guardian(); 72 assertEq(address(optimismPortal.L2_ORACLE()), address(l2OutputOracle)); 73 assertEq(address(optimismPortal.l2Oracle()), address(l2OutputOracle)); 74 assertEq(address(optimismPortal.SYSTEM_CONFIG()), address(systemConfig)); 75 assertEq(address(optimismPortal.systemConfig()), address(systemConfig)); 76 assertEq(optimismPortal.GUARDIAN(), guardian); 77 assertEq(optimismPortal.guardian(), guardian); 78 assertEq(address(optimismPortal.superchainConfig()), address(superchainConfig)); 79 assertEq(optimismPortal.l2Sender(), Constants.DEFAULT_L2_SENDER); 80 assertEq(optimismPortal.paused(), false); 81 } 82 83 /// @notice This test is overridden because `KontrolDeployment` doesn't initialize 84 /// the L2OutputOracle, which is needed in this test 85 function test_simple_isOutputFinalized_succeeds() external override { } 86 87 /// @notice This test is overridden because `KontrolDeployment` doesn't initialize 88 /// the L2OutputOracle, which is needed in this test 89 function test_isOutputFinalized_succeeds() external override { } 90 } 91 92 contract DeploymentSummary_TestL1CrossDomainMessenger is DeploymentSummary, L1CrossDomainMessenger_Test { 93 /// @notice super.setUp is not called on purpose 94 function setUp() public override { 95 // Recreate Deployment Summary state changes 96 DeploymentSummary deploymentSummary = new DeploymentSummary(); 97 deploymentSummary.recreateDeployment(); 98 99 // Set summary addresses 100 optimismPortal = OptimismPortal(payable(optimismPortalProxyAddress)); 101 superchainConfig = SuperchainConfig(superchainConfigProxyAddress); 102 l2OutputOracle = L2OutputOracle(l2OutputOracleProxyAddress); 103 systemConfig = SystemConfig(systemConfigProxyAddress); 104 l1CrossDomainMessenger = L1CrossDomainMessenger(l1CrossDomainMessengerProxyAddress); 105 106 // Set up utilized addresses 107 alice = makeAddr("alice"); 108 bob = makeAddr("bob"); 109 vm.deal(alice, 10000 ether); 110 vm.deal(bob, 10000 ether); 111 } 112 113 /// @dev Skips the first line of `super.test_constructor_succeeds` because 114 /// we're not exercising the `Deploy` logic in these tests. However, 115 /// the remaining assertions of the test are important to check 116 function test_constructor_succeeds() external override { 117 // L1CrossDomainMessenger impl = L1CrossDomainMessenger(deploy.mustGetAddress("L1CrossDomainMessenger")); 118 L1CrossDomainMessenger impl = L1CrossDomainMessenger(l1CrossDomainMessengerAddress); 119 assertEq(address(impl.superchainConfig()), address(0)); 120 assertEq(address(impl.PORTAL()), address(0)); 121 assertEq(address(impl.portal()), address(0)); 122 assertEq(address(impl.OTHER_MESSENGER()), Predeploys.L2_CROSS_DOMAIN_MESSENGER); 123 assertEq(address(impl.otherMessenger()), Predeploys.L2_CROSS_DOMAIN_MESSENGER); 124 } 125 126 /// @notice This test is overridden because `KontrolDeployment` doesn't deploy 127 /// L2CrossDomainMessenger, which is needed in this test 128 function test_relayMessage_v2_reverts() external override { } 129 } 130 131 contract DeploymentSummary_TestL1ERC721Bridge is DeploymentSummary, L1ERC721Bridge_Test { 132 /// @notice super.setUp is not called on purpose 133 function setUp() public override { 134 // Recreate Deployment Summary state changes 135 DeploymentSummary deploymentSummary = new DeploymentSummary(); 136 deploymentSummary.recreateDeployment(); 137 138 // Set summary addresses 139 optimismPortal = OptimismPortal(payable(optimismPortalProxyAddress)); 140 superchainConfig = SuperchainConfig(superchainConfigProxyAddress); 141 l2OutputOracle = L2OutputOracle(l2OutputOracleProxyAddress); 142 systemConfig = SystemConfig(systemConfigProxyAddress); 143 l1CrossDomainMessenger = L1CrossDomainMessenger(l1CrossDomainMessengerProxyAddress); 144 l1ERC721Bridge = L1ERC721Bridge(l1ERC721BridgeProxyAddress); 145 146 // Set up utilized addresses 147 alice = makeAddr("alice"); 148 bob = makeAddr("bob"); 149 vm.deal(alice, 10000 ether); 150 vm.deal(bob, 10000 ether); 151 152 // Bridge_Initializer setUp 153 L1Token = new ERC20("Native L1 Token", "L1T"); 154 155 LegacyL2Token = new LegacyMintableERC20({ 156 _l2Bridge: address(l2StandardBridge), 157 _l1Token: address(L1Token), 158 _name: string.concat("LegacyL2-", L1Token.name()), 159 _symbol: string.concat("LegacyL2-", L1Token.symbol()) 160 }); 161 vm.label(address(LegacyL2Token), "LegacyMintableERC20"); 162 163 // Deploy the L2 ERC20 now 164 // L2Token = OptimismMintableERC20( 165 // l2OptimismMintableERC20Factory.createStandardL2Token( 166 // address(L1Token), 167 // string(abi.encodePacked("L2-", L1Token.name())), 168 // string(abi.encodePacked("L2-", L1Token.symbol())) 169 // ) 170 // ); 171 172 // BadL2Token = OptimismMintableERC20( 173 // l2OptimismMintableERC20Factory.createStandardL2Token( 174 // address(1), 175 // string(abi.encodePacked("L2-", L1Token.name())), 176 // string(abi.encodePacked("L2-", L1Token.symbol())) 177 // ) 178 // ); 179 180 NativeL2Token = new ERC20("Native L2 Token", "L2T"); 181 182 // RemoteL1Token = OptimismMintableERC20( 183 // l1OptimismMintableERC20Factory.createStandardL2Token( 184 // address(NativeL2Token), 185 // string(abi.encodePacked("L1-", NativeL2Token.name())), 186 // string(abi.encodePacked("L1-", NativeL2Token.symbol())) 187 // ) 188 // ); 189 190 // BadL1Token = OptimismMintableERC20( 191 // l1OptimismMintableERC20Factory.createStandardL2Token( 192 // address(1), 193 // string(abi.encodePacked("L1-", NativeL2Token.name())), 194 // string(abi.encodePacked("L1-", NativeL2Token.symbol())) 195 // ) 196 // ); 197 198 // L1ERC721Bridge_Test setUp 199 localToken = new TestERC721(); 200 remoteToken = new TestERC721(); 201 202 // Mint alice a token. 203 localToken.mint(alice, tokenId); 204 205 // Approve the bridge to transfer the token. 206 vm.prank(alice); 207 localToken.approve(address(l1ERC721Bridge), tokenId); 208 } 209 210 /// @dev Skips the first line of `super.test_constructor_succeeds` because 211 /// we're not exercising the `Deploy` logic in these tests. However, 212 /// the remaining assertions of the test are important to check 213 function test_constructor_succeeds() public override { 214 // L1ERC721Bridge impl = L1ERC721Bridge(deploy.mustGetAddress("L1ERC721Bridge")); 215 L1ERC721Bridge impl = L1ERC721Bridge(l1ERC721BridgeAddress); 216 assertEq(address(impl.MESSENGER()), address(0)); 217 assertEq(address(impl.messenger()), address(0)); 218 assertEq(address(impl.OTHER_BRIDGE()), Predeploys.L2_ERC721_BRIDGE); 219 assertEq(address(impl.otherBridge()), Predeploys.L2_ERC721_BRIDGE); 220 assertEq(address(impl.superchainConfig()), address(0)); 221 } 222 } 223 224 contract DeploymentSummary_TestL1StandardBridge is 225 DeploymentSummary, 226 L1StandardBridge_Getter_Test, 227 L1StandardBridge_Initialize_Test, 228 L1StandardBridge_Pause_Test 229 { 230 /// @notice super.setUp is not called on purpose 231 function setUp() public override { 232 // Recreate Deployment Summary state changes 233 DeploymentSummary deploymentSummary = new DeploymentSummary(); 234 deploymentSummary.recreateDeployment(); 235 236 // Set summary addresses 237 optimismPortal = OptimismPortal(payable(optimismPortalProxyAddress)); 238 superchainConfig = SuperchainConfig(superchainConfigProxyAddress); 239 l2OutputOracle = L2OutputOracle(l2OutputOracleProxyAddress); 240 systemConfig = SystemConfig(systemConfigProxyAddress); 241 l1CrossDomainMessenger = L1CrossDomainMessenger(l1CrossDomainMessengerProxyAddress); 242 l1ERC721Bridge = L1ERC721Bridge(l1ERC721BridgeProxyAddress); 243 l1StandardBridge = L1StandardBridge(payable(l1StandardBridgeProxyAddress)); 244 } 245 246 /// @dev Skips the first line of `super.test_constructor_succeeds` because 247 /// we're not exercising the `Deploy` logic in these tests. However, 248 /// the remaining assertions of the test are important to check 249 function test_constructor_succeeds() external override { 250 // L1StandardBridge impl = L1StandardBridge(deploy.mustGetAddress("L1StandardBridge")); 251 L1StandardBridge impl = L1StandardBridge(payable(l1StandardBridgeAddress)); 252 assertEq(address(impl.superchainConfig()), address(0)); 253 assertEq(address(impl.MESSENGER()), address(0)); 254 assertEq(address(impl.messenger()), address(0)); 255 assertEq(address(impl.OTHER_BRIDGE()), Predeploys.L2_STANDARD_BRIDGE); 256 assertEq(address(impl.otherBridge()), Predeploys.L2_STANDARD_BRIDGE); 257 assertEq(address(l2StandardBridge), Predeploys.L2_STANDARD_BRIDGE); 258 } 259 }