Skip to content

Commit

Permalink
feat: deployImplementations and depImplementationsInterop (ethereum-o…
Browse files Browse the repository at this point in the history
…ptimism#12226)

* feat: Use DeploySuperchain script in Deploy.s.sol

Demonstrate that build breaks when using high level syntax

* fix: Cannot set null protocol versions error

* feat: Also save impls

* fix: semver lock

* fix: bump ProtocolVersions semver

* feat: Add superchainProxyAdmin

* feat: Undo removeing ProtocolVersion type from interface

* fix: semver-lock

* feat: remove setupOpChainAdmin

* fix: transfer ProxyAdmin ownership after all setup is complete

* feat: separate deployImplementations

* feat: split up deployImplementations and deployImplementationsInterop

* fix: lint
  • Loading branch information
maurelian authored Oct 2, 2024
1 parent b1d119f commit a12738b
Showing 1 changed file with 83 additions and 54 deletions.
137 changes: 83 additions & 54 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -269,30 +269,27 @@ contract Deploy is Deployer {
setupSuperchain();
console.log("set up superchain!");
}

setupOpChainAdmin();
if (cfg.useInterop()) {
deployImplementationsInterop();
} else {
deployImplementations();
}
setupOpChain();
if (cfg.useAltDA()) {
bytes32 typeHash = keccak256(bytes(cfg.daCommitmentType()));
bytes32 keccakHash = keccak256(bytes("KeccakCommitment"));
if (typeHash == keccakHash) {
setupOpAltDA();
}
}

setupOpChain();
transferProxyAdminOwnership({ _isSuperchain: false });
console.log("set up op chain!");
}

////////////////////////////////////////////////////////////////
// High Level Deployment Functions //
////////////////////////////////////////////////////////////////

/// @notice Deploy the address manager and proxy admin contracts.
function setupOpChainAdmin() public {
deployAddressManager();
deployProxyAdmin({ _isSuperchain: false });
}

/// @notice Deploy a full system with a new SuperchainConfig
/// The Superchain system has 2 singleton contracts which lie outside of an OP Chain:
/// 1. The SuperchainConfig contract
Expand Down Expand Up @@ -324,14 +321,14 @@ contract Deploy is Deployer {
/// @notice Deploy a new OP Chain, with an existing SuperchainConfig provided
function setupOpChain() public {
console.log("Deploying OP Chain");
deployAddressManager();
deployProxyAdmin({ _isSuperchain: false });

// Ensure that the requisite contracts are deployed
mustGetAddress("SuperchainConfigProxy");
mustGetAddress("AddressManager");
mustGetAddress("ProxyAdmin");

deployImplementations();

deployOpChain();
initializeOpChain();

Expand All @@ -342,7 +339,6 @@ contract Deploy is Deployer {

transferDisputeGameFactoryOwnership();
transferDelayedWETHOwnership();
transferProxyAdminOwnership({ _isSuperchain: false });
}

/// @notice Deploy all of the OP Chain specific contracts
Expand Down Expand Up @@ -378,8 +374,9 @@ contract Deploy is Deployer {
deploySystemConfig();
deployL1StandardBridge();
deployL1ERC721Bridge();
deployOptimismPortal();
deployOptimismPortal(); // todo: pull this out into an override option after DeployImplementations runs
deployL2OutputOracle();

// Fault proofs
deployOptimismPortal2();
deployDisputeGameFactory();
Expand All @@ -388,6 +385,24 @@ contract Deploy is Deployer {
deployMips();
}

/// @notice Deploy all of the implementations
function deployImplementationsInterop() public {
console.log("Deploying implementations");
deployL1CrossDomainMessenger();
deployOptimismMintableERC20Factory();
deploySystemConfigInterop();
deployL1StandardBridge();
deployL1ERC721Bridge();
deployL2OutputOracle();

// Fault proofs
deployOptimismPortalInterop();
deployDisputeGameFactory();
deployDelayedWETH();
deployPreimageOracle();
deployMips();
}

/// @notice Initialize all of the proxies in an OP Chain by upgrading to the correct proxy and calling the
/// initialize function
function initializeOpChain() public {
Expand Down Expand Up @@ -633,32 +648,45 @@ contract Deploy is Deployer {
uint32(cfg.respectedGameType()) == cfg.respectedGameType(), "Deploy: respectedGameType must fit into uint32"
);

if (cfg.useInterop()) {
addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "OptimismPortalInterop",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IOptimismPortalInterop.__constructor__,
(cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds())
)
addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "OptimismPortal2",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IOptimismPortal2.__constructor__,
(cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds())
)
});
save("OptimismPortal2", addr_);
} else {
addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "OptimismPortal2",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IOptimismPortal2.__constructor__,
(cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds())
)
)
});

// Override the `OptimismPortal2` contract to the deployed implementation. This is necessary
// to check the `OptimismPortal2` implementation alongside dependent contracts, which
// are always proxies.
Types.ContractSet memory contracts = _proxiesUnstrict();
contracts.OptimismPortal2 = addr_;
ChainAssertions.checkOptimismPortal2({ _contracts: contracts, _cfg: cfg, _isProxy: false });
}

/// @notice Deploy the OptimismPortalInterop contract
function deployOptimismPortalInterop() public broadcast returns (address addr_) {
// Could also verify this inside DeployConfig but doing it here is a bit more reliable.
require(
uint32(cfg.respectedGameType()) == cfg.respectedGameType(), "Deploy: respectedGameType must fit into uint32"
);

addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "OptimismPortalInterop",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IOptimismPortalInterop.__constructor__,
(cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds())
)
});
}
)
});
save("OptimismPortal2", addr_);

// Override the `OptimismPortal2` contract to the deployed implementation. This is necessary
// to check the `OptimismPortal2` implementation alongside dependent contracts, which
Expand Down Expand Up @@ -814,22 +842,23 @@ contract Deploy is Deployer {

/// @notice Deploy the SystemConfig
function deploySystemConfig() public broadcast returns (address addr_) {
if (cfg.useInterop()) {
addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "SystemConfigInterop",
_args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfigInterop.__constructor__, ()))
});
save("SystemConfig", addr_);
} else {
addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "SystemConfig",
_args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfig.__constructor__, ()))
});
}
addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "SystemConfig",
_args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfig.__constructor__, ()))
});
}

/// @notice Deploy the SystemConfigInterop contract
function deploySystemConfigInterop() public broadcast returns (address addr_) {
addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "SystemConfigInterop",
_args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfigInterop.__constructor__, ()))
});
save("SystemConfig", addr_);

// Override the `SystemConfig` contract to the deployed implementation. This is necessary
// to check the `SystemConfig` implementation alongside dependent contracts, which
Expand Down

0 comments on commit a12738b

Please sign in to comment.