Commit f155cc42 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: clean up check l2 task

parent 7ac556ad
...@@ -5,6 +5,8 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types' ...@@ -5,6 +5,8 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { predeploys } from '../src' import { predeploys } from '../src'
import assert from 'assert'
// expectedSemver is the semver version of the contracts // expectedSemver is the semver version of the contracts
// deployed at bedrock deployment // deployed at bedrock deployment
const expectedSemver = '0.0.1' const expectedSemver = '0.0.1'
...@@ -18,6 +20,12 @@ const logLoud = () => { ...@@ -18,6 +20,12 @@ const logLoud = () => {
console.log(' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') console.log(' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
} }
const yell = (msg: string) => {
logLoud()
console.log(msg)
logLoud()
}
// checkPredeploys will ensure that all of the predeploys are set // checkPredeploys will ensure that all of the predeploys are set
const checkPredeploys = async (hre: HardhatRuntimeEnvironment) => { const checkPredeploys = async (hre: HardhatRuntimeEnvironment) => {
console.log('Checking predeploys are configured correctly') console.log('Checking predeploys are configured correctly')
...@@ -128,9 +136,7 @@ const check = { ...@@ -128,9 +136,7 @@ const check = {
assertSemver(version, 'DeployerWhitelist') assertSemver(version, 'DeployerWhitelist')
const owner = await DeployerWhitelist.owner() const owner = await DeployerWhitelist.owner()
if (owner !== hre.ethers.constants.AddressZero) { assert(owner === hre.ethers.constants.AddressZero)
throw new Error('owner misconfigured')
}
console.log(` - owner: ${owner}`) console.log(` - owner: ${owner}`)
await checkProxy(hre, 'DeployerWhitelist') await checkProxy(hre, 'DeployerWhitelist')
...@@ -158,32 +164,24 @@ const check = { ...@@ -158,32 +164,24 @@ const check = {
) )
const xDomainMessageSender = '0x' + xDomainMessageSenderSlot.slice(26) const xDomainMessageSender = '0x' + xDomainMessageSenderSlot.slice(26)
if (xDomainMessageSender !== '0x000000000000000000000000000000000000dead') { assert(
throw new Error('xDomainMessageSender not set') xDomainMessageSender === '0x000000000000000000000000000000000000dead'
} )
const otherMessenger = await L2CrossDomainMessenger.OTHER_MESSENGER() const otherMessenger = await L2CrossDomainMessenger.OTHER_MESSENGER()
if (otherMessenger === hre.ethers.constants.AddressZero) { assert(otherMessenger !== hre.ethers.constants.AddressZero)
throw new Error('otherMessenger misconfigured') yell(` - OTHER_MESSENGER: ${otherMessenger}`)
}
logLoud()
console.log(` - OTHER_MESSENGER: ${otherMessenger}`)
logLoud()
const l1CrossDomainMessenger = const l1CrossDomainMessenger =
await L2CrossDomainMessenger.l1CrossDomainMessenger() await L2CrossDomainMessenger.l1CrossDomainMessenger()
console.log(` - l1CrossDomainMessenger: ${l1CrossDomainMessenger}`) yell(` - l1CrossDomainMessenger: ${l1CrossDomainMessenger}`)
await checkProxy(hre, 'L2CrossDomainMessenger') await checkProxy(hre, 'L2CrossDomainMessenger')
await assertProxy(hre, 'L2CrossDomainMessenger') await assertProxy(hre, 'L2CrossDomainMessenger')
const owner = await L2CrossDomainMessenger.owner() const owner = await L2CrossDomainMessenger.owner()
if (owner === hre.ethers.constants.AddressZero) { assert(owner !== hre.ethers.constants.AddressZero)
throw new Error('owner misconfigured') yell(` - owner: ${owner}`)
}
logLoud()
console.log(` - owner: ${owner}`)
logLoud()
const MESSAGE_VERSION = await L2CrossDomainMessenger.MESSAGE_VERSION() const MESSAGE_VERSION = await L2CrossDomainMessenger.MESSAGE_VERSION()
console.log(` - MESSAGE_VERSION: ${MESSAGE_VERSION}`) console.log(` - MESSAGE_VERSION: ${MESSAGE_VERSION}`)
...@@ -213,9 +211,7 @@ const check = { ...@@ -213,9 +211,7 @@ const check = {
console.log(` - legacy spacer: ${spacer}`) console.log(` - legacy spacer: ${spacer}`)
const initialized = '0x' + slot.slice(24, 26) const initialized = '0x' + slot.slice(24, 26)
if (initialized !== '0x01') { assert(initialized === '0x01')
throw new Error('not initialized')
}
console.log(` - initialized: ${initialized}`) console.log(` - initialized: ${initialized}`)
}, },
// GasPriceOracle // GasPriceOracle
...@@ -231,9 +227,7 @@ const check = { ...@@ -231,9 +227,7 @@ const check = {
assertSemver(version, 'GasPriceOracle') assertSemver(version, 'GasPriceOracle')
const decimals = await GasPriceOracle.decimals() const decimals = await GasPriceOracle.decimals()
if (!decimals.eq(6)) { assert(decimals.eq(6))
throw new Error('decimals misconfigured')
}
console.log(` - decimals: ${decimals.toNumber()}`) console.log(` - decimals: ${decimals.toNumber()}`)
await checkProxy(hre, 'GasPriceOracle') await checkProxy(hre, 'GasPriceOracle')
...@@ -251,17 +245,11 @@ const check = { ...@@ -251,17 +245,11 @@ const check = {
assertSemver(version, 'L2StandardBridge', '0.0.2') assertSemver(version, 'L2StandardBridge', '0.0.2')
const OTHER_BRIDGE = await L2StandardBridge.OTHER_BRIDGE() const OTHER_BRIDGE = await L2StandardBridge.OTHER_BRIDGE()
if (OTHER_BRIDGE === hre.ethers.constants.AddressZero) { assert(OTHER_BRIDGE !== hre.ethers.constants.AddressZero)
throw new Error('invalid OTHER_BRIDGE') yell(` - OTHER_BRIDGE: ${OTHER_BRIDGE}`)
}
logLoud()
console.log(` - OTHER_BRIDGE: ${OTHER_BRIDGE}`)
logLoud()
const MESSENGER = await L2StandardBridge.MESSENGER() const MESSENGER = await L2StandardBridge.MESSENGER()
if (MESSENGER !== predeploys.L2CrossDomainMessenger) { assert(MESSENGER === predeploys.L2CrossDomainMessenger)
throw new Error('misconfigured MESSENGER')
}
await checkProxy(hre, 'L2StandardBridge') await checkProxy(hre, 'L2StandardBridge')
await assertProxy(hre, 'L2StandardBridge') await assertProxy(hre, 'L2StandardBridge')
...@@ -280,17 +268,11 @@ const check = { ...@@ -280,17 +268,11 @@ const check = {
assertSemver(version, 'SequencerFeeVault') assertSemver(version, 'SequencerFeeVault')
const RECIPIENT = await SequencerFeeVault.RECIPIENT() const RECIPIENT = await SequencerFeeVault.RECIPIENT()
if (RECIPIENT === hre.ethers.constants.AddressZero) { assert(RECIPIENT !== hre.ethers.constants.AddressZero)
throw new Error('undefined RECIPIENT') yell(` - RECIPIENT: ${RECIPIENT}`)
}
logLoud()
console.log(` - RECIPIENT: ${RECIPIENT}`)
logLoud()
const l1FeeWallet = await SequencerFeeVault.l1FeeWallet() const l1FeeWallet = await SequencerFeeVault.l1FeeWallet()
if (l1FeeWallet === hre.ethers.constants.AddressZero) { assert(l1FeeWallet !== hre.ethers.constants.AddressZero)
throw new Error('undefined l1FeeWallet')
}
console.log(` - l1FeeWallet: ${l1FeeWallet}`) console.log(` - l1FeeWallet: ${l1FeeWallet}`)
const MIN_WITHDRAWAL_AMOUNT = const MIN_WITHDRAWAL_AMOUNT =
...@@ -312,9 +294,7 @@ const check = { ...@@ -312,9 +294,7 @@ const check = {
assertSemver(version, 'OptimismMintableERC20Factory', '1.0.0') assertSemver(version, 'OptimismMintableERC20Factory', '1.0.0')
const BRIDGE = await OptimismMintableERC20Factory.BRIDGE() const BRIDGE = await OptimismMintableERC20Factory.BRIDGE()
if (BRIDGE === hre.ethers.constants.AddressZero) { assert(BRIDGE !== hre.ethers.constants.AddressZero)
throw new Error('BRIDGE misconfigured')
}
await checkProxy(hre, 'OptimismMintableERC20Factory') await checkProxy(hre, 'OptimismMintableERC20Factory')
await assertProxy(hre, 'OptimismMintableERC20Factory') await assertProxy(hre, 'OptimismMintableERC20Factory')
...@@ -362,37 +342,26 @@ const check = { ...@@ -362,37 +342,26 @@ const check = {
) )
const name = await LegacyERC20ETH.name() const name = await LegacyERC20ETH.name()
if (name !== 'Ether') { assert(name === 'Ether')
throw new Error('name mismatch')
}
console.log(` - name: ${name}`) console.log(` - name: ${name}`)
const symbol = await LegacyERC20ETH.symbol() const symbol = await LegacyERC20ETH.symbol()
if (symbol !== 'ETH') { assert(symbol === 'ETH')
throw new Error('symbol mismatch')
}
console.log(` - symbol: ${symbol}`) console.log(` - symbol: ${symbol}`)
const decimals = await LegacyERC20ETH.decimals() const decimals = await LegacyERC20ETH.decimals()
if (decimals !== 18) { assert(decimals === 18)
throw new Error('decimals mismatch')
}
console.log(` - decimals: ${decimals}`) console.log(` - decimals: ${decimals}`)
const BRIDGE = await LegacyERC20ETH.BRIDGE() const BRIDGE = await LegacyERC20ETH.BRIDGE()
if (BRIDGE !== predeploys.L2StandardBridge) { assert(BRIDGE === predeploys.L2StandardBridge)
throw new Error('BRIDGE misconfigured')
}
const REMOTE_TOKEN = await LegacyERC20ETH.REMOTE_TOKEN() const REMOTE_TOKEN = await LegacyERC20ETH.REMOTE_TOKEN()
if (REMOTE_TOKEN !== hre.ethers.constants.AddressZero) { assert(REMOTE_TOKEN === hre.ethers.constants.AddressZero)
throw new Error('REMOTE_TOKEN misconfigured')
}
const totalSupply = await LegacyERC20ETH.totalSupply() const totalSupply = await LegacyERC20ETH.totalSupply()
if (!totalSupply.eq(0)) { assert(totalSupply.eq(0))
throw new Error('totalSupply not 0') console.log(` - totalSupply: ${totalSupply}`)
}
await checkProxy(hre, 'LegacyERC20ETH') await checkProxy(hre, 'LegacyERC20ETH')
// No proxy at this address, don't call assertProxy // No proxy at this address, don't call assertProxy
...@@ -406,21 +375,15 @@ const check = { ...@@ -406,21 +375,15 @@ const check = {
const WETH9 = await hre.ethers.getContractAt('WETH9', predeploys.WETH9) const WETH9 = await hre.ethers.getContractAt('WETH9', predeploys.WETH9)
const name = await WETH9.name() const name = await WETH9.name()
if (name !== 'Wrapped Ether') { assert(name === 'Wrapped Ether')
throw new Error('name misconfigured')
}
console.log(` - name: ${name}`) console.log(` - name: ${name}`)
const symbol = await WETH9.symbol() const symbol = await WETH9.symbol()
if (symbol !== 'WETH') { assert(symbol === 'WETH')
throw new Error('symbol misconfigured')
}
console.log(` - symbol: ${symbol}`) console.log(` - symbol: ${symbol}`)
const decimals = await WETH9.decimals() const decimals = await WETH9.decimals()
if (decimals !== 18) { assert(decimals === 18)
throw new Error('decimals misconfigured')
}
console.log(` - decimals: ${decimals}`) console.log(` - decimals: ${decimals}`)
await checkProxy(hre, 'WETH9') await checkProxy(hre, 'WETH9')
...@@ -438,21 +401,15 @@ const check = { ...@@ -438,21 +401,15 @@ const check = {
) )
const name = await GovernanceToken.name() const name = await GovernanceToken.name()
if (name !== 'Optimism') { assert(name === 'Optimism')
throw new Error('name misconfigured')
}
console.log(` - name: ${name}`) console.log(` - name: ${name}`)
const symbol = await GovernanceToken.symbol() const symbol = await GovernanceToken.symbol()
if (symbol !== 'OP') { assert(symbol === 'OP')
throw new Error('symbol misconfigured')
}
console.log(` - symbol: ${symbol}`) console.log(` - symbol: ${symbol}`)
const owner = await GovernanceToken.owner() const owner = await GovernanceToken.owner()
logLoud() yell(` - owner: ${owner}`)
console.log(` - owner: ${owner}`)
logLoud()
const totalSupply = await GovernanceToken.totalSupply() const totalSupply = await GovernanceToken.totalSupply()
console.log(` - totalSupply: ${totalSupply}`) console.log(` - totalSupply: ${totalSupply}`)
...@@ -472,18 +429,12 @@ const check = { ...@@ -472,18 +429,12 @@ const check = {
assertSemver(version, 'L2ERC721Bridge') assertSemver(version, 'L2ERC721Bridge')
const MESSENGER = await L2ERC721Bridge.MESSENGER() const MESSENGER = await L2ERC721Bridge.MESSENGER()
if (MESSENGER === hre.ethers.constants.AddressZero) { assert(MESSENGER !== hre.ethers.constants.AddressZero)
throw new Error('MESSENGER misconfigured')
}
console.log(` - MESSENGER: ${MESSENGER}`) console.log(` - MESSENGER: ${MESSENGER}`)
const OTHER_BRIDGE = await L2ERC721Bridge.OTHER_BRIDGE() const OTHER_BRIDGE = await L2ERC721Bridge.OTHER_BRIDGE()
if (OTHER_BRIDGE === hre.ethers.constants.AddressZero) { assert(OTHER_BRIDGE !== hre.ethers.constants.AddressZero)
throw new Error('OTHER_BRIDGE misconfigured') yell(` - OTHER_BRIDGE: ${OTHER_BRIDGE}`)
}
logLoud()
console.log(` - OTHER_BRIDGE: ${OTHER_BRIDGE}`)
logLoud()
await checkProxy(hre, 'L2ERC721Bridge') await checkProxy(hre, 'L2ERC721Bridge')
await assertProxy(hre, 'L2ERC721Bridge') await assertProxy(hre, 'L2ERC721Bridge')
...@@ -500,10 +451,12 @@ const check = { ...@@ -500,10 +451,12 @@ const check = {
assertSemver(version, 'OptimismMintableERC721Factory', '1.0.0') assertSemver(version, 'OptimismMintableERC721Factory', '1.0.0')
const BRIDGE = await OptimismMintableERC721Factory.BRIDGE() const BRIDGE = await OptimismMintableERC721Factory.BRIDGE()
assert(BRIDGE !== hre.ethers.constants.AddressZero)
console.log(` - BRIDGE: ${BRIDGE}`) console.log(` - BRIDGE: ${BRIDGE}`)
const REMOTE_CHAIN_ID = const REMOTE_CHAIN_ID =
await OptimismMintableERC721Factory.REMOTE_CHAIN_ID() await OptimismMintableERC721Factory.REMOTE_CHAIN_ID()
assert(REMOTE_CHAIN_ID !== 0)
console.log(` - REMOTE_CHAIN_ID: ${REMOTE_CHAIN_ID}`) console.log(` - REMOTE_CHAIN_ID: ${REMOTE_CHAIN_ID}`)
await checkProxy(hre, 'OptimismMintableERC721Factory') await checkProxy(hre, 'OptimismMintableERC721Factory')
...@@ -518,12 +471,8 @@ const check = { ...@@ -518,12 +471,8 @@ const check = {
) )
const owner = await ProxyAdmin.owner() const owner = await ProxyAdmin.owner()
if (owner === hre.ethers.constants.AddressZero) { assert(owner !== hre.ethers.constants.AddressZero)
throw new Error('misconfigured owner') yell(` - owner: ${owner}`)
}
logLoud()
console.log(` - owner: ${owner}`)
logLoud()
const addressManager = await ProxyAdmin.addressManager() const addressManager = await ProxyAdmin.addressManager()
console.log(` - addressManager: ${addressManager}`) console.log(` - addressManager: ${addressManager}`)
...@@ -545,12 +494,8 @@ const check = { ...@@ -545,12 +494,8 @@ const check = {
console.log(` - MIN_WITHDRAWAL_AMOUNT: ${MIN_WITHDRAWAL_AMOUNT}`) console.log(` - MIN_WITHDRAWAL_AMOUNT: ${MIN_WITHDRAWAL_AMOUNT}`)
const RECIPIENT = await BaseFeeVault.RECIPIENT() const RECIPIENT = await BaseFeeVault.RECIPIENT()
if (RECIPIENT === hre.ethers.constants.AddressZero) { assert(RECIPIENT !== hre.ethers.constants.AddressZero)
throw new Error(`RECIPIENT misconfigured`) yell(` - RECIPIENT: ${RECIPIENT}`)
}
logLoud()
console.log(` - RECIPIENT: ${RECIPIENT}`)
logLoud()
assertSemver(version, 'BaseFeeVault') assertSemver(version, 'BaseFeeVault')
await checkProxy(hre, 'BaseFeeVault') await checkProxy(hre, 'BaseFeeVault')
...@@ -573,12 +518,8 @@ const check = { ...@@ -573,12 +518,8 @@ const check = {
console.log(` - MIN_WITHDRAWAL_AMOUNT: ${MIN_WITHDRAWAL_AMOUNT}`) console.log(` - MIN_WITHDRAWAL_AMOUNT: ${MIN_WITHDRAWAL_AMOUNT}`)
const RECIPIENT = await L1FeeVault.RECIPIENT() const RECIPIENT = await L1FeeVault.RECIPIENT()
if (RECIPIENT === hre.ethers.constants.AddressZero) { assert(RECIPIENT !== hre.ethers.constants.AddressZero)
throw new Error(`RECIPIENT misconfigured`) yell(` - RECIPIENT: ${RECIPIENT}`)
}
logLoud()
console.log(` - RECIPIENT: ${RECIPIENT}`)
logLoud()
assertSemver(version, 'L1FeeVault') assertSemver(version, 'L1FeeVault')
await checkProxy(hre, 'L1FeeVault') await checkProxy(hre, 'L1FeeVault')
...@@ -610,9 +551,7 @@ task( ...@@ -610,9 +551,7 @@ task(
'check-l2', 'check-l2',
'Checks a freshly migrated L2 system for correct migration' 'Checks a freshly migrated L2 system for correct migration'
).setAction(async (_, hre: HardhatRuntimeEnvironment) => { ).setAction(async (_, hre: HardhatRuntimeEnvironment) => {
logLoud() yell('Manually check values wrapped in !!!!')
console.log('Manually check values wrapped in !!!!')
logLoud()
console.log() console.log()
// Ensure that all the predeploys exist, including the not // Ensure that all the predeploys exist, including the not
......
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