Commit 3cadef55 authored by Karl Floersch's avatar Karl Floersch Committed by GitHub

Wait for deploy transactions (#180)

* Remove buggy batch validation

* Add deploy overrides and wait for txs

* Wait for more afterDeploy txs

* Wait for more receipts

* Make wait for receipt optional

* Fix WAIT_FOR_RECEIPT config parsing

* Fix lint

* Use wait for receipt for deployment
Co-authored-by: default avatarben-chain <ben@pseudonym.party>
parent 7759fe6e
......@@ -10,10 +10,12 @@ const key = env.DEPLOYER_PRIVATE_KEY;
const sequencerKey = env.SEQUENCER_PRIVATE_KEY;
let SEQUENCER_ADDRESS = env.SEQUENCER_ADDRESS;
const web3Url = env.L1_NODE_WEB3_URL || 'http://127.0.0.1:8545';
const DEPLOY_TX_GAS_LIMIT = env.DEPLOY_TX_GAS_LIMIT || 5000000;
const MIN_TRANSACTION_GAS_LIMIT = env.MIN_TRANSACTION_GAS_LIMIT || 50000;
const MAX_TRANSACTION_GAS_LIMIT = env.MAX_TRANSACTION_GAS_LIMIT || 9000000;
const MAX_GAS_PER_QUEUE_PER_EPOCH = env.MAX_GAS_PER_QUEUE_PER_EPOCH || 250000000;
const SECONDS_PER_EPOCH = env.SECONDS_PER_EPOCH || 0;
const WAIT_FOR_RECEIPTS = env.WAIT_FOR_RECEIPTS === 'true';
let WHITELIST_OWNER = env.WHITELIST_OWNER;
const WHITELIST_ALLOW_ARBITRARY_CONTRACT_DEPLOYMENT = env.WHITELIST_ALLOW_ARBITRARY_CONTRACT_DEPLOYMENT || true;
const FORCE_INCLUSION_PERIOD_SECONDS = env.FORCE_INCLUSION_PERIOD_SECONDS || 2592000; // 30 days
......@@ -95,6 +97,10 @@ const RELAYER_PRIVATE_KEY = env.RELAYER_PRIVATE_KEY;
ethConfig: {
initialAmount: 0,
},
deployOverrides: {
gasLimit: DEPLOY_TX_GAS_LIMIT
},
waitForReceipts: WAIT_FOR_RECEIPTS,
});
const { failedDeployments, AddressManager } = result;
......
......@@ -30,6 +30,7 @@
},
"dependencies": {
"@eth-optimism/solc": "^0.6.12-alpha.1",
"@ethersproject/abstract-provider": "^5.0.8",
"@ethersproject/contracts": "^5.0.5",
"@ethersproject/hardware-wallets": "^5.0.8",
"@openzeppelin/contracts": "^3.3.0",
......
/* External Imports */
import { Signer, ContractFactory, Contract } from 'ethers'
import { TransactionResponse } from '@ethersproject/abstract-provider'
import { Overrides } from '@ethersproject/contracts'
/* Internal Imports */
......@@ -37,8 +38,9 @@ export interface RollupDeployConfig {
allowArbitraryContractDeployment: boolean
}
addressManager?: string
deployOverrides?: Overrides
dependencies?: string[]
deployOverrides: Overrides
waitForReceipts: boolean
}
export interface ContractDeployParameters {
......@@ -55,6 +57,16 @@ export const makeContractDeployConfig = async (
config: RollupDeployConfig,
AddressManager: Contract
): Promise<ContractDeployConfig> => {
const _sendTx = async (
txPromise: Promise<TransactionResponse>
): Promise<TransactionResponse> => {
const res = await txPromise
if (config.waitForReceipts) {
await res.wait()
}
return res
}
return {
OVM_L2CrossDomainMessenger: {
factory: getContractFactory('OVM_L2CrossDomainMessenger'),
......@@ -68,7 +80,9 @@ export const makeContractDeployConfig = async (
const relayer = config.l1CrossDomainMessengerConfig.relayerAddress
const address =
typeof relayer === 'string' ? relayer : await relayer.getAddress()
await AddressManager.setAddress('OVM_L2MessageRelayer', address)
await _sendTx(
AddressManager.setAddress('OVM_L2MessageRelayer', address)
)
}
},
},
......@@ -81,10 +95,18 @@ export const makeContractDeployConfig = async (
)
.connect(config.deploymentSigner)
.attach(contracts.Proxy__OVM_L1CrossDomainMessenger.address)
await xDomainMessenger.initialize(AddressManager.address)
await AddressManager.setAddress(
'OVM_L2CrossDomainMessenger',
config.ovmGlobalContext.L2CrossDomainMessengerAddress
await _sendTx(
xDomainMessenger.initialize(
AddressManager.address,
config.deployOverrides
)
)
await _sendTx(
AddressManager.setAddress(
'OVM_L2CrossDomainMessenger',
config.ovmGlobalContext.L2CrossDomainMessengerAddress,
config.deployOverrides
)
)
},
},
......@@ -102,12 +124,16 @@ export const makeContractDeployConfig = async (
typeof sequencer === 'string'
? sequencer
: await sequencer.getAddress()
await AddressManager.setAddress(
'OVM_DecompressionPrecompileAddress',
'0x4200000000000000000000000000000000000005'
await _sendTx(
AddressManager.setAddress(
'OVM_DecompressionPrecompileAddress',
'0x4200000000000000000000000000000000000005'
)
)
await _sendTx(
AddressManager.setAddress('OVM_Sequencer', sequencerAddress)
)
await AddressManager.setAddress('OVM_Sequencer', sequencerAddress)
await AddressManager.setAddress('Sequencer', sequencerAddress)
await _sendTx(AddressManager.setAddress('Sequencer', sequencerAddress))
},
},
OVM_StateCommitmentChain: {
......@@ -146,8 +172,11 @@ export const makeContractDeployConfig = async (
factory: getContractFactory('OVM_StateManager'),
params: [await config.deploymentSigner.getAddress()],
afterDeploy: async (contracts): Promise<void> => {
await contracts.OVM_StateManager.setExecutionManager(
contracts.OVM_ExecutionManager.address
await _sendTx(
contracts.OVM_StateManager.setExecutionManager(
contracts.OVM_ExecutionManager.address,
config.deployOverrides
)
)
},
},
......
......@@ -33,6 +33,9 @@ export const deploy = async (
config.deploymentSigner
).deploy()
}
if (config.waitForReceipts) {
await AddressManager.deployTransaction.wait()
}
const contractDeployConfig = await makeContractDeployConfig(
config,
......@@ -56,9 +59,15 @@ export const deploy = async (
.connect(config.deploymentSigner)
.deploy(
...(contractDeployParameters.params || []),
config.deployOverrides || {}
config.deployOverrides
)
await AddressManager.setAddress(name, contracts[name].address)
if (config.waitForReceipts) {
await contracts[name].deployTransaction.wait()
}
const res = await AddressManager.setAddress(name, contracts[name].address)
if (config.waitForReceipts) {
await res.wait()
}
} catch (err) {
console.error(`Error deploying ${name}: ${err}`)
failedDeployments.push(name)
......
......@@ -156,6 +156,8 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => {
'OVM_ETH',
'mockOVM_ECDSAContractAccount',
],
deployOverrides: {},
waitForReceipts: false,
}
config = { ...config, ...cfg }
......
This diff is collapsed.
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