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 @@ -50,8 +50,8 @@
"l2GenesisFjordTimeOffset": "0x0",
"l1CancunTimeOffset": "0x0",
"systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001",
"faultGameAbsolutePrestate": "0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98",
"faultGameMaxDepth": 50,
"faultGameClockExtension": 0,
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/deploy-config/hardhat.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"eip1559Elasticity": 10,
"l2GenesisRegolithTimeOffset": "0x0",
"systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001",
"faultGameAbsolutePrestate": "0x0000000000000000000000000000000000000000000000000000000000000000",
"faultGameMaxDepth": 8,
"faultGameClockExtension": 0,
Expand Down
230 changes: 102 additions & 128 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol";
import { Process } from "scripts/libraries/Process.sol";
import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol";
import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
import { DeploySuperchainInput, DeploySuperchain, DeploySuperchainOutput } from "scripts/DeploySuperchain.s.sol";

// Contracts
import { AddressManager } from "src/legacy/AddressManager.sol";
Expand Down Expand Up @@ -268,59 +269,66 @@ 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
/// 2. The ProtocolVersions contract
function setupSuperchain() public {
console.log("Setting up Superchain");
DeploySuperchain deploySuperchain = new DeploySuperchain();
(DeploySuperchainInput dsi, DeploySuperchainOutput dso) = deploySuperchain.etchIOContracts();

// Deploy the SuperchainConfigProxy
deployERC1967ProxyWithOwner("SuperchainConfigProxy", mustGetAddress("SuperchainProxyAdmin"));
deploySuperchainConfig();
initializeSuperchainConfig();
// Set the input values on the input contract.
dsi.set(dsi.superchainProxyAdminOwner.selector, mustGetAddress("SuperchainProxyAdmin"));
// TODO: when DeployAuthSystem is done, finalSystemOwner should be replaced with the Foundation Upgrades Safe
dsi.set(dsi.protocolVersionsOwner.selector, cfg.finalSystemOwner());
dsi.set(dsi.guardian.selector, cfg.superchainConfigGuardian());
dsi.set(dsi.paused.selector, false);

// Deploy the ProtocolVersionsProxy
deployERC1967ProxyWithOwner("ProtocolVersionsProxy", mustGetAddress("SuperchainProxyAdmin"));
deployProtocolVersions();
initializeProtocolVersions();
dsi.set(dsi.requiredProtocolVersion.selector, ProtocolVersion.wrap(cfg.requiredProtocolVersion()));
dsi.set(dsi.recommendedProtocolVersion.selector, ProtocolVersion.wrap(cfg.recommendedProtocolVersion()));

// Run the deployment script.
deploySuperchain.run(dsi, dso);
save("superchainProxyAdmin", address(dso.superchainProxyAdmin()));
save("SuperchainConfigProxy", address(dso.superchainConfigProxy()));
save("SuperchainConfig", address(dso.superchainConfigImpl()));
save("ProtocolVersionsProxy", address(dso.protocolVersionsProxy()));
save("ProtocolVersions", address(dso.protocolVersionsImpl()));
}

/// @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 @@ -331,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 @@ -367,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 @@ -377,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 @@ -622,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 @@ -751,27 +790,6 @@ contract Deploy is Deployer {
addr_ = address(weth);
}

/// @notice Deploy the ProtocolVersions
function deployProtocolVersions() public broadcast returns (address addr_) {
IProtocolVersions versions = IProtocolVersions(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "ProtocolVersions",
_args: DeployUtils.encodeConstructor(abi.encodeCall(IProtocolVersions.__constructor__, ()))
})
);

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

addr_ = address(versions);
}

/// @notice Deploy the PreimageOracle
function deployPreimageOracle() public broadcast returns (address addr_) {
IPreimageOracle preimageOracle = IPreimageOracle(
Expand Down Expand Up @@ -824,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 Expand Up @@ -923,21 +942,6 @@ contract Deploy is Deployer {
// Initialize Functions //
////////////////////////////////////////////////////////////////

/// @notice Initialize the SuperchainConfig
function initializeSuperchainConfig() public broadcast {
address payable superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");
address payable superchainConfig = mustGetAddress("SuperchainConfig");

IProxyAdmin proxyAdmin = IProxyAdmin(payable(mustGetAddress("SuperchainProxyAdmin")));
proxyAdmin.upgradeAndCall({
_proxy: superchainConfigProxy,
_implementation: superchainConfig,
_data: abi.encodeCall(ISuperchainConfig.initialize, (cfg.superchainConfigGuardian(), false))
});

ChainAssertions.checkSuperchainConfig({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isPaused: false });
}

/// @notice Initialize the DisputeGameFactory
function initializeDisputeGameFactory() public broadcast {
console.log("Upgrading and initializing DisputeGameFactory proxy");
Expand Down Expand Up @@ -1331,36 +1335,6 @@ contract Deploy is Deployer {
ChainAssertions.checkOptimismPortal2({ _contracts: _proxies(), _cfg: cfg, _isProxy: true });
}

function initializeProtocolVersions() public broadcast {
console.log("Upgrading and initializing ProtocolVersions proxy");
address protocolVersionsProxy = mustGetAddress("ProtocolVersionsProxy");
address protocolVersions = mustGetAddress("ProtocolVersions");

address finalSystemOwner = cfg.finalSystemOwner();
uint256 requiredProtocolVersion = cfg.requiredProtocolVersion();
uint256 recommendedProtocolVersion = cfg.recommendedProtocolVersion();

IProxyAdmin proxyAdmin = IProxyAdmin(payable(mustGetAddress("SuperchainProxyAdmin")));
proxyAdmin.upgradeAndCall({
_proxy: payable(protocolVersionsProxy),
_implementation: protocolVersions,
_data: abi.encodeCall(
IProtocolVersions.initialize,
(
finalSystemOwner,
ProtocolVersion.wrap(requiredProtocolVersion),
ProtocolVersion.wrap(recommendedProtocolVersion)
)
)
});

IProtocolVersions versions = IProtocolVersions(protocolVersionsProxy);
string memory version = versions.version();
console.log("ProtocolVersions version: %s", version);

ChainAssertions.checkProtocolVersions({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true });
}

/// @notice Transfer ownership of the DisputeGameFactory contract to the final system owner
function transferDisputeGameFactoryOwnership() public broadcast {
console.log("Transferring DisputeGameFactory ownership to Safe");
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"sourceCodeHash": "0x6401b81f04093863557ef46192f56793daa0d412618065383ab353b2ed2929d8"
},
"src/L1/ProtocolVersions.sol": {
"initCodeHash": "0x8f033874dd8b36615b2209d553660dcff1ff91ca2bad3ca1de7b441dbfba4842",
"sourceCodeHash": "0x5a7e91e02224e02a5a4bbf0fea7e9bd4a1168e2fe5e787023c9a75bcb6c26204"
"initCodeHash": "0xf7a9ed8c772cfb1234988fd6fd195dc21615b216bb39e728e7699b875040d902",
"sourceCodeHash": "0x92f15d62361bffc305f0db48a5676329f8e5ed2e454f8c8ff83ef7d3667d7f01"
},
"src/L1/SuperchainConfig.sol": {
"initCodeHash": "0xfca12d9016c746e5c275b186e0ca40cfd65cf45a5665aab7589a669fea3abb47",
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/src/L1/ProtocolVersions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ contract ProtocolVersions is OwnableUpgradeable, ISemver {
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);

/// @notice Semantic version.
/// @custom:semver 1.0.1-beta.1
string public constant version = "1.0.1-beta.1";
/// @custom:semver 1.0.1-beta.2
string public constant version = "1.0.1-beta.2";

/// @notice Constructs the ProtocolVersion contract. Cannot set
/// the owner to `address(0)` due to the Ownable contract's
Expand Down