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