Skip to content

Commit

Permalink
Interop deployer script
Browse files Browse the repository at this point in the history
 - Deploy script for multiple L2 chains in devnet
 - resolves ethereum-optimism#10608
  • Loading branch information
jinmel committed Jun 8, 2024
1 parent 46a9f00 commit 7ae18a7
Show file tree
Hide file tree
Showing 5 changed files with 1,649 additions and 11 deletions.
66 changes: 66 additions & 0 deletions packages/contracts-bedrock/deploy-config/hardhat-interop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"finalSystemOwner": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
"superchainConfigGuardian": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
"proxyAdminOwner": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
"l1StartingBlockTag": "earliest",
"l1ChainID": 900,
"l2ChainID": 902,
"l2BlockTime": 2,
"l1BlockTime": 12,
"maxSequencerDrift": 300,
"sequencerWindowSize": 15,
"channelTimeout": 40,
"p2pSequencerAddress": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
"batchInboxAddress": "0xff00000000000000000000000000000000000000",
"batchSenderAddress": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
"l2OutputOracleSubmissionInterval": 6,
"l2OutputOracleStartingTimestamp": 1,
"l2OutputOracleStartingBlockNumber": 1,
"gasPriceOracleBaseFeeScalar": 1368,
"gasPriceOracleBlobBaseFeeScalar": 810949,
"l2OutputOracleProposer": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"l2OutputOracleChallenger": "0x6925B8704Ff96DEe942623d6FB5e946EF5884b63",
"l2GenesisBlockBaseFeePerGas": "0x3B9ACA00",
"l2GenesisBlockGasLimit": "0x17D7840",
"baseFeeVaultRecipient": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
"l1FeeVaultRecipient": "0x71bE63f3384f5fb98995898A86B02Fb2426c5788",
"sequencerFeeVaultRecipient": "0xfabb0ac9d68b0b445fb7357272ff202c5651694a",
"baseFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
"l1FeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
"sequencerFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
"baseFeeVaultWithdrawalNetwork": 0,
"l1FeeVaultWithdrawalNetwork": 0,
"sequencerFeeVaultWithdrawalNetwork": 0,
"enableGovernance": true,
"governanceTokenName": "InterOptimism",
"governanceTokenSymbol": "IOP",
"governanceTokenOwner": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
"finalizationPeriodSeconds": 36,
"eip1559Denominator": 50,
"eip1559DenominatorCanyon": 250,
"eip1559Elasticity": 10,
"l2GenesisRegolithTimeOffset": "0x0",
"systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"faultGameAbsolutePrestate": "0x0000000000000000000000000000000000000000000000000000000000000000",
"faultGameMaxDepth": 8,
"faultGameClockExtension": 0,
"faultGameMaxClockDuration": 1200,
"faultGameGenesisBlock": 0,
"faultGameGenesisOutputRoot": "0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF",
"faultGameSplitDepth": 4,
"faultGameWithdrawalDelay": 604800,
"preimageOracleMinProposalSize": 10000,
"preimageOracleChallengePeriod": 120,
"proofMaturityDelaySeconds": 12,
"disputeGameFinalityDelaySeconds": 6,
"respectedGameType": 0,
"useFaultProofs": false,
"fundDevAccounts": true,
"usePlasma": false,
"daChallengeWindow": 100,
"daResolveWindow": 100,
"daBondSize": 1000,
"daResolverRefundPercentage": 50
}
27 changes: 16 additions & 11 deletions packages/contracts-bedrock/scripts/Artifacts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ abstract contract Artifacts {
error InvalidDeployment(string);
/// @notice The set of deployments that have been done during execution.

mapping(string => Deployment) internal _namedDeployments;
mapping(string => mapping(string => Deployment)) internal _namedDeployments;
/// @notice The same as `_namedDeployments` but as an array.
Deployment[] internal _newDeployments;
mapping(string => Deployment[]) internal _newDeployments;
/// @notice Path to the directory containing the hh deploy style artifacts
string internal deploymentsDir;
/// @notice The path to the deployment artifact that is being written to.
Expand All @@ -50,6 +50,10 @@ abstract contract Artifacts {
console.log("Writing artifact to %s", deploymentOutfile);
ForgeArtifacts.ensurePath(deploymentOutfile);

interopDeploymentOutfile = Config.interopDeploymentOutfile();
console.log("Writing interop artifact to %s", interopDeploymentOutfile);
ForgeArtifacts.ensurePath(interopDeploymentOutfile);

uint256 chainId = Config.chainID();
console.log("Connected to network with chainid %s", chainId);

Expand Down Expand Up @@ -88,17 +92,18 @@ abstract contract Artifacts {
/// @notice Returns whether or not a particular deployment exists.
/// @param _name The name of the deployment.
/// @return Whether the deployment exists or not.
function has(string memory _name) public view returns (bool) {
Deployment memory existing = _namedDeployments[_name];
function has(string memory _name, string memory namespace) public view returns (bool) {
Deployment memory existing = _namedDeployments[namespace][_name];
return bytes(existing.name).length > 0;
}

/// @notice Returns the address of a deployment. Also handles the predeploys.
/// @param _name The name of the deployment.
/// @return The address of the deployment. May be `address(0)` if the deployment does not
/// exist.
function getAddress(string memory _name) public view returns (address payable) {
Deployment memory existing = _namedDeployments[_name];
function getAddress(string memory _name, string memory namespace) public view returns (address payable) {

Deployment memory existing = _namedDeployments[namespace][_name];
if (existing.addr != address(0)) {
if (bytes(existing.name).length == 0) {
return payable(address(0));
Expand Down Expand Up @@ -168,7 +173,7 @@ abstract contract Artifacts {
/// @param _name The name of the deployment.
/// @return The deployment.
function get(string memory _name) public view returns (Deployment memory) {
return _namedDeployments[_name];
return _namedDeployments[namespace][_name];
}

/// @notice Appends a deployment to disk as a JSON deploy artifact.
Expand All @@ -178,14 +183,14 @@ abstract contract Artifacts {
if (bytes(_name).length == 0) {
revert InvalidDeployment("EmptyName");
}
if (bytes(_namedDeployments[_name].name).length > 0) {
if (bytes(_namedDeployments[namespace][_name].name).length > 0) {
revert InvalidDeployment("AlreadyExists");
}

console.log("Saving %s: %s", _name, _deployed);
Deployment memory deployment = Deployment({ name: _name, addr: payable(_deployed) });
_namedDeployments[_name] = deployment;
_newDeployments.push(deployment);
_namedDeployments[namespace][_name] = deployment;
_newDeployments[namespace].push(deployment);
_appendDeployment(_name, _deployed);
}

Expand Down Expand Up @@ -224,7 +229,7 @@ abstract contract Artifacts {
}

Deployment memory deployment = Deployment({ name: _name, addr: payable(_addr) });
_namedDeployments[_name] = deployment;
_namedDeployments[namespace][_name] = deployment;
}

/// @notice Returns the value of the internal `_initialized` storage slot for a given contract.
Expand Down
16 changes: 16 additions & 0 deletions packages/contracts-bedrock/scripts/Config.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ library Config {
);
}

function interopDeploymentOutfile() internal view returns (string memory _env) {
_env = vm.envOr(
"INTEROP_DEPLOYMENT_OUTFILE",
string.concat(vm.projectRoot(), "/deployments/", vm.toString(block.chainid), "-deploy-interop.json")
);
}

/// @notice Returns the path on the local filesystem where the deploy config is
function deployConfigPath() internal view returns (string memory _env) {
if (vm.isContext(VmSafe.ForgeContext.TestGroup)) {
Expand All @@ -29,6 +36,15 @@ library Config {
}
}

function interopDeployConfigPath() internal view returns (string memory _env) {
if (vm.isContext(VmSafe.ForgeContext.TestGroup)) {
_env = string.concat(vm.projectRoot(), "/deploy-config/hardhat-interop.json");
} else {
_env = vm.envOr("INTEROP_DEPLOY_CONFIG_PATH", string(""));
require(bytes(_env).length > 0, "Config: must set INTEROP_DEPLOY_CONFIG_PATH to filesystem path of deploy config");
}
}

/// @notice Returns the chainid from the EVM context or the value of the CHAIN_ID env var as
/// an override.
function chainID() internal view returns (uint256 _env) {
Expand Down
Loading

0 comments on commit 7ae18a7

Please sign in to comment.