diff --git a/Cargo.lock b/Cargo.lock index 0b398215a..784f629e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8660,7 +8660,6 @@ dependencies = [ "proptest", "proptest-arbitrary-interop", "rand 0.8.5", - "rayon", "reth-chainspec", "reth-codecs", "reth-ethereum-forks", diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index e7036f175..6937ec285 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -53,7 +53,6 @@ derive_more.workspace = true modular-bitfield = { workspace = true, optional = true } once_cell.workspace = true rand = { workspace = true, optional = true } -rayon.workspace = true serde.workspace = true serde_with = { workspace = true, optional = true } diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 64531d29a..6189eb10c 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -26,7 +26,6 @@ use op_alloy_consensus::DepositTransaction; #[cfg(feature = "optimism")] use op_alloy_consensus::TxDeposit; pub use pooled::PooledTransactionsElementEcRecovered; -use rayon::prelude::{IntoParallelIterator, ParallelIterator}; pub use reth_primitives_traits::{ sync::{LazyLock, OnceLock}, transaction::{ @@ -51,15 +50,6 @@ pub mod util; mod pooled; mod tx_type; -/// Expected number of transactions where we can expect a speed-up by recovering the senders in -/// parallel. -pub static PARALLEL_SENDER_RECOVERY_THRESHOLD: LazyLock = - LazyLock::new(|| match rayon::current_num_threads() { - 0..=1 => usize::MAX, - 2..=8 => 10, - _ => 5, - }); - /// A raw transaction. /// /// Transaction types were introduced in [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718). @@ -1724,37 +1714,6 @@ pub mod serde_bincode_compat { } } -/// Recovers a list of signers from a transaction list iterator. -/// -/// Returns `None`, if some transaction's signature is invalid -pub fn recover_signers<'a, I, T>(txes: I, num_txes: usize) -> Option> -where - T: SignedTransaction, - I: IntoParallelIterator + IntoIterator + Send, -{ - if num_txes < *PARALLEL_SENDER_RECOVERY_THRESHOLD { - txes.into_iter().map(|tx| tx.recover_signer()).collect() - } else { - txes.into_par_iter().map(|tx| tx.recover_signer()).collect() - } -} - -/// Recovers a list of signers from a transaction list iterator _without ensuring that the -/// signature has a low `s` value_. -/// -/// Returns `None`, if some transaction's signature is invalid. -pub fn recover_signers_unchecked<'a, I, T>(txes: I, num_txes: usize) -> Option> -where - T: SignedTransaction, - I: IntoParallelIterator + IntoIterator + Send, -{ - if num_txes < *PARALLEL_SENDER_RECOVERY_THRESHOLD { - txes.into_iter().map(|tx| tx.recover_signer_unchecked()).collect() - } else { - txes.into_par_iter().map(|tx| tx.recover_signer_unchecked()).collect() - } -} - #[cfg(test)] mod tests { use crate::{ diff --git a/crates/storage/provider/src/providers/static_file/jar.rs b/crates/storage/provider/src/providers/static_file/jar.rs index 598e726ab..d4a7bbf34 100644 --- a/crates/storage/provider/src/providers/static_file/jar.rs +++ b/crates/storage/provider/src/providers/static_file/jar.rs @@ -18,8 +18,7 @@ use reth_db::{ table::{Decompress, Value}, }; use reth_node_types::NodePrimitives; -use reth_primitives::{transaction::recover_signers, SealedHeader}; -use reth_primitives_traits::SignedTransaction; +use reth_primitives_traits::{SealedHeader, SignedTransaction}; use reth_storage_errors::provider::{ProviderError, ProviderResult}; use std::{ fmt::Debug, @@ -297,7 +296,8 @@ impl> TransactionsPr range: impl RangeBounds, ) -> ProviderResult> { let txs = self.transactions_by_tx_range(range)?; - recover_signers(&txs, txs.len()).ok_or(ProviderError::SenderRecoveryError) + reth_primitives_traits::transaction::recover::recover_signers(&txs) + .ok_or(ProviderError::SenderRecoveryError) } fn transaction_sender(&self, num: TxNumber) -> ProviderResult> { diff --git a/crates/storage/provider/src/providers/static_file/manager.rs b/crates/storage/provider/src/providers/static_file/manager.rs index cb8be0f92..e81c42284 100644 --- a/crates/storage/provider/src/providers/static_file/manager.rs +++ b/crates/storage/provider/src/providers/static_file/manager.rs @@ -33,7 +33,6 @@ use reth_primitives::{ find_fixed_range, HighestStaticFiles, SegmentHeader, SegmentRangeInclusive, DEFAULT_BLOCKS_PER_STATIC_FILE, }, - transaction::recover_signers, BlockWithSenders, Receipt, SealedBlockFor, SealedBlockWithSenders, SealedHeader, StaticFileSegment, TransactionSigned, }; @@ -1554,7 +1553,8 @@ impl> TransactionsPr range: impl RangeBounds, ) -> ProviderResult> { let txes = self.transactions_by_tx_range(range)?; - recover_signers(&txes, txes.len()).ok_or(ProviderError::SenderRecoveryError) + reth_primitives_traits::transaction::recover::recover_signers(&txes) + .ok_or(ProviderError::SenderRecoveryError) } fn transaction_sender(&self, id: TxNumber) -> ProviderResult> {