Merge bitcoin/bitcoin#35017: mempool: remove all subsequent tx in pkg on failure

ac9aa71b7f mempool: remove all subsequent tx in pkg on failure (Greg Sanders)

Pull request description:

  This belt-and-suspenders check, if ever hit in production, could result in an inconsistent mempool if somehow the parent failed in the ConsensusScriptChecks but the child did not. Rather than allow the mempool to get in an inconsistent state, remove the following txs in the package.

ACKs for top commit:
  ismaelsadeeq:
    Code review ACK ac9aa71b7f
  marcofleon:
    ACK ac9aa71b7f
  sedited:
    ACK ac9aa71b7f

Tree-SHA512: c25310045fa4dfd40bd38c9d54fff3f9fdb817e617154444d4691576393eee5f9cc86e26c59ddcdeef20eb6dddab0a168e91aec85c8291e6d68abbcb333d24f8
This commit is contained in:
merge-script
2026-05-21 23:28:40 +02:00

View File

@@ -1261,7 +1261,9 @@ bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>&
package_state.Invalid(PackageValidationResult::PCKG_MEMPOOL_ERROR,
strprintf("BUG! PolicyScriptChecks succeeded but ConsensusScriptChecks failed: %s",
ws.m_ptx->GetHash().ToString()));
// Remove the transaction from the mempool.
}
// Remove first failing tx and all subsequent in package
if (!all_submitted) {
if (!m_subpackage.m_changeset) m_subpackage.m_changeset = m_pool.GetChangeSet();
m_subpackage.m_changeset->StageRemoval(m_pool.GetIter(ws.m_ptx->GetHash()).value());
}