Commit 84b1cde3 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

Add entrypoint to deploy against existing Superchain (#11791)

* Add entrypoint to deploy against existing Superchain

Creates a separate entrypoint in the deploy script to allow an L2 to be deployed against an existing set of Superchain contracts. The deployment assumes that the Superchain contracts have been deployed correctly. The L2 still gets its own ProxyAdmin, AddressManager, and Safe. The API is additive and backwards-compatible.

* Update packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Co-authored-by: default avatarMaurelian <john@oplabs.co>

* remove redundant call

---------
Co-authored-by: default avatarMaurelian <john@oplabs.co>
parent 707791b4
...@@ -279,6 +279,39 @@ contract Deploy is Deployer { ...@@ -279,6 +279,39 @@ contract Deploy is Deployer {
_run(); _run();
} }
/// @notice Deploy a new OP Chain using an existing SuperchainConfig and ProtocolVersions
/// @param _superchainConfigProxy Address of the existing SuperchainConfig proxy
/// @param _protocolVersionsProxy Address of the existing ProtocolVersions proxy
/// @param includeDump Whether to include a state dump after deployment
function runWithSuperchain(
address payable _superchainConfigProxy,
address payable _protocolVersionsProxy,
bool includeDump
)
public
{
require(_superchainConfigProxy != address(0), "must specify address for superchain config proxy");
require(_protocolVersionsProxy != address(0), "must specify address for protocol versions proxy");
vm.chainId(cfg.l1ChainID());
console.log("Deploying a fresh OP Stack with existing SuperchainConfig and ProtocolVersions");
Proxy scProxy = Proxy(_superchainConfigProxy);
save("SuperchainConfig", scProxy.implementation());
save("SuperchainConfigProxy", _superchainConfigProxy);
Proxy pvProxy = Proxy(_protocolVersionsProxy);
save("ProtocolVersions", pvProxy.implementation());
save("ProtocolVersionsProxy", _protocolVersionsProxy);
_run(false);
if (includeDump) {
vm.dumpState(Config.stateDumpPath(""));
}
}
function runWithStateDump() public { function runWithStateDump() public {
vm.chainId(cfg.l1ChainID()); vm.chainId(cfg.l1ChainID());
_run(); _run();
...@@ -290,13 +323,27 @@ contract Deploy is Deployer { ...@@ -290,13 +323,27 @@ contract Deploy is Deployer {
_run(); _run();
} }
/// @notice Internal function containing the deploy logic. /// @notice Compatibility function for tests that override _run().
function _run() internal virtual { function _run() internal virtual {
_run(true);
}
/// @notice Internal function containing the deploy logic.
function _run(bool _needsSuperchain) internal {
console.log("start of L1 Deploy!"); console.log("start of L1 Deploy!");
deploySafe("SystemOwnerSafe"); deploySafe("SystemOwnerSafe");
console.log("deployed Safe!"); console.log("deployed Safe!");
setupSuperchain();
console.log("set up superchain!"); // Deploy a new ProxyAdmin and AddressManager
// This proxy will be used on the SuperchainConfig and ProtocolVersions contracts, as well as the contracts
// in the OP Chain system.
setupAdmin();
if (_needsSuperchain) {
setupSuperchain();
console.log("set up superchain!");
}
if (cfg.useAltDA()) { if (cfg.useAltDA()) {
bytes32 typeHash = keccak256(bytes(cfg.daCommitmentType())); bytes32 typeHash = keccak256(bytes(cfg.daCommitmentType()));
bytes32 keccakHash = keccak256(bytes("KeccakCommitment")); bytes32 keccakHash = keccak256(bytes("KeccakCommitment"));
...@@ -312,6 +359,13 @@ contract Deploy is Deployer { ...@@ -312,6 +359,13 @@ contract Deploy is Deployer {
// High Level Deployment Functions // // High Level Deployment Functions //
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
/// @notice Deploy the address manager and proxy admin contracts.
function setupAdmin() public {
deployAddressManager();
deployProxyAdmin();
transferProxyAdminOwnership();
}
/// @notice Deploy a full system with a new SuperchainConfig /// @notice Deploy a full system with a new SuperchainConfig
/// The Superchain system has 2 singleton contracts which lie outside of an OP Chain: /// The Superchain system has 2 singleton contracts which lie outside of an OP Chain:
/// 1. The SuperchainConfig contract /// 1. The SuperchainConfig contract
...@@ -319,13 +373,6 @@ contract Deploy is Deployer { ...@@ -319,13 +373,6 @@ contract Deploy is Deployer {
function setupSuperchain() public { function setupSuperchain() public {
console.log("Setting up Superchain"); console.log("Setting up Superchain");
// Deploy a new ProxyAdmin and AddressManager
// This proxy will be used on the SuperchainConfig and ProtocolVersions contracts, as well as the contracts
// in the OP Chain system.
deployAddressManager();
deployProxyAdmin();
transferProxyAdminOwnership();
// Deploy the SuperchainConfigProxy // Deploy the SuperchainConfigProxy
deployERC1967Proxy("SuperchainConfigProxy"); deployERC1967Proxy("SuperchainConfigProxy");
deploySuperchainConfig(); deploySuperchainConfig();
......
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