From d0af4239b7f04278123a2ca192e05f29f739b28f Mon Sep 17 00:00:00 2001 From: glozow Date: Fri, 16 May 2025 10:27:35 -0400 Subject: [PATCH] [prep/refactor] move DEFAULT_MAX_ORPHAN_TRANSACTIONS to txorphanage.h This is move only. --- src/net_processing.h | 4 +--- src/node/txorphanage.h | 2 ++ src/test/fuzz/txorphan.cpp | 4 ++-- src/test/txdownload_tests.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/net_processing.h b/src/net_processing.h index f1e5640a889..fea7c6fa1db 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -36,8 +36,6 @@ class Warnings; /** Whether transaction reconciliation protocol should be enabled by default. */ static constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false}; -/** Default maximum number of orphan transactions kept in memory */ -static const uint32_t DEFAULT_MAX_ORPHAN_TRANSACTIONS{100}; /** Default number of non-mempool transactions to keep around for block reconstruction. Includes orphan, replaced, and rejected transactions. */ static const uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN{100}; @@ -79,7 +77,7 @@ public: //! Whether transaction reconciliation protocol is enabled bool reconcile_txs{DEFAULT_TXRECONCILIATION_ENABLE}; //! Maximum number of orphan transactions kept in memory - uint32_t max_orphan_txs{DEFAULT_MAX_ORPHAN_TRANSACTIONS}; + uint32_t max_orphan_txs{node::DEFAULT_MAX_ORPHAN_TRANSACTIONS}; //! Number of non-mempool transactions to keep around for block reconstruction. Includes //! orphan, replaced, and rejected transactions. uint32_t max_extra_txs{DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN}; diff --git a/src/node/txorphanage.h b/src/node/txorphanage.h index ac43cb1d231..f168d2e1055 100644 --- a/src/node/txorphanage.h +++ b/src/node/txorphanage.h @@ -20,6 +20,8 @@ namespace node{ static constexpr auto ORPHAN_TX_EXPIRE_TIME{20min}; /** Minimum time between orphan transactions expire time checks */ static constexpr auto ORPHAN_TX_EXPIRE_INTERVAL{5min}; +/** Default maximum number of orphan transactions kept in memory */ +static const uint32_t DEFAULT_MAX_ORPHAN_TRANSACTIONS{100}; /** A class to track orphan transactions (failed on TX_MISSING_INPUTS) * Since we cannot distinguish orphans from bad transactions with diff --git a/src/test/fuzz/txorphan.cpp b/src/test/fuzz/txorphan.cpp index 6ae45c51b69..26486af7635 100644 --- a/src/test/fuzz/txorphan.cpp +++ b/src/test/fuzz/txorphan.cpp @@ -50,7 +50,7 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage) std::vector tx_history; - LIMITED_WHILE(outpoints.size() < 200'000 && fuzzed_data_provider.ConsumeBool(), 10 * DEFAULT_MAX_ORPHAN_TRANSACTIONS) + LIMITED_WHILE(outpoints.size() < 200'000 && fuzzed_data_provider.ConsumeBool(), 10 * node::DEFAULT_MAX_ORPHAN_TRANSACTIONS) { // construct transaction const CTransactionRef tx = [&] { @@ -98,7 +98,7 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage) } // trigger orphanage functions - LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10 * DEFAULT_MAX_ORPHAN_TRANSACTIONS) + LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10 * node::DEFAULT_MAX_ORPHAN_TRANSACTIONS) { NodeId peer_id = fuzzed_data_provider.ConsumeIntegral(); const auto total_bytes_start{orphanage.TotalOrphanUsage()}; diff --git a/src/test/txdownload_tests.cpp b/src/test/txdownload_tests.cpp index f9d50108c24..e5e0d652d60 100644 --- a/src/test/txdownload_tests.cpp +++ b/src/test/txdownload_tests.cpp @@ -114,7 +114,7 @@ BOOST_FIXTURE_TEST_CASE(tx_rejection_types, TestChain100Setup) { CTxMemPool& pool = *Assert(m_node.mempool); FastRandomContext det_rand{true}; - node::TxDownloadOptions DEFAULT_OPTS{pool, det_rand, DEFAULT_MAX_ORPHAN_TRANSACTIONS, true}; + node::TxDownloadOptions DEFAULT_OPTS{pool, det_rand, node::DEFAULT_MAX_ORPHAN_TRANSACTIONS, true}; // A new TxDownloadManagerImpl is created for each tx so we can just reuse the same one. TxValidationState state; @@ -172,7 +172,7 @@ BOOST_FIXTURE_TEST_CASE(handle_missing_inputs, TestChain100Setup) { CTxMemPool& pool = *Assert(m_node.mempool); FastRandomContext det_rand{true}; - node::TxDownloadOptions DEFAULT_OPTS{pool, det_rand, DEFAULT_MAX_ORPHAN_TRANSACTIONS, true}; + node::TxDownloadOptions DEFAULT_OPTS{pool, det_rand, node::DEFAULT_MAX_ORPHAN_TRANSACTIONS, true}; NodeId nodeid{1}; node::TxDownloadConnectionInfo DEFAULT_CONN{/*m_preferred=*/false, /*m_relay_permissions=*/false, /*m_wtxid_relay=*/true};