Commit 193befed authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

contracts-bedrock: parallel deployment fix (#3284)

* contracts-bedrock: parallel deployment fix

Uses local nonce management for sending configuration
transactions. This will make the parallel deployments
more reliable.

* contracts-bedrock: harden for live network deployments
parent bcb317e4
---
'@eth-optimism/contracts-bedrock': patch
---
Fix nonce issue for parallel deployments
......@@ -109,6 +109,9 @@ const deployFn: DeployFunction = async (hre) => {
]
await Promise.all(implTxs)
// Reset the nonce for the next set of transactions
nonce = await l1.getTransactionCount(deployer)
const upgradeTxs = []
for (const [proxy, upgrader] of Object.entries(upgradeABIs)) {
const upgraderOut = await upgrader(deployConfig, hre)
......
......@@ -16,12 +16,17 @@ 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)
const tx = await Proxy.changeAdmin(admin.address, { nonce: ++nonce })
txs.push(tx)
}
await Promise.all(txs.map((tx) => tx.wait()))
......@@ -33,8 +38,10 @@ const deployFn: DeployFunction = async (hre) => {
)
const postConfig = [
await AddressManager.transferOwnership(admin.address),
await ProxyAdmin.setAddressManager(addressManager.address),
await AddressManager.transferOwnership(admin.address, { nonce: ++nonce }),
await ProxyAdmin.setAddressManager(addressManager.address, {
nonce: ++nonce,
}),
]
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