From b84a488851358ea99b47c47b9983243398130a2e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 3 Jan 2025 17:41:07 +0100 Subject: [PATCH] chore: rm unused recovery fns (#13634) --- crates/primitives/src/transaction/mod.rs | 63 ------------------------ 1 file changed, 63 deletions(-) diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index d37175869..b7ca75f87 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -909,37 +909,6 @@ impl TransactionSigned { *self.tx_hash() } - /// Recovers a list of signers from a transaction list iterator. - /// - /// Returns `None`, if some transaction's signature is invalid, see also - /// [`Self::recover_signer`]. - pub fn recover_signers<'a, T>(txes: T, num_txes: usize) -> Option> - where - T: 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, see also - /// [`Self::recover_signer_unchecked`]. - pub fn recover_signers_unchecked<'a, T>(txes: T, num_txes: usize) -> Option> - where - T: IntoParallelIterator + IntoIterator, - { - 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() - } - } - /// Returns the [`RecoveredTx`] transaction with the given sender. #[inline] pub const fn with_signer(self, signer: Address) -> RecoveredTx { @@ -2206,38 +2175,6 @@ mod tests { assert_eq!(data.as_slice(), b.as_slice()); } - #[cfg(feature = "secp256k1")] - proptest::proptest! { - #![proptest_config(proptest::prelude::ProptestConfig::with_cases(1))] - - #[test] - fn test_parallel_recovery_order(txes in proptest::collection::vec( - proptest_arbitrary_interop::arb::(), - *crate::transaction::PARALLEL_SENDER_RECOVERY_THRESHOLD * 5 - )) { - let mut rng =rand::thread_rng(); - let secp = secp256k1::Secp256k1::new(); - let txes: Vec = txes.into_iter().map(|mut tx| { - if let Some(chain_id) = tx.chain_id() { - // Otherwise we might overflow when calculating `v` on `recalculate_hash` - tx.set_chain_id(chain_id % (u64::MAX / 2 - 36)); - } - - let key_pair = secp256k1::Keypair::new(&secp, &mut rng); - - let signature = - crate::sign_message(B256::from_slice(&key_pair.secret_bytes()[..]), tx.signature_hash()).unwrap(); - - TransactionSigned::new_unhashed(tx, signature) - }).collect(); - - let parallel_senders = TransactionSigned::recover_signers(&txes, txes.len()).unwrap(); - let seq_senders = txes.iter().map(|tx| tx.recover_signer()).collect::>>().unwrap(); - - assert_eq!(parallel_senders, seq_senders); - } - } - // #[test] fn recover_legacy_singer() {