Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter announcement txns pending import #6932

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()));
mattsse marked this conversation as resolved.
Show resolved Hide resolved

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
Loading