From 4594dc5661627e4eeb86db7adaa5fb3eba206096 Mon Sep 17 00:00:00 2001 From: prateek Date: Fri, 24 Jan 2025 01:20:17 +0530 Subject: [PATCH 1/7] add option to load fork state --- packages/contracts-bedrock/test/setup/ForkLive.s.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/contracts-bedrock/test/setup/ForkLive.s.sol b/packages/contracts-bedrock/test/setup/ForkLive.s.sol index 60fa31d619329..709b5e7c4a69e 100644 --- a/packages/contracts-bedrock/test/setup/ForkLive.s.sol +++ b/packages/contracts-bedrock/test/setup/ForkLive.s.sol @@ -53,6 +53,10 @@ contract ForkLive is Deployer { /// 2. deploying the updated OPCM and implementations of the contracts. /// 3. upgrading the system using the OPCM.upgrade() function. function run() public { + if (bytes(vm.envString("LOAD_STATE_PATH")).length > 0) { + console.log("ForkLive: loading state from %s", vm.envString("LOAD_STATE_PATH")); + vm.loadAllocs(vm.envString("LOAD_STATE_PATH")); + } // Read the superchain registry and save the addresses to the Artifacts contract. _readSuperchainRegistry(); From a86c2a1526f5551c1726f334b0a0cc8bc8057d79 Mon Sep 17 00:00:00 2001 From: Elliot Date: Thu, 23 Jan 2025 18:22:22 -0600 Subject: [PATCH 2/7] address feedback on run function structure Signed-off-by: Elliot --- .../test/setup/ForkLive.s.sol | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/contracts-bedrock/test/setup/ForkLive.s.sol b/packages/contracts-bedrock/test/setup/ForkLive.s.sol index 709b5e7c4a69e..a70bfb6d8aea6 100644 --- a/packages/contracts-bedrock/test/setup/ForkLive.s.sol +++ b/packages/contracts-bedrock/test/setup/ForkLive.s.sol @@ -49,24 +49,31 @@ contract ForkLive is Deployer { /// @notice Forks, upgrades and tests a production network. /// @dev This function sets up the system to test by: - /// 1. reading the superchain-registry to get the contract addresses we wish to test from that network. - /// 2. deploying the updated OPCM and implementations of the contracts. - /// 3. upgrading the system using the OPCM.upgrade() function. + /// 0. reading the environment variable to determine the base and OP chain names, read the STATE_PATH data created from superchain ops. + /// 1. if the environment variable is set, load the state from the given path. + /// 2. read the superchain-registry to get the contract addresses we wish to test from that network. + /// 3. deploying the updated OPCM and implementations of the contracts. + /// 4. upgrading the system using the OPCM.upgrade() function if not using the applied state from superchain ops. function run() public { - if (bytes(vm.envString("LOAD_STATE_PATH")).length > 0) { - console.log("ForkLive: loading state from %s", vm.envString("LOAD_STATE_PATH")); - vm.loadAllocs(vm.envString("LOAD_STATE_PATH")); + bool useOpsRepo = bytes(vm.envOr("STATE_PATH", string(""))).length > 0; + if (useOpsRepo) { + console.log("ForkLive: loading state from %s", vm.envString("STATE_PATH")); + vm.loadAllocs(vm.envString("STATE_PATH")); + _readSuperchainRegistry(); + } else{ + // Read the superchain registry and save the addresses to the Artifacts contract. + _readSuperchainRegistry(); + // Now deploy the updated OPCM and implementations of the contracts + _deployNewImplementations(); } - // Read the superchain registry and save the addresses to the Artifacts contract. - _readSuperchainRegistry(); - - // Now deploy the updated OPCM and implementations of the contracts - _deployNewImplementations(); // Now upgrade the contracts (if the config is set to do so) if (cfg.useUpgradedFork()) { + require(!useOpsRepo, "ForkLive: cannot upgrade and use ops repo"); console.log("ForkLive: upgrading"); _upgrade(); + } else if (useOpsRepo) { + console.log("ForkLive: using ops repo to upgrade"); } } From 93ed5d50991289303c2c0a1ec2335bbdd776ac21 Mon Sep 17 00:00:00 2001 From: Elliot Date: Thu, 23 Jan 2025 18:29:29 -0600 Subject: [PATCH 3/7] fmt Signed-off-by: Elliot --- packages/contracts-bedrock/test/setup/ForkLive.s.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/contracts-bedrock/test/setup/ForkLive.s.sol b/packages/contracts-bedrock/test/setup/ForkLive.s.sol index a70bfb6d8aea6..1c64f421f3203 100644 --- a/packages/contracts-bedrock/test/setup/ForkLive.s.sol +++ b/packages/contracts-bedrock/test/setup/ForkLive.s.sol @@ -49,18 +49,20 @@ contract ForkLive is Deployer { /// @notice Forks, upgrades and tests a production network. /// @dev This function sets up the system to test by: - /// 0. reading the environment variable to determine the base and OP chain names, read the STATE_PATH data created from superchain ops. + /// 0. reading the environment variable to determine the base and OP chain names, read the STATE_PATH data + /// created from superchain ops. /// 1. if the environment variable is set, load the state from the given path. /// 2. read the superchain-registry to get the contract addresses we wish to test from that network. /// 3. deploying the updated OPCM and implementations of the contracts. - /// 4. upgrading the system using the OPCM.upgrade() function if not using the applied state from superchain ops. + /// 4. upgrading the system using the OPCM.upgrade() function if not using the applied state from superchain + /// ops. function run() public { bool useOpsRepo = bytes(vm.envOr("STATE_PATH", string(""))).length > 0; if (useOpsRepo) { console.log("ForkLive: loading state from %s", vm.envString("STATE_PATH")); vm.loadAllocs(vm.envString("STATE_PATH")); _readSuperchainRegistry(); - } else{ + } else { // Read the superchain registry and save the addresses to the Artifacts contract. _readSuperchainRegistry(); // Now deploy the updated OPCM and implementations of the contracts From c42eb7ea29bd900ed01888190bf626ede151bfa7 Mon Sep 17 00:00:00 2001 From: Elliot Date: Thu, 23 Jan 2025 18:49:29 -0600 Subject: [PATCH 4/7] update env var name Signed-off-by: Elliot --- packages/contracts-bedrock/test/setup/ForkLive.s.sol | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/contracts-bedrock/test/setup/ForkLive.s.sol b/packages/contracts-bedrock/test/setup/ForkLive.s.sol index 1c64f421f3203..683c41e7327cc 100644 --- a/packages/contracts-bedrock/test/setup/ForkLive.s.sol +++ b/packages/contracts-bedrock/test/setup/ForkLive.s.sol @@ -49,7 +49,8 @@ contract ForkLive is Deployer { /// @notice Forks, upgrades and tests a production network. /// @dev This function sets up the system to test by: - /// 0. reading the environment variable to determine the base and OP chain names, read the STATE_PATH data + /// 0. reading the environment variable to determine the base and OP chain names, read the + /// SUPERCHAIN_OPS_ALLOCS_PATH data /// created from superchain ops. /// 1. if the environment variable is set, load the state from the given path. /// 2. read the superchain-registry to get the contract addresses we wish to test from that network. @@ -57,10 +58,10 @@ contract ForkLive is Deployer { /// 4. upgrading the system using the OPCM.upgrade() function if not using the applied state from superchain /// ops. function run() public { - bool useOpsRepo = bytes(vm.envOr("STATE_PATH", string(""))).length > 0; + bool useOpsRepo = bytes(vm.envOr("SUPERCHAIN_OPS_ALLOCS_PATH", string(""))).length > 0; if (useOpsRepo) { - console.log("ForkLive: loading state from %s", vm.envString("STATE_PATH")); - vm.loadAllocs(vm.envString("STATE_PATH")); + console.log("ForkLive: loading state from %s", vm.envString("SUPERCHAIN_OPS_ALLOCS_PATH")); + vm.loadAllocs(vm.envString("SUPERCHAIN_OPS_ALLOCS_PATH")); _readSuperchainRegistry(); } else { // Read the superchain registry and save the addresses to the Artifacts contract. From f505a1565dd7403d599e75fd01666cc24976be77 Mon Sep 17 00:00:00 2001 From: Elliot Date: Thu, 23 Jan 2025 20:04:33 -0600 Subject: [PATCH 5/7] address feedback Signed-off-by: Elliot --- packages/contracts-bedrock/test/setup/ForkLive.s.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/contracts-bedrock/test/setup/ForkLive.s.sol b/packages/contracts-bedrock/test/setup/ForkLive.s.sol index 683c41e7327cc..2f59122c03c44 100644 --- a/packages/contracts-bedrock/test/setup/ForkLive.s.sol +++ b/packages/contracts-bedrock/test/setup/ForkLive.s.sol @@ -58,10 +58,12 @@ contract ForkLive is Deployer { /// 4. upgrading the system using the OPCM.upgrade() function if not using the applied state from superchain /// ops. function run() public { - bool useOpsRepo = bytes(vm.envOr("SUPERCHAIN_OPS_ALLOCS_PATH", string(""))).length > 0; + string memory superchainOpsAllocsPath = vm.envOr("SUPERCHAIN_OPS_ALLOCS_PATH", string("")); + + bool useOpsRepo = bytes(superchainOpsAllocsPath).length > 0; if (useOpsRepo) { - console.log("ForkLive: loading state from %s", vm.envString("SUPERCHAIN_OPS_ALLOCS_PATH")); - vm.loadAllocs(vm.envString("SUPERCHAIN_OPS_ALLOCS_PATH")); + console.log("ForkLive: loading state from %s", superchainOpsAllocsPath); + vm.loadAllocs(superchainOpsAllocsPath); _readSuperchainRegistry(); } else { // Read the superchain registry and save the addresses to the Artifacts contract. From ed0e12120252b58366d7e8b4c984883cef018c0e Mon Sep 17 00:00:00 2001 From: Elliot <34463580+ElliotFriedman@users.noreply.github.com> Date: Mon, 27 Jan 2025 12:40:58 -0500 Subject: [PATCH 6/7] Update packages/contracts-bedrock/test/setup/ForkLive.s.sol Co-authored-by: Matt Solomon --- packages/contracts-bedrock/test/setup/ForkLive.s.sol | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/contracts-bedrock/test/setup/ForkLive.s.sol b/packages/contracts-bedrock/test/setup/ForkLive.s.sol index 2f59122c03c44..36ce56c3f72e7 100644 --- a/packages/contracts-bedrock/test/setup/ForkLive.s.sol +++ b/packages/contracts-bedrock/test/setup/ForkLive.s.sol @@ -50,8 +50,7 @@ contract ForkLive is Deployer { /// @notice Forks, upgrades and tests a production network. /// @dev This function sets up the system to test by: /// 0. reading the environment variable to determine the base and OP chain names, read the - /// SUPERCHAIN_OPS_ALLOCS_PATH data - /// created from superchain ops. + /// SUPERCHAIN_OPS_ALLOCS_PATH data created from superchain ops. /// 1. if the environment variable is set, load the state from the given path. /// 2. read the superchain-registry to get the contract addresses we wish to test from that network. /// 3. deploying the updated OPCM and implementations of the contracts. From 3a7df1e466018e7449de67be5b7ec266ea3119e9 Mon Sep 17 00:00:00 2001 From: Elliot Date: Mon, 27 Jan 2025 09:44:46 -0800 Subject: [PATCH 7/7] update comments Signed-off-by: Elliot --- packages/contracts-bedrock/test/setup/ForkLive.s.sol | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/contracts-bedrock/test/setup/ForkLive.s.sol b/packages/contracts-bedrock/test/setup/ForkLive.s.sol index 36ce56c3f72e7..bb4a5817a2b38 100644 --- a/packages/contracts-bedrock/test/setup/ForkLive.s.sol +++ b/packages/contracts-bedrock/test/setup/ForkLive.s.sol @@ -49,8 +49,8 @@ contract ForkLive is Deployer { /// @notice Forks, upgrades and tests a production network. /// @dev This function sets up the system to test by: - /// 0. reading the environment variable to determine the base and OP chain names, read the - /// SUPERCHAIN_OPS_ALLOCS_PATH data created from superchain ops. + /// 0. read the environment variable to determine the + /// SUPERCHAIN_OPS_ALLOCS_PATH environment variable set from superchain ops. /// 1. if the environment variable is set, load the state from the given path. /// 2. read the superchain-registry to get the contract addresses we wish to test from that network. /// 3. deploying the updated OPCM and implementations of the contracts. @@ -62,7 +62,11 @@ contract ForkLive is Deployer { bool useOpsRepo = bytes(superchainOpsAllocsPath).length > 0; if (useOpsRepo) { console.log("ForkLive: loading state from %s", superchainOpsAllocsPath); + /// run the upgrades from the ops repo first vm.loadAllocs(superchainOpsAllocsPath); + /// then fetch the addresses from the superchain registry after the upgrade + /// as this function will read the logic contract addresses which may have + /// changed from the upgrade. _readSuperchainRegistry(); } else { // Read the superchain registry and save the addresses to the Artifacts contract.