mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 09:43:55 +02:00
Merge bitcoin/bitcoin#23173: Add ChainstateManager::ProcessTransaction
0fdb619aaf[validation] Always call mempool.check() after processing a new transaction (John Newbery)2c64270bbe[refactor] Don't call AcceptToMemoryPool() from outside validation.cpp (John Newbery)92a3aeecf6[validation] Add CChainState::ProcessTransaction() (John Newbery)36167faea9[logging/documentation] Remove reference to AcceptToMemoryPool from error string (John Newbery)4c24142b1e[validation] Remove comment about AcceptToMemoryPool() (John Newbery)5759fd12b8[test] Don't set bypass_limits to true in txvalidation_tests.cpp (John Newbery)497c9e2964[test] Don't set bypass_limits to true in txvalidationcache_tests.cpp (John Newbery) Pull request description: Similarly to how #18698 added `ProcessNewBlock()` and `ProcessNewBlockHeaders()` methods to the `ChainstateManager` class, this PR adds a new `ProcessTransaction()` method. Code outside validation no longer calls `AcceptToMemoryPool()` directly, but calls through the higher-level `ProcessTransaction()` method. Advantages: - The interface is simplified. Calling code no longer needs to know about the active chainstate or mempool object, since `AcceptToMemoryPool()` can only ever be called for the active chainstate, and that chainstate knows which mempool it's using. We can also remove the `bypass_limits` argument, since that can only be used internally in validation. - responsibility for calling `CTxMemPool::check()` is removed from the callers, and run automatically by `ChainstateManager` every time `ProcessTransaction()` is called. ACKs for top commit: lsilva01: tACK0fdb619on Ubuntu 20.04 theStack: Code-review ACK0fdb619aafryanofsky: Code review ACK0fdb619aaf. Only changes since last review: splitting & joining commits, adding more explanations to commit messages, tweaking MEMPOOL_ERROR string, fixing up argument name comments. Tree-SHA512: 0b395c2e3ef242f0d41d47174b1646b0a73aeece38f1fe29349837e6fb832f4bf8d57e1a1eaed82a97c635cfd59015a7e07f824e0d7c00b2bee4144e80608172
This commit is contained in:
@@ -37,8 +37,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup)
|
||||
LOCK(cs_main);
|
||||
|
||||
unsigned int initialPoolSize = m_node.mempool->size();
|
||||
const MempoolAcceptResult result = AcceptToMemoryPool(m_node.chainman->ActiveChainstate(), *m_node.mempool, MakeTransactionRef(coinbaseTx),
|
||||
true /* bypass_limits */);
|
||||
const MempoolAcceptResult result = m_node.chainman->ProcessTransaction(MakeTransactionRef(coinbaseTx));
|
||||
|
||||
BOOST_CHECK(result.m_result_type == MempoolAcceptResult::ResultType::INVALID);
|
||||
|
||||
|
||||
@@ -36,8 +36,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, Dersig100Setup)
|
||||
const auto ToMemPool = [this](const CMutableTransaction& tx) {
|
||||
LOCK(cs_main);
|
||||
|
||||
const MempoolAcceptResult result = AcceptToMemoryPool(m_node.chainman->ActiveChainstate(), *m_node.mempool, MakeTransactionRef(tx),
|
||||
true /* bypass_limits */);
|
||||
const MempoolAcceptResult result = m_node.chainman->ProcessTransaction(MakeTransactionRef(tx));
|
||||
return result.m_result_type == MempoolAcceptResult::ResultType::VALID;
|
||||
};
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction(CTransactio
|
||||
// If submit=true, add transaction to the mempool.
|
||||
if (submit) {
|
||||
LOCK(cs_main);
|
||||
const MempoolAcceptResult result = AcceptToMemoryPool(m_node.chainman->ActiveChainstate(), *m_node.mempool.get(), MakeTransactionRef(mempool_txn), /* bypass_limits */ false);
|
||||
const MempoolAcceptResult result = m_node.chainman->ProcessTransaction(MakeTransactionRef(mempool_txn));
|
||||
assert(result.m_result_type == MempoolAcceptResult::ResultType::VALID);
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE(mempool_locks_reorg)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
for (const auto& tx : txs) {
|
||||
const MempoolAcceptResult result = AcceptToMemoryPool(m_node.chainman->ActiveChainstate(), *m_node.mempool, tx, false /* bypass_limits */);
|
||||
const MempoolAcceptResult result = m_node.chainman->ProcessTransaction(tx);
|
||||
BOOST_REQUIRE(result.m_result_type == MempoolAcceptResult::ResultType::VALID);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user