Commit 27aa017f authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

contracts-bedrock: Make initialization serial, add logging (#3416)

* contracts-bedrock: Make initialization serial, add logging

* lint
parent 26a8b239
......@@ -104,10 +104,8 @@ const deployFn: DeployFunction = async (hre) => {
]
await Promise.all(implTxs)
let tx
// Reset the nonce for the next set of transactions
nonce = await l1.getTransactionCount(deployer)
const upgradeTxs: any[] = []
for (const [proxy, upgrader] of Object.entries(upgradeABIs)) {
const upgraderOut = await upgrader(deployConfig)
const implName = proxy.replace('Proxy', '')
......@@ -121,18 +119,17 @@ const deployFn: DeployFunction = async (hre) => {
'Proxy',
proxyDeployment.address
)
upgradeTxs.push(
proxyContract.upgradeToAndCall(
implContract.address,
implContract.interface.encodeFunctionData(
upgraderOut[0] as string,
upgraderOut[1] as any[]
),
{
nonce: ++nonce,
}
console.log(`Upgrading contract impl ${implName}.`)
tx = await proxyContract.upgradeToAndCall(
implContract.address,
implContract.interface.encodeFunctionData(
upgraderOut[0] as string,
upgraderOut[1] as any[]
)
)
console.log(`Awaiting TX hash ${tx.hash}.`)
await tx.wait()
console.log('Done.')
}
const bridge = await get('L1StandardBridge')
......@@ -140,11 +137,11 @@ const deployFn: DeployFunction = async (hre) => {
'Proxy',
bridgeProxy.address
)
upgradeTxs.push(
bridgeProxyContract.upgradeTo(bridge.address, {
nonce: ++nonce,
})
)
console.log(`Upgrading L1StandardBridge at ${bridge.address}.`)
tx = await bridgeProxyContract.upgradeTo(bridge.address)
console.log(`Awaiting TX hash ${tx.hash}.`)
await tx.wait()
console.log('Done')
const factory = await get('OptimismMintableERC20Factory')
const factoryProxy = await get('OptimismMintableERC20FactoryProxy')
......@@ -152,13 +149,11 @@ const deployFn: DeployFunction = async (hre) => {
'Proxy',
factoryProxy.address
)
upgradeTxs.push(
factoryProxyContract.upgradeTo(factory.address, {
nonce: ++nonce,
})
)
const rawTxs = await Promise.all(upgradeTxs)
await Promise.all(rawTxs.map((tx) => tx.wait()))
console.log(`Upgrading OptimismMintableERC20Factory at ${factory.address}.`)
tx = await factoryProxyContract.upgradeTo(factory.address)
console.log(`Awaiting TX hash ${tx.hash}.`)
await tx.wait()
console.log('Done')
await validateOracle(hre, deployConfig, deployL2StartingTimestamp)
await validatePortal(hre)
......
......@@ -16,17 +16,12 @@ const deployFn: DeployFunction = async (hre) => {
'OptimismMintableERC20FactoryProxy',
]
const { deployer } = await hre.getNamedAccounts()
let nonce = await hre.ethers.provider.getTransactionCount(deployer)
// Subtract 1 from the nonce to simplify the loop below
nonce = nonce - 1
// Wait on all the txs in parallel so that the deployment goes faster
const txs = []
for (const proxy of proxies) {
const deployment = await hre.deployments.get(proxy)
const Proxy = await hre.ethers.getContractAt('Proxy', deployment.address)
const tx = await Proxy.changeAdmin(admin.address, { nonce: ++nonce })
const tx = await Proxy.changeAdmin(admin.address)
txs.push(tx)
}
await Promise.all(txs.map((tx) => tx.wait()))
......@@ -38,10 +33,8 @@ const deployFn: DeployFunction = async (hre) => {
)
const postConfig = [
await AddressManager.transferOwnership(admin.address, { nonce: ++nonce }),
await ProxyAdmin.setAddressManager(addressManager.address, {
nonce: ++nonce,
}),
await AddressManager.transferOwnership(admin.address),
await ProxyAdmin.setAddressManager(addressManager.address),
]
await Promise.all(postConfig.map((tx) => tx.wait()))
}
......
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