Skip to content

Commit 26e71c2

Browse files
committed
Mempool: Do not enforce TRUC checks on reorg
Not enforcing TRUC topology on reorg was the intended behavior, but the appropriate bypass argument was not checked. This mistake means we could potentially invalidate a long chain of perfectly incentive-compatible transactions that were made historically, including subsequent non-TRUC transactions, all of which may have been very high feerate. Lastly, it wastes CPU cycles doing topology checks since this behavior cannot actually enforce the topology in general for the reorg setting.
1 parent bbe8e90 commit 26e71c2

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/validation.cpp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,26 +1044,28 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
10441044
// Even though just checking direct mempool parents for inheritance would be sufficient, we
10451045
// check using the full ancestor set here because it's more convenient to use what we have
10461046
// already calculated.
1047-
if (const auto err{SingleTRUCChecks(ws.m_ptx, ws.m_ancestors, ws.m_conflicts, ws.m_vsize)}) {
1048-
// Single transaction contexts only.
1049-
if (args.m_allow_sibling_eviction && err->second != nullptr) {
1050-
// We should only be considering where replacement is considered valid as well.
1051-
Assume(args.m_allow_replacement);
1052-
1053-
// Potential sibling eviction. Add the sibling to our list of mempool conflicts to be
1054-
// included in RBF checks.
1055-
ws.m_conflicts.insert(err->second->GetHash());
1056-
// Adding the sibling to m_iters_conflicting here means that it doesn't count towards
1057-
// RBF Carve Out above. This is correct, since removing to-be-replaced transactions from
1058-
// the descendant count is done separately in SingleTRUCChecks for TRUC transactions.
1059-
ws.m_iters_conflicting.insert(m_pool.GetIter(err->second->GetHash()).value());
1060-
ws.m_sibling_eviction = true;
1061-
// The sibling will be treated as part of the to-be-replaced set in ReplacementChecks.
1062-
// Note that we are not checking whether it opts in to replaceability via BIP125 or TRUC
1063-
// (which is normally done in PreChecks). However, the only way a TRUC transaction can
1064-
// have a non-TRUC and non-BIP125 descendant is due to a reorg.
1065-
} else {
1066-
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "TRUC-violation", err->first);
1047+
if (!args.m_bypass_limits) {
1048+
if (const auto err{SingleTRUCChecks(ws.m_ptx, ws.m_ancestors, ws.m_conflicts, ws.m_vsize)}) {
1049+
// Single transaction contexts only.
1050+
if (args.m_allow_sibling_eviction && err->second != nullptr) {
1051+
// We should only be considering where replacement is considered valid as well.
1052+
Assume(args.m_allow_replacement);
1053+
1054+
// Potential sibling eviction. Add the sibling to our list of mempool conflicts to be
1055+
// included in RBF checks.
1056+
ws.m_conflicts.insert(err->second->GetHash());
1057+
// Adding the sibling to m_iters_conflicting here means that it doesn't count towards
1058+
// RBF Carve Out above. This is correct, since removing to-be-replaced transactions from
1059+
// the descendant count is done separately in SingleTRUCChecks for TRUC transactions.
1060+
ws.m_iters_conflicting.insert(m_pool.GetIter(err->second->GetHash()).value());
1061+
ws.m_sibling_eviction = true;
1062+
// The sibling will be treated as part of the to-be-replaced set in ReplacementChecks.
1063+
// Note that we are not checking whether it opts in to replaceability via BIP125 or TRUC
1064+
// (which is normally done in PreChecks). However, the only way a TRUC transaction can
1065+
// have a non-TRUC and non-BIP125 descendant is due to a reorg.
1066+
} else {
1067+
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "TRUC-violation", err->first);
1068+
}
10671069
}
10681070
}
10691071

0 commit comments

Comments
 (0)