mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
feat: add thorough error message to state root error (#7607)
This commit is contained in:
@@ -243,6 +243,36 @@ impl InsertBlockErrorKind {
|
||||
matches!(self, InsertBlockErrorKind::Consensus(_))
|
||||
}
|
||||
|
||||
/// Returns true if this error is a state root error
|
||||
pub fn is_state_root_error(&self) -> bool {
|
||||
// we need to get the state root errors inside of the different variant branches
|
||||
match self {
|
||||
InsertBlockErrorKind::Execution(err) => {
|
||||
matches!(
|
||||
err,
|
||||
BlockExecutionError::Validation(BlockValidationError::StateRoot { .. })
|
||||
)
|
||||
}
|
||||
InsertBlockErrorKind::Canonical(err) => {
|
||||
matches!(
|
||||
err,
|
||||
CanonicalError::Validation(BlockValidationError::StateRoot { .. }) |
|
||||
CanonicalError::Provider(
|
||||
ProviderError::StateRootMismatch(_) |
|
||||
ProviderError::UnwindStateRootMismatch(_)
|
||||
)
|
||||
)
|
||||
}
|
||||
InsertBlockErrorKind::Provider(err) => {
|
||||
matches!(
|
||||
err,
|
||||
ProviderError::StateRootMismatch(_) | ProviderError::UnwindStateRootMismatch(_)
|
||||
)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the error is caused by an invalid block
|
||||
///
|
||||
/// This is intended to be used to determine if the block should be marked as invalid.
|
||||
|
||||
@@ -153,4 +153,9 @@ impl BlockExecutionError {
|
||||
pub fn is_fatal(&self) -> bool {
|
||||
matches!(self, Self::CanonicalCommit { .. } | Self::CanonicalRevert { .. })
|
||||
}
|
||||
|
||||
/// Returns `true` if the error is a state root error.
|
||||
pub fn is_state_root_error(&self) -> bool {
|
||||
matches!(self, Self::Validation(BlockValidationError::StateRoot(_)))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user