Skip to content

Commit

Permalink
feat: Extract deployment of pre-v1.6.0 code (ethereum-optimism#12233)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
maurelian authored Oct 2, 2024
1 parent 2c7de99 commit 33bc0be
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 60 deletions.
4 changes: 4 additions & 0 deletions op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,10 @@ func (d *L1Deployments) Check(deployConfig *DeployConfig) error {
name == "DisputeGameFactoryProxy") {
continue
}
if deployConfig.UseFaultProofs &&
(name == "OptimismPortal") {
continue
}
if !deployConfig.UseAltDA &&
(name == "DataAvailabilityChallenge" ||
name == "DataAvailabilityChallengeProxy") {
Expand Down
104 changes: 44 additions & 60 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,26 +144,6 @@ contract Deploy is Deployer {
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.
function _proxiesUnstrict() internal view returns (Types.ContractSet memory proxies_) {
proxies_ = Types.ContractSet({
Expand Down Expand Up @@ -274,7 +254,23 @@ contract Deploy is Deployer {
} else {
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()) {
bytes32 typeHash = keccak256(bytes(cfg.daCommitmentType()));
bytes32 keccakHash = keccak256(bytes("KeccakCommitment"));
Expand Down Expand Up @@ -318,33 +314,18 @@ contract Deploy is Deployer {
save("ProtocolVersions", address(dso.protocolVersionsImpl()));
}

/// @notice Deploy a new OP Chain, with an existing SuperchainConfig provided
function setupOpChain() public {
/// @notice Deploy all of the OP Chain specific contracts
function deployOpChain() public {
console.log("Deploying OP Chain");
deployAddressManager();
deployProxyAdmin({ _isSuperchain: false });
transferAddressManagerOwnership(); // to the ProxyAdmin

// Ensure that the requisite contracts are deployed
mustGetAddress("SuperchainConfigProxy");
mustGetAddress("AddressManager");
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("SystemConfigProxy");
deployL1StandardBridgeProxy();
Expand All @@ -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
// removed. If fault proofs are not enabled, the DisputeGameFactory proxy will be unused.
deployERC1967Proxy("DisputeGameFactoryProxy");
deployERC1967Proxy("L2OutputOracleProxy");
deployERC1967Proxy("DelayedWETHProxy");
deployERC1967Proxy("PermissionedDelayedWETHProxy");
deployERC1967Proxy("AnchorStateRegistryProxy");

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
function deployImplementations() public {
// TODO: Replace the actions in this function with a call to DeployImplementationsInterop.run()
console.log("Deploying implementations");
deployL1CrossDomainMessenger();
deployOptimismMintableERC20Factory();
deploySystemConfig();
deployL1StandardBridge();
deployL1ERC721Bridge();
deployOptimismPortal(); // todo: pull this out into an override option after DeployImplementations runs
deployL2OutputOracle();

// Fault proofs
deployOptimismPortal2();
Expand All @@ -387,13 +374,13 @@ contract Deploy is Deployer {

/// @notice Deploy all of the implementations
function deployImplementationsInterop() public {
// TODO: Replace the actions in this function with a call to DeployImplementationsInterop.run()
console.log("Deploying implementations");
deployL1CrossDomainMessenger();
deployOptimismMintableERC20Factory();
deploySystemConfigInterop();
deployL1StandardBridge();
deployL1ERC721Bridge();
deployL2OutputOracle();

// Fault proofs
deployOptimismPortalInterop();
Expand All @@ -407,21 +394,18 @@ contract Deploy is Deployer {
/// initialize function
function initializeOpChain() public {
console.log("Initializing Op Chain proxies");
// Selectively initialize either the original OptimismPortal or the new OptimismPortal2. Since this will upgrade
// the proxy, we cannot initialize both.
// The OptimismPortal Proxy is shared between the legacy and current deployment path, so we should initialize
// the OptimismPortal2 only if using FaultProofs.
if (cfg.useFaultProofs()) {
console.log("Fault proofs enabled. Initializing the OptimismPortal proxy with the OptimismPortal2.");
initializeOptimismPortal2();
} else {
initializeOptimismPortal();
}

initializeSystemConfig();
initializeL1StandardBridge();
initializeL1ERC721Bridge();
initializeOptimismMintableERC20Factory();
initializeL1CrossDomainMessenger();
initializeL2OutputOracle();
initializeDisputeGameFactory();
initializeDelayedWETH();
initializePermissionedDelayedWETH();
Expand Down Expand Up @@ -1108,7 +1092,7 @@ contract Deploy is Deployer {
string memory version = config.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
Expand Down Expand Up @@ -1143,7 +1127,7 @@ contract Deploy is Deployer {
string memory version = IL1StandardBridge(payable(l1StandardBridgeProxy)).version();
console.log("L1StandardBridge version: %s", version);

ChainAssertions.checkL1StandardBridge({ _contracts: _proxies(), _isProxy: true });
ChainAssertions.checkL1StandardBridge({ _contracts: _proxiesUnstrict(), _isProxy: true });
}

/// @notice Initialize the L1ERC721Bridge
Expand All @@ -1168,7 +1152,7 @@ contract Deploy is Deployer {
string memory version = bridge.version();
console.log("L1ERC721Bridge version: %s", version);

ChainAssertions.checkL1ERC721Bridge({ _contracts: _proxies(), _isProxy: true });
ChainAssertions.checkL1ERC721Bridge({ _contracts: _proxiesUnstrict(), _isProxy: true });
}

/// @notice Initialize the OptimismMintableERC20Factory
Expand All @@ -1189,7 +1173,7 @@ contract Deploy is Deployer {
string memory version = factory.version();
console.log("OptimismMintableERC20Factory version: %s", version);

ChainAssertions.checkOptimismMintableERC20Factory({ _contracts: _proxies(), _isProxy: true });
ChainAssertions.checkOptimismMintableERC20Factory({ _contracts: _proxiesUnstrict(), _isProxy: true });
}

/// @notice initializeL1CrossDomainMessenger
Expand Down Expand Up @@ -1235,7 +1219,7 @@ contract Deploy is Deployer {
string memory version = messenger.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
Expand Down Expand Up @@ -1267,7 +1251,7 @@ contract Deploy is Deployer {
console.log("L2OutputOracle version: %s", version);

ChainAssertions.checkL2OutputOracle({
_contracts: _proxies(),
_contracts: _proxiesUnstrict(),
_cfg: cfg,
_l2OutputOracleStartingTimestamp: cfg.l2OutputOracleStartingTimestamp(),
_isProxy: true
Expand Down Expand Up @@ -1301,7 +1285,7 @@ contract Deploy is Deployer {
string memory version = portal.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
Expand Down Expand Up @@ -1332,7 +1316,7 @@ contract Deploy is Deployer {
string memory version = portal.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
Expand All @@ -1346,7 +1330,7 @@ contract Deploy is Deployer {
disputeGameFactory.transferOwnership(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
Expand All @@ -1361,7 +1345,7 @@ contract Deploy is Deployer {
console.log("DelayedWETH ownership transferred to final system owner at: %s", finalSystemOwner);
}
ChainAssertions.checkDelayedWETH({
_contracts: _proxies(),
_contracts: _proxiesUnstrict(),
_cfg: cfg,
_isProxy: true,
_expectedOwner: finalSystemOwner
Expand All @@ -1380,7 +1364,7 @@ contract Deploy is Deployer {
console.log("DelayedWETH ownership transferred to final system owner at: %s", finalSystemOwner);
}
ChainAssertions.checkPermissionedDelayedWETH({
_contracts: _proxies(),
_contracts: _proxiesUnstrict(),
_cfg: cfg,
_isProxy: true,
_expectedOwner: finalSystemOwner
Expand Down
1 change: 1 addition & 0 deletions packages/contracts-bedrock/test/L1/SystemConfig.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init {
function setUp() public override {
token = new ERC20("Silly", "SIL");
super.enableCustomGasToken(address(token));
super.enableFaultProofs();
super.setUp();
}

Expand Down

0 comments on commit 33bc0be

Please sign in to comment.