Commit ee66a8e2 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge pull request #4257 from ethereum-optimism/sc/ctb-clean-deploy-2

maint(ctb): remove unnecessary deploy utils
parents 61843b80 0e230f24
import assert from 'assert'
import { ethers } from 'ethers' import { ethers } from 'ethers'
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import { awaitCondition } from '@eth-optimism/core-utils' import { awaitCondition } from '@eth-optimism/core-utils'
...@@ -5,9 +7,8 @@ import '@eth-optimism/hardhat-deploy-config' ...@@ -5,9 +7,8 @@ import '@eth-optimism/hardhat-deploy-config'
import 'hardhat-deploy' import 'hardhat-deploy'
import { import {
assertDictatorConfig,
makeDictatorConfig,
getContractsFromArtifacts, getContractsFromArtifacts,
getDeploymentAddress,
} from '../src/deploy-utils' } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
...@@ -73,7 +74,67 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -73,7 +74,67 @@ const deployFn: DeployFunction = async (hre) => {
]) ])
// Load the dictator configuration. // Load the dictator configuration.
const config = await makeDictatorConfig(hre, controller, finalOwner, false) const config = {
globalConfig: {
proxyAdmin: await getDeploymentAddress(hre, 'ProxyAdmin'),
controller,
finalOwner,
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.systemConfigOwner,
overhead: hre.deployConfig.gasPriceOracleOverhead,
scalar: hre.deployConfig.gasPriceOracleDecimals,
batcherHash: hre.ethers.utils.hexZeroPad(
hre.deployConfig.batchSenderAddress,
32
),
gasLimit: hre.deployConfig.l2GenesisBlockGasLimit,
},
}
// Update the implementation if necessary. // Update the implementation if necessary.
if ( if (
...@@ -103,7 +164,33 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -103,7 +164,33 @@ const deployFn: DeployFunction = async (hre) => {
) )
// Verify that the contract was initialized correctly. // Verify that the contract was initialized correctly.
await assertDictatorConfig(SystemDictator, config) 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. // Update the owner if necessary.
......
...@@ -3,47 +3,12 @@ import assert from 'assert' ...@@ -3,47 +3,12 @@ import assert from 'assert'
import { ethers, Contract } from 'ethers' import { ethers, Contract } from 'ethers'
import { Provider } from '@ethersproject/abstract-provider' import { Provider } from '@ethersproject/abstract-provider'
import { Signer } from '@ethersproject/abstract-signer' import { Signer } from '@ethersproject/abstract-signer'
import { sleep, getChainId } from '@eth-optimism/core-utils' import { sleep } from '@eth-optimism/core-utils'
import { HardhatRuntimeEnvironment } from 'hardhat/types' import { HardhatRuntimeEnvironment } from 'hardhat/types'
import 'hardhat-deploy' import 'hardhat-deploy'
import '@eth-optimism/hardhat-deploy-config' import '@eth-optimism/hardhat-deploy-config'
import '@nomiclabs/hardhat-ethers' import '@nomiclabs/hardhat-ethers'
export interface DictatorConfig {
globalConfig: {
proxyAdmin: string
controller: string
finalOwner: string
addressManager: string
}
proxyAddressConfig: {
l2OutputOracleProxy: string
optimismPortalProxy: string
l1CrossDomainMessengerProxy: string
l1StandardBridgeProxy: string
optimismMintableERC20FactoryProxy: string
l1ERC721BridgeProxy: string
systemConfigProxy: string
}
implementationAddressConfig: {
l2OutputOracleImpl: string
optimismPortalImpl: string
l1CrossDomainMessengerImpl: string
l1StandardBridgeImpl: string
optimismMintableERC20FactoryImpl: string
l1ERC721BridgeImpl: string
portalSenderImpl: string
systemConfigImpl: string
}
systemConfigConfig: {
owner: string
overhead: number
scalar: number
batcherHash: string
gasLimit: number
}
}
export const deployAndVerifyAndThen = async ({ export const deployAndVerifyAndThen = async ({
hre, hre,
name, name,
...@@ -234,10 +199,6 @@ export const getContractsFromArtifacts = async ( ...@@ -234,10 +199,6 @@ export const getContractsFromArtifacts = async (
return contracts return contracts
} }
export const isHardhatNode = async (hre) => {
return (await getChainId(hre.ethers.provider)) === 31337
}
export const assertContractVariable = async ( export const assertContractVariable = async (
contract: ethers.Contract, contract: ethers.Contract,
variable: string, variable: string,
...@@ -276,109 +237,3 @@ export const getDeploymentAddress = async ( ...@@ -276,109 +237,3 @@ export const getDeploymentAddress = async (
const deployment = await hre.deployments.get(name) const deployment = await hre.deployments.get(name)
return deployment.address return deployment.address
} }
export const makeDictatorConfig = async (
hre: any,
controller: string,
finalOwner: string,
fresh: boolean
): Promise<DictatorConfig> => {
return {
globalConfig: {
proxyAdmin: await getDeploymentAddress(hre, 'ProxyAdmin'),
controller,
finalOwner,
addressManager: fresh
? ethers.constants.AddressZero
: await getDeploymentAddress(hre, 'Lib_AddressManager'),
},
proxyAddressConfig: {
l2OutputOracleProxy: await getDeploymentAddress(
hre,
'L2OutputOracleProxy'
),
optimismPortalProxy: await getDeploymentAddress(
hre,
'OptimismPortalProxy'
),
l1CrossDomainMessengerProxy: await getDeploymentAddress(
hre,
fresh
? 'L1CrossDomainMessengerProxy'
: 'Proxy__OVM_L1CrossDomainMessenger'
),
l1StandardBridgeProxy: await getDeploymentAddress(
hre,
fresh ? 'L1StandardBridgeProxy' : '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.systemConfigOwner,
overhead: hre.deployConfig.gasPriceOracleOverhead,
scalar: hre.deployConfig.gasPriceOracleDecimals,
batcherHash: hre.ethers.utils.hexZeroPad(
hre.deployConfig.batchSenderAddress,
32
),
gasLimit: hre.deployConfig.l2GenesisBlockGasLimit,
},
}
}
export const assertDictatorConfig = async (
dictator: Contract,
config: DictatorConfig
) => {
const dictatorConfig = await dictator.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}`
)
}
}
}
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