Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
26 changes: 13 additions & 13 deletions packages/contracts-bedrock/snapshots/abi/ConditionalDeployer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
[
{
"inputs": [],
"name": "DETERMINISTIC_DEPLOYMENT_PROXY",
"outputs": [
{
"internalType": "address payable",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 10 additions & 3 deletions packages/contracts-bedrock/src/L2/ConditionalDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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";
Expand Down Expand Up @@ -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;
}
}
21 changes: 9 additions & 12 deletions packages/contracts-bedrock/test/L2/ConditionalDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
}
}
Expand All @@ -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
)
)
)
Expand Down Expand Up @@ -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
)
)
)
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts-bedrock/test/setup/FeatureFlags.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down