Skip to content

Commit b001b9f

Browse files
committed
MOVEONLY: BIP125 max conflicts limit to policy/rbf.h
A circular dependency is added because policy now depends on txmempool and txmempool depends on validation. It is natural for [mempool] policy to rely on mempool; the problem is caused by txmempool depending on validation. #22677 will resolve this.
1 parent 4fc15d1 commit b001b9f

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/policy/rbf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
#include <txmempool.h>
99

10+
/** Maximum number of transactions that can be replaced by BIP125 RBF (Rule #5). This includes all
11+
* mempool conflicts and their descendants. */
12+
static constexpr uint32_t MAX_BIP125_REPLACEMENT_CANDIDATES{100};
13+
1014
/** The rbf state of unconfirmed transactions */
1115
enum class RBFTransactionState {
1216
/** Unconfirmed tx that does not signal rbf and is not in the mempool */

src/validation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <node/coinstats.h>
2626
#include <node/ui_interface.h>
2727
#include <policy/policy.h>
28+
#include <policy/rbf.h>
2829
#include <policy/settings.h>
2930
#include <pow.h>
3031
#include <primitives/block.h>
@@ -810,7 +811,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
810811
{
811812
CFeeRate newFeeRate(nModifiedFees, nSize);
812813
std::set<uint256> setConflictsParents;
813-
const int maxDescendantsToVisit = 100;
814814
for (const auto& mi : setIterConflicting) {
815815
// Don't allow the replacement to reduce the feerate of the
816816
// mempool.
@@ -846,7 +846,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
846846
// This potentially overestimates the number of actual descendants
847847
// but we just want to be conservative to avoid doing too much
848848
// work.
849-
if (nConflictingCount <= maxDescendantsToVisit) {
849+
if (nConflictingCount <= MAX_BIP125_REPLACEMENT_CANDIDATES) {
850850
// If not too many to replace, then calculate the set of
851851
// transactions that would have to be evicted
852852
for (CTxMemPool::txiter it : setIterConflicting) {
@@ -861,7 +861,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
861861
strprintf("rejecting replacement %s; too many potential replacements (%d > %d)\n",
862862
hash.ToString(),
863863
nConflictingCount,
864-
maxDescendantsToVisit));
864+
MAX_BIP125_REPLACEMENT_CANDIDATES));
865865
}
866866

867867
for (unsigned int j = 0; j < tx.vin.size(); j++)

test/lint/lint-circular-dependencies.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
1515
"index/base -> validation -> index/blockfilterindex -> index/base"
1616
"index/coinstatsindex -> node/coinstats -> index/coinstatsindex"
1717
"policy/fees -> txmempool -> policy/fees"
18+
"policy/rbf -> txmempool -> validation -> policy/rbf"
1819
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel"
1920
"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel"
2021
"qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog"

0 commit comments

Comments
 (0)