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