From 3a2bf263d70b1d4dc4ba193b080f66ecdad33cf9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 31 Jul 2025 20:54:44 +0200 Subject: [PATCH] fix(txpool): also emit promoted pending tx on pool drift (#17695) --- crates/transaction-pool/src/pool/events.rs | 7 +++++++ crates/transaction-pool/src/pool/mod.rs | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/crates/transaction-pool/src/pool/events.rs b/crates/transaction-pool/src/pool/events.rs index 0dc07e7ee9..89cfc95bdf 100644 --- a/crates/transaction-pool/src/pool/events.rs +++ b/crates/transaction-pool/src/pool/events.rs @@ -93,6 +93,13 @@ pub struct NewTransactionEvent { pub transaction: Arc>, } +impl NewTransactionEvent { + /// Creates a new event for a pending transaction. + pub const fn pending(transaction: Arc>) -> Self { + Self { subpool: SubPool::Pending, transaction } + } +} + impl Clone for NewTransactionEvent { fn clone(&self) -> Self { Self { subpool: self.subpool, transaction: self.transaction.clone() } diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index 41770650cd..070c3feb1e 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -414,6 +414,8 @@ where /// Performs account updates on the pool. /// /// This will either promote or discard transactions based on the new account state. + /// + /// This should be invoked when the pool drifted and accounts are updated manually pub fn update_accounts(&self, accounts: Vec) { let changed_senders = self.changed_senders(accounts.into_iter()); let UpdateOutcome { promoted, discarded } = @@ -431,6 +433,18 @@ where }); listener.send_all(promoted_hashes) }); + + // in this case we should also emit promoted transactions in full + self.transaction_listener.lock().retain_mut(|listener| { + let promoted_txs = promoted.iter().filter_map(|tx| { + if listener.kind.is_propagate_only() && !tx.propagate { + None + } else { + Some(NewTransactionEvent::pending(tx.clone())) + } + }); + listener.send_all(promoted_txs) + }); } {