feat(interfaces): move BlockHashNotFoundInChain to BlockchainTreeError (#4697)

This commit is contained in:
Thomas Coratger
2023-09-21 13:16:22 +02:00
committed by GitHub
parent f00df57ea5
commit 6d3e229e12
4 changed files with 10 additions and 6 deletions

View File

@ -931,7 +931,7 @@ where
}) })
.with_latest_valid_hash(H256::zero()) .with_latest_valid_hash(H256::zero())
} }
RethError::Execution(BlockExecutionError::BlockHashNotFoundInChain { .. }) => { RethError::BlockchainTree(BlockchainTreeError::BlockHashNotFoundInChain { .. }) => {
// This just means we couldn't find the block when attempting to make it canonical, // This just means we couldn't find the block when attempting to make it canonical,
// so we should not warn the user, since this will result in us attempting to sync // so we should not warn the user, since this will result in us attempting to sync
// to a new target and is considered normal operation during sync // to a new target and is considered normal operation during sync

View File

@ -207,6 +207,9 @@ pub enum InsertBlockErrorKind {
/// Canonical error. /// Canonical error.
#[error(transparent)] #[error(transparent)]
Canonical(CanonicalError), Canonical(CanonicalError),
/// BlockchainTree error.
#[error(transparent)]
BlockchainTree(BlockchainTreeError),
} }
impl InsertBlockErrorKind { impl InsertBlockErrorKind {
@ -238,7 +241,6 @@ impl InsertBlockErrorKind {
BlockExecutionError::Pruning(_) | BlockExecutionError::Pruning(_) |
BlockExecutionError::CanonicalRevert { .. } | BlockExecutionError::CanonicalRevert { .. } |
BlockExecutionError::CanonicalCommit { .. } | BlockExecutionError::CanonicalCommit { .. } |
BlockExecutionError::BlockHashNotFoundInChain { .. } |
BlockExecutionError::AppendChainDoesntConnect { .. } | BlockExecutionError::AppendChainDoesntConnect { .. } |
BlockExecutionError::UnavailableForTest => false, BlockExecutionError::UnavailableForTest => false,
} }
@ -266,6 +268,7 @@ impl InsertBlockErrorKind {
CanonicalError::CanonicalRevert { .. } => false, CanonicalError::CanonicalRevert { .. } => false,
CanonicalError::Validation(_) => true, CanonicalError::Validation(_) => true,
}, },
InsertBlockErrorKind::BlockchainTree(_) => false,
} }
} }
@ -327,6 +330,7 @@ impl From<crate::RethError> for InsertBlockErrorKind {
RethError::Network(err) => InsertBlockErrorKind::Internal(Box::new(err)), RethError::Network(err) => InsertBlockErrorKind::Internal(Box::new(err)),
RethError::Custom(err) => InsertBlockErrorKind::Internal(err.into()), RethError::Custom(err) => InsertBlockErrorKind::Internal(err.into()),
RethError::Canonical(err) => InsertBlockErrorKind::Canonical(err), RethError::Canonical(err) => InsertBlockErrorKind::Canonical(err),
RethError::BlockchainTree(err) => InsertBlockErrorKind::BlockchainTree(err),
} }
} }
} }

View File

@ -23,6 +23,9 @@ pub enum RethError {
#[error(transparent)] #[error(transparent)]
Canonical(#[from] crate::blockchain_tree::error::CanonicalError), Canonical(#[from] crate::blockchain_tree::error::CanonicalError),
#[error(transparent)]
BlockchainTree(#[from] crate::blockchain_tree::error::BlockchainTreeError),
#[error("{0}")] #[error("{0}")]
Custom(String), Custom(String),
} }

View File

@ -1,4 +1,4 @@
use reth_primitives::{BlockHash, BlockNumHash, Bloom, PrunePartError, H256}; use reth_primitives::{BlockNumHash, Bloom, PrunePartError, H256};
use thiserror::Error; use thiserror::Error;
/// Transaction validation errors /// Transaction validation errors
@ -52,9 +52,6 @@ pub enum BlockExecutionError {
CanonicalCommit { inner: String }, CanonicalCommit { inner: String },
// === tree errors === // === tree errors ===
// TODO(mattsse): move this to tree error
#[error("Block hash {block_hash} not found in blockchain tree chain")]
BlockHashNotFoundInChain { block_hash: BlockHash },
#[error( #[error(
"Appending chain on fork (other_chain_fork:?) is not possible as the tip is {chain_tip:?}" "Appending chain on fork (other_chain_fork:?) is not possible as the tip is {chain_tip:?}"
)] )]