Commit a4b294e6 authored by Kelvin Fichter's avatar Kelvin Fichter

feat(ctb): make owner and controller required

Makes the finalSystemOwner and controller configuration values required.
By making these required, we avoid the massive warnings that come with
not setting the values. Much easier than repeating the warnings
everywhere.
parent 25be16bf
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
"sequencerFeeVaultRecipient": "0xfabb0ac9d68b0b445fb7357272ff202c5651694a", "sequencerFeeVaultRecipient": "0xfabb0ac9d68b0b445fb7357272ff202c5651694a",
"proxyAdminOwner": "0xBcd4042DE499D14e55001CcbB24a551F3b954096", "proxyAdminOwner": "0xBcd4042DE499D14e55001CcbB24a551F3b954096",
"finalSystemOwner": "0xBcd4042DE499D14e55001CcbB24a551F3b954096", "finalSystemOwner": "0xBcd4042DE499D14e55001CcbB24a551F3b954096",
"controller": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"finalizationPeriodSeconds": 2, "finalizationPeriodSeconds": 2,
"deploymentWaitConfirmations": 1, "deploymentWaitConfirmations": 1,
"fundDevAccounts": true, "fundDevAccounts": true,
......
{ {
"finalSystemOwner": "0x62790eFcB3a5f3A5D398F95B47930A9Addd83807", "finalSystemOwner": "0x62790eFcB3a5f3A5D398F95B47930A9Addd83807",
"controller": "0x62790eFcB3a5f3A5D398F95B47930A9Addd83807",
"l1StartingBlockTag": "0xcbcbf93fa6ef953a491466311fce85846252a808aa3cc6a8fd432afc5ea4487b", "l1StartingBlockTag": "0xcbcbf93fa6ef953a491466311fce85846252a808aa3cc6a8fd432afc5ea4487b",
"l1ChainID": 5, "l1ChainID": 5,
......
{ {
"finalSystemOwner": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc", "finalSystemOwner": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
"controller": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"l1StartingBlockTag": "earliest", "l1StartingBlockTag": "earliest",
"l1ChainID": 900, "l1ChainID": 900,
......
import { ethers } from 'ethers'
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import '@eth-optimism/hardhat-deploy-config' import '@eth-optimism/hardhat-deploy-config'
import { assertContractVariable, deploy } from '../src/deploy-utils' import { assertContractVariable, deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
let finalOwner = hre.deployConfig.finalSystemOwner
if (finalOwner === ethers.constants.AddressZero) {
if (hre.network.config.live === false) {
console.log(`WARNING!!!`)
console.log(`WARNING!!!`)
console.log(`WARNING!!!`)
console.log(`WARNING!!! A proxy admin owner address was not provided.`)
console.log(
`WARNING!!! Make sure you are ONLY doing this on a test network.`
)
finalOwner = deployer
} else {
throw new Error(`must specify the finalSystemOwner on live networks`)
}
}
const batcherHash = hre.ethers.utils.hexZeroPad( const batcherHash = hre.ethers.utils.hexZeroPad(
hre.deployConfig.batchSenderAddress, hre.deployConfig.batchSenderAddress,
32 32
...@@ -32,14 +13,18 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -32,14 +13,18 @@ const deployFn: DeployFunction = async (hre) => {
hre, hre,
name: 'SystemConfig', name: 'SystemConfig',
args: [ args: [
finalOwner, hre.deployConfig.finalSystemOwner,
hre.deployConfig.gasPriceOracleOverhead, hre.deployConfig.gasPriceOracleOverhead,
hre.deployConfig.gasPriceOracleScalar, hre.deployConfig.gasPriceOracleScalar,
batcherHash, batcherHash,
hre.deployConfig.l2GenesisBlockGasLimit, hre.deployConfig.l2GenesisBlockGasLimit,
], ],
postDeployAction: async (contract) => { postDeployAction: async (contract) => {
await assertContractVariable(contract, 'owner', finalOwner) await assertContractVariable(
contract,
'owner',
hre.deployConfig.finalSystemOwner
)
await assertContractVariable( await assertContractVariable(
contract, contract,
'overhead', 'overhead',
......
...@@ -14,40 +14,6 @@ import { ...@@ -14,40 +14,6 @@ import {
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts() const { deployer } = await hre.getNamedAccounts()
let controller = hre.deployConfig.controller
if (controller === ethers.constants.AddressZero) {
if (hre.network.config.live === false) {
console.log(`WARNING!!!`)
console.log(`WARNING!!!`)
console.log(`WARNING!!!`)
console.log(`WARNING!!! A controller address was not provided.`)
console.log(
`WARNING!!! Make sure you are ONLY doing this on a test network.`
)
controller = deployer
} else {
throw new Error(
`controller address MUST NOT be the deployer on live networks`
)
}
}
let finalOwner = hre.deployConfig.finalSystemOwner
if (finalOwner === ethers.constants.AddressZero) {
if (hre.network.config.live === false) {
console.log(`WARNING!!!`)
console.log(`WARNING!!!`)
console.log(`WARNING!!!`)
console.log(`WARNING!!! A proxy admin owner address was not provided.`)
console.log(
`WARNING!!! Make sure you are ONLY doing this on a test network.`
)
finalOwner = deployer
} else {
throw new Error(`must specify the finalSystemOwner on live networks`)
}
}
// Load the contracts we need to interact with. // Load the contracts we need to interact with.
const [ const [
SystemDictator, SystemDictator,
...@@ -77,8 +43,8 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -77,8 +43,8 @@ const deployFn: DeployFunction = async (hre) => {
const config = { const config = {
globalConfig: { globalConfig: {
proxyAdmin: await getDeploymentAddress(hre, 'ProxyAdmin'), proxyAdmin: await getDeploymentAddress(hre, 'ProxyAdmin'),
controller, controller: hre.deployConfig.controller,
finalOwner, finalOwner: hre.deployConfig.finalSystemOwner,
addressManager: await getDeploymentAddress(hre, 'Lib_AddressManager'), addressManager: await getDeploymentAddress(hre, 'Lib_AddressManager'),
}, },
proxyAddressConfig: { proxyAddressConfig: {
...@@ -125,7 +91,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -125,7 +91,7 @@ const deployFn: DeployFunction = async (hre) => {
systemConfigImpl: await getDeploymentAddress(hre, 'SystemConfig'), systemConfigImpl: await getDeploymentAddress(hre, 'SystemConfig'),
}, },
systemConfigConfig: { systemConfigConfig: {
owner: finalOwner, owner: hre.deployConfig.finalSystemOwner,
overhead: hre.deployConfig.gasPriceOracleOverhead, overhead: hre.deployConfig.gasPriceOracleOverhead,
scalar: hre.deployConfig.gasPriceOracleDecimals, scalar: hre.deployConfig.gasPriceOracleDecimals,
batcherHash: hre.ethers.utils.hexZeroPad( batcherHash: hre.ethers.utils.hexZeroPad(
...@@ -197,12 +163,14 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -197,12 +163,14 @@ const deployFn: DeployFunction = async (hre) => {
if ( if (
(await SystemDictatorProxy.callStatic.admin({ (await SystemDictatorProxy.callStatic.admin({
from: ethers.constants.AddressZero, from: ethers.constants.AddressZero,
})) !== controller })) !== hre.deployConfig.controller
) { ) {
console.log('Transferring ownership of the SystemDictator proxy...') console.log('Transferring ownership of the SystemDictator proxy...')
// Transfer ownership to the controller address. // Transfer ownership to the controller address.
await SystemDictatorProxyWithSigner.transferOwnership(controller) await SystemDictatorProxyWithSigner.transferOwnership(
hre.deployConfig.controller
)
// Wait for the transaction to execute properly. // Wait for the transaction to execute properly.
await awaitCondition( await awaitCondition(
...@@ -210,7 +178,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -210,7 +178,7 @@ const deployFn: DeployFunction = async (hre) => {
return ( return (
(await SystemDictatorProxy.callStatic.admin({ (await SystemDictatorProxy.callStatic.admin({
from: ethers.constants.AddressZero, from: ethers.constants.AddressZero,
})) === controller })) === hre.deployConfig.controller
) )
}, },
30000, 30000,
......
...@@ -16,43 +16,6 @@ import { ...@@ -16,43 +16,6 @@ import {
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts() const { deployer } = await hre.getNamedAccounts()
let isLiveDeployer = false
let controller = hre.deployConfig.controller
if (controller === ethers.constants.AddressZero) {
if (hre.network.config.live === false) {
console.log(`WARNING!!!`)
console.log(`WARNING!!!`)
console.log(`WARNING!!!`)
console.log(`WARNING!!! A controller address was not provided.`)
console.log(
`WARNING!!! Make sure you are ONLY doing this on a test network.`
)
console.log('using a live deployer')
isLiveDeployer = true
controller = deployer
} else {
throw new Error(
`controller address MUST NOT be the deployer on live networks`
)
}
}
let finalOwner = hre.deployConfig.finalSystemOwner
if (finalOwner === ethers.constants.AddressZero) {
if (hre.network.config.live === false) {
console.log(`WARNING!!!`)
console.log(`WARNING!!!`)
console.log(`WARNING!!!`)
console.log(`WARNING!!! A proxy admin owner address was not provided.`)
console.log(
`WARNING!!! Make sure you are ONLY doing this on a test network.`
)
finalOwner = deployer
} else {
throw new Error(`must specify the finalSystemOwner on live networks`)
}
}
// Set up required contract references. // Set up required contract references.
const [ const [
SystemDictator, SystemDictator,
...@@ -128,6 +91,10 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -128,6 +91,10 @@ const deployFn: DeployFunction = async (hre) => {
}, },
]) ])
// If we have the key for the controller then we don't need to wait for external txns.
const isLiveDeployer =
deployer.toLowerCase() === hre.deployConfig.controller.toLowerCase()
// Transfer ownership of the ProxyAdmin to the SystemDictator. // Transfer ownership of the ProxyAdmin to the SystemDictator.
if ((await ProxyAdmin.owner()) !== SystemDictator.address) { if ((await ProxyAdmin.owner()) !== SystemDictator.address) {
console.log(`Setting ProxyAdmin owner to MSD`) console.log(`Setting ProxyAdmin owner to MSD`)
...@@ -570,8 +537,16 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -570,8 +537,16 @@ const deployFn: DeployFunction = async (hre) => {
1000 1000
) )
await assertContractVariable(L1CrossDomainMessenger, 'owner', finalOwner) await assertContractVariable(
await assertContractVariable(ProxyAdmin, 'owner', finalOwner) L1CrossDomainMessenger,
'owner',
hre.deployConfig.finalSystemOwner
)
await assertContractVariable(
ProxyAdmin,
'owner',
hre.deployConfig.finalSystemOwner
)
} }
} }
......
...@@ -165,11 +165,9 @@ export const deployConfigSpec: { ...@@ -165,11 +165,9 @@ export const deployConfigSpec: {
}, },
finalSystemOwner: { finalSystemOwner: {
type: 'address', type: 'address',
default: ethers.constants.AddressZero,
}, },
controller: { controller: {
type: 'address', type: 'address',
default: ethers.constants.AddressZero,
}, },
l1StartingBlockTag: { l1StartingBlockTag: {
type: 'string', type: 'string',
......
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