Skip to content

Commit

Permalink
Merge pull request #7352 from mdehoog/michael/deploy-impl-salt
Browse files Browse the repository at this point in the history
L1 contract deploy: add support for customization of the IMPL_SALT
  • Loading branch information
tynes committed Sep 22, 2023
2 parents 99d0ef1 + 17225b7 commit a7ff5a8
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions packages/contracts-bedrock/scripts/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ import "src/libraries/DisputeTypes.sol";
contract Deploy is Deployer {
DeployConfig cfg;

/// @notice The create2 salt used for deployment of the contract implementations.
/// Using this helps to reduce config across networks as the implementation
/// addresses will be the same across networks when deployed with create2.
bytes32 constant IMPL_SALT = keccak256(bytes("ether's phoenix"));

/// @notice The name of the script, used to ensure the right deploy artifacts
/// are used.
function name() public pure override returns (string memory name_) {
Expand Down Expand Up @@ -92,6 +87,13 @@ contract Deploy is Deployer {
transferDisputeGameFactoryOwnership();
}

/// @notice The create2 salt used for deployment of the contract implementations.
/// Using this helps to reduce config across networks as the implementation
/// addresses will be the same across networks when deployed with create2.
function implSalt() public returns (bytes32) {
return keccak256(bytes(vm.envOr("IMPL_SALT", string("ether's phoenix"))));
}

/// @notice Modifier that wraps a function in broadcasting.
modifier broadcast() {
vm.startBroadcast();
Expand Down Expand Up @@ -327,7 +329,7 @@ contract Deploy is Deployer {

/// @notice Deploy the L1CrossDomainMessenger
function deployL1CrossDomainMessenger() public broadcast returns (address addr_) {
L1CrossDomainMessenger messenger = new L1CrossDomainMessenger{ salt: IMPL_SALT }();
L1CrossDomainMessenger messenger = new L1CrossDomainMessenger{ salt: implSalt() }();

require(address(messenger.PORTAL()) == address(0));
require(address(messenger.portal()) == address(0));
Expand All @@ -343,7 +345,7 @@ contract Deploy is Deployer {

/// @notice Deploy the OptimismPortal
function deployOptimismPortal() public broadcast returns (address addr_) {
OptimismPortal portal = new OptimismPortal{ salt: IMPL_SALT }();
OptimismPortal portal = new OptimismPortal{ salt: implSalt() }();

require(address(portal.L2_ORACLE()) == address(0));
require(portal.GUARDIAN() == address(0));
Expand All @@ -358,7 +360,7 @@ contract Deploy is Deployer {

/// @notice Deploy the L2OutputOracle
function deployL2OutputOracle() public broadcast returns (address addr_) {
L2OutputOracle oracle = new L2OutputOracle{ salt: IMPL_SALT }({
L2OutputOracle oracle = new L2OutputOracle{ salt: implSalt() }({
_submissionInterval: cfg.l2OutputOracleSubmissionInterval(),
_l2BlockTime: cfg.l2BlockTime(),
_finalizationPeriodSeconds: cfg.finalizationPeriodSeconds()
Expand All @@ -385,7 +387,7 @@ contract Deploy is Deployer {

/// @notice Deploy the OptimismMintableERC20Factory
function deployOptimismMintableERC20Factory() public broadcast returns (address addr_) {
OptimismMintableERC20Factory factory = new OptimismMintableERC20Factory{ salt: IMPL_SALT }();
OptimismMintableERC20Factory factory = new OptimismMintableERC20Factory{ salt: implSalt() }();

require(factory.BRIDGE() == address(0));
require(factory.bridge() == address(0));
Expand All @@ -398,7 +400,7 @@ contract Deploy is Deployer {

/// @notice Deploy the DisputeGameFactory
function deployDisputeGameFactory() public onlyDevnet broadcast returns (address addr_) {
DisputeGameFactory factory = new DisputeGameFactory{ salt: IMPL_SALT }();
DisputeGameFactory factory = new DisputeGameFactory{ salt: implSalt() }();
save("DisputeGameFactory", address(factory));
console.log("DisputeGameFactory deployed at %s", address(factory));

Expand All @@ -407,7 +409,7 @@ contract Deploy is Deployer {

/// @notice Deploy the BlockOracle
function deployBlockOracle() public onlyDevnet broadcast returns (address addr_) {
BlockOracle oracle = new BlockOracle{ salt: IMPL_SALT }();
BlockOracle oracle = new BlockOracle{ salt: implSalt() }();
save("BlockOracle", address(oracle));
console.log("BlockOracle deployed at %s", address(oracle));

Expand All @@ -416,7 +418,7 @@ contract Deploy is Deployer {

/// @notice Deploy the ProtocolVersions
function deployProtocolVersions() public onlyTestnetOrDevnet broadcast returns (address addr_) {
ProtocolVersions versions = new ProtocolVersions{ salt: IMPL_SALT }();
ProtocolVersions versions = new ProtocolVersions{ salt: implSalt() }();
save("ProtocolVersions", address(versions));
console.log("ProtocolVersions deployed at %s", address(versions));

Expand All @@ -425,7 +427,7 @@ contract Deploy is Deployer {

/// @notice Deploy the PreimageOracle
function deployPreimageOracle() public onlyDevnet broadcast returns (address addr_) {
PreimageOracle preimageOracle = new PreimageOracle{ salt: IMPL_SALT }();
PreimageOracle preimageOracle = new PreimageOracle{ salt: implSalt() }();
save("PreimageOracle", address(preimageOracle));
console.log("PreimageOracle deployed at %s", address(preimageOracle));

Expand All @@ -434,7 +436,7 @@ contract Deploy is Deployer {

/// @notice Deploy Mips
function deployMips() public onlyDevnet broadcast returns (address addr_) {
MIPS mips = new MIPS{ salt: IMPL_SALT }(IPreimageOracle(mustGetAddress("PreimageOracle")));
MIPS mips = new MIPS{ salt: implSalt() }(IPreimageOracle(mustGetAddress("PreimageOracle")));
save("Mips", address(mips));
console.log("MIPS deployed at %s", address(mips));

Expand All @@ -443,7 +445,7 @@ contract Deploy is Deployer {

/// @notice Deploy the SystemConfig
function deploySystemConfig() public broadcast returns (address addr_) {
SystemConfig config = new SystemConfig{ salt: IMPL_SALT }();
SystemConfig config = new SystemConfig{ salt: implSalt() }();

require(config.owner() == address(0xdEaD));
require(config.overhead() == 0);
Expand Down Expand Up @@ -476,7 +478,7 @@ contract Deploy is Deployer {

/// @notice Deploy the L1StandardBridge
function deployL1StandardBridge() public broadcast returns (address addr_) {
L1StandardBridge bridge = new L1StandardBridge{ salt: IMPL_SALT }();
L1StandardBridge bridge = new L1StandardBridge{ salt: implSalt() }();

require(address(bridge.MESSENGER()) == address(0));
require(address(bridge.messenger()) == address(0));
Expand All @@ -491,7 +493,7 @@ contract Deploy is Deployer {

/// @notice Deploy the L1ERC721Bridge
function deployL1ERC721Bridge() public broadcast returns (address addr_) {
L1ERC721Bridge bridge = new L1ERC721Bridge{ salt: IMPL_SALT }();
L1ERC721Bridge bridge = new L1ERC721Bridge{ salt: implSalt() }();

require(address(bridge.MESSENGER()) == address(0));
require(bridge.OTHER_BRIDGE() == Predeploys.L2_ERC721_BRIDGE);
Expand Down

0 comments on commit a7ff5a8

Please sign in to comment.