From 5af99729a4599812a252b81d1cf0093f232a4807 Mon Sep 17 00:00:00 2001 From: Leonardo Yvens Date: Thu, 26 Aug 2021 14:39:30 -0300 Subject: [PATCH] block ingestor: Improve error reporting for missing recepits --- chain/ethereum/src/ethereum_adapter.rs | 22 ++++++++-------------- graph/src/blockchain/block_ingestor.rs | 6 ++++++ graph/src/blockchain/mod.rs | 5 +++++ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/chain/ethereum/src/ethereum_adapter.rs b/chain/ethereum/src/ethereum_adapter.rs index 96280aad568..09e0d4e6f1b 100644 --- a/chain/ethereum/src/ethereum_adapter.rs +++ b/chain/ethereum/src/ethereum_adapter.rs @@ -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(), diff --git a/graph/src/blockchain/block_ingestor.rs b/graph/src/blockchain/block_ingestor.rs index 8c787c11be2..ed9065c23b0 100644 --- a/graph/src/blockchain/block_ingestor.rs +++ b/graph/src/blockchain/block_ingestor.rs @@ -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, diff --git a/graph/src/blockchain/mod.rs b/graph/src/blockchain/mod.rs index 67b95c1e299..3c8a00bcc2a 100644 --- a/graph/src/blockchain/mod.rs +++ b/graph/src/blockchain/mod.rs @@ -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),