Skip to content

Commit 018e5fc

Browse files
committed
Merge bitcoin/bitcoin#31190: TxDownloadManager followups
5dc94d1 fuzz fix: assert MAX_PEER_TX_ANNOUNCEMENTS is not exceeded (glozow) 8351562 [fuzz] allow negative time jumps in txdownloadman_impl (glozow) 917ab81 [doc] comment fixups from n30110 (glozow) Pull request description: Addresses some remaining followups from #30110: - bitcoin/bitcoin#30110 (comment) - bitcoin/bitcoin#30110 (comment) - bitcoin/bitcoin#30110 (comment) ACKs for top commit: naumenkogs: ACK bitcoin/bitcoin@5dc94d1 instagibbs: ACK 5dc94d1 theStack: ACK 5dc94d1 Tree-SHA512: 568de8822b2ba73407d2231d9c8c83e6c53fb929b598102b6135c16805752954b3b9b53f4e698856d4422fd8ac2f58ce7d033e9d8e101ed09986578b7605df66
2 parents 3a5f602 + 5dc94d1 commit 018e5fc

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/node/txdownloadman.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ class TxDownloadManager {
134134
/** Deletes all txrequest announcements and orphans for a given peer. */
135135
void DisconnectedPeer(NodeId nodeid);
136136

137-
/** New inv has been received. May be added as a candidate to txrequest.
137+
/** Consider adding this tx hash to txrequest. Should be called whenever a new inv has been received.
138+
* Also called internally when a transaction is missing parents so that we can request them.
138139
* @param[in] p2p_inv When true, only add this announcement if we don't already have the tx.
139140
* Returns true if this was a dropped inv (p2p_inv=true and we already have the tx), false otherwise. */
140141
bool AddTxAnnouncement(NodeId peer, const GenTxid& gtxid, std::chrono::microseconds now, bool p2p_inv);

src/node/txdownloadman_impl.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ class TxDownloadManagerImpl {
160160
void ConnectedPeer(NodeId nodeid, const TxDownloadConnectionInfo& info);
161161
void DisconnectedPeer(NodeId nodeid);
162162

163-
/** New inv has been received. May be added as a candidate to txrequest. */
163+
/** Consider adding this tx hash to txrequest. Should be called whenever a new inv has been received.
164+
* Also called internally when a transaction is missing parents so that we can request them.
165+
*/
164166
bool AddTxAnnouncement(NodeId peer, const GenTxid& gtxid, std::chrono::microseconds now, bool p2p_inv);
165167

166168
/** Get getdata requests to send. */

src/test/fuzz/txdownloadman.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static void CheckInvariants(const node::TxDownloadManagerImpl& txdownload_impl,
287287
// We should never have more than the maximum in-flight requests out for a peer.
288288
for (NodeId peer = 0; peer < NUM_PEERS; ++peer) {
289289
if (!HasRelayPermissions(peer)) {
290-
Assert(txdownload_impl.m_txrequest.CountInFlight(peer) <= node::MAX_PEER_TX_REQUEST_IN_FLIGHT);
290+
Assert(txdownload_impl.m_txrequest.Count(peer) <= node::MAX_PEER_TX_ANNOUNCEMENTS);
291291
}
292292
}
293293
txdownload_impl.m_txrequest.SanityCheck();
@@ -430,8 +430,9 @@ FUZZ_TARGET(txdownloadman_impl, .init = initialize)
430430
}
431431
);
432432

433-
// Jump ahead in time
434-
time += fuzzed_data_provider.PickValueInArray(TIME_SKIPS);
433+
auto time_skip = fuzzed_data_provider.PickValueInArray(TIME_SKIPS);
434+
if (fuzzed_data_provider.ConsumeBool()) time_skip *= -1;
435+
time += time_skip;
435436
CheckInvariants(txdownload_impl, max_orphan_count);
436437
}
437438
// Disconnect everybody, check that all data structures are empty.

src/test/txdownload_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct Behaviors {
2727
bool m_ignore_inv_txid;
2828
bool m_ignore_inv_wtxid;
2929

30-
// Constructor. We are passing and casting ints because they are more readable in a table (see all_expected_results).
30+
// Constructor. We are passing and casting ints because they are more readable in a table (see expected_behaviors).
3131
Behaviors(bool txid_rejects, bool wtxid_rejects, bool txid_recon, bool wtxid_recon, bool keep, bool txid_inv, bool wtxid_inv) :
3232
m_txid_in_rejects(txid_rejects),
3333
m_wtxid_in_rejects(wtxid_rejects),

0 commit comments

Comments
 (0)