diff --git a/crates/engine/tree/src/tree/payload_processor/mod.rs b/crates/engine/tree/src/tree/payload_processor/mod.rs index 7e54d8a38e2..42587737298 100644 --- a/crates/engine/tree/src/tree/payload_processor/mod.rs +++ b/crates/engine/tree/src/tree/payload_processor/mod.rs @@ -318,7 +318,7 @@ where let (execute_tx, execute_rx) = mpsc::channel(); self.executor.spawn_blocking(move || { for tx in transactions { - let tx = tx.map(|tx| WithTxEnv { tx_env: tx.to_tx_env(), tx }); + let tx = tx.map(|tx| WithTxEnv { tx_env: tx.to_tx_env(), tx: Arc::new(tx) }); // only send Ok(_) variants to prewarming task if let Ok(tx) = &tx { let _ = prewarm_tx.send(tx.clone()); diff --git a/crates/engine/tree/src/tree/payload_processor/prewarm.rs b/crates/engine/tree/src/tree/payload_processor/prewarm.rs index de831d1858b..ddbfc0715a1 100644 --- a/crates/engine/tree/src/tree/payload_processor/prewarm.rs +++ b/crates/engine/tree/src/tree/payload_processor/prewarm.rs @@ -521,7 +521,7 @@ where done_tx: Sender<()>, ) -> mpsc::Sender> where - Tx: ExecutableTxFor + Clone + Send + 'static, + Tx: ExecutableTxFor + Send + 'static, { let (tx, rx) = mpsc::channel(); let ctx = self.clone(); diff --git a/crates/evm/evm/src/engine.rs b/crates/evm/evm/src/engine.rs index 5b46a086170..e8316426079 100644 --- a/crates/evm/evm/src/engine.rs +++ b/crates/evm/evm/src/engine.rs @@ -23,14 +23,14 @@ pub trait ExecutableTxIterator: Iterator> + Send + 'static { /// The executable transaction type iterator yields. - type Tx: ExecutableTxFor + Clone + Send + 'static; + type Tx: ExecutableTxFor + Clone + Send + Sync + 'static; /// Errors that may occur while recovering or decoding transactions. type Error: core::error::Error + Send + Sync + 'static; } impl ExecutableTxIterator for T where - Tx: ExecutableTxFor + Clone + Send + 'static, + Tx: ExecutableTxFor + Clone + Send + Sync + 'static, Err: core::error::Error + Send + Sync + 'static, T: Iterator> + Send + 'static, { diff --git a/crates/evm/evm/src/execute.rs b/crates/evm/evm/src/execute.rs index 76a9b078394..fca8f6241d5 100644 --- a/crates/evm/evm/src/execute.rs +++ b/crates/evm/evm/src/execute.rs @@ -1,7 +1,7 @@ //! Traits for execution. use crate::{ConfigureEvm, Database, OnStateHook, TxEnvFor}; -use alloc::{boxed::Box, vec::Vec}; +use alloc::{boxed::Box, sync::Arc, vec::Vec}; use alloy_consensus::{BlockHeader, Header}; use alloy_eips::eip2718::WithEncoded; pub use alloy_evm::block::{BlockExecutor, BlockExecutorFactory}; @@ -447,7 +447,7 @@ impl ExecutorTx for Recovered ExecutorTx for WithTxEnv<<::Evm as Evm>::Tx, T> where - T: ExecutorTx, + T: ExecutorTx + Clone, Executor: BlockExecutor, <::Evm as Evm>::Tx: Clone, Self: RecoveredTx, @@ -457,7 +457,7 @@ where } fn into_recovered(self) -> Recovered { - self.tx.into_recovered() + Arc::unwrap_or_clone(self.tx).into_recovered() } } @@ -641,7 +641,7 @@ pub struct WithTxEnv { /// The transaction environment for EVM. pub tx_env: TxEnv, /// The recovered transaction. - pub tx: T, + pub tx: Arc, } impl> RecoveredTx for WithTxEnv {