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 { /// 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>, ) -> Result; } /// BlockExecutor Errors #[allow(missing_docs)] #[derive(Error, Debug, Clone, PartialEq, Eq)] pub enum Error { #[error("EVM reported invalid transaction:{0}")] EVM(String), #[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, expected: Box }, #[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("Provider error")] ProviderError, }