Commit 3c228713 authored by Andreas Bigger's avatar Andreas Bigger Committed by Mark Tyneway

DisputeGameFactory devnet deploy scripts

parent cd24e96b
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { deploy, getDeploymentAddress } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const proxyAdmin = await getDeploymentAddress(hre, 'ProxyAdmin')
// We only want to deploy the dgf on devnet for now
if (hre.deployConfig.l1ChainID === 900) {
console.log('Devnet detected, deploying DisputeGameFactoryProxy')
const disputeGameFactoryProxy = await deploy({
hre,
name: 'DisputeGameFactoryProxy',
contract: 'Proxy',
args: [proxyAdmin],
})
console.log(
'DisputeGameFactoryProxy deployed at ' + disputeGameFactoryProxy.address
)
}
}
deployFn.tags = ['DisputeGameFactoryProxy', 'setup', 'l1']
export default deployFn
import { DeployFunction } from 'hardhat-deploy/dist/types'
import {
assertContractVariable,
deploy,
getContractFromArtifact,
} from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const OptimismPortalProxy = await getContractFromArtifact(
hre,
'OptimismPortalProxy'
)
await deploy({
hre,
name: 'L1CrossDomainMessenger',
args: [OptimismPortalProxy.address],
postDeployAction: async (contract) => {
await assertContractVariable(
contract,
'PORTAL',
OptimismPortalProxy.address
)
},
})
}
deployFn.tags = ['L1CrossDomainMessengerImpl', 'setup', 'l1']
export default deployFn
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { predeploys } from '../src'
import {
assertContractVariable,
deploy,
getContractFromArtifact,
} from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const L1CrossDomainMessengerProxy = await getContractFromArtifact(
hre,
'Proxy__OVM_L1CrossDomainMessenger'
)
await deploy({
hre,
name: 'L1StandardBridge',
args: [L1CrossDomainMessengerProxy.address],
postDeployAction: async (contract) => {
await assertContractVariable(
contract,
'MESSENGER',
L1CrossDomainMessengerProxy.address
)
await assertContractVariable(
contract,
'OTHER_BRIDGE',
predeploys.L2StandardBridge
)
},
})
}
deployFn.tags = ['L1StandardBridgeImpl', 'setup', 'l1']
export default deployFn
import { DeployFunction } from 'hardhat-deploy/dist/types'
import '@eth-optimism/hardhat-deploy-config'
import '@nomiclabs/hardhat-ethers'
import { assertContractVariable, deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
if (hre.deployConfig.l2BlockTime === 0) {
throw new Error(
'L2OutputOracle deployment: l2BlockTime must be greater than 0'
)
}
if (hre.deployConfig.l2OutputOracleSubmissionInterval === 0) {
throw new Error('L2OutputOracle deployment: submissionInterval cannot be 0')
}
await deploy({
hre,
name: 'L2OutputOracle',
args: [
hre.deployConfig.l2OutputOracleSubmissionInterval,
hre.deployConfig.l2BlockTime,
0,
0,
hre.deployConfig.l2OutputOracleProposer,
hre.deployConfig.l2OutputOracleChallenger,
hre.deployConfig.finalizationPeriodSeconds,
],
postDeployAction: async (contract) => {
await assertContractVariable(
contract,
'SUBMISSION_INTERVAL',
hre.deployConfig.l2OutputOracleSubmissionInterval
)
await assertContractVariable(
contract,
'L2_BLOCK_TIME',
hre.deployConfig.l2BlockTime
)
await assertContractVariable(
contract,
'PROPOSER',
hre.deployConfig.l2OutputOracleProposer
)
await assertContractVariable(
contract,
'CHALLENGER',
hre.deployConfig.l2OutputOracleChallenger
)
await assertContractVariable(
contract,
'FINALIZATION_PERIOD_SECONDS',
hre.deployConfig.finalizationPeriodSeconds
)
},
})
}
deployFn.tags = ['L2OutputOracleImpl', 'setup', 'l1']
export default deployFn
import { DeployFunction } from 'hardhat-deploy/dist/types'
import '@eth-optimism/hardhat-deploy-config'
import {
assertContractVariable,
deploy,
getContractFromArtifact,
} from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
const isLiveDeployer =
deployer.toLowerCase() === hre.deployConfig.controller.toLowerCase()
const L2OutputOracleProxy = await getContractFromArtifact(
hre,
'L2OutputOracleProxy'
)
const Artifact__SystemConfigProxy = await hre.deployments.get(
'SystemConfigProxy'
)
const portalGuardian = hre.deployConfig.portalGuardian
const portalGuardianCode = await hre.ethers.provider.getCode(portalGuardian)
if (portalGuardianCode === '0x') {
console.log(
`WARNING: setting OptimismPortal.GUARDIAN to ${portalGuardian} and it has no code`
)
if (!isLiveDeployer) {
throw new Error(
'Do not deploy to production networks without the GUARDIAN being a contract'
)
}
}
// Deploy the OptimismPortal implementation as paused to
// ensure that users do not interact with it and instead
// interact with the proxied contract.
// The `portalGuardian` is set at the GUARDIAN.
await deploy({
hre,
name: 'OptimismPortal',
args: [
L2OutputOracleProxy.address,
portalGuardian,
true, // paused
Artifact__SystemConfigProxy.address,
],
postDeployAction: async (contract) => {
await assertContractVariable(
contract,
'L2_ORACLE',
L2OutputOracleProxy.address
)
await assertContractVariable(
contract,
'GUARDIAN',
hre.deployConfig.portalGuardian
)
await assertContractVariable(
contract,
'SYSTEM_CONFIG',
Artifact__SystemConfigProxy.address
)
},
})
}
deployFn.tags = ['OptimismPortalImpl', 'setup', 'l1']
export default deployFn
import { DeployFunction } from 'hardhat-deploy/dist/types'
import {
assertContractVariable,
deploy,
getContractFromArtifact,
} from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const L1StandardBridgeProxy = await getContractFromArtifact(
hre,
'Proxy__OVM_L1StandardBridge'
)
await deploy({
hre,
name: 'OptimismMintableERC20Factory',
args: [L1StandardBridgeProxy.address],
postDeployAction: async (contract) => {
await assertContractVariable(
contract,
'BRIDGE',
L1StandardBridgeProxy.address
)
},
})
}
deployFn.tags = ['OptimismMintableERC20FactoryImpl', 'setup', 'l1']
export default deployFn
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { predeploys } from '../src'
import {
assertContractVariable,
deploy,
getContractFromArtifact,
} from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const L1CrossDomainMessengerProxy = await getContractFromArtifact(
hre,
'Proxy__OVM_L1CrossDomainMessenger'
)
await deploy({
hre,
name: 'L1ERC721Bridge',
args: [L1CrossDomainMessengerProxy.address, predeploys.L2ERC721Bridge],
postDeployAction: async (contract) => {
await assertContractVariable(
contract,
'MESSENGER',
L1CrossDomainMessengerProxy.address
)
},
})
}
deployFn.tags = ['L1ERC721BridgeImpl', 'setup', 'l1']
export default deployFn
import { DeployFunction } from 'hardhat-deploy/dist/types'
import {
assertContractVariable,
deploy,
getContractFromArtifact,
} from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const OptimismPortalProxy = await getContractFromArtifact(
hre,
'OptimismPortalProxy'
)
await deploy({
hre,
name: 'PortalSender',
args: [OptimismPortalProxy.address],
postDeployAction: async (contract) => {
await assertContractVariable(
contract,
'PORTAL',
OptimismPortalProxy.address
)
},
})
}
deployFn.tags = ['PortalSenderImpl', 'setup', 'l1']
export default deployFn
import assert from 'assert'
import { DeployFunction } from 'hardhat-deploy/dist/types'
import '@eth-optimism/hardhat-deploy-config'
import { BigNumber } from 'ethers'
import { defaultResourceConfig } from '../src/constants'
import { assertContractVariable, deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const batcherHash = hre.ethers.utils
.hexZeroPad(hre.deployConfig.batchSenderAddress, 32)
.toLowerCase()
const l2GenesisBlockGasLimit = BigNumber.from(
hre.deployConfig.l2GenesisBlockGasLimit
)
const l2GasLimitLowerBound = BigNumber.from(
defaultResourceConfig.systemTxMaxGas +
defaultResourceConfig.maxResourceLimit
)
if (l2GenesisBlockGasLimit.lt(l2GasLimitLowerBound)) {
throw new Error(
`L2 genesis block gas limit must be at least ${l2GasLimitLowerBound}`
)
}
await deploy({
hre,
name: 'SystemConfig',
args: [
hre.deployConfig.finalSystemOwner,
hre.deployConfig.gasPriceOracleOverhead,
hre.deployConfig.gasPriceOracleScalar,
batcherHash,
l2GenesisBlockGasLimit,
hre.deployConfig.p2pSequencerAddress,
defaultResourceConfig,
],
postDeployAction: async (contract) => {
await assertContractVariable(
contract,
'owner',
hre.deployConfig.finalSystemOwner
)
await assertContractVariable(
contract,
'overhead',
hre.deployConfig.gasPriceOracleOverhead
)
await assertContractVariable(
contract,
'scalar',
hre.deployConfig.gasPriceOracleScalar
)
await assertContractVariable(contract, 'batcherHash', batcherHash)
await assertContractVariable(
contract,
'unsafeBlockSigner',
hre.deployConfig.p2pSequencerAddress
)
const config = await contract.resourceConfig()
assert(config.maxResourceLimit === defaultResourceConfig.maxResourceLimit)
assert(
config.elasticityMultiplier ===
defaultResourceConfig.elasticityMultiplier
)
assert(
config.baseFeeMaxChangeDenominator ===
defaultResourceConfig.baseFeeMaxChangeDenominator
)
assert(
BigNumber.from(config.systemTxMaxGas).eq(
defaultResourceConfig.systemTxMaxGas
)
)
assert(
BigNumber.from(config.minimumBaseFee).eq(
defaultResourceConfig.minimumBaseFee
)
)
assert(
BigNumber.from(config.maximumBaseFee).eq(
defaultResourceConfig.maximumBaseFee
)
)
},
})
}
deployFn.tags = ['SystemConfigImpl', 'setup', 'l1']
export default deployFn
import { DeployFunction } from 'hardhat-deploy/dist/types'
import '@eth-optimism/hardhat-deploy-config'
import 'hardhat-deploy'
import { deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
await deploy({
hre,
name: 'SystemDictator',
args: [],
})
}
deployFn.tags = ['SystemDictatorImpl', 'setup', 'l1']
export default deployFn
import assert from 'assert'
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
// We only want to deploy the dgf on devnet for now
if (hre.deployConfig.l1ChainID === 900) {
const disputeGameFactory = await deploy({
hre,
name: 'DisputeGameFactory',
args: [],
})
console.log('DisputeGameFactory deployed at ' + disputeGameFactory.address)
const finalOwner = hre.deployConfig.finalSystemOwner
await disputeGameFactory.initialize(finalOwner)
const fetchedOwner = await disputeGameFactory.owner()
assert(fetchedOwner === finalOwner)
console.log('DisputeGameFactory implementation initialized')
}
}
deployFn.tags = ['DisputeGameFactoryImpl', 'setup', 'l1']
export default deployFn
import assert from 'assert'
import { DeployFunction } from 'hardhat-deploy/dist/types'
import '@eth-optimism/hardhat-deploy-config'
import 'hardhat-deploy'
import { getContractsFromArtifacts } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
// The DisputeGameFactory is only deployed on devnet
if (hre.deployConfig.l1ChainID === 900) {
const { deployer } = await hre.getNamedAccounts()
const [proxyAdmin, disputeGameFactoryProxy, disputeGameFactoryImpl] =
await getContractsFromArtifacts(hre, [
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'DisputeGameFactoryProxy',
iface: 'DisputeGameFactory',
signerOrProvider: deployer,
},
{
name: 'DisputeGameFactory',
},
])
const finalOwner = hre.deployConfig.finalSystemOwner
try {
const tx = await proxyAdmin.upgradeAndCall(
disputeGameFactoryProxy.address,
disputeGameFactoryImpl.address,
disputeGameFactoryProxy.interface.encodeFunctionData('initialize', [
finalOwner,
])
)
await tx.wait()
} catch (e) {
console.log('DisputeGameFactory already initialized')
}
const fetchedOwner = await disputeGameFactoryProxy.callStatic.owner()
assert(fetchedOwner === finalOwner)
console.log('Updgraded and initialized DisputeGameFactory')
}
}
deployFn.tags = ['DisputeGameFactoryInitialize', 'l1']
export default deployFn
import assert from 'assert'
import { ethers } from 'ethers'
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { awaitCondition } from '@eth-optimism/core-utils'
import '@eth-optimism/hardhat-deploy-config'
import 'hardhat-deploy'
import {
getContractsFromArtifacts,
getDeploymentAddress,
} from '../src/deploy-utils'
import { defaultResourceConfig } from '../src/constants'
const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
// Load the contracts we need to interact with.
const [
SystemDictator,
SystemDictatorProxy,
SystemDictatorProxyWithSigner,
SystemDictatorImpl,
] = await getContractsFromArtifacts(hre, [
{
name: 'SystemDictatorProxy',
iface: 'SystemDictator',
signerOrProvider: deployer,
},
{
name: 'SystemDictatorProxy',
},
{
name: 'SystemDictatorProxy',
signerOrProvider: deployer,
},
{
name: 'SystemDictator',
signerOrProvider: deployer,
},
])
// Load the dictator configuration.
const config = {
globalConfig: {
proxyAdmin: await getDeploymentAddress(hre, 'ProxyAdmin'),
controller: hre.deployConfig.controller,
finalOwner: hre.deployConfig.finalSystemOwner,
addressManager: await getDeploymentAddress(hre, 'Lib_AddressManager'),
},
proxyAddressConfig: {
l2OutputOracleProxy: await getDeploymentAddress(
hre,
'L2OutputOracleProxy'
),
optimismPortalProxy: await getDeploymentAddress(
hre,
'OptimismPortalProxy'
),
l1CrossDomainMessengerProxy: await getDeploymentAddress(
hre,
'Proxy__OVM_L1CrossDomainMessenger'
),
l1StandardBridgeProxy: await getDeploymentAddress(
hre,
'Proxy__OVM_L1StandardBridge'
),
optimismMintableERC20FactoryProxy: await getDeploymentAddress(
hre,
'OptimismMintableERC20FactoryProxy'
),
l1ERC721BridgeProxy: await getDeploymentAddress(
hre,
'L1ERC721BridgeProxy'
),
systemConfigProxy: await getDeploymentAddress(hre, 'SystemConfigProxy'),
},
implementationAddressConfig: {
l2OutputOracleImpl: await getDeploymentAddress(hre, 'L2OutputOracle'),
optimismPortalImpl: await getDeploymentAddress(hre, 'OptimismPortal'),
l1CrossDomainMessengerImpl: await getDeploymentAddress(
hre,
'L1CrossDomainMessenger'
),
l1StandardBridgeImpl: await getDeploymentAddress(hre, 'L1StandardBridge'),
optimismMintableERC20FactoryImpl: await getDeploymentAddress(
hre,
'OptimismMintableERC20Factory'
),
l1ERC721BridgeImpl: await getDeploymentAddress(hre, 'L1ERC721Bridge'),
portalSenderImpl: await getDeploymentAddress(hre, 'PortalSender'),
systemConfigImpl: await getDeploymentAddress(hre, 'SystemConfig'),
},
systemConfigConfig: {
owner: hre.deployConfig.finalSystemOwner,
overhead: hre.deployConfig.gasPriceOracleOverhead,
scalar: hre.deployConfig.gasPriceOracleScalar,
batcherHash: hre.ethers.utils.hexZeroPad(
hre.deployConfig.batchSenderAddress,
32
),
gasLimit: hre.deployConfig.l2GenesisBlockGasLimit,
unsafeBlockSigner: hre.deployConfig.p2pSequencerAddress,
// The resource config is not exposed to the end user
// to simplify deploy config. It may be introduced in the future.
resourceConfig: defaultResourceConfig,
},
}
// Update the implementation if necessary.
if (
(await SystemDictatorProxy.callStatic.implementation({
from: ethers.constants.AddressZero,
})) !== SystemDictatorImpl.address
) {
console.log('Upgrading the SystemDictator proxy...')
// Upgrade and initialize the proxy.
await SystemDictatorProxyWithSigner.upgradeToAndCall(
SystemDictatorImpl.address,
SystemDictatorImpl.interface.encodeFunctionData('initialize', [config])
)
// Wait for the transaction to execute properly.
await awaitCondition(
async () => {
return (
(await SystemDictatorProxy.callStatic.implementation({
from: ethers.constants.AddressZero,
})) === SystemDictatorImpl.address
)
},
30000,
1000
)
// Verify that the contract was initialized correctly.
const dictatorConfig = await SystemDictator.config()
for (const [outerConfigKey, outerConfigValue] of Object.entries(config)) {
for (const [innerConfigKey, innerConfigValue] of Object.entries(
outerConfigValue
)) {
let have = dictatorConfig[outerConfigKey][innerConfigKey]
let want = innerConfigValue as any
if (ethers.utils.isAddress(want)) {
want = want.toLowerCase()
have = have.toLowerCase()
} else if (typeof want === 'number') {
want = ethers.BigNumber.from(want)
have = ethers.BigNumber.from(have)
assert(
want.eq(have),
`incorrect config for ${outerConfigKey}.${innerConfigKey}. Want: ${want}, have: ${have}`
)
return
}
assert(
want === have,
`incorrect config for ${outerConfigKey}.${innerConfigKey}. Want: ${want}, have: ${have}`
)
}
}
}
// Update the owner if necessary.
if (
(await SystemDictatorProxy.callStatic.admin({
from: ethers.constants.AddressZero,
})) !== hre.deployConfig.controller
) {
console.log('Transferring ownership of the SystemDictator proxy...')
// Transfer ownership to the controller address.
await SystemDictatorProxyWithSigner.changeAdmin(hre.deployConfig.controller)
// Wait for the transaction to execute properly.
await awaitCondition(
async () => {
return (
(await SystemDictatorProxy.callStatic.admin({
from: ethers.constants.AddressZero,
})) === hre.deployConfig.controller
)
},
30000,
1000
)
}
}
deployFn.tags = ['SystemDictatorImpl', 'setup', 'l1']
export default deployFn
import assert from 'assert'
import { ethers } from 'ethers'
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { awaitCondition } from '@eth-optimism/core-utils'
import '@eth-optimism/hardhat-deploy-config'
import 'hardhat-deploy'
import '@nomiclabs/hardhat-ethers'
import {
assertContractVariable,
getContractsFromArtifacts,
getDeploymentAddress,
doOwnershipTransfer,
doPhase,
liveDeployer,
} from '../src/deploy-utils'
const uint128Max = ethers.BigNumber.from('0xffffffffffffffffffffffffffffffff')
const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
// Set up required contract references.
const [
SystemDictator,
ProxyAdmin,
AddressManager,
L1StandardBridgeProxy,
L1StandardBridgeProxyWithSigner,
L1ERC721BridgeProxy,
L1ERC721BridgeProxyWithSigner,
SystemConfigProxy,
] = await getContractsFromArtifacts(hre, [
{
name: 'SystemDictatorProxy',
iface: 'SystemDictator',
signerOrProvider: deployer,
},
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'Lib_AddressManager',
signerOrProvider: deployer,
},
{
name: 'Proxy__OVM_L1StandardBridge',
},
{
name: 'Proxy__OVM_L1StandardBridge',
signerOrProvider: deployer,
},
{
name: 'L1ERC721BridgeProxy',
},
{
name: 'L1ERC721BridgeProxy',
signerOrProvider: deployer,
},
{
name: 'SystemConfigProxy',
iface: 'SystemConfig',
signerOrProvider: deployer,
},
])
// If we have the key for the controller then we don't need to wait for external txns.
// Set the DISABLE_LIVE_DEPLOYER=true in the env to ensure the script will pause to simulate scenarios
// where the controller is not the deployer.
const isLiveDeployer = await liveDeployer({
hre,
disabled: process.env.DISABLE_LIVE_DEPLOYER,
})
// Transfer ownership of the ProxyAdmin to the SystemDictator.
if ((await ProxyAdmin.owner()) !== SystemDictator.address) {
await doOwnershipTransfer({
isLiveDeployer,
proxy: ProxyAdmin,
name: 'ProxyAdmin',
transferFunc: 'transferOwnership',
dictator: SystemDictator,
})
}
// We don't need to transfer proxy addresses if we're already beyond the proxy transfer step.
const needsProxyTransfer =
(await SystemDictator.currentStep()) <=
(await SystemDictator.PROXY_TRANSFER_STEP())
// Transfer ownership of the AddressManager to SystemDictator.
if (
needsProxyTransfer &&
(await AddressManager.owner()) !== SystemDictator.address
) {
await doOwnershipTransfer({
isLiveDeployer,
proxy: AddressManager,
name: 'AddressManager',
transferFunc: 'transferOwnership',
dictator: SystemDictator,
})
} else {
console.log(`AddressManager already owned by the SystemDictator`)
}
// Transfer ownership of the L1StandardBridge (proxy) to SystemDictator.
if (
needsProxyTransfer &&
(await L1StandardBridgeProxy.callStatic.getOwner({
from: ethers.constants.AddressZero,
})) !== SystemDictator.address
) {
await doOwnershipTransfer({
isLiveDeployer,
proxy: L1StandardBridgeProxyWithSigner,
name: 'L1StandardBridgeProxy',
transferFunc: 'setOwner',
dictator: SystemDictator,
})
} else {
console.log(`L1StandardBridge already owned by MSD`)
}
// Transfer ownership of the L1ERC721Bridge (proxy) to SystemDictator.
if (
needsProxyTransfer &&
(await L1ERC721BridgeProxy.callStatic.admin({
from: ethers.constants.AddressZero,
})) !== SystemDictator.address
) {
await doOwnershipTransfer({
isLiveDeployer,
proxy: L1ERC721BridgeProxyWithSigner,
name: 'L1ERC721BridgeProxy',
transferFunc: 'changeAdmin',
dictator: SystemDictator,
})
} else {
console.log(`L1ERC721Bridge already owned by MSD`)
}
// Wait for the ownership transfers to complete before continuing.
await awaitCondition(
async (): Promise<boolean> => {
const proxyAdminOwner = await ProxyAdmin.owner()
const addressManagerOwner = await AddressManager.owner()
const l1StandardBridgeOwner =
await L1StandardBridgeProxy.callStatic.getOwner({
from: ethers.constants.AddressZero,
})
const l1Erc721BridgeOwner = await L1ERC721BridgeProxy.callStatic.admin({
from: ethers.constants.AddressZero,
})
return (
proxyAdminOwner === SystemDictator.address &&
addressManagerOwner === SystemDictator.address &&
l1StandardBridgeOwner === SystemDictator.address &&
l1Erc721BridgeOwner === SystemDictator.address
)
},
5000,
1000
)
await doPhase({
isLiveDeployer,
SystemDictator,
phase: 1,
message: `
Phase 1 includes the following steps:
Step 1 will configure the ProxyAdmin contract, you can safely execute this step at any time
without impacting the functionality of the rest of the system.
Step 2 will stop deposits and withdrawals via the L1CrossDomainMessenger and will stop the
DTL from syncing new deposits via the CTC, effectively shutting down the legacy system. Once
this step has been executed, you should immediately begin the L2 migration process. If you
need to restart the system, run exit1() followed by finalize().
`,
checks: async () => {
// Step 1 checks
await assertContractVariable(
ProxyAdmin,
'addressManager',
AddressManager.address
)
assert(
(await ProxyAdmin.implementationName(
getDeploymentAddress(hre, 'Proxy__OVM_L1CrossDomainMessenger')
)) === 'OVM_L1CrossDomainMessenger'
)
assert(
(await ProxyAdmin.proxyType(
getDeploymentAddress(hre, 'Proxy__OVM_L1CrossDomainMessenger')
)) === 2
)
assert(
(await ProxyAdmin.proxyType(
getDeploymentAddress(hre, 'Proxy__OVM_L1StandardBridge')
)) === 1
)
// Check the SystemConfig was initialized properly.
await assertContractVariable(
SystemConfigProxy,
'owner',
hre.deployConfig.finalSystemOwner
)
await assertContractVariable(
SystemConfigProxy,
'overhead',
hre.deployConfig.gasPriceOracleOverhead
)
await assertContractVariable(
SystemConfigProxy,
'scalar',
hre.deployConfig.gasPriceOracleScalar
)
await assertContractVariable(
SystemConfigProxy,
'batcherHash',
ethers.utils.hexZeroPad(
hre.deployConfig.batchSenderAddress.toLowerCase(),
32
)
)
await assertContractVariable(
SystemConfigProxy,
'gasLimit',
hre.deployConfig.l2GenesisBlockGasLimit
)
const config = await SystemConfigProxy.resourceConfig()
assert(config.maxResourceLimit === 20_000_000)
assert(config.elasticityMultiplier === 10)
assert(config.baseFeeMaxChangeDenominator === 8)
assert(config.systemTxMaxGas === 1_000_000)
assert(ethers.utils.parseUnits('1', 'gwei').eq(config.minimumBaseFee))
assert(config.maximumBaseFee.eq(uint128Max))
// Step 2 checks
const messenger = await AddressManager.getAddress(
'OVM_L1CrossDomainMessenger'
)
assert(messenger === ethers.constants.AddressZero)
},
})
}
deployFn.tags = ['SystemDictatorSteps', 'phase1', 'l1']
export default deployFn
import assert from 'assert'
import { ethers } from 'ethers'
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { awaitCondition } from '@eth-optimism/core-utils'
import '@eth-optimism/hardhat-deploy-config'
import 'hardhat-deploy'
import '@nomiclabs/hardhat-ethers'
import {
assertContractVariable,
getContractsFromArtifacts,
printJsonTransaction,
isStep,
printTenderlySimulationLink,
printCastCommand,
liveDeployer,
doPhase,
isStartOfPhase,
} from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
// Set up required contract references.
const [
SystemDictator,
ProxyAdmin,
AddressManager,
L1CrossDomainMessenger,
L1StandardBridgeProxy,
L1StandardBridge,
L2OutputOracle,
OptimismPortal,
OptimismMintableERC20Factory,
L1ERC721BridgeProxy,
L1ERC721Bridge,
] = await getContractsFromArtifacts(hre, [
{
name: 'SystemDictatorProxy',
iface: 'SystemDictator',
signerOrProvider: deployer,
},
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'Lib_AddressManager',
signerOrProvider: deployer,
},
{
name: 'Proxy__OVM_L1CrossDomainMessenger',
iface: 'L1CrossDomainMessenger',
signerOrProvider: deployer,
},
{
name: 'Proxy__OVM_L1StandardBridge',
},
{
name: 'Proxy__OVM_L1StandardBridge',
iface: 'L1StandardBridge',
signerOrProvider: deployer,
},
{
name: 'L2OutputOracleProxy',
iface: 'L2OutputOracle',
signerOrProvider: deployer,
},
{
name: 'OptimismPortalProxy',
iface: 'OptimismPortal',
signerOrProvider: deployer,
},
{
name: 'OptimismMintableERC20FactoryProxy',
iface: 'OptimismMintableERC20Factory',
signerOrProvider: deployer,
},
{
name: 'L1ERC721BridgeProxy',
},
{
name: 'L1ERC721BridgeProxy',
iface: 'L1ERC721Bridge',
signerOrProvider: deployer,
},
])
// If we have the key for the controller then we don't need to wait for external txns.
// Set the DISABLE_LIVE_DEPLOYER=true in the env to ensure the script will pause to simulate scenarios
// where the controller is not the deployer.
const isLiveDeployer = await liveDeployer({
hre,
disabled: process.env.DISABLE_LIVE_DEPLOYER,
})
// Make sure the dynamic system configuration has been set.
if (
(await isStartOfPhase(SystemDictator, 2)) &&
!(await SystemDictator.dynamicConfigSet())
) {
console.log(`
You must now set the dynamic L2OutputOracle configuration by calling the function
updateL2OutputOracleDynamicConfig. You will need to provide the
l2OutputOracleStartingBlockNumber and the l2OutputOracleStartingTimestamp which can both be
found by querying the last finalized block in the L2 node.
`)
if (isLiveDeployer) {
console.log(`Updating dynamic oracle config...`)
// Use default starting time if not provided
let deployL2StartingTimestamp =
hre.deployConfig.l2OutputOracleStartingTimestamp
if (deployL2StartingTimestamp < 0) {
const l1StartingBlock = await hre.ethers.provider.getBlock(
hre.deployConfig.l1StartingBlockTag
)
if (l1StartingBlock === null) {
throw new Error(
`Cannot fetch block tag ${hre.deployConfig.l1StartingBlockTag}`
)
}
deployL2StartingTimestamp = l1StartingBlock.timestamp
}
await SystemDictator.updateDynamicConfig(
{
l2OutputOracleStartingBlockNumber:
hre.deployConfig.l2OutputOracleStartingBlockNumber,
l2OutputOracleStartingTimestamp: deployL2StartingTimestamp,
},
false // do not pause the the OptimismPortal when initializing
)
} else {
// pause the OptimismPortal when initializing
const optimismPortalPaused = true
const tx = await SystemDictator.populateTransaction.updateDynamicConfig(
{
l2OutputOracleStartingBlockNumber:
hre.deployConfig.l2OutputOracleStartingBlockNumber,
l2OutputOracleStartingTimestamp:
hre.deployConfig.l2OutputOracleStartingTimestamp,
},
optimismPortalPaused
)
console.log(`Please update dynamic oracle config...`)
console.log(
JSON.stringify(
{
l2OutputOracleStartingBlockNumber:
hre.deployConfig.l2OutputOracleStartingBlockNumber,
l2OutputOracleStartingTimestamp:
hre.deployConfig.l2OutputOracleStartingTimestamp,
optimismPortalPaused,
},
null,
2
)
)
console.log(`MSD address: ${SystemDictator.address}`)
printJsonTransaction(tx)
printCastCommand(tx)
await printTenderlySimulationLink(SystemDictator.provider, tx)
}
await awaitCondition(
async () => {
return SystemDictator.dynamicConfigSet()
},
5000,
1000
)
}
await doPhase({
isLiveDeployer,
SystemDictator,
phase: 2,
message: `
Phase 2 includes the following steps:
Step 3 will clear out some legacy state from the AddressManager. Once you execute this step,
you WILL NOT BE ABLE TO RESTART THE SYSTEM using exit1(). You should confirm that the L2
system is entirely operational before executing this step.
Step 4 will transfer ownership of the AddressManager and L1StandardBridge to the ProxyAdmin.
Step 5 will initialize all Bedrock contracts. After this step is executed, the OptimismPortal
will be open for deposits but withdrawals will be paused if deploying a production network.
The Proposer will also be able to submit L2 outputs to the L2OutputOracle.
Lastly the finalize step will be executed. This will transfer ownership of the ProxyAdmin to
the final system owner as specified in the deployment configuration.
`,
checks: async () => {
// Step 3 checks
const deads = [
'OVM_CanonicalTransactionChain',
'OVM_L2CrossDomainMessenger',
'OVM_DecompressionPrecompileAddress',
'OVM_Sequencer',
'OVM_Proposer',
'OVM_ChainStorageContainer-CTC-batches',
'OVM_ChainStorageContainer-CTC-queue',
'OVM_CanonicalTransactionChain',
'OVM_StateCommitmentChain',
'OVM_BondManager',
'OVM_ExecutionManager',
'OVM_FraudVerifier',
'OVM_StateManagerFactory',
'OVM_StateTransitionerFactory',
'OVM_SafetyChecker',
'OVM_L1MultiMessageRelayer',
'BondManager',
]
for (const dead of deads) {
const addr = await AddressManager.getAddress(dead)
assert(addr === ethers.constants.AddressZero)
}
// Step 4 checks
await assertContractVariable(AddressManager, 'owner', ProxyAdmin.address)
assert(
(await L1StandardBridgeProxy.callStatic.getOwner({
from: ethers.constants.AddressZero,
})) === ProxyAdmin.address
)
assert(
(await L1ERC721BridgeProxy.callStatic.admin({
from: ProxyAdmin.address,
})) === ProxyAdmin.address
)
// Step 5 checks
// Check L2OutputOracle was initialized properly.
await assertContractVariable(
L2OutputOracle,
'latestBlockNumber',
hre.deployConfig.l2OutputOracleStartingBlockNumber
)
// Check OptimismPortal was initialized properly.
await assertContractVariable(
OptimismPortal,
'l2Sender',
'0x000000000000000000000000000000000000dEaD'
)
const resourceParams = await OptimismPortal.params()
assert(
resourceParams.prevBaseFee.eq(ethers.utils.parseUnits('1', 'gwei')),
`OptimismPortal was not initialized with the correct initial base fee`
)
assert(
resourceParams.prevBoughtGas.eq(0),
`OptimismPortal was not initialized with the correct initial bought gas`
)
assert(
!resourceParams.prevBlockNum.eq(0),
`OptimismPortal was not initialized with the correct initial block number`
)
assert(
(await hre.ethers.provider.getBalance(L1StandardBridge.address)).eq(0)
)
if (isLiveDeployer) {
await assertContractVariable(OptimismPortal, 'paused', false)
} else {
await assertContractVariable(OptimismPortal, 'paused', true)
}
// Check L1CrossDomainMessenger was initialized properly.
try {
await L1CrossDomainMessenger.xDomainMessageSender()
assert(false, `L1CrossDomainMessenger was not initialized properly`)
} catch (err) {
// Expected.
}
// Check L1StandardBridge was initialized properly.
await assertContractVariable(
L1StandardBridge,
'messenger',
L1CrossDomainMessenger.address
)
assert(
(await hre.ethers.provider.getBalance(L1StandardBridge.address)).eq(0)
)
// Check OptimismMintableERC20Factory was initialized properly.
await assertContractVariable(
OptimismMintableERC20Factory,
'BRIDGE',
L1StandardBridge.address
)
// Check L1ERC721Bridge was initialized properly.
await assertContractVariable(
L1ERC721Bridge,
'messenger',
L1CrossDomainMessenger.address
)
// finalize checks
await assertContractVariable(
ProxyAdmin,
'owner',
hre.deployConfig.finalSystemOwner
)
},
})
// Step 6 unpauses the OptimismPortal.
if (await isStep(SystemDictator, 6)) {
console.log(`
Unpause the OptimismPortal. The GUARDIAN account should be used. In practice
this is the multisig. In test networks, the OptimismPortal is initialized
without being paused.
`)
if (isLiveDeployer) {
console.log('WARNING: OptimismPortal configured to not be paused')
console.log('This should only happen for test environments')
await assertContractVariable(OptimismPortal, 'paused', false)
} else {
const tx = await OptimismPortal.populateTransaction.unpause()
console.log(`Please unpause the OptimismPortal...`)
console.log(`OptimismPortal address: ${OptimismPortal.address}`)
printJsonTransaction(tx)
printCastCommand(tx)
await printTenderlySimulationLink(SystemDictator.provider, tx)
}
await awaitCondition(
async () => {
const paused = await OptimismPortal.paused()
return !paused
},
5000,
1000
)
await assertContractVariable(OptimismPortal, 'paused', false)
await awaitCondition(
async () => {
return SystemDictator.finalized()
},
5000,
1000
)
}
}
deployFn.tags = ['SystemDictatorSteps', 'phase2', 'l1']
export default deployFn
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