From a70beafdb22564043dc24fc98133fdadbaf77d8a Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Sat, 15 Jul 2023 21:46:19 +1000 Subject: [PATCH] validation: when adding txs due to a block reorg, allow immediate relay --- src/validation.cpp | 5 ++++- src/validation.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 04c86e77c8d..0efe6753ac8 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -834,7 +834,10 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws) } } - entry.reset(new CTxMemPoolEntry(ptx, ws.m_base_fees, nAcceptTime, m_active_chainstate.m_chain.Height(), m_pool.GetSequence(), + // Set entry_sequence to 0 when bypass_limits is used; this allows txs from a block + // reorg to be marked earlier than any child txs that were already in the mempool. + const uint64_t entry_sequence = bypass_limits ? 0 : m_pool.GetSequence(); + entry.reset(new CTxMemPoolEntry(ptx, ws.m_base_fees, nAcceptTime, m_active_chainstate.m_chain.Height(), entry_sequence, fSpendsCoinbase, nSigOpsCost, lock_points.value())); ws.m_vsize = entry->GetTxSize(); diff --git a/src/validation.h b/src/validation.h index 8bc8842c54d..e8d54484427 100644 --- a/src/validation.h +++ b/src/validation.h @@ -239,7 +239,8 @@ struct PackageMempoolAcceptResult * @param[in] tx The transaction to submit for mempool acceptance. * @param[in] accept_time The timestamp for adding the transaction to the mempool. * It is also used to determine when the entry expires. - * @param[in] bypass_limits When true, don't enforce mempool fee and capacity limits. + * @param[in] bypass_limits When true, don't enforce mempool fee and capacity limits, + * and set entry_sequence to zero. * @param[in] test_accept When true, run validation checks but don't submit to mempool. * * @returns a MempoolAcceptResult indicating whether the transaction was accepted/rejected with reason.