mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 09:08:05 -05:00
58 lines
2.3 KiB
Rust
58 lines
2.3 KiB
Rust
use async_trait::async_trait;
|
|
use reth_primitives::{Address, Block, Bloom, H256, U256};
|
|
use thiserror::Error;
|
|
|
|
/// An executor capable of executing a block.
|
|
#[async_trait]
|
|
pub trait BlockExecutor<T> {
|
|
/// Execute a block.
|
|
///
|
|
/// The number of `senders` should be equal to the number of transactions in the block.
|
|
///
|
|
/// If no senders are specified, the `execute` function MUST recover the senders for the
|
|
/// provided block's transactions internally. We use this to allow for calculating senders in
|
|
/// parallel in e.g. staged sync, so that execution can happen without paying for sender
|
|
/// recovery costs.
|
|
fn execute(
|
|
&mut self,
|
|
block: &Block,
|
|
total_difficulty: U256,
|
|
senders: Option<Vec<Address>>,
|
|
) -> Result<T, Error>;
|
|
}
|
|
|
|
/// BlockExecutor Errors
|
|
#[allow(missing_docs)]
|
|
#[derive(Error, Debug, Clone, PartialEq, Eq)]
|
|
pub enum Error {
|
|
#[error("Example of error.")]
|
|
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:?}.")]
|
|
BloomLogDiff { got: Box<Bloom>, expected: Box<Bloom> },
|
|
#[error("Transaction gas limit {transaction_gas_limit} is more than blocks available gas {block_available_gas}")]
|
|
TransactionGasLimitMoreThenAvailableBlockGas {
|
|
transaction_gas_limit: u64,
|
|
block_available_gas: u64,
|
|
},
|
|
#[error("Block gas used {got} is different from expected gas used {expected}.")]
|
|
BlockGasUsed { got: u64, expected: u64 },
|
|
#[error("Revm error {error_code}")]
|
|
EVMError { error_code: u32 },
|
|
#[error("Provider error")]
|
|
ProviderError,
|
|
}
|