reth_evm/
engine.rs

1use crate::{execute::ExecutableTxFor, ConfigureEvm, EvmEnvFor, ExecutionCtxFor};
2
3/// [`ConfigureEvm`] extension providing methods for executing payloads.
4pub trait ConfigureEngineEvm<ExecutionData>: ConfigureEvm {
5    /// Returns an [`EvmEnvFor`] for the given payload.
6    fn evm_env_for_payload(&self, payload: &ExecutionData) -> Result<EvmEnvFor<Self>, Self::Error>;
7
8    /// Returns an [`ExecutionCtxFor`] for the given payload.
9    fn context_for_payload<'a>(
10        &self,
11        payload: &'a ExecutionData,
12    ) -> Result<ExecutionCtxFor<'a, Self>, Self::Error>;
13
14    /// Returns an [`ExecutableTxIterator`] for the given payload.
15    fn tx_iterator_for_payload(
16        &self,
17        payload: &ExecutionData,
18    ) -> Result<impl ExecutableTxIterator<Self>, Self::Error>;
19}
20
21/// Iterator over executable transactions.
22pub trait ExecutableTxIterator<Evm: ConfigureEvm>:
23    Iterator<Item = Result<Self::Tx, Self::Error>> + Send + 'static
24{
25    /// The executable transaction type iterator yields.
26    type Tx: ExecutableTxFor<Evm> + Clone + Send + 'static;
27    /// Errors that may occur while recovering or decoding transactions.
28    type Error: core::error::Error + Send + Sync + 'static;
29}
30
31impl<Evm: ConfigureEvm, Tx, Err, T> ExecutableTxIterator<Evm> for T
32where
33    Tx: ExecutableTxFor<Evm> + Clone + Send + 'static,
34    Err: core::error::Error + Send + Sync + 'static,
35    T: Iterator<Item = Result<Tx, Err>> + Send + 'static,
36{
37    type Tx = Tx;
38    type Error = Err;
39}