Commit e7dbd848 authored by Maurelian's avatar Maurelian Committed by GitHub

feat: Use DeploySuperchain script in Deploy.s.sol (#12203)

* 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
parent ab8b3719
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
"l2GenesisFjordTimeOffset": "0x0", "l2GenesisFjordTimeOffset": "0x0",
"l1CancunTimeOffset": "0x0", "l1CancunTimeOffset": "0x0",
"systemConfigStartBlock": 0, "systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000", "requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000", "recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001",
"faultGameAbsolutePrestate": "0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98", "faultGameAbsolutePrestate": "0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98",
"faultGameMaxDepth": 50, "faultGameMaxDepth": 50,
"faultGameClockExtension": 0, "faultGameClockExtension": 0,
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
"eip1559Elasticity": 10, "eip1559Elasticity": 10,
"l2GenesisRegolithTimeOffset": "0x0", "l2GenesisRegolithTimeOffset": "0x0",
"systemConfigStartBlock": 0, "systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000", "requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000", "recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000001",
"faultGameAbsolutePrestate": "0x0000000000000000000000000000000000000000000000000000000000000000", "faultGameAbsolutePrestate": "0x0000000000000000000000000000000000000000000000000000000000000000",
"faultGameMaxDepth": 8, "faultGameMaxDepth": 8,
"faultGameClockExtension": 0, "faultGameClockExtension": 0,
......
...@@ -17,6 +17,7 @@ import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol"; ...@@ -17,6 +17,7 @@ import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol";
import { Process } from "scripts/libraries/Process.sol"; import { Process } from "scripts/libraries/Process.sol";
import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol"; import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol";
import { DeployUtils } from "scripts/libraries/DeployUtils.sol"; import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
import { DeploySuperchainInput, DeploySuperchain, DeploySuperchainOutput } from "scripts/DeploySuperchain.s.sol";
// Contracts // Contracts
import { AddressManager } from "src/legacy/AddressManager.sol"; import { AddressManager } from "src/legacy/AddressManager.sol";
...@@ -298,16 +299,26 @@ contract Deploy is Deployer { ...@@ -298,16 +299,26 @@ contract Deploy is Deployer {
/// 2. The ProtocolVersions contract /// 2. The ProtocolVersions contract
function setupSuperchain() public { function setupSuperchain() public {
console.log("Setting up Superchain"); console.log("Setting up Superchain");
DeploySuperchain deploySuperchain = new DeploySuperchain();
(DeploySuperchainInput dsi, DeploySuperchainOutput dso) = deploySuperchain.etchIOContracts();
// Deploy the SuperchainConfigProxy // Set the input values on the input contract.
deployERC1967ProxyWithOwner("SuperchainConfigProxy", mustGetAddress("SuperchainProxyAdmin")); dsi.set(dsi.superchainProxyAdminOwner.selector, mustGetAddress("SuperchainProxyAdmin"));
deploySuperchainConfig(); // TODO: when DeployAuthSystem is done, finalSystemOwner should be replaced with the Foundation Upgrades Safe
initializeSuperchainConfig(); dsi.set(dsi.protocolVersionsOwner.selector, cfg.finalSystemOwner());
dsi.set(dsi.guardian.selector, cfg.superchainConfigGuardian());
dsi.set(dsi.paused.selector, false);
// Deploy the ProtocolVersionsProxy dsi.set(dsi.requiredProtocolVersion.selector, ProtocolVersion.wrap(cfg.requiredProtocolVersion()));
deployERC1967ProxyWithOwner("ProtocolVersionsProxy", mustGetAddress("SuperchainProxyAdmin")); dsi.set(dsi.recommendedProtocolVersion.selector, ProtocolVersion.wrap(cfg.recommendedProtocolVersion()));
deployProtocolVersions();
initializeProtocolVersions(); // 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 /// @notice Deploy a new OP Chain, with an existing SuperchainConfig provided
...@@ -751,27 +762,6 @@ contract Deploy is Deployer { ...@@ -751,27 +762,6 @@ contract Deploy is Deployer {
addr_ = address(weth); 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 /// @notice Deploy the PreimageOracle
function deployPreimageOracle() public broadcast returns (address addr_) { function deployPreimageOracle() public broadcast returns (address addr_) {
IPreimageOracle preimageOracle = IPreimageOracle( IPreimageOracle preimageOracle = IPreimageOracle(
...@@ -923,21 +913,6 @@ contract Deploy is Deployer { ...@@ -923,21 +913,6 @@ contract Deploy is Deployer {
// Initialize Functions // // 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 /// @notice Initialize the DisputeGameFactory
function initializeDisputeGameFactory() public broadcast { function initializeDisputeGameFactory() public broadcast {
console.log("Upgrading and initializing DisputeGameFactory proxy"); console.log("Upgrading and initializing DisputeGameFactory proxy");
...@@ -1331,36 +1306,6 @@ contract Deploy is Deployer { ...@@ -1331,36 +1306,6 @@ contract Deploy is Deployer {
ChainAssertions.checkOptimismPortal2({ _contracts: _proxies(), _cfg: cfg, _isProxy: true }); 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 /// @notice Transfer ownership of the DisputeGameFactory contract to the final system owner
function transferDisputeGameFactoryOwnership() public broadcast { function transferDisputeGameFactoryOwnership() public broadcast {
console.log("Transferring DisputeGameFactory ownership to Safe"); console.log("Transferring DisputeGameFactory ownership to Safe");
......
...@@ -48,8 +48,8 @@ ...@@ -48,8 +48,8 @@
"sourceCodeHash": "0x6401b81f04093863557ef46192f56793daa0d412618065383ab353b2ed2929d8" "sourceCodeHash": "0x6401b81f04093863557ef46192f56793daa0d412618065383ab353b2ed2929d8"
}, },
"src/L1/ProtocolVersions.sol": { "src/L1/ProtocolVersions.sol": {
"initCodeHash": "0x8f033874dd8b36615b2209d553660dcff1ff91ca2bad3ca1de7b441dbfba4842", "initCodeHash": "0xf7a9ed8c772cfb1234988fd6fd195dc21615b216bb39e728e7699b875040d902",
"sourceCodeHash": "0x5a7e91e02224e02a5a4bbf0fea7e9bd4a1168e2fe5e787023c9a75bcb6c26204" "sourceCodeHash": "0x92f15d62361bffc305f0db48a5676329f8e5ed2e454f8c8ff83ef7d3667d7f01"
}, },
"src/L1/SuperchainConfig.sol": { "src/L1/SuperchainConfig.sol": {
"initCodeHash": "0xfca12d9016c746e5c275b186e0ca40cfd65cf45a5665aab7589a669fea3abb47", "initCodeHash": "0xfca12d9016c746e5c275b186e0ca40cfd65cf45a5665aab7589a669fea3abb47",
......
...@@ -37,8 +37,8 @@ contract ProtocolVersions is OwnableUpgradeable, ISemver { ...@@ -37,8 +37,8 @@ contract ProtocolVersions is OwnableUpgradeable, ISemver {
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data); event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
/// @notice Semantic version. /// @notice Semantic version.
/// @custom:semver 1.0.1-beta.1 /// @custom:semver 1.0.1-beta.2
string public constant version = "1.0.1-beta.1"; string public constant version = "1.0.1-beta.2";
/// @notice Constructs the ProtocolVersion contract. Cannot set /// @notice Constructs the ProtocolVersion contract. Cannot set
/// the owner to `address(0)` due to the Ownable contract's /// the owner to `address(0)` due to the Ownable contract's
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment