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.
This commit is contained in:
glozow committed 2021-08-24 15:47:21 +01:00
1 parent 4fc15d1566
commit b001b9f6de
3 files changed
+8 -3

No files matched your search

+4
View File
@@ -7,6 +7,10 @@
#include <txmempool.h> #include <txmempool.h>
/** Maximum number of transactions that can be replaced by BIP125 RBF (Rule #5). This includes all
* mempool conflicts and their descendants. */
static constexpr uint32_t MAX_BIP125_REPLACEMENT_CANDIDATES{100};
/** The rbf state of unconfirmed transactions */ /** The rbf state of unconfirmed transactions */
enum class RBFTransactionState { enum class RBFTransactionState {
/** Unconfirmed tx that does not signal rbf and is not in the mempool */ /** Unconfirmed tx that does not signal rbf and is not in the mempool */
+3 -3
View File
@@ -25,6 +25,7 @@
#include <node/coinstats.h> #include <node/coinstats.h>
#include <node/ui_interface.h> #include <node/ui_interface.h>
#include <policy/policy.h> #include <policy/policy.h>
#include <policy/rbf.h>
#include <policy/settings.h> #include <policy/settings.h>
#include <pow.h> #include <pow.h>
#include <primitives/block.h> #include <primitives/block.h>
@@ -810,7 +811,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
{ {
CFeeRate newFeeRate(nModifiedFees, nSize); CFeeRate newFeeRate(nModifiedFees, nSize);
std::set<uint256> setConflictsParents; std::set<uint256> setConflictsParents;
const int maxDescendantsToVisit = 100;
for (const auto& mi : setIterConflicting) { for (const auto& mi : setIterConflicting) {
// Don't allow the replacement to reduce the feerate of the // Don't allow the replacement to reduce the feerate of the
// mempool. // mempool.
@@ -846,7 +846,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
// This potentially overestimates the number of actual descendants // This potentially overestimates the number of actual descendants
// but we just want to be conservative to avoid doing too much // but we just want to be conservative to avoid doing too much
// work. // work.
if (nConflictingCount <= maxDescendantsToVisit) { if (nConflictingCount <= MAX_BIP125_REPLACEMENT_CANDIDATES) {
// If not too many to replace, then calculate the set of // If not too many to replace, then calculate the set of
// transactions that would have to be evicted // transactions that would have to be evicted
for (CTxMemPool::txiter it : setIterConflicting) { for (CTxMemPool::txiter it : setIterConflicting) {
@@ -861,7 +861,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
strprintf("rejecting replacement %s; too many potential replacements (%d > %d)\n", strprintf("rejecting replacement %s; too many potential replacements (%d > %d)\n",
hash.ToString(), hash.ToString(),
nConflictingCount, nConflictingCount,
maxDescendantsToVisit)); MAX_BIP125_REPLACEMENT_CANDIDATES));
} }
for (unsigned int j = 0; j < tx.vin.size(); j++) for (unsigned int j = 0; j < tx.vin.size(); j++)
+1
View File
@@ -15,6 +15,7 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
"index/base -> validation -> index/blockfilterindex -> index/base" "index/base -> validation -> index/blockfilterindex -> index/base"
"index/coinstatsindex -> node/coinstats -> index/coinstatsindex" "index/coinstatsindex -> node/coinstats -> index/coinstatsindex"
"policy/fees -> txmempool -> policy/fees" "policy/fees -> txmempool -> policy/fees"
"policy/rbf -> txmempool -> validation -> policy/rbf"
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel" "qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel"
"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel" "qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel"
"qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog" "qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog"