Skip to content

Commit 83f814b

Browse files
committed
Remove m_all_conflicts from SubPackageState
1 parent d3c8e7d commit 83f814b

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/txmempool.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,8 @@ class CTxMemPool
804804
TxHandle StageAddition(const CTransactionRef& tx, const CAmount fee, int64_t time, unsigned int entry_height, uint64_t entry_sequence, bool spends_coinbase, int64_t sigops_cost, LockPoints lp);
805805
void StageRemoval(CTxMemPool::txiter it) { m_to_remove.insert(it); }
806806

807+
const CTxMemPool::setEntries& GetRemovals() const { return m_to_remove; }
808+
807809
util::Result<CTxMemPool::setEntries> CalculateMemPoolAncestors(TxHandle tx, const Limits& limits)
808810
{
809811
// Look up transaction in our cache first

src/validation.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ class MemPoolAccept
635635
CTxMemPool::setEntries m_ancestors;
636636
/* Handle to the tx in the changeset */
637637
CTxMemPool::ChangeSet::TxHandle m_tx_handle;
638-
/** Whether RBF-related data structures (m_conflicts, m_iters_conflicting, m_all_conflicting,
638+
/** Whether RBF-related data structures (m_conflicts, m_iters_conflicting,
639639
* m_replaced_transactions) include a sibling in addition to txns with conflicting inputs. */
640640
bool m_sibling_eviction{false};
641641

@@ -739,8 +739,6 @@ class MemPoolAccept
739739
/** Whether the transaction(s) would replace any mempool transactions and/or evict any siblings.
740740
* If so, RBF rules apply. */
741741
bool m_rbf{false};
742-
/** All directly conflicting mempool transactions and their descendants. */
743-
CTxMemPool::setEntries m_all_conflicts;
744742
/** Mempool transactions that were replaced. */
745743
std::list<CTransactionRef> m_replaced_transactions;
746744
/* Changeset representing adding transactions and removing their conflicts. */
@@ -1089,13 +1087,15 @@ bool MemPoolAccept::ReplacementChecks(Workspace& ws)
10891087
strprintf("insufficient fee%s", ws.m_sibling_eviction ? " (including sibling eviction)" : ""), *err_string);
10901088
}
10911089

1090+
CTxMemPool::setEntries all_conflicts;
1091+
10921092
// Calculate all conflicting entries and enforce Rule #5.
1093-
if (const auto err_string{GetEntriesForConflicts(tx, m_pool, ws.m_iters_conflicting, m_subpackage.m_all_conflicts)}) {
1093+
if (const auto err_string{GetEntriesForConflicts(tx, m_pool, ws.m_iters_conflicting, all_conflicts)}) {
10941094
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY,
10951095
strprintf("too many potential replacements%s", ws.m_sibling_eviction ? " (including sibling eviction)" : ""), *err_string);
10961096
}
10971097
// Enforce Rule #2.
1098-
if (const auto err_string{HasNoNewUnconfirmed(tx, m_pool, m_subpackage.m_all_conflicts)}) {
1098+
if (const auto err_string{HasNoNewUnconfirmed(tx, m_pool, all_conflicts)}) {
10991099
// Sibling eviction is only done for TRUC transactions, which cannot have multiple ancestors.
11001100
Assume(!ws.m_sibling_eviction);
11011101
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY,
@@ -1104,7 +1104,7 @@ bool MemPoolAccept::ReplacementChecks(Workspace& ws)
11041104

11051105
// Check if it's economically rational to mine this transaction rather than the ones it
11061106
// replaces and pays for its own relay fees. Enforce Rules #3 and #4.
1107-
for (CTxMemPool::txiter it : m_subpackage.m_all_conflicts) {
1107+
for (CTxMemPool::txiter it : all_conflicts) {
11081108
m_subpackage.m_conflicting_fees += it->GetModifiedFee();
11091109
m_subpackage.m_conflicting_size += it->GetTxSize();
11101110
}
@@ -1116,7 +1116,7 @@ bool MemPoolAccept::ReplacementChecks(Workspace& ws)
11161116
}
11171117

11181118
// Add all the to-be-removed transactions to the changeset.
1119-
for (auto it : m_subpackage.m_all_conflicts) {
1119+
for (auto it : all_conflicts) {
11201120
m_subpackage.m_changeset->StageRemoval(it);
11211121
}
11221122
return true;
@@ -1172,14 +1172,15 @@ bool MemPoolAccept::PackageMempoolChecks(const std::vector<CTransactionRef>& txn
11721172

11731173
// Don't consider replacements that would cause us to remove a large number of mempool entries.
11741174
// This limit is not increased in a package RBF. Use the aggregate number of transactions.
1175+
CTxMemPool::setEntries all_conflicts;
11751176
if (const auto err_string{GetEntriesForConflicts(*child_ws.m_ptx, m_pool, direct_conflict_iters,
1176-
m_subpackage.m_all_conflicts)}) {
1177+
all_conflicts)}) {
11771178
return package_state.Invalid(PackageValidationResult::PCKG_POLICY,
11781179
"package RBF failed: too many potential replacements", *err_string);
11791180
}
11801181

11811182

1182-
for (CTxMemPool::txiter it : m_subpackage.m_all_conflicts) {
1183+
for (CTxMemPool::txiter it : all_conflicts) {
11831184
m_subpackage.m_changeset->StageRemoval(it);
11841185
m_subpackage.m_conflicting_fees += it->GetModifiedFee();
11851186
m_subpackage.m_conflicting_size += it->GetTxSize();
@@ -1287,9 +1288,9 @@ void MemPoolAccept::FinalizeSubpackage(const ATMPArgs& args)
12871288
AssertLockHeld(cs_main);
12881289
AssertLockHeld(m_pool.cs);
12891290

1290-
if (!m_subpackage.m_all_conflicts.empty()) Assume(args.m_allow_replacement);
1291+
if (!m_subpackage.m_changeset->GetRemovals().empty()) Assume(args.m_allow_replacement);
12911292
// Remove conflicting transactions from the mempool
1292-
for (CTxMemPool::txiter it : m_subpackage.m_all_conflicts)
1293+
for (CTxMemPool::txiter it : m_subpackage.m_changeset->GetRemovals())
12931294
{
12941295
std::string log_string = strprintf("replacing mempool tx %s (wtxid=%s, fees=%s, vsize=%s). ",
12951296
it->GetTx().GetHash().ToString(),
@@ -1329,9 +1330,6 @@ void MemPoolAccept::FinalizeSubpackage(const ATMPArgs& args)
13291330
}
13301331
m_subpackage.m_changeset->Apply();
13311332
m_subpackage.m_changeset.reset();
1332-
// Don't attempt to process the same conflicts repeatedly during subpackage evaluation:
1333-
// they no longer exist on subsequent calls to Finalize() post-Apply()
1334-
m_subpackage.m_all_conflicts.clear();
13351333
}
13361334

13371335
bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>& workspaces,

0 commit comments

Comments
 (0)