Skip to content

Commit

Permalink
block ingestor: Improve error reporting for missing recepits
Browse files Browse the repository at this point in the history
  • Loading branch information
leoyvens committed Aug 27, 2021
1 parent 6775ad9 commit 73075df
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
22 changes: 8 additions & 14 deletions chain/ethereum/src/ethereum_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,27 +1103,21 @@ impl EthereumAdapterTrait for EthereumAdapter {
// trying to ingest this block.
//
// This could also be because the receipt is simply not
// available yet. For that case, we should retry until
// available yet. For that case, we should retry until
// it becomes available.
IngestorError::BlockUnavailable(block_hash)
IngestorError::ReceiptUnavailable(block_hash, tx_hash)
})
})
.and_then(move |receipt| {
// Parity nodes seem to return receipts with no block hash
// when a transaction is no longer in the main chain, so
// treat that case the same as a receipt being absent
// entirely.
let receipt_block_hash =
receipt.block_hash.ok_or_else(|| {
IngestorError::BlockUnavailable(block_hash)
})?;

// Check if receipt is for the right block
if receipt_block_hash != block_hash {
// Check if the receipt has a block hash and is for the right
// block. Parity nodes seem to return receipts with no block
// hash when a transaction is no longer in the main chain, so
// treat that case the same as a receipt being absent entirely.
if receipt.block_hash != Some(block_hash) {
info!(
logger, "receipt block mismatch";
"receipt_block_hash" =>
receipt_block_hash.to_string(),
receipt.block_hash.unwrap_or_default().to_string(),
"block_hash" =>
block_hash.to_string(),
"tx_hash" => tx_hash.to_string(),
Expand Down
6 changes: 6 additions & 0 deletions graph/src/blockchain/block_ingestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ where
"Trying again after block polling failed: {}", err
);
}
Err(err @ IngestorError::ReceiptUnavailable(_, _)) => {
info!(
self.logger,
"Trying again after block polling failed: {}", err
);
}
Err(IngestorError::Unknown(inner_err)) => {
warn!(
self.logger,
Expand Down
5 changes: 5 additions & 0 deletions graph/src/blockchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ pub enum IngestorError {
#[error("Block data unavailable, block was likely uncled (block hash = {0:?})")]
BlockUnavailable(H256),

/// The Ethereum node does not know about this block for some reason, probably because it
/// disappeared in a chain reorg.
#[error("Receipt for tx {1:?} unavailable, block was likely uncled (block hash = {0:?})")]
ReceiptUnavailable(H256, H256),

/// An unexpected error occurred.
#[error("Ingestor error: {0}")]
Unknown(Error),
Expand Down

0 comments on commit 73075df

Please sign in to comment.