diff options
author | glozow <gloriajzhao@gmail.com> | 2023-08-25 11:11:36 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2023-09-13 16:14:17 +0100 |
commit | d227b7234cd4cfd7c593ffcf8e2f24573d1ebea5 (patch) | |
tree | 97c48f8959e626d6aaa6a25efb037f129bf5d9d9 /src | |
parent | 9698b81828ff98820fa49c83ca364063233374c6 (diff) | |
download | bitcoin-d227b7234cd4cfd7c593ffcf8e2f24573d1ebea5.tar.xz |
[validation] return correct result when already-in-mempool tx gets evicted
Bug fix: a transaction may be in the mempool when package evaluation
begins (so it is added to results_final with MEMPOOL_ENTRY or
DIFFERENT_WITNESS), but get evicted due to another transaction
submission.
Diffstat (limited to 'src')
-rw-r--r-- | src/validation.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 3cd815da26..70aa51b102 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1525,9 +1525,19 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptPackage(const Package& package, Assume(results_final.count(wtxid) == 0); results_final.emplace(wtxid, multi_submission_result.m_tx_results.at(wtxid)); } else if (const auto it{results_final.find(wtxid)}; it != results_final.end()) { - // Already-in-mempool transaction. + // Already-in-mempool transaction. Check to see if it's still there, as it could have + // been evicted when LimitMempoolSize() was called. Assume(it->second.m_result_type != MempoolAcceptResult::ResultType::INVALID); Assume(individual_results_nonfinal.count(wtxid) == 0); + // Query by txid to include the same-txid-different-witness ones. + if (!m_pool.exists(GenTxid::Txid(tx->GetHash()))) { + package_state_final.Invalid(PackageValidationResult::PCKG_TX, "transaction failed"); + TxValidationState mempool_full_state; + mempool_full_state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "mempool full"); + // Replace the previous result. + results_final.erase(wtxid); + results_final.emplace(wtxid, MempoolAcceptResult::Failure(mempool_full_state)); + } } else if (const auto it{individual_results_nonfinal.find(wtxid)}; it != individual_results_nonfinal.end()) { Assume(it->second.m_result_type == MempoolAcceptResult::ResultType::INVALID); // Interesting result from previous processing. |