From 285c1acb84eb794b5e6445b785204d73d0ccd373 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 5 Jun 2025 17:41:09 +0200 Subject: [PATCH] fix: use correct sender_id_or_create as intended (#16684) --- crates/transaction-pool/src/identifier.rs | 2 +- crates/transaction-pool/src/pool/mod.rs | 26 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/transaction-pool/src/identifier.rs b/crates/transaction-pool/src/identifier.rs index 2abbe0b589..17320ecf93 100644 --- a/crates/transaction-pool/src/identifier.rs +++ b/crates/transaction-pool/src/identifier.rs @@ -43,7 +43,7 @@ impl SenderIdentifiers { &mut self, addrs: impl IntoIterator, ) -> Vec { - addrs.into_iter().filter_map(|addr| self.sender_id(&addr)).collect() + addrs.into_iter().map(|addr| self.sender_id_or_create(addr)).collect() } /// Returns the current identifier and increments the counter. diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index d4d4929113..90bd7dcb20 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -1213,11 +1213,13 @@ impl OnNewCanonicalStateOutcome { mod tests { use crate::{ blobstore::{BlobStore, InMemoryBlobStore}, + identifier::SenderId, test_utils::{MockTransaction, TestPoolBuilder}, validate::ValidTransaction, BlockInfo, PoolConfig, SubPoolLimit, TransactionOrigin, TransactionValidationOutcome, U256, }; use alloy_eips::{eip4844::BlobTransactionSidecar, eip7594::BlobTransactionSidecarVariant}; + use alloy_primitives::Address; use std::{fs, path::PathBuf}; #[test] @@ -1304,4 +1306,28 @@ mod tests { // Assert that the pool's blob store matches the expected blob store. assert_eq!(*test_pool.blob_store(), blob_store); } + + #[test] + fn test_auths_stored_in_identifiers() { + // Create a test pool with default configuration. + let test_pool = &TestPoolBuilder::default().with_config(Default::default()).pool; + + let auth = Address::new([1; 20]); + let tx = MockTransaction::eip7702(); + + test_pool.add_transactions( + TransactionOrigin::Local, + [TransactionValidationOutcome::Valid { + balance: U256::from(1_000), + state_nonce: 0, + bytecode_hash: None, + transaction: ValidTransaction::Valid(tx), + propagate: true, + authorities: Some(vec![auth]), + }], + ); + + let identifiers = test_pool.identifiers.read(); + assert_eq!(identifiers.sender_id(&auth), Some(SenderId::from(1))); + } }