Skip to content

Commit 2d2f6e3

Browse files
jnewberyPiRK
authored andcommitted
[validation] Always call mempool.check() after processing a new transaction
Summary: CTxMemPool::check() will carry out internal consistency checks 1/n times, where n is set by the `-checkmempool` configuration option. By default, mempool consistency checks are disabled entirely on mainnet. Therefore, this change has no effect on mainnet nodes running with default configuration. It simply removes the responsibility to trigger mempool consistency checks from net_processing. This concludes a backport of [[bitcoin/bitcoin#23173 | core#23173]] bitcoin/bitcoin@0fdb619 Depends on D12235 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D12236
1 parent 924ee9e commit 2d2f6e3

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/net_processing.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,9 +3133,6 @@ void PeerManagerImpl::ProcessOrphanTx(const Config &config,
31333133
break;
31343134
}
31353135
}
3136-
CChainState &active_chainstate = m_chainman.ActiveChainstate();
3137-
m_mempool.check(active_chainstate.CoinsTip(),
3138-
active_chainstate.m_chain.Height() + 1);
31393136
}
31403137

31413138
bool PeerManagerImpl::PrepareBlockFilterRequest(
@@ -4367,9 +4364,6 @@ void PeerManagerImpl::ProcessMessage(
43674364
const TxValidationState &state = result.m_state;
43684365

43694366
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
4370-
CChainState &active_chainstate = m_chainman.ActiveChainstate();
4371-
m_mempool.check(active_chainstate.CoinsTip(),
4372-
active_chainstate.m_chain.Height() + 1);
43734367
// As this version of the transaction was acceptable, we can forget
43744368
// about any requests for it.
43754369
m_txrequest.ForgetInvId(tx.GetId());

src/validation.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4287,9 +4287,12 @@ ChainstateManager::ProcessTransaction(const CTransactionRef &tx,
42874287
// making AcceptToMemoryPool take a CChainParams instead of a Config.
42884288
// This avoids passing an extra Config argument to this function that will
42894289
// be removed soon.
4290-
return AcceptToMemoryPool(active_chainstate, ::GetConfig(),
4291-
*active_chainstate.m_mempool, tx,
4292-
/*bypass_limits=*/false, test_accept);
4290+
auto result = AcceptToMemoryPool(active_chainstate, ::GetConfig(),
4291+
*active_chainstate.m_mempool, tx,
4292+
/*bypass_limits=*/false, test_accept);
4293+
active_chainstate.m_mempool->check(active_chainstate.CoinsTip(),
4294+
active_chainstate.m_chain.Height() + 1);
4295+
return result;
42934296
}
42944297

42954298
bool TestBlockValidity(BlockValidationState &state, const CChainParams &params,

0 commit comments

Comments
 (0)