From 959f7dea4dbb5d5d5374ac5bef388ae82fa7d231 Mon Sep 17 00:00:00 2001 From: SkandaBhat Date: Fri, 9 Aug 2024 13:52:32 +0100 Subject: [PATCH] fix: only mark propagated txs as seen --- crates/net/network/src/transactions/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/net/network/src/transactions/mod.rs b/crates/net/network/src/transactions/mod.rs index ba6b0c8543e8..bd03e8bdb6e6 100644 --- a/crates/net/network/src/transactions/mod.rs +++ b/crates/net/network/src/transactions/mod.rs @@ -433,7 +433,9 @@ where // transaction lists, before deciding whether or not to send full transactions to the // peer. for tx in &to_propagate { - if peer.seen_transactions.insert(tx.hash()) { + // Only proceed if the transaction is not in the peer's list of seen transactions + if !peer.seen_transactions.contains(&tx.hash()) { + // add transaction to the list of hashes to propagate hashes.push(tx); // Do not send full 4844 transaction hashes to peers. @@ -463,6 +465,8 @@ where for hash in new_pooled_hashes.iter_hashes().copied() { propagated.0.entry(hash).or_default().push(PropagateKind::Hash(*peer_id)); + // mark transaction as seen by peer + peer.seen_transactions.insert(hash); } trace!(target: "net::tx", ?peer_id, num_txs=?new_pooled_hashes.len(), "Propagating tx hashes to peer"); @@ -478,6 +482,8 @@ where .entry(tx.hash()) .or_default() .push(PropagateKind::Full(*peer_id)); + // mark transaction as seen by peer + peer.seen_transactions.insert(tx.hash()); } trace!(target: "net::tx", ?peer_id, num_txs=?new_full_transactions.len(), "Propagating full transactions to peer");