@@ -6,6 +6,7 @@ import { stdJson } from "forge-std/StdJson.sol";
66
77// Scripts
88import { Deployer } from "scripts/deploy/Deployer.sol " ;
9+ import { Deploy } from "scripts/deploy/Deploy.s.sol " ;
910
1011// Libraries
1112import { GameTypes } from "src/dispute/lib/Types.sol " ;
@@ -19,9 +20,9 @@ import { IAddressManager } from "interfaces/legacy/IAddressManager.sol";
1920/// @title ForkLive
2021/// @notice This script is called by Setup.sol as a preparation step for the foundry test suite, and is run as an
2122/// alternative to Deploy.s.sol, when `FORK_TEST=true` is set in the env.
22- /// Like Deploy.s.sol this script saves the system addresses to disk so that they can be read into memory later
23- /// on, however rather than deploying new contracts from the local source code, it simply reads the addresses
24- /// from the superchain-registry.
23+ /// Like Deploy.s.sol this script saves the system addresses to the Artifacts contract so that they can be
24+ /// read by other contracts. However, rather than deploying new contracts from the local source code, it
25+ /// simply reads the addresses from the superchain-registry.
2526/// Therefore this script can only be run against a fork of a production network which is listed in the
2627/// superchain-registry.
2728/// This contract must not have constructor logic because it is set into state using `etch`.
@@ -40,17 +41,29 @@ contract ForkLive is Deployer {
4041 return vm.envOr ("FORK_OP_CHAIN " , string ("op " ));
4142 }
4243
43- /// @notice Reads a standard chains addresses from the superchain-registry and saves them to disk.
44+ /// @notice Forks, upgrades and tests a production network.
45+ /// @dev This function sets up the system to test by:
46+ /// 1. reading the superchain-registry to get the contract addresses we wish to test from that network.
47+ /// 2. deploying the updated OPCM and implementations of the contracts.
48+ /// 3. upgrading the system using the OPCM.upgrade() function.
4449 function run () public {
50+ // Read the superchain registry and save the addresses to the Artifacts contract.
51+ _readSuperchainRegistry ();
52+
53+ // Now deploy the updated OPCM and implementations of the contracts
54+ _deployNewImplementations ();
55+ }
56+
57+ /// @notice Reads the superchain config files and saves the addresses to disk.
58+ /// @dev During development of an upgrade which adds a new contract, the contract will not yet be present in the
59+ /// superchain-registry. In this case, the contract will be deployed by the upgrade process, and will need to
60+ /// be stored by artifacts.save() after the call to opcm.upgrade().
61+ /// After the upgrade is complete, the superchain-registry will be updated and the contract will be present. At
62+ /// that point, this function will need to be updated to read the new contract from the superchain-registry
63+ /// using either the `saveProxyAndImpl` or `artifacts.save()` functions.
64+ function _readSuperchainRegistry () internal {
4565 string memory superchainBasePath = "./lib/superchain-registry/superchain/configs/ " ;
4666
47- // Read the superchain config files
48- // During development of an upgrade which adds a new contract, the contract will not yet be present in the
49- // superchain-registry. In this case, the contract will be deployed by the upgrade process, and will need to
50- // be saved by after the call to opcm.upgrade().
51- // After the upgrade is complete, the superchain-registry will be updated and the contract will be present.
52- // At this point, the test will need to be updated to read the new contract from the superchain-registry using
53- // either the `saveProxyAndImpl` or `save` functions.
5467 string memory superchainToml = vm.readFile (string .concat (superchainBasePath, baseChain (), "/superchain.toml " ));
5568 string memory opToml = vm.readFile (string .concat (superchainBasePath, baseChain (), "/ " , opChain (), ".toml " ));
5669
@@ -99,13 +112,21 @@ contract ForkLive is Deployer {
99112 artifacts.save ("PermissionedDelayedWETHProxy " , address (permissionedDisputeGame.weth ()));
100113 }
101114
115+ /// @notice Calls to the Deploy.s.sol contract etched by Setup.sol to a deterministic address, sets up the
116+ /// environment, and deploys new implementations.
117+ function _deployNewImplementations () internal {
118+ Deploy deploy = Deploy (address (uint160 (uint256 (keccak256 (abi.encode ("optimism.deploy " ))))));
119+ deploy.deployImplementations ({ _isInterop: false });
120+ }
121+
102122 /// @notice Saves the proxy and implementation addresses for a contract name
103123 /// @param _contractName The name of the contract to save
104124 /// @param _tomlPath The path to the superchain config file
105125 /// @param _tomlKey The key in the superchain config file to get the proxy address
106126 function saveProxyAndImpl (string memory _contractName , string memory _tomlPath , string memory _tomlKey ) internal {
107127 address proxy = vm.parseTomlAddress (_tomlPath, _tomlKey);
108128 artifacts.save (string .concat (_contractName, "Proxy " ), proxy);
129+
109130 address impl = EIP1967Helper.getImplementation (proxy);
110131 require (impl != address (0 ), "Upgrade: Implementation address is zero " );
111132 artifacts.save (string .concat (_contractName, "Impl " ), impl);
0 commit comments