mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge bitcoin/bitcoin#28251: validation: fix coins disappearing mid-package evaluation
32c1dd1ad6[test] mempool coins disappearing mid-package evaluation (glozow)a67f460c3f[refactor] split setup in mempool_limit test (glozow)d08696120e[test framework] add ability to spend only confirmed utxos (glozow)3ea71feb11[validation] don't LimitMempoolSize in any subpackage submissions (glozow)d227b7234c[validation] return correct result when already-in-mempool tx gets evicted (glozow)9698b81828[refactor] back-fill results in AcceptPackage (glozow)8ad7ad3392[validation] make PackageMempoolAcceptResult members mutable (glozow)03b87c11ca[validation] add AcceptSubPackage to delegate Accept* calls and clean up m_view (glozow)3f01a3dab1[CCoinsViewMemPool] track non-base coins and allow Reset (glozow)7d7f7a1189[policy] check for duplicate txids in package (glozow) Pull request description: While we are evaluating a package, we split it into "subpackages" for evaluation (currently subpackages all have size 1 except the last one). If a subpackage has size 1, we may add a tx to mempool and call `LimitMempoolSize()`, which evicts transactions if the mempool gets full. We handle the case where the just-submitted transaction is evicted immediately, but we don't handle the case in which a transaction from a previous subpackage (either just submitted or already in mempool) is evicted. Mainly, since the coins created by the evicted transaction are cached in `m_view`, we don't realize the UTXO has disappeared until `CheckInputsFromMempoolAndCache` asserts that they exist. Also, the returned `PackageMempoolAcceptResult` reports that the transaction is in mempool even though it isn't anymore. Fix this by not calling `LimitMempoolSize()` until the very end, and editing the results map with "mempool full" if things fall out. Pointed out by instagibbs infaeed687e5on top of the v3 PR. ACKs for top commit: instagibbs: reACK32c1dd1ad6Tree-SHA512: 61e7f69db4712e5e5bfa27d037ab66bdd97f1bf60a8d9ffb96adb1f0609af012c810d681102ee5c7baec7b5fe8cb7c304a60c63ccc445d00d86a2b7f0e7ddb90
This commit is contained in:
@@ -210,21 +210,21 @@ private:
|
||||
*/
|
||||
struct PackageMempoolAcceptResult
|
||||
{
|
||||
const PackageValidationState m_state;
|
||||
PackageValidationState m_state;
|
||||
/**
|
||||
* Map from wtxid to finished MempoolAcceptResults. The client is responsible
|
||||
* for keeping track of the transaction objects themselves. If a result is not
|
||||
* present, it means validation was unfinished for that transaction. If there
|
||||
* was a package-wide error (see result in m_state), m_tx_results will be empty.
|
||||
*/
|
||||
std::map<const uint256, const MempoolAcceptResult> m_tx_results;
|
||||
std::map<uint256, MempoolAcceptResult> m_tx_results;
|
||||
|
||||
explicit PackageMempoolAcceptResult(PackageValidationState state,
|
||||
std::map<const uint256, const MempoolAcceptResult>&& results)
|
||||
std::map<uint256, MempoolAcceptResult>&& results)
|
||||
: m_state{state}, m_tx_results(std::move(results)) {}
|
||||
|
||||
explicit PackageMempoolAcceptResult(PackageValidationState state, CFeeRate feerate,
|
||||
std::map<const uint256, const MempoolAcceptResult>&& results)
|
||||
std::map<uint256, MempoolAcceptResult>&& results)
|
||||
: m_state{state}, m_tx_results(std::move(results)) {}
|
||||
|
||||
/** Constructor to create a PackageMempoolAcceptResult from a single MempoolAcceptResult */
|
||||
|
||||
Reference in New Issue
Block a user