Commit bba041d5 authored by Maurelian's avatar Maurelian Committed by Kelvin Fichter

refactor(contracts): Move to a single address setter step at end

parent bc8943d0
...@@ -24,18 +24,20 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -24,18 +24,20 @@ const deployFn: DeployFunction = async (hre) => {
contract: 'Lib_ResolvedDelegateProxy', contract: 'Lib_ResolvedDelegateProxy',
iface: 'L1CrossDomainMessenger', iface: 'L1CrossDomainMessenger',
args: [Lib_AddressManager.address, 'OVM_L1CrossDomainMessenger'], args: [Lib_AddressManager.address, 'OVM_L1CrossDomainMessenger'],
postDeployAction: async (contract) => { // This reverts on a fresh deploy, because the implementation is not yet added to the AddressManager.
console.log(`Initializing Proxy__OVM_L1CrossDomainMessenger...`) // I think the best option is to do the initialization atomically from within the AddressSetter.
await contract.initialize(Lib_AddressManager.address) // postDeployAction: async (contract) => {
// console.log(`Initializing Proxy__OVM_L1CrossDomainMessenger...`)
// await contract.initialize(Lib_AddressManager.address)
console.log(`Checking that contract was correctly initialized...`) // console.log(`Checking that contract was correctly initialized...`)
await waitUntilTrue(async () => { // await waitUntilTrue(async () => {
return hexStringEquals( // return hexStringEquals(
await contract.libAddressManager(), // await contract.libAddressManager(),
Lib_AddressManager.address // Lib_AddressManager.address
) // )
}) // })
}, // },
}) })
} }
......
/* Imports: External */ /* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import { ethers } from 'ethers' import { ethers } from 'ethers'
import { hexStringEquals } from '@eth-optimism/core-utils' import { hexStringEquals, sleep } from '@eth-optimism/core-utils'
/* Imports: Internal */ /* Imports: Internal */
import { predeploys } from '../src/predeploys' import { predeploys } from '../src/predeploys'
......
...@@ -17,6 +17,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -17,6 +17,7 @@ const deployFn: DeployFunction = async (hre) => {
// ToDo: Clean up the method of mapping names to addresses esp. // ToDo: Clean up the method of mapping names to addresses esp.
// There's probably a more functional way to generate an object or something. // There's probably a more functional way to generate an object or something.
// ToDo: in the case of an upgrade, only add names of contracts that are new deployed.
const names = [ const names = [
'ChainStorageContainer-CTC-batches', 'ChainStorageContainer-CTC-batches',
'ChainStorageContainer-SCC-batches', 'ChainStorageContainer-SCC-batches',
...@@ -24,6 +25,8 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -24,6 +25,8 @@ const deployFn: DeployFunction = async (hre) => {
'StateCommitmentChain', 'StateCommitmentChain',
'BondManager', 'BondManager',
'OVM_L1CrossDomainMessenger', 'OVM_L1CrossDomainMessenger',
'Proxy__L1CrossDomainMessenger',
'Proxy__L1StandardBridge',
] ]
const addresses = await Promise.all( const addresses = await Promise.all(
...@@ -51,7 +54,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -51,7 +54,7 @@ const deployFn: DeployFunction = async (hre) => {
await deployAndPostDeploy({ await deployAndPostDeploy({
hre, hre,
name: 'AddressSetter1', name: 'AddressSetter',
contract: 'AddressSetter', contract: 'AddressSetter',
args: [ args: [
Lib_AddressManager.address, Lib_AddressManager.address,
...@@ -62,6 +65,6 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -62,6 +65,6 @@ const deployFn: DeployFunction = async (hre) => {
}) })
} }
deployFn.tags = ['fresh', 'upgrade', 'AddressSetter1'] deployFn.tags = ['fresh', 'upgrade', 'AddressSetter']
export default deployFn export default deployFn
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import {
deployAndPostDeploy,
getDeployedContract,
getReusableContract,
} from '../src/hardhat-deploy-ethers'
import { predeploys } from '../src/predeploys'
const deployFn: DeployFunction = async (hre) => {
const Lib_AddressManager = await getReusableContract(
hre,
'Lib_AddressManager'
)
const names = ['Proxy__L1CrossDomainMessenger', 'Proxy__L1StandardBridge']
const addresses = await Promise.all(
names.map(async (n) => {
return (await getDeployedContract(hre, n)).address
})
)
await deployAndPostDeploy({
hre,
name: 'AddressSetter2',
args: [
Lib_AddressManager.address,
(hre as any).deployConfig.ovmAddressManagerOwner,
names,
addresses,
],
})
}
deployFn.tags = ['fresh', 'upgrade', 'AddressSetter2']
export default deployFn
...@@ -3,18 +3,15 @@ import { hexStringEquals } from '@eth-optimism/core-utils' ...@@ -3,18 +3,15 @@ import { hexStringEquals } from '@eth-optimism/core-utils'
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */ /* Imports: Internal */
import { import { getLiveContract, waitUntilTrue } from '../src/hardhat-deploy-ethers'
getDeployedContract,
getReusableContract,
waitUntilTrue,
} from '../src/hardhat-deploy-ethers'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const addressSetter1 = await getDeployedContract(hre, 'AddressSetter1') const addressSetter = await getLiveContract(hre, 'AddressSetter')
const libAddressManager = await getReusableContract(hre, 'Lib_AddressManager') const libAddressManager = await getLiveContract(hre, 'Lib_AddressManager')
const names = await addressSetter1.getNames() const names = await addressSetter.getNames()
const addresses = await addressSetter1.getAddresses() const addresses = await addressSetter.getAddresses()
const finalOwner = await addressSetter1.finalOwner() const finalOwner = await addressSetter.finalOwner()
let currentOwner
console.log( console.log(
'\n', '\n',
...@@ -30,15 +27,13 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -30,15 +27,13 @@ const deployFn: DeployFunction = async (hre) => {
console.log( console.log(
` then transfer ownership of the Address Manager at (${libAddressManager.address})` ` then transfer ownership of the Address Manager at (${libAddressManager.address})`
) )
console.log(` to the Address Setter contract at ${addressSetter1.address}.`) console.log(` to the Address Setter contract at ${addressSetter.address}.`)
await waitUntilTrue( await waitUntilTrue(
async () => { async () => {
console.log('Checking ownership of Lib_AddressManager') currentOwner = await libAddressManager.owner()
return hexStringEquals( console.log('Checking ownership of Lib_AddressManager... ')
await libAddressManager.owner(), return hexStringEquals(currentOwner, addressSetter.address)
addressSetter1.address
)
}, },
{ {
// Try every 30 seconds for 500 minutes. // Try every 30 seconds for 500 minutes.
...@@ -48,18 +43,17 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -48,18 +43,17 @@ const deployFn: DeployFunction = async (hre) => {
) )
// Set the addresses! // Set the addresses!
await addressSetter1.setAddresses() await addressSetter.setAddresses()
const currentOwner = await libAddressManager.owner() currentOwner = await libAddressManager.owner()
console.log('Verifying final ownership of Lib_AddressManager') console.log('Verifying final ownership of Lib_AddressManager')
if (!hexStringEquals(finalOwner, currentOwner)) { if (!hexStringEquals(finalOwner, currentOwner)) {
// todo: pause here get user input deciding whether to continue or exit?
console.log( console.log(
`The current address manager owner ${currentOwner}, \nis not equal to the expected owner: ${finalOwner}` `The current address manager owner ${currentOwner}, \nis not equal to the expected owner: ${finalOwner}`
) )
} }
} }
deployFn.tags = ['fresh', 'upgrade', 'set-addresses1'] deployFn.tags = ['fresh', 'upgrade', 'set-addresses']
export default deployFn export default deployFn
/* Imports: External */
import { hexStringEquals } from '@eth-optimism/core-utils'
import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import {
getDeployedContract,
getReusableContract,
waitUntilTrue,
} from '../src/hardhat-deploy-ethers'
// todo: reduce redundancy between this and 071
const deployFn: DeployFunction = async (hre) => {
const addressSetter2 = await getDeployedContract(hre, 'AddressSetter2')
const libAddressManager = await getReusableContract(hre, 'Lib_AddressManager')
const names = await addressSetter2.getNames()
const addresses = await addressSetter2.getAddresses()
const finalOwner = await addressSetter2.finalOwner()
console.log(
'An Address Setter contract has been deployed, with the following address <=> name pairs:'
)
for (let i = 0; i < names.length; i++) {
console.log(`${addresses[i]} <=> ${names[i]}`)
}
console.log(
'\n',
'Please verify the values above, and the deployment steps up to this point,'
)
console.log(
` then transfer ownership of the Address Manager at (${libAddressManager.address})`
)
console.log(` to the Address Setter contract at ${addressSetter2.address}.`)
await waitUntilTrue(
async () => {
console.log('Checking ownership of Lib_AddressManager')
return hexStringEquals(
await libAddressManager.owner(),
addressSetter2.address
)
},
{
// Try every 30 seconds for 500 minutes.
delay: 30_000,
retries: 1000,
}
)
// Set the addresses!
await addressSetter2.setAddresses()
const currentOwner = await libAddressManager.owner()
console.log('Verifying final ownership of Lib_AddressManager')
if (!hexStringEquals(finalOwner, currentOwner)) {
// todo: pause here get user input deciding whether to continue or exit?
console.log(
`The current address manager owner ${currentOwner}, \nis not equal to the expected owner: ${finalOwner}`
)
}
}
deployFn.tags = ['fresh', 'upgrade', 'set-addresses2']
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