Skip to content

Commit

Permalink
Filter announcement txns pending import (#6932)
Browse files Browse the repository at this point in the history
  • Loading branch information
emhane committed Mar 2, 2024
1 parent b6dca63 commit ef7ce36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion crates/net/network/src/transactions/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,6 @@ impl TransactionFetcher {
true
});
fetched.shrink_to_fit();
self.remove_hashes_from_transaction_fetcher(fetched);

// buffer left over hashes
self.try_buffer_hashes_for_retry(requested_hashes, &peer_id);
Expand Down
19 changes: 10 additions & 9 deletions crates/net/network/src/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,10 @@ where
self.report_peer(peer_id, ReputationChangeKind::BadAnnouncement);
}

// 2. filter out known hashes
// 2. filter out transactions pending import to pool
partially_valid_msg.retain_by_hash(|hash| !self.transactions_by_peers.contains_key(hash));

// 3. filter out known hashes
//
// known txns have already been successfully fetched or received over gossip.
//
Expand All @@ -713,7 +716,7 @@ where
return
}

// 3. filter out invalid entries (spam)
// 4. filter out invalid entries (spam)
//
// validates messages with respect to the given network, e.g. allowed tx types
//
Expand Down Expand Up @@ -742,7 +745,7 @@ where
return
}

// 4. filter out already seen unknown hashes
// 5. filter out already seen unknown hashes
//
// seen hashes are already in the tx fetcher, pending fetch.
//
Expand Down Expand Up @@ -863,11 +866,6 @@ where
.filter_map(Result::ok)
.collect::<PooledTransactions>();

// mark the transactions as received
self.transaction_fetcher.remove_hashes_from_transaction_fetcher(
non_blob_txs.iter().map(|tx| *tx.hash()),
);

self.import_transactions(peer_id, non_blob_txs, TransactionSource::Broadcast);

if has_blob_txs {
Expand Down Expand Up @@ -989,6 +987,10 @@ where

let mut transactions = transactions.0;

// mark the transactions as received
self.transaction_fetcher
.remove_hashes_from_transaction_fetcher(transactions.iter().map(|tx| *tx.hash()));

let Some(peer) = self.peers.get_mut(&peer_id) else { return };

// track that the peer knows these transaction, but only if this is a new broadcast.
Expand Down Expand Up @@ -1151,7 +1153,6 @@ where
self.report_peer_bad_transactions(peer_id);
}
}
self.transaction_fetcher.remove_hashes_from_transaction_fetcher([hash]);
self.bad_imports.insert(hash);
}

Expand Down

0 comments on commit ef7ce36

Please sign in to comment.