Commit 33bc0bec authored by Maurelian's avatar Maurelian Committed by GitHub

feat: Extract deployment of pre-v1.6.0 code (#12233)

* feat: Add a test to simplify deploy script testing

* fix: lint

* feat: Add clarifying comments to DeployVariations_Test

* feat: Extract deployment of pre-v1.6.0 code

* feat: combine setupOPChain and DeployOpChain

This will help to clarify where the DeployOpcChain script can be used.

* fix: op-e2e issues with unfound contracts

* fix: Undo conditional init of L2OutputOracle

It needs to be in the state no matter what for op-e2e

* fix: correct deploy ordering of legacy contracts

* ugly but working

* clean up legacy deployments

* enable FP on system config custom gas token tests

* op-e2e: allow no OptimismPortal impl if useFaultProofs

* fix: lint
parent 2c7de99f
...@@ -1017,6 +1017,10 @@ func (d *L1Deployments) Check(deployConfig *DeployConfig) error { ...@@ -1017,6 +1017,10 @@ func (d *L1Deployments) Check(deployConfig *DeployConfig) error {
name == "DisputeGameFactoryProxy") { name == "DisputeGameFactoryProxy") {
continue continue
} }
if deployConfig.UseFaultProofs &&
(name == "OptimismPortal") {
continue
}
if !deployConfig.UseAltDA && if !deployConfig.UseAltDA &&
(name == "DataAvailabilityChallenge" || (name == "DataAvailabilityChallenge" ||
name == "DataAvailabilityChallengeProxy") { name == "DataAvailabilityChallengeProxy") {
......
...@@ -144,26 +144,6 @@ contract Deploy is Deployer { ...@@ -144,26 +144,6 @@ contract Deploy is Deployer {
return keccak256(bytes(Config.implSalt())); return keccak256(bytes(Config.implSalt()));
} }
/// @notice Returns the proxy addresses. If a proxy is not found, it will have address(0).
function _proxies() internal view returns (Types.ContractSet memory proxies_) {
proxies_ = Types.ContractSet({
L1CrossDomainMessenger: mustGetAddress("L1CrossDomainMessengerProxy"),
L1StandardBridge: mustGetAddress("L1StandardBridgeProxy"),
L2OutputOracle: mustGetAddress("L2OutputOracleProxy"),
DisputeGameFactory: mustGetAddress("DisputeGameFactoryProxy"),
DelayedWETH: mustGetAddress("DelayedWETHProxy"),
PermissionedDelayedWETH: mustGetAddress("PermissionedDelayedWETHProxy"),
AnchorStateRegistry: mustGetAddress("AnchorStateRegistryProxy"),
OptimismMintableERC20Factory: mustGetAddress("OptimismMintableERC20FactoryProxy"),
OptimismPortal: mustGetAddress("OptimismPortalProxy"),
OptimismPortal2: mustGetAddress("OptimismPortalProxy"),
SystemConfig: mustGetAddress("SystemConfigProxy"),
L1ERC721Bridge: mustGetAddress("L1ERC721BridgeProxy"),
ProtocolVersions: mustGetAddress("ProtocolVersionsProxy"),
SuperchainConfig: mustGetAddress("SuperchainConfigProxy")
});
}
/// @notice Returns the proxy addresses, not reverting if any are unset. /// @notice Returns the proxy addresses, not reverting if any are unset.
function _proxiesUnstrict() internal view returns (Types.ContractSet memory proxies_) { function _proxiesUnstrict() internal view returns (Types.ContractSet memory proxies_) {
proxies_ = Types.ContractSet({ proxies_ = Types.ContractSet({
...@@ -274,7 +254,23 @@ contract Deploy is Deployer { ...@@ -274,7 +254,23 @@ contract Deploy is Deployer {
} else { } else {
deployImplementations(); deployImplementations();
} }
setupOpChain();
// Deploy Current OPChain Contracts
deployOpChain();
// Deploy and setup the legacy (pre-faultproofs) contracts
deployERC1967Proxy("L2OutputOracleProxy");
deployL2OutputOracle();
initializeL2OutputOracle();
// The OptimismPortalProxy contract is used both with and without Fault Proofs enabled, and is deployed by
// deployOPChain. So we only need to deploy the legacy OptimismPortal implementation and initialize with it
// when Fault Proofs are disabled.
if (!cfg.useFaultProofs()) {
deployOptimismPortal();
initializeOptimismPortal();
}
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"));
...@@ -318,33 +314,18 @@ contract Deploy is Deployer { ...@@ -318,33 +314,18 @@ contract Deploy is Deployer {
save("ProtocolVersions", address(dso.protocolVersionsImpl())); save("ProtocolVersions", address(dso.protocolVersionsImpl()));
} }
/// @notice Deploy a new OP Chain, with an existing SuperchainConfig provided /// @notice Deploy all of the OP Chain specific contracts
function setupOpChain() public { function deployOpChain() public {
console.log("Deploying OP Chain"); console.log("Deploying OP Chain");
deployAddressManager(); deployAddressManager();
deployProxyAdmin({ _isSuperchain: false }); deployProxyAdmin({ _isSuperchain: false });
transferAddressManagerOwnership(); // to the ProxyAdmin
// Ensure that the requisite contracts are deployed // Ensure that the requisite contracts are deployed
mustGetAddress("SuperchainConfigProxy"); mustGetAddress("SuperchainConfigProxy");
mustGetAddress("AddressManager"); mustGetAddress("AddressManager");
mustGetAddress("ProxyAdmin"); mustGetAddress("ProxyAdmin");
deployOpChain();
initializeOpChain();
setAlphabetFaultGameImplementation({ _allowUpgrade: false });
setFastFaultGameImplementation({ _allowUpgrade: false });
setCannonFaultGameImplementation({ _allowUpgrade: false });
setPermissionedCannonFaultGameImplementation({ _allowUpgrade: false });
transferDisputeGameFactoryOwnership();
transferDelayedWETHOwnership();
}
/// @notice Deploy all of the OP Chain specific contracts
function deployOpChain() public {
console.log("Deploying OP Chain contracts");
deployERC1967Proxy("OptimismPortalProxy"); deployERC1967Proxy("OptimismPortalProxy");
deployERC1967Proxy("SystemConfigProxy"); deployERC1967Proxy("SystemConfigProxy");
deployL1StandardBridgeProxy(); deployL1StandardBridgeProxy();
...@@ -356,26 +337,32 @@ contract Deploy is Deployer { ...@@ -356,26 +337,32 @@ contract Deploy is Deployer {
// enabled to prevent a nastier refactor to the deploy scripts. In the future, the L2OutputOracle will be // enabled to prevent a nastier refactor to the deploy scripts. In the future, the L2OutputOracle will be
// removed. If fault proofs are not enabled, the DisputeGameFactory proxy will be unused. // removed. If fault proofs are not enabled, the DisputeGameFactory proxy will be unused.
deployERC1967Proxy("DisputeGameFactoryProxy"); deployERC1967Proxy("DisputeGameFactoryProxy");
deployERC1967Proxy("L2OutputOracleProxy");
deployERC1967Proxy("DelayedWETHProxy"); deployERC1967Proxy("DelayedWETHProxy");
deployERC1967Proxy("PermissionedDelayedWETHProxy"); deployERC1967Proxy("PermissionedDelayedWETHProxy");
deployERC1967Proxy("AnchorStateRegistryProxy"); deployERC1967Proxy("AnchorStateRegistryProxy");
deployAnchorStateRegistry(); deployAnchorStateRegistry();
transferAddressManagerOwnership(); // to the ProxyAdmin initializeOpChain();
setAlphabetFaultGameImplementation({ _allowUpgrade: false });
setFastFaultGameImplementation({ _allowUpgrade: false });
setCannonFaultGameImplementation({ _allowUpgrade: false });
setPermissionedCannonFaultGameImplementation({ _allowUpgrade: false });
transferDisputeGameFactoryOwnership();
transferDelayedWETHOwnership();
} }
/// @notice Deploy all of the implementations /// @notice Deploy all of the implementations
function deployImplementations() public { function deployImplementations() public {
// TODO: Replace the actions in this function with a call to DeployImplementationsInterop.run()
console.log("Deploying implementations"); console.log("Deploying implementations");
deployL1CrossDomainMessenger(); deployL1CrossDomainMessenger();
deployOptimismMintableERC20Factory(); deployOptimismMintableERC20Factory();
deploySystemConfig(); deploySystemConfig();
deployL1StandardBridge(); deployL1StandardBridge();
deployL1ERC721Bridge(); deployL1ERC721Bridge();
deployOptimismPortal(); // todo: pull this out into an override option after DeployImplementations runs
deployL2OutputOracle();
// Fault proofs // Fault proofs
deployOptimismPortal2(); deployOptimismPortal2();
...@@ -387,13 +374,13 @@ contract Deploy is Deployer { ...@@ -387,13 +374,13 @@ contract Deploy is Deployer {
/// @notice Deploy all of the implementations /// @notice Deploy all of the implementations
function deployImplementationsInterop() public { function deployImplementationsInterop() public {
// TODO: Replace the actions in this function with a call to DeployImplementationsInterop.run()
console.log("Deploying implementations"); console.log("Deploying implementations");
deployL1CrossDomainMessenger(); deployL1CrossDomainMessenger();
deployOptimismMintableERC20Factory(); deployOptimismMintableERC20Factory();
deploySystemConfigInterop(); deploySystemConfigInterop();
deployL1StandardBridge(); deployL1StandardBridge();
deployL1ERC721Bridge(); deployL1ERC721Bridge();
deployL2OutputOracle();
// Fault proofs // Fault proofs
deployOptimismPortalInterop(); deployOptimismPortalInterop();
...@@ -407,13 +394,11 @@ contract Deploy is Deployer { ...@@ -407,13 +394,11 @@ contract Deploy is Deployer {
/// initialize function /// initialize function
function initializeOpChain() public { function initializeOpChain() public {
console.log("Initializing Op Chain proxies"); console.log("Initializing Op Chain proxies");
// Selectively initialize either the original OptimismPortal or the new OptimismPortal2. Since this will upgrade // The OptimismPortal Proxy is shared between the legacy and current deployment path, so we should initialize
// the proxy, we cannot initialize both. // the OptimismPortal2 only if using FaultProofs.
if (cfg.useFaultProofs()) { if (cfg.useFaultProofs()) {
console.log("Fault proofs enabled. Initializing the OptimismPortal proxy with the OptimismPortal2."); console.log("Fault proofs enabled. Initializing the OptimismPortal proxy with the OptimismPortal2.");
initializeOptimismPortal2(); initializeOptimismPortal2();
} else {
initializeOptimismPortal();
} }
initializeSystemConfig(); initializeSystemConfig();
...@@ -421,7 +406,6 @@ contract Deploy is Deployer { ...@@ -421,7 +406,6 @@ contract Deploy is Deployer {
initializeL1ERC721Bridge(); initializeL1ERC721Bridge();
initializeOptimismMintableERC20Factory(); initializeOptimismMintableERC20Factory();
initializeL1CrossDomainMessenger(); initializeL1CrossDomainMessenger();
initializeL2OutputOracle();
initializeDisputeGameFactory(); initializeDisputeGameFactory();
initializeDelayedWETH(); initializeDelayedWETH();
initializePermissionedDelayedWETH(); initializePermissionedDelayedWETH();
...@@ -1108,7 +1092,7 @@ contract Deploy is Deployer { ...@@ -1108,7 +1092,7 @@ contract Deploy is Deployer {
string memory version = config.version(); string memory version = config.version();
console.log("SystemConfig version: %s", version); console.log("SystemConfig version: %s", version);
ChainAssertions.checkSystemConfig({ _contracts: _proxies(), _cfg: cfg, _isProxy: true }); ChainAssertions.checkSystemConfig({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true });
} }
/// @notice Initialize the L1StandardBridge /// @notice Initialize the L1StandardBridge
...@@ -1143,7 +1127,7 @@ contract Deploy is Deployer { ...@@ -1143,7 +1127,7 @@ contract Deploy is Deployer {
string memory version = IL1StandardBridge(payable(l1StandardBridgeProxy)).version(); string memory version = IL1StandardBridge(payable(l1StandardBridgeProxy)).version();
console.log("L1StandardBridge version: %s", version); console.log("L1StandardBridge version: %s", version);
ChainAssertions.checkL1StandardBridge({ _contracts: _proxies(), _isProxy: true }); ChainAssertions.checkL1StandardBridge({ _contracts: _proxiesUnstrict(), _isProxy: true });
} }
/// @notice Initialize the L1ERC721Bridge /// @notice Initialize the L1ERC721Bridge
...@@ -1168,7 +1152,7 @@ contract Deploy is Deployer { ...@@ -1168,7 +1152,7 @@ contract Deploy is Deployer {
string memory version = bridge.version(); string memory version = bridge.version();
console.log("L1ERC721Bridge version: %s", version); console.log("L1ERC721Bridge version: %s", version);
ChainAssertions.checkL1ERC721Bridge({ _contracts: _proxies(), _isProxy: true }); ChainAssertions.checkL1ERC721Bridge({ _contracts: _proxiesUnstrict(), _isProxy: true });
} }
/// @notice Initialize the OptimismMintableERC20Factory /// @notice Initialize the OptimismMintableERC20Factory
...@@ -1189,7 +1173,7 @@ contract Deploy is Deployer { ...@@ -1189,7 +1173,7 @@ contract Deploy is Deployer {
string memory version = factory.version(); string memory version = factory.version();
console.log("OptimismMintableERC20Factory version: %s", version); console.log("OptimismMintableERC20Factory version: %s", version);
ChainAssertions.checkOptimismMintableERC20Factory({ _contracts: _proxies(), _isProxy: true }); ChainAssertions.checkOptimismMintableERC20Factory({ _contracts: _proxiesUnstrict(), _isProxy: true });
} }
/// @notice initializeL1CrossDomainMessenger /// @notice initializeL1CrossDomainMessenger
...@@ -1235,7 +1219,7 @@ contract Deploy is Deployer { ...@@ -1235,7 +1219,7 @@ contract Deploy is Deployer {
string memory version = messenger.version(); string memory version = messenger.version();
console.log("L1CrossDomainMessenger version: %s", version); console.log("L1CrossDomainMessenger version: %s", version);
ChainAssertions.checkL1CrossDomainMessenger({ _contracts: _proxies(), _vm: vm, _isProxy: true }); ChainAssertions.checkL1CrossDomainMessenger({ _contracts: _proxiesUnstrict(), _vm: vm, _isProxy: true });
} }
/// @notice Initialize the L2OutputOracle /// @notice Initialize the L2OutputOracle
...@@ -1267,7 +1251,7 @@ contract Deploy is Deployer { ...@@ -1267,7 +1251,7 @@ contract Deploy is Deployer {
console.log("L2OutputOracle version: %s", version); console.log("L2OutputOracle version: %s", version);
ChainAssertions.checkL2OutputOracle({ ChainAssertions.checkL2OutputOracle({
_contracts: _proxies(), _contracts: _proxiesUnstrict(),
_cfg: cfg, _cfg: cfg,
_l2OutputOracleStartingTimestamp: cfg.l2OutputOracleStartingTimestamp(), _l2OutputOracleStartingTimestamp: cfg.l2OutputOracleStartingTimestamp(),
_isProxy: true _isProxy: true
...@@ -1301,7 +1285,7 @@ contract Deploy is Deployer { ...@@ -1301,7 +1285,7 @@ contract Deploy is Deployer {
string memory version = portal.version(); string memory version = portal.version();
console.log("OptimismPortal version: %s", version); console.log("OptimismPortal version: %s", version);
ChainAssertions.checkOptimismPortal({ _contracts: _proxies(), _cfg: cfg, _isProxy: true }); ChainAssertions.checkOptimismPortal({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true });
} }
/// @notice Initialize the OptimismPortal2 /// @notice Initialize the OptimismPortal2
...@@ -1332,7 +1316,7 @@ contract Deploy is Deployer { ...@@ -1332,7 +1316,7 @@ contract Deploy is Deployer {
string memory version = portal.version(); string memory version = portal.version();
console.log("OptimismPortal2 version: %s", version); console.log("OptimismPortal2 version: %s", version);
ChainAssertions.checkOptimismPortal2({ _contracts: _proxies(), _cfg: cfg, _isProxy: true }); ChainAssertions.checkOptimismPortal2({ _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
...@@ -1346,7 +1330,7 @@ contract Deploy is Deployer { ...@@ -1346,7 +1330,7 @@ contract Deploy is Deployer {
disputeGameFactory.transferOwnership(finalSystemOwner); disputeGameFactory.transferOwnership(finalSystemOwner);
console.log("DisputeGameFactory ownership transferred to final system owner at: %s", finalSystemOwner); console.log("DisputeGameFactory ownership transferred to final system owner at: %s", finalSystemOwner);
} }
ChainAssertions.checkDisputeGameFactory({ _contracts: _proxies(), _expectedOwner: finalSystemOwner }); ChainAssertions.checkDisputeGameFactory({ _contracts: _proxiesUnstrict(), _expectedOwner: finalSystemOwner });
} }
/// @notice Transfer ownership of the DelayedWETH contract to the final system owner /// @notice Transfer ownership of the DelayedWETH contract to the final system owner
...@@ -1361,7 +1345,7 @@ contract Deploy is Deployer { ...@@ -1361,7 +1345,7 @@ contract Deploy is Deployer {
console.log("DelayedWETH ownership transferred to final system owner at: %s", finalSystemOwner); console.log("DelayedWETH ownership transferred to final system owner at: %s", finalSystemOwner);
} }
ChainAssertions.checkDelayedWETH({ ChainAssertions.checkDelayedWETH({
_contracts: _proxies(), _contracts: _proxiesUnstrict(),
_cfg: cfg, _cfg: cfg,
_isProxy: true, _isProxy: true,
_expectedOwner: finalSystemOwner _expectedOwner: finalSystemOwner
...@@ -1380,7 +1364,7 @@ contract Deploy is Deployer { ...@@ -1380,7 +1364,7 @@ contract Deploy is Deployer {
console.log("DelayedWETH ownership transferred to final system owner at: %s", finalSystemOwner); console.log("DelayedWETH ownership transferred to final system owner at: %s", finalSystemOwner);
} }
ChainAssertions.checkPermissionedDelayedWETH({ ChainAssertions.checkPermissionedDelayedWETH({
_contracts: _proxies(), _contracts: _proxiesUnstrict(),
_cfg: cfg, _cfg: cfg,
_isProxy: true, _isProxy: true,
_expectedOwner: finalSystemOwner _expectedOwner: finalSystemOwner
......
...@@ -312,6 +312,7 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init { ...@@ -312,6 +312,7 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init {
function setUp() public override { function setUp() public override {
token = new ERC20("Silly", "SIL"); token = new ERC20("Silly", "SIL");
super.enableCustomGasToken(address(token)); super.enableCustomGasToken(address(token));
super.enableFaultProofs();
super.setUp(); super.setUp();
} }
......
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