diff --git a/packages/contracts-bedrock/interfaces/L2/IConditionalDeployer.sol b/packages/contracts-bedrock/interfaces/L2/IConditionalDeployer.sol index bf14e8e435c..0fa6e57c800 100644 --- a/packages/contracts-bedrock/interfaces/L2/IConditionalDeployer.sol +++ b/packages/contracts-bedrock/interfaces/L2/IConditionalDeployer.sol @@ -18,13 +18,13 @@ interface IConditionalDeployer is ISemver { /// @notice Error thrown when deployment fails. error ConditionalDeployer_DeploymentFailed(bytes data); - /// @notice Address of the DeterministicDeploymentProxy (Nick's method). - function DETERMINISTIC_DEPLOYMENT_PROXY() external view returns (address payable); - /// @notice Deploys an implementation using CREATE2 if it doesn't already exist. /// @param _value The amount of ETH to send with the deployment. /// @param _salt The salt to use for CREATE2 deployment. /// @param _code The initialization code for the contract. /// @return implementation_ The address of the deployed or existing implementation. function deploy(uint256 _value, bytes32 _salt, bytes memory _code) external returns (address implementation_); + + /// @notice Address of the DeterministicDeploymentProxy (Nick's method). + function deterministicDeploymentProxy() external pure returns (address payable deterministicDeploymentProxy_); } diff --git a/packages/contracts-bedrock/snapshots/abi/ConditionalDeployer.json b/packages/contracts-bedrock/snapshots/abi/ConditionalDeployer.json index 922177b8e24..f79de366688 100644 --- a/packages/contracts-bedrock/snapshots/abi/ConditionalDeployer.json +++ b/packages/contracts-bedrock/snapshots/abi/ConditionalDeployer.json @@ -1,17 +1,4 @@ [ - { - "inputs": [], - "name": "DETERMINISTIC_DEPLOYMENT_PROXY", - "outputs": [ - { - "internalType": "address payable", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -41,6 +28,19 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "deterministicDeploymentProxy", + "outputs": [ + { + "internalType": "address payable", + "name": "deterministicDeploymentProxy_", + "type": "address" + } + ], + "stateMutability": "pure", + "type": "function" + }, { "inputs": [], "name": "version", diff --git a/packages/contracts-bedrock/snapshots/semver-lock.json b/packages/contracts-bedrock/snapshots/semver-lock.json index 873c9fa81d7..81cd93dfb55 100644 --- a/packages/contracts-bedrock/snapshots/semver-lock.json +++ b/packages/contracts-bedrock/snapshots/semver-lock.json @@ -60,8 +60,8 @@ "sourceCodeHash": "0xcb329746df0baddd3dc03c6c88da5d6bdc0f0a96d30e6dc78d0891bb1e935032" }, "src/L2/ConditionalDeployer.sol:ConditionalDeployer": { - "initCodeHash": "0x6b88fe95359f7166b90bcf9414b91cef3662be2e02b4a0540e486a5040c9e84c", - "sourceCodeHash": "0xaf67802e6fc99cb9a267bef3a736cf97e032ec215fc8fb8ca15c3f17eb978543" + "initCodeHash": "0x0832b6528dbe32959c0e633599d2c7d3c634760003704fa2f3edc9154abfcff0", + "sourceCodeHash": "0x6a65f3b260d68b0c41abc97d9f0410536c2aa27e8576a4b5ef83546fd8ec9630" }, "src/L2/CrossL2Inbox.sol:CrossL2Inbox": { "initCodeHash": "0x56f868e561c4abe539043f98b16aad9305479e68fd03ece2233249b0c73a24ea", diff --git a/packages/contracts-bedrock/src/L2/ConditionalDeployer.sol b/packages/contracts-bedrock/src/L2/ConditionalDeployer.sol index 893922f15b7..e43138d46dd 100644 --- a/packages/contracts-bedrock/src/L2/ConditionalDeployer.sol +++ b/packages/contracts-bedrock/src/L2/ConditionalDeployer.sol @@ -10,9 +10,6 @@ import { ISemver } from "interfaces/universal/ISemver.sol"; /// @notice ConditionalDeployer is used to deploy implementations for predeploys during network upgrades. /// It uses the DeterministicDeploymentProxy (Nick's method) to deploy the implementations. contract ConditionalDeployer is ISemver { - /// @notice Address of the DeterministicDeploymentProxy (Nick's method). - address payable public constant DETERMINISTIC_DEPLOYMENT_PROXY = payable(0x4e59b44847b379578588920cA78FbF26c0B4956C); - /// @notice Emitted when an implementation is deployed. /// @param implementation The address of the deployed implementation. /// @param salt The salt used for deployment. @@ -25,6 +22,10 @@ contract ConditionalDeployer is ISemver { /// @notice Error thrown when deployment fails. error ConditionalDeployer_DeploymentFailed(bytes data); + /// @notice Address of the DeterministicDeploymentProxy (Nick's method). + address payable internal constant DETERMINISTIC_DEPLOYMENT_PROXY = + payable(0x4e59b44847b379578588920cA78FbF26c0B4956C); + /// @notice Semantic version. /// @custom:semver 1.0.0 string public constant version = "1.0.0"; @@ -58,4 +59,10 @@ contract ConditionalDeployer is ISemver { emit ImplementationDeployed(implementation_, _salt); return implementation_; } + + /// @notice Returns the address of the DeterministicDeploymentProxy (Nick's method). + /// @return deterministicDeploymentProxy_ The address of the DeterministicDeploymentProxy (Nick's method). + function deterministicDeploymentProxy() external pure returns (address payable deterministicDeploymentProxy_) { + deterministicDeploymentProxy_ = DETERMINISTIC_DEPLOYMENT_PROXY; + } } diff --git a/packages/contracts-bedrock/test/L2/ConditionalDeployer.t.sol b/packages/contracts-bedrock/test/L2/ConditionalDeployer.t.sol index d33d4e7134e..fa476291754 100644 --- a/packages/contracts-bedrock/test/L2/ConditionalDeployer.t.sol +++ b/packages/contracts-bedrock/test/L2/ConditionalDeployer.t.sol @@ -2,10 +2,10 @@ pragma solidity 0.8.15; // Testing -import { Test } from "forge-std/Test.sol"; +import { CommonTest } from "test/setup/CommonTest.sol"; // Libraries -import { Config } from "scripts/libraries/Config.sol"; +import { DevFeatures } from "src/libraries/DevFeatures.sol"; // Contracts import { ConditionalDeployer } from "src/L2/ConditionalDeployer.sol"; @@ -22,17 +22,14 @@ contract ConditionalDeployer_Harness { /// @title ConditionalDeployer_TestInit /// @notice Reusable test initialization for `ConditionalDeployer` tests. -contract ConditionalDeployer_TestInit is Test { +contract ConditionalDeployer_TestInit is CommonTest { // Test contracts - ConditionalDeployer public conditionalDeployer; bytes public simpleContractCreationCode; - function setUp() public { - // Create fork - vm.createSelectFork(Config.forkRpcUrl()); - + function setUp() public override { + super.setUp(); + skipIfDevFeatureDisabled(DevFeatures.L2CM); // Deploy contracts - conditionalDeployer = new ConditionalDeployer(); simpleContractCreationCode = type(ConditionalDeployer_Harness).creationCode; } } @@ -55,7 +52,7 @@ contract ConditionalDeployer_Deploy_Test is ConditionalDeployer_TestInit { uint256( keccak256( abi.encodePacked( - bytes1(0xff), conditionalDeployer.DETERMINISTIC_DEPLOYMENT_PROXY(), _salt, codeHash + bytes1(0xff), conditionalDeployer.deterministicDeploymentProxy(), _salt, codeHash ) ) ) @@ -84,7 +81,7 @@ contract ConditionalDeployer_Deploy_Test is ConditionalDeployer_TestInit { uint256( keccak256( abi.encodePacked( - bytes1(0xff), conditionalDeployer.DETERMINISTIC_DEPLOYMENT_PROXY(), _salt, codeHash + bytes1(0xff), conditionalDeployer.deterministicDeploymentProxy(), _salt, codeHash ) ) ) @@ -116,7 +113,7 @@ contract ConditionalDeployer_Deploy_Test is ConditionalDeployer_TestInit { bytes memory _initCode = abi.encodePacked(simpleContractCreationCode, abi.encode(0)); vm.mockCallRevert( - conditionalDeployer.DETERMINISTIC_DEPLOYMENT_PROXY(), _value, abi.encodePacked(_salt, _initCode), bytes("") + conditionalDeployer.deterministicDeploymentProxy(), _value, abi.encodePacked(_salt, _initCode), bytes("") ); vm.prank(_caller); diff --git a/packages/contracts-bedrock/test/setup/FeatureFlags.sol b/packages/contracts-bedrock/test/setup/FeatureFlags.sol index 772b6a9bb91..b9c22cae022 100644 --- a/packages/contracts-bedrock/test/setup/FeatureFlags.sol +++ b/packages/contracts-bedrock/test/setup/FeatureFlags.sol @@ -45,6 +45,10 @@ abstract contract FeatureFlags { console.log("Setup: DEV_FEATURE__OPCM_V2 is enabled"); devFeatureBitmap |= DevFeatures.OPCM_V2; } + if (Config.devFeatureL2CM()) { + console.log("Setup: DEV_FEATURE__L2CM is enabled"); + devFeatureBitmap |= DevFeatures.L2CM; + } } /// @notice Returns the string name of a feature.