Commit bbd6243e authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #2991 from ethereum-optimism/debug/devnet-ci

contracts-bedrock: better logging in deposit task
parents f48b2abc 1341ddb9
......@@ -66,6 +66,10 @@ task('deposit', 'Deposits funds onto L2.')
const amountWei = utils.parseEther(amountEth)
const value = amountWei.add(utils.parseEther('0.01'))
console.log(`Depositing ${amountEth} ETH to ${to}`)
const preL2Balance = await l2Provider.getBalance(to)
console.log(`${to} has ${utils.formatEther(preL2Balance)} ETH on L2`)
// Below adds 0.01 ETH to account for gas.
const tx = await OptimismPortal.depositTransaction(
to,
......@@ -77,26 +81,39 @@ task('deposit', 'Deposits funds onto L2.')
)
console.log(`Got TX hash ${tx.hash}. Waiting...`)
const receipt = await tx.wait()
console.log(
`Included in block ${receipt.blockHash} with index ${receipt.logIndex}`
)
console.log(`Included in block ${receipt.blockHash}`)
// find the transaction deposited event and derive
// the deposit transaction from it
const event = receipt.events.find(
(e: Event) => e.event === 'TransactionDeposited'
)
const l2tx = DepositTx.fromL1Event(event)
console.log(`Deposit has log index ${event.logIndex}`)
const l2tx = DepositTx.fromL1Event(event)
const hash = l2tx.hash()
console.log(`Waiting for L2 TX hash ${hash}`)
let i = 0
while (true) {
const expected = await l2Provider.send('eth_getTransactionByHash', [hash])
if (expected) {
console.log('Deposit success')
console.log(JSON.stringify(expected, null, 2))
break
}
const postL2Balance = await l2Provider.getBalance(to)
if (postL2Balance.gt(preL2Balance)) {
console.log(
`Unexpected balance increase without detecting deposit transaction`
)
}
if (i % 100 === 0) {
const block = await l2Provider.getBlock('latest')
console.log(`latest block ${block.number}:${block.hash}`)
}
await sleep(500)
i++
}
})
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