Skip to content

Commit

Permalink
wip: deployOpChain using OPCM
Browse files Browse the repository at this point in the history
  • Loading branch information
maurelian committed Oct 3, 2024
1 parent 9aa3ee8 commit 807e4ea
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ import {
DeployImplementationsInterop,
DeployImplementationsOutput
} from "scripts/DeployImplementations.s.sol";
import { DeployOPChainInput, DeployOPChain, DeployOPChainOutput } from "scripts/DeployOPChain.s.sol";

// Contracts
import { AddressManager } from "src/legacy/AddressManager.sol";
import { StorageSetter } from "src/universal/StorageSetter.sol";
import { OPContractsManager } from "src/L1/OPContractsManager.sol";

// Libraries
import { Constants } from "src/libraries/Constants.sol";
Expand Down Expand Up @@ -418,10 +420,65 @@ contract Deploy is Deployer {
}
}

// TODO: put this somewhere better
// This helper function is used to convert the input struct type defined in DeployOPChain.s.sol
// to the input struct type defined in OPContractsManager.sol.
function toOPCMDeployInput(DeployOPChainInput _doi) internal view returns (OPContractsManager.DeployInput memory) {
return OPContractsManager.DeployInput({
roles: OPContractsManager.Roles({
opChainProxyAdminOwner: _doi.opChainProxyAdminOwner(),
systemConfigOwner: _doi.systemConfigOwner(),
batcher: _doi.batcher(),
unsafeBlockSigner: _doi.unsafeBlockSigner(),
proposer: _doi.proposer(),
challenger: _doi.challenger()
}),
basefeeScalar: _doi.basefeeScalar(),
blobBasefeeScalar: _doi.blobBaseFeeScalar(),
l2ChainId: _doi.l2ChainId(),
startingAnchorRoots: _doi.startingAnchorRoots(),
saltMixer: _doi.saltMixer(),
gasLimit: _doi.gasLimit(),
disputeGameType: _doi.disputeGameType(),
disputeAbsolutePrestate: _doi.disputeAbsolutePrestate(),
disputeMaxGameDepth: _doi.disputeMaxGameDepth(),
disputeSplitDepth: _doi.disputeSplitDepth(),
disputeClockExtension: _doi.disputeClockExtension(),
disputeMaxClockDuration: _doi.disputeMaxClockDuration()
});
}

/// @notice Deploy all of the OP Chain specific contracts
function deployOpChain() public {
console.log("Deploying OP Chain");
deployAddressManager();
OPContractsManager opcm = OPContractsManager(mustGetAddress("OPContractsManagerProxy"));
DeployOPChain dc = new DeployOPChain();
(DeployOPChainInput dci, DeployOPChainOutput dco) = dc.etchIOContracts();

dci.set(dci.opChainProxyAdminOwner.selector, cfg.finalSystemOwner());
dci.set(dci.systemConfigOwner.selector, cfg.finalSystemOwner());
dci.set(dci.batcher.selector, cfg.batchSenderAddress());
dci.set(dci.unsafeBlockSigner.selector, cfg.p2pSequencerAddress());
dci.set(dci.proposer.selector, cfg.l2OutputOracleProposer());
dci.set(dci.challenger.selector, cfg.l2OutputOracleChallenger());
dci.set(dci.basefeeScalar.selector, cfg.basefeeScalar());
dci.set(dci.blobBaseFeeScalar.selector, cfg.blobbasefeeScalar());
dci.set(dci.l2ChainId.selector, cfg.l2ChainID());
dci.set(dci.opcmProxy.selector, address(opcm));
dci.set(dci.gasLimit.selector, cfg.l2GenesisBlockGasLimit());

dci.set(dci.disputeGameType.selector, cfg.respectedGameType());
dci.set(dci.disputeAbsolutePrestate.selector, cfg.faultGameAbsolutePrestate());
dci.set(dci.disputeMaxGameDepth.selector, cfg.faultGameMaxDepth());
dci.set(dci.disputeSplitDepth.selector, cfg.faultGameSplitDepth());
dci.set(dci.disputeClockExtension.selector, cfg.faultGameClockExtension());
dci.set(dci.disputeMaxClockDuration.selector, cfg.faultGameMaxClockDuration());

OPContractsManager.DeployInput memory deployInput = toOPCMDeployInput(dci);
OPContractsManager.DeployOutput memory deployOutput = opcm.deploy(deployInput);

// deployAddressManager();
save("AddressManager", address(deployOutput.addressManager));
deployProxyAdmin();
transferAddressManagerOwnership(); // to the ProxyAdmin

Expand Down

0 comments on commit 807e4ea

Please sign in to comment.