From fa584cbe727b62853a410623b3d7c738e11cbffd Mon Sep 17 00:00:00 2001 From: glozow Date: Tue, 27 Aug 2024 12:12:12 +0100 Subject: [PATCH] [p2p] add TxDownloadOptions bool to make TxRequestTracker deterministic Forward this bool to the TxRequestTracker ctor. This is needed for stablity in TxDownloadManager fuzzers --- src/net_processing.cpp | 2 +- src/node/txdownloadman.h | 2 ++ src/node/txdownloadman_impl.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 063dd441c9f..170352f7299 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1889,7 +1889,7 @@ PeerManagerImpl::PeerManagerImpl(CConnman& connman, AddrMan& addrman, m_banman(banman), m_chainman(chainman), m_mempool(pool), - m_txdownloadman(node::TxDownloadOptions{pool, m_rng, opts.max_orphan_txs}), + m_txdownloadman(node::TxDownloadOptions{pool, m_rng, opts.max_orphan_txs, opts.deterministic_rng}), m_warnings{warnings}, m_opts{opts} { diff --git a/src/node/txdownloadman.h b/src/node/txdownloadman.h index c2a76b3a4f2..28ca90c5542 100644 --- a/src/node/txdownloadman.h +++ b/src/node/txdownloadman.h @@ -43,6 +43,8 @@ struct TxDownloadOptions { FastRandomContext& m_rng; /** Maximum number of transactions allowed in orphanage. */ const uint32_t m_max_orphan_txs; + /** Instantiate TxRequestTracker as deterministic (used for tests). */ + bool m_deterministic_txrequest{false}; }; struct TxDownloadConnectionInfo { /** Whether this peer is preferred for transaction download. */ diff --git a/src/node/txdownloadman_impl.h b/src/node/txdownloadman_impl.h index c3e2417aa54..48f02e607af 100644 --- a/src/node/txdownloadman_impl.h +++ b/src/node/txdownloadman_impl.h @@ -128,7 +128,7 @@ public: return *m_lazy_recent_confirmed_transactions; } - TxDownloadManagerImpl(const TxDownloadOptions& options) : m_opts{options} {} + TxDownloadManagerImpl(const TxDownloadOptions& options) : m_opts{options}, m_txrequest{options.m_deterministic_txrequest} {} struct PeerInfo { /** Information relevant to scheduling tx requests. */