mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: executor error cleanup (#2709)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::{executor::Error as ExecutionError, Error};
|
||||
use crate::{executor::BlockExecutionError, Error};
|
||||
use reth_primitives::{
|
||||
BlockHash, BlockNumHash, BlockNumber, SealedBlock, SealedBlockWithSenders, SealedHeader,
|
||||
};
|
||||
@ -14,13 +14,13 @@ use std::collections::{BTreeMap, HashSet};
|
||||
pub trait BlockchainTreeEngine: BlockchainTreeViewer + Send + Sync {
|
||||
/// Recover senders and call [`BlockchainTreeEngine::insert_block`].
|
||||
fn insert_block_without_senders(&self, block: SealedBlock) -> Result<BlockStatus, Error> {
|
||||
let block = block.seal_with_senders().ok_or(ExecutionError::SenderRecoveryError)?;
|
||||
let block = block.seal_with_senders().ok_or(BlockExecutionError::SenderRecoveryError)?;
|
||||
self.insert_block(block)
|
||||
}
|
||||
|
||||
/// Recover senders and call [`BlockchainTreeEngine::buffer_block`].
|
||||
fn buffer_block_without_sender(&self, block: SealedBlock) -> Result<(), Error> {
|
||||
let block = block.seal_with_senders().ok_or(ExecutionError::SenderRecoveryError)?;
|
||||
let block = block.seal_with_senders().ok_or(BlockExecutionError::SenderRecoveryError)?;
|
||||
self.buffer_block(block)
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ pub type Result<T> = std::result::Result<T, Error>;
|
||||
#[allow(missing_docs)]
|
||||
pub enum Error {
|
||||
#[error(transparent)]
|
||||
Execution(#[from] crate::executor::Error),
|
||||
Execution(#[from] crate::executor::BlockExecutionError),
|
||||
|
||||
#[error(transparent)]
|
||||
Consensus(#[from] crate::consensus::ConsensusError),
|
||||
|
||||
@ -4,23 +4,11 @@ use thiserror::Error;
|
||||
/// BlockExecutor Errors
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Error {
|
||||
pub enum BlockExecutionError {
|
||||
#[error("EVM reported invalid transaction ({hash:?}): {message}")]
|
||||
EVM { hash: H256, message: String },
|
||||
#[error("Verification failed.")]
|
||||
VerificationFailed,
|
||||
#[error("Fatal internal error")]
|
||||
ExecutionFatalError,
|
||||
#[error("Failed to recover sender for transaction")]
|
||||
SenderRecoveryError,
|
||||
#[error("Receipt cumulative gas used {got:?} is different from expected {expected:?}")]
|
||||
ReceiptCumulativeGasUsedDiff { got: u64, expected: u64 },
|
||||
#[error("Receipt log count {got:?} is different from expected {expected:?}.")]
|
||||
ReceiptLogCountDiff { got: usize, expected: usize },
|
||||
#[error("Receipt log is different.")]
|
||||
ReceiptLogDiff,
|
||||
#[error("Receipt log is different.")]
|
||||
ExecutionSuccessDiff { got: bool, expected: bool },
|
||||
#[error("Receipt root {got:?} is different than expected {expected:?}.")]
|
||||
ReceiptRootDiff { got: H256, expected: H256 },
|
||||
#[error("Header bloom filter {got:?} is different than expected {expected:?}.")]
|
||||
@ -56,15 +44,18 @@ pub enum Error {
|
||||
CanonicalRevert { inner: String },
|
||||
#[error("Transaction error on commit: {inner:?}")]
|
||||
CanonicalCommit { inner: String },
|
||||
#[error("Transaction error on pipeline status update: {inner:?}")]
|
||||
PipelineStatusUpdate { inner: String },
|
||||
#[error("Block {hash:?} is pre merge")]
|
||||
BlockPreMerge { hash: H256 },
|
||||
#[error("Missing total difficulty")]
|
||||
MissingTotalDifficulty { hash: H256 },
|
||||
|
||||
/// Only used for TestExecutor
|
||||
#[cfg(feature = "test-utils")]
|
||||
#[error("Execution unavailable for tests")]
|
||||
UnavailableForTest,
|
||||
}
|
||||
|
||||
impl Error {
|
||||
impl BlockExecutionError {
|
||||
/// Returns `true` if the error is fatal.
|
||||
pub fn is_fatal(&self) -> bool {
|
||||
matches!(self, Self::CanonicalCommit { .. } | Self::CanonicalRevert { .. })
|
||||
|
||||
Reference in New Issue
Block a user