Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions packages/core-db/src/app/ethereum/ethereum-block-processor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* External Imports */
import { getLogger, logError } from '@eth-optimism/core-utils'
import { Block, Provider } from 'ethers/providers'
import { Block, Provider, TransactionReceipt } from 'ethers/providers'

/* Internal Imports */
import { EthereumListener } from '../../types/ethereum'
Expand Down Expand Up @@ -90,7 +90,7 @@ export class EthereumBlockProcessor {
}

/**
* Fetches and broadcasts the Block for the provided block number.
* Fetches the Block, waits for finalization, and broadcasts the Block for the provided block number.
*
* @param provider The provider with the connection to the blockchain
* @param blockNumber The block number
Expand All @@ -111,12 +111,17 @@ export class EthereumBlockProcessor {
log.debug(
`Waiting for ${this.confirmsUntilFinal} confirms before disseminating block ${blockNumber}`
)
// TODO: What happens on re-org? I think we're stuck waiting on this confirmation that will never come forever.
try {
await provider.waitForTransaction(
const receipt: TransactionReceipt = await provider.waitForTransaction(
(block.transactions[0] as any).hash,
this.confirmsUntilFinal
)
if (receipt.blockHash !== block.hash) {
log.info(
`Re-org processing block number ${blockNumber}. Re-fetching block.`
)
return this.fetchAndDisseminateBlock(provider, blockNumber)
}
} catch (e) {
logError(
log,
Expand Down