Commit cb8fbc4c authored by Maurelian's avatar Maurelian Committed by GitHub

Merge pull request #5354 from ethereum-optimism/jm/streamline-migration/doProxyTransfer

parents 653ca9d6 79706a9a
...@@ -11,10 +11,8 @@ import { ...@@ -11,10 +11,8 @@ import {
assertContractVariable, assertContractVariable,
getContractsFromArtifacts, getContractsFromArtifacts,
getDeploymentAddress, getDeploymentAddress,
doOwnershipTransfer,
doPhase, doPhase,
printJsonTransaction,
printTenderlySimulationLink,
printCastCommand,
} from '../src/deploy-utils' } from '../src/deploy-utils'
const uint128Max = ethers.BigNumber.from('0xffffffffffffffffffffffffffffffff') const uint128Max = ethers.BigNumber.from('0xffffffffffffffffffffffffffffffff')
...@@ -73,10 +71,13 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -73,10 +71,13 @@ const deployFn: DeployFunction = async (hre) => {
// 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`) await doOwnershipTransfer({
await ProxyAdmin.transferOwnership(SystemDictator.address) isLiveDeployer,
} else { proxy: ProxyAdmin,
console.log(`Proxy admin already owned by MSD`) name: 'ProxyAdmin',
transferFunc: 'transferOwnership',
dictator: SystemDictator,
})
} }
// We don't need to transfer proxy addresses if we're already beyond the proxy transfer step. // We don't need to transfer proxy addresses if we're already beyond the proxy transfer step.
...@@ -89,30 +90,13 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -89,30 +90,13 @@ const deployFn: DeployFunction = async (hre) => {
needsProxyTransfer && needsProxyTransfer &&
(await AddressManager.owner()) !== SystemDictator.address (await AddressManager.owner()) !== SystemDictator.address
) { ) {
if (isLiveDeployer) { await doOwnershipTransfer({
console.log(`Setting AddressManager owner to MSD`) isLiveDeployer,
await AddressManager.transferOwnership(SystemDictator.address) proxy: AddressManager,
} else { name: 'AddressManager',
const tx = await AddressManager.populateTransaction.transferOwnership( transferFunc: 'transferOwnership',
SystemDictator.address dictator: SystemDictator,
) })
console.log(`Please transfer AddressManager owner to MSD`)
console.log(`AddressManager address: ${AddressManager.address}`)
console.log(`MSD address: ${SystemDictator.address}`)
printJsonTransaction(tx)
printCastCommand(tx)
await printTenderlySimulationLink(SystemDictator.provider, tx)
}
// Wait for the ownership transfer to complete.
await awaitCondition(
async () => {
const owner = await AddressManager.owner()
return owner === SystemDictator.address
},
5000,
1000
)
} else { } else {
console.log(`AddressManager already owned by the SystemDictator`) console.log(`AddressManager already owned by the SystemDictator`)
} }
...@@ -124,34 +108,13 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -124,34 +108,13 @@ const deployFn: DeployFunction = async (hre) => {
from: ethers.constants.AddressZero, from: ethers.constants.AddressZero,
})) !== SystemDictator.address })) !== SystemDictator.address
) { ) {
if (isLiveDeployer) { await doOwnershipTransfer({
console.log(`Setting L1StandardBridge owner to MSD`) isLiveDeployer,
await L1StandardBridgeProxyWithSigner.setOwner(SystemDictator.address) proxy: L1StandardBridgeProxyWithSigner,
} else { name: 'L1StandardBridgeProxy',
const tx = await L1StandardBridgeProxy.populateTransaction.setOwner( transferFunc: 'setOwner',
SystemDictator.address dictator: SystemDictator,
) })
console.log(`Please transfer L1StandardBridge (proxy) owner to MSD`)
console.log(
`L1StandardBridgeProxy address: ${L1StandardBridgeProxy.address}`
)
console.log(`MSD address: ${SystemDictator.address}`)
printJsonTransaction(tx)
printCastCommand(tx)
await printTenderlySimulationLink(SystemDictator.provider, tx)
}
// Wait for the ownership transfer to complete.
await awaitCondition(
async () => {
const owner = await L1StandardBridgeProxy.callStatic.getOwner({
from: ethers.constants.AddressZero,
})
return owner === SystemDictator.address
},
5000,
1000
)
} else { } else {
console.log(`L1StandardBridge already owned by MSD`) console.log(`L1StandardBridge already owned by MSD`)
} }
...@@ -163,36 +126,41 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -163,36 +126,41 @@ const deployFn: DeployFunction = async (hre) => {
from: ethers.constants.AddressZero, from: ethers.constants.AddressZero,
})) !== SystemDictator.address })) !== SystemDictator.address
) { ) {
if (isLiveDeployer) { await doOwnershipTransfer({
console.log(`Setting L1ERC721Bridge owner to MSD`) isLiveDeployer,
await L1ERC721BridgeProxyWithSigner.changeAdmin(SystemDictator.address) proxy: L1ERC721BridgeProxyWithSigner,
} else { name: 'L1ERC721BridgeProxy',
const tx = await L1ERC721BridgeProxy.populateTransaction.changeAdmin( transferFunc: 'changeAdmin',
SystemDictator.address dictator: SystemDictator,
) })
console.log(`Please transfer L1ERC721Bridge (proxy) owner to MSD`)
console.log(`L1ERC721BridgeProxy address: ${L1ERC721BridgeProxy.address}`)
console.log(`MSD address: ${SystemDictator.address}`)
printJsonTransaction(tx)
printCastCommand(tx)
await printTenderlySimulationLink(SystemDictator.provider, tx)
}
// Wait for the ownership transfer to complete.
await awaitCondition(
async () => {
const owner = await L1ERC721BridgeProxy.callStatic.admin({
from: ethers.constants.AddressZero,
})
return owner === SystemDictator.address
},
5000,
1000
)
} else { } else {
console.log(`L1ERC721Bridge already owned by MSD`) 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({ await doPhase({
isLiveDeployer, isLiveDeployer,
SystemDictator, SystemDictator,
......
...@@ -322,6 +322,39 @@ export const printJsonTransaction = (tx: ethers.PopulatedTransaction): void => { ...@@ -322,6 +322,39 @@ export const printJsonTransaction = (tx: ethers.PopulatedTransaction): void => {
) )
} }
/**
* Mini helper for transferring a Proxy to the MSD
*
* @param opts Options for executing the step.
* @param opts.isLiveDeployer True if the deployer is live.
* @param opts.proxy proxy contract.
* @param opts.dictator dictator contract.
*/
export const doOwnershipTransfer = async (opts: {
isLiveDeployer?: boolean
proxy: ethers.Contract
name: string
transferFunc: string
dictator: ethers.Contract
}): Promise<void> => {
if (opts.isLiveDeployer) {
console.log(`Setting ${opts.name} owner to MSD`)
await opts.proxy[opts.transferFunc](opts.dictator.address)
} else {
const tx = await opts.proxy.populateTransaction[opts.transferFunc](
opts.dictator.address
)
console.log(`
Please transfer ${opts.name} (proxy) owner to MSD
- ${opts.name} address: ${opts.proxy.address}
- MSD address: ${opts.dictator.address}
`)
printJsonTransaction(tx)
printCastCommand(tx)
await printTenderlySimulationLink(opts.dictator.provider, tx)
}
}
/** /**
* Mini helper for checking if the current step is a target step. * Mini helper for checking if the current step is a target step.
* *
......
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