Commit ae8a3a74 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #6000 from ethereum-optimism/refcell/remove/migrationdeploys

fix(ctb): Update Deploys
parents f09accb1 fb46010e
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { OptimismPortal } from "../L1/OptimismPortal.sol";
/**
* @title PortalSender
* @notice The PortalSender is a simple intermediate contract that will transfer the balance of the
* L1StandardBridge to the OptimismPortal during the Bedrock migration.
*/
contract PortalSender {
/**
* @notice Address of the OptimismPortal contract.
*/
OptimismPortal public immutable PORTAL;
/**
* @param _portal Address of the OptimismPortal contract.
*/
constructor(OptimismPortal _portal) {
PORTAL = _portal;
}
/**
* @notice Sends balance of this contract to the OptimismPortal.
*/
function donate() public {
PORTAL.donateETH{ value: address(this).balance }();
}
}
...@@ -34,13 +34,13 @@ ...@@ -34,13 +34,13 @@
"l2GenesisBlockBaseFeePerGas": "0x3B9ACA00", "l2GenesisBlockBaseFeePerGas": "0x3B9ACA00",
"gasPriceOracleOverhead": 2100, "gasPriceOracleOverhead": 2100,
"gasPriceOracleScalar": 1000000, "gasPriceOracleScalar": 1000000,
"enableGovernance": true, "enableGovernance": true,
"governanceTokenSymbol": "OP", "governanceTokenSymbol": "OP",
"governanceTokenName": "Optimism", "governanceTokenName": "Optimism",
"governanceTokenOwner": "0xBcd4042DE499D14e55001CcbB24a551F3b954096", "governanceTokenOwner": "0xBcd4042DE499D14e55001CcbB24a551F3b954096",
"eip1559Denominator": 8, "eip1559Denominator": 8,
"eip1559Elasticity": 2, "eip1559Elasticity": 2,
"l1GenesisBlockTimestamp": "0x638a4554", "l1GenesisBlockTimestamp": "0x648a0943",
"l1StartingBlockTag": "earliest", "l1StartingBlockTag": "earliest",
"l2GenesisRegolithTimeOffset": "0x0" "l2GenesisRegolithTimeOffset": "0x0"
} }
\ No newline at end of file
...@@ -11,7 +11,6 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -11,7 +11,6 @@ const deployFn: DeployFunction = async (hre) => {
contract: 'AddressManager', contract: 'AddressManager',
args: [], args: [],
postDeployAction: async (contract) => { postDeployAction: async (contract) => {
// Owner is temporarily set to the deployer.
await assertContractVariable(contract, 'owner', deployer) await assertContractVariable(contract, 'owner', deployer)
}, },
}) })
......
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { assertContractVariable, deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
await deploy({
hre,
name: 'ProxyAdmin',
args: [deployer],
postDeployAction: async (contract) => {
// Owner is temporarily set to the deployer. We transfer ownership of the ProxyAdmin to the
// SystemDictator before we trigger the dictator steps.
await assertContractVariable(contract, 'owner', deployer)
},
})
}
deployFn.tags = ['ProxyAdmin', 'setup', 'l1']
export default deployFn
import assert from 'assert'
import { DeployFunction } from 'hardhat-deploy/dist/types'
import {
assertContractVariable,
getContractsFromArtifacts,
deploy,
} from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
const [addressManager] = await getContractsFromArtifacts(hre, [
{
name: 'Lib_AddressManager',
signerOrProvider: deployer,
},
])
const proxyAdmin = await deploy({
hre,
name: 'ProxyAdmin',
args: [deployer],
postDeployAction: async (contract) => {
// Owner is temporarily set to the deployer.
await assertContractVariable(contract, 'owner', deployer)
},
})
let addressManagerOnProxy = await proxyAdmin.callStatic.addressManager()
if (addressManagerOnProxy !== addressManager.address) {
// Set the address manager on the proxy admin
console.log(
`ProxyAdmin(${proxyAdmin.address}).setAddressManager(${addressManager.address})`
)
const tx = await proxyAdmin.setAddressManager(addressManager.address)
await tx.wait()
}
// Validate the address manager was set correctly.
addressManagerOnProxy = await proxyAdmin.callStatic.addressManager()
assert(
addressManagerOnProxy === addressManager.address,
'AddressManager not set on ProxyAdmin'
)
}
deployFn.tags = ['ProxyAdmin', 'setup', 'l1']
export default deployFn
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import { assertContractVariable, deploy } from '../src/deploy-utils' import {
assertContractVariable,
getDeploymentAddress,
deploy,
} from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts() const proxyAdmin = await getDeploymentAddress(hre, 'ProxyAdmin')
await deploy({ await deploy({
hre, hre,
name: 'Proxy__OVM_L1StandardBridge', name: 'Proxy__OVM_L1StandardBridge',
contract: 'L1ChugSplashProxy', contract: 'L1ChugSplashProxy',
args: [deployer], args: [proxyAdmin],
postDeployAction: async (contract) => { postDeployAction: async (contract) => {
await assertContractVariable(contract, 'getOwner', deployer) await assertContractVariable(contract, 'getOwner', proxyAdmin)
}, },
}) })
} }
......
import assert from 'assert'
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import { deploy, getDeploymentAddress } from '../src/deploy-utils' import { deploy, getContractsFromArtifacts } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const addressManager = await getDeploymentAddress(hre, 'Lib_AddressManager') const { deployer } = await hre.getNamedAccounts()
const [addressManager] = await getContractsFromArtifacts(hre, [
{
name: 'Lib_AddressManager',
signerOrProvider: deployer,
},
])
// The name in the address manager for this contract
const name = 'OVM_L1CrossDomainMessenger'
console.log(
`Setting up ResolvedDelegateProxy with AddressManager(${addressManager.address})`
)
await deploy({ const l1CrossDomainMessengerProxy = await deploy({
hre, hre,
name: 'Proxy__OVM_L1CrossDomainMessenger', name: 'Proxy__OVM_L1CrossDomainMessenger',
contract: 'ResolvedDelegateProxy', contract: 'ResolvedDelegateProxy',
args: [addressManager, 'OVM_L1CrossDomainMessenger'], args: [addressManager.address, name],
}) })
let addr = await addressManager.getAddress(name)
if (addr !== l1CrossDomainMessengerProxy.address) {
console.log(
`AddressManager(${addressManager.address}).setAddress(${name}, ${l1CrossDomainMessengerProxy.address})`
)
const tx = await addressManager.setAddress(
name,
l1CrossDomainMessengerProxy.address
)
await tx.wait()
}
addr = await addressManager.getAddress(name)
assert(
addr === l1CrossDomainMessengerProxy.address,
`${name} not set correctly`
)
} }
deployFn.tags = ['L1CrossDomainMessengerProxy', 'setup', 'l1'] deployFn.tags = ['L1CrossDomainMessengerProxy', 'setup', 'l1']
......
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import { assertContractVariable, deploy } from '../src/deploy-utils' import {
assertContractVariable,
getDeploymentAddress,
deploy,
} from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts() const proxyAdmin = await getDeploymentAddress(hre, 'ProxyAdmin')
await deploy({ await deploy({
hre, hre,
name: 'L1ERC721BridgeProxy', name: 'L1ERC721BridgeProxy',
contract: 'Proxy', contract: 'Proxy',
args: [deployer], args: [proxyAdmin],
postDeployAction: async (contract) => { postDeployAction: async (contract) => {
await assertContractVariable(contract, 'admin', deployer) await assertContractVariable(contract, 'admin', proxyAdmin)
}, },
}) })
} }
......
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { assertContractVariable, deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
await deploy({
hre,
name: 'SystemDictatorProxy',
contract: 'Proxy',
args: [deployer],
postDeployAction: async (contract) => {
await assertContractVariable(contract, 'admin', deployer)
},
})
}
deployFn.tags = ['SystemDictatorProxy', '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 { getContractsFromArtifacts } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
const [proxyAdmin, addressManager] = await getContractsFromArtifacts(hre, [
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'Lib_AddressManager',
signerOrProvider: deployer,
},
])
let addressManagerOwner = await addressManager.callStatic.owner()
if (addressManagerOwner !== proxyAdmin.address) {
console.log(
`AddressManager(${addressManager.address}).transferOwnership(${proxyAdmin.address})`
)
const tx = await addressManager.transferOwnership(proxyAdmin.address)
await tx.wait()
}
addressManagerOwner = await addressManager.callStatic.owner()
assert(
addressManagerOwner === proxyAdmin.address,
'AddressManager owner not set correctly'
)
}
deployFn.tags = ['AddressManager', '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) => {
const { deployer } = await hre.getNamedAccounts()
const [proxyAdmin, l2OutputOracleProxy, l2OutputOracleImpl] =
await getContractsFromArtifacts(hre, [
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'L2OutputOracleProxy',
iface: 'L2OutputOracle',
signerOrProvider: deployer,
},
{
name: 'L2OutputOracle',
},
])
const startingBlockNumber = hre.deployConfig.l2OutputOracleStartingBlockNumber
let startingTimestamp = hre.deployConfig.l2OutputOracleStartingTimestamp
if (startingTimestamp < 0) {
const l1StartingBlock = await hre.ethers.provider.getBlock(
hre.deployConfig.l1StartingBlockTag
)
if (l1StartingBlock === null) {
throw new Error(
`Cannot fetch block tag ${hre.deployConfig.l1StartingBlockTag}`
)
}
startingTimestamp = l1StartingBlock.timestamp
}
try {
const tx = await proxyAdmin.upgradeAndCall(
l2OutputOracleProxy.address,
l2OutputOracleImpl.address,
l2OutputOracleProxy.interface.encodeFunctionData('initialize', [
startingBlockNumber,
startingTimestamp,
])
)
await tx.wait()
} catch (e) {
console.log('L2OutputOracle already initialized')
}
const fetchedStartingBlockNumber =
await l2OutputOracleProxy.callStatic.startingBlockNumber()
const fetchedStartingTimestamp =
await l2OutputOracleProxy.callStatic.startingTimestamp()
assert(fetchedStartingBlockNumber.toNumber() === startingBlockNumber)
assert(fetchedStartingTimestamp.toNumber() === startingTimestamp)
console.log('Updgraded and initialized L2OutputOracle')
const version = await l2OutputOracleProxy.callStatic.version()
console.log(`L2OutputOracle version: ${version}`)
}
deployFn.tags = ['L2OutputOracleInitialize', '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) => {
const { deployer } = await hre.getNamedAccounts()
const [proxyAdmin, optimismPortalProxy, optimismPortalImpl] =
await getContractsFromArtifacts(hre, [
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'OptimismPortalProxy',
iface: 'OptimismPortal',
signerOrProvider: deployer,
},
{
name: 'OptimismPortal',
},
])
// Initialize the portal, setting paused to false
try {
const tx = await proxyAdmin.upgradeAndCall(
optimismPortalProxy.address,
optimismPortalImpl.address,
optimismPortalProxy.interface.encodeFunctionData('initialize', [false])
)
await tx.wait()
} catch (e) {
console.log('OptimismPortal already initialized')
}
const isPaused = await optimismPortalProxy.callStatic.paused()
assert(isPaused === false)
console.log('Upgraded and initialized OptimismPortal')
const version = await optimismPortalProxy.callStatic.version()
console.log(`OptimismPortal version: ${version}`)
}
deployFn.tags = ['OptimismPortalInitialize', '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 { 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) => {
const { deployer } = await hre.getNamedAccounts()
const [proxyAdmin, l1CrossDomainMessengerProxy, l1CrossDomainMessengerImpl] =
await getContractsFromArtifacts(hre, [
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'Proxy__OVM_L1CrossDomainMessenger',
iface: 'L1CrossDomainMessenger',
signerOrProvider: deployer,
},
{
name: 'L1CrossDomainMessenger',
},
])
const proxyType = await proxyAdmin.callStatic.proxyType(
l1CrossDomainMessengerProxy.address
)
if (proxyType !== 2) {
console.log(
`ProxyAdmin(${proxyAdmin.address}).setProxyType(${l1CrossDomainMessengerProxy.address}, 2)`
)
// Set the L1CrossDomainMessenger to the RESOLVED proxy type.
const tx = await proxyAdmin.setProxyType(
l1CrossDomainMessengerProxy.address,
2
)
await tx.wait()
}
const name = 'OVM_L1CrossDomainMessenger'
const implementationName = proxyAdmin.implementationName(
l1CrossDomainMessengerImpl.address
)
if (implementationName !== name) {
console.log(
`ProxyAdmin(${proxyAdmin.address}).setImplementationName(${l1CrossDomainMessengerImpl.address}, 'OVM_L1CrossDomainMessenger')`
)
const tx = await proxyAdmin.setImplementationName(
l1CrossDomainMessengerProxy.address,
name
)
await tx.wait()
}
try {
const tx = await proxyAdmin.upgradeAndCall(
l1CrossDomainMessengerProxy.address,
l1CrossDomainMessengerImpl.address,
l1CrossDomainMessengerImpl.interface.encodeFunctionData('initialize')
)
await tx.wait()
} catch (e) {
console.log('L1CrossDomainMessenger already initialized')
}
const version = await l1CrossDomainMessengerProxy.callStatic.version()
console.log(`L1CrossDomainMessenger version: ${version}`)
console.log('Upgraded L1CrossDomainMessenger')
}
deployFn.tags = ['L1CrossDomainMessengerInitialize', '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 { DeployFunction } from 'hardhat-deploy/dist/types'
import { BigNumber } from 'ethers'
import '@eth-optimism/hardhat-deploy-config'
import 'hardhat-deploy'
import { defaultResourceConfig } from '../src/constants'
import { getContractsFromArtifacts } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
const [proxyAdmin, systemConfigProxy, systemConfigImpl] =
await getContractsFromArtifacts(hre, [
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'SystemConfigProxy',
iface: 'SystemConfig',
signerOrProvider: deployer,
},
{
name: 'SystemConfig',
},
])
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}`
)
}
try {
const tx = await proxyAdmin.upgradeAndCall(
systemConfigProxy.address,
systemConfigImpl.address,
systemConfigImpl.interface.encodeFunctionData('initialize', [
hre.deployConfig.finalSystemOwner,
hre.deployConfig.gasPriceOracleOverhead,
hre.deployConfig.gasPriceOracleScalar,
batcherHash,
l2GenesisBlockGasLimit,
hre.deployConfig.p2pSequencerAddress,
defaultResourceConfig,
])
)
await tx.wait()
} catch (e) {
console.log('SystemConfig already initialized')
console.log(e)
}
const version = await systemConfigProxy.callStatic.version()
console.log(`SystemConfig version: ${version}`)
console.log('Upgraded SystemConfig')
}
deployFn.tags = ['SystemConfigInitialize', '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 { 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) => {
const { deployer } = await hre.getNamedAccounts()
const [proxyAdmin, l1StandardBridgeProxy, l1StandardBridgeImpl] =
await getContractsFromArtifacts(hre, [
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'Proxy__OVM_L1StandardBridge',
iface: 'L1StandardBridge',
signerOrProvider: deployer,
},
{
name: 'L1StandardBridge',
},
])
const proxyType = await proxyAdmin.callStatic.proxyType(
l1StandardBridgeProxy.address
)
if (proxyType !== 1) {
console.log(
`ProxyAdmin(${proxyAdmin.address}).setProxyType(${l1StandardBridgeProxy.address}, 1)`
)
// Set the L1StandardBridge to the UPGRADEABLE proxy type.
const tx = await proxyAdmin.setProxyType(l1StandardBridgeProxy.address, 1)
await tx.wait()
}
try {
const tx = await proxyAdmin.upgrade(
l1StandardBridgeProxy.address,
l1StandardBridgeImpl.address
)
await tx.wait()
} catch (e) {
console.log('L1StandardBridge already initialized')
}
const version = await l1StandardBridgeProxy.callStatic.version()
console.log(`L1StandardBridge version: ${version}`)
console.log('Upgraded L1StandardBridge')
}
deployFn.tags = ['L1StandardBridgeInitialize', 'l1']
export default deployFn
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) => {
const { deployer } = await hre.getNamedAccounts()
const [proxyAdmin, l1ERC721BridgeProxy, l1ERC721BridgeImpl] =
await getContractsFromArtifacts(hre, [
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'L1ERC721BridgeProxy',
iface: 'L1ERC721Bridge',
signerOrProvider: deployer,
},
{
name: 'L1ERC721Bridge',
},
])
try {
const tx = await proxyAdmin.upgrade(
l1ERC721BridgeProxy.address,
l1ERC721BridgeImpl.address
)
await tx.wait()
} catch (e) {
console.log('L1ERC721Bridge already initialized')
}
const version = await l1ERC721BridgeProxy.callStatic.version()
console.log(`L1ERC721Bridge version: ${version}`)
console.log('Upgraded L1ERC721Bridge')
}
deployFn.tags = ['L1ERC721BridgeInitialize', 'l1']
export default deployFn
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) => {
const { deployer } = await hre.getNamedAccounts()
const [proxyAdmin, mintableERC20FactoryProxy, mintableERC20FactoryImpl] =
await getContractsFromArtifacts(hre, [
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
{
name: 'OptimismMintableERC20FactoryProxy',
iface: 'OptimismMintableERC20Factory',
signerOrProvider: deployer,
},
{
name: 'OptimismMintableERC20Factory',
},
])
try {
const tx = await proxyAdmin.upgrade(
mintableERC20FactoryProxy.address,
mintableERC20FactoryImpl.address
)
await tx.wait()
} catch (e) {
console.log('OptimismMintableERC20Factory already initialized')
}
const version = await mintableERC20FactoryProxy.callStatic.version()
console.log(`OptimismMintableERC20Factory version: ${version}`)
console.log('Upgraded OptimismMintableERC20Factory')
}
deployFn.tags = ['OptimismMintableERC20FactoryInitialize', 'l1']
export default deployFn
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 } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
const [proxyAdmin] = await getContractsFromArtifacts(hre, [
{
name: 'ProxyAdmin',
signerOrProvider: deployer,
},
])
const finalOwner = hre.deployConfig.finalSystemOwner
const proxyAdminOwner = await proxyAdmin.callStatic.owner()
if (proxyAdminOwner !== finalOwner) {
const tx = await proxyAdmin.transferOwnership(finalOwner)
await tx.wait()
await awaitCondition(
async () => {
return (await proxyAdmin.callStatic.owner()) === finalOwner
},
30000,
1000
)
}
}
deployFn.tags = ['ProxyAdmin', 'transferOwnership', 'l1']
export default deployFn
...@@ -37,7 +37,7 @@ export const deploy = async ({ ...@@ -37,7 +37,7 @@ export const deploy = async ({
contract?: string contract?: string
iface?: string iface?: string
postDeployAction?: (contract: Contract) => Promise<void> postDeployAction?: (contract: Contract) => Promise<void>
}) => { }): Promise<Contract> => {
const { deployer } = await hre.getNamedAccounts() const { deployer } = await hre.getNamedAccounts()
// Hardhat deploy will usually do this check for us, but currently doesn't also consider // Hardhat deploy will usually do this check for us, but currently doesn't also consider
......
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