HomePhabricator

validation: fix coins disappearing mid-package evaluation

Description

validation: fix coins disappearing mid-package evaluation

Summary:

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.

Of course the replacement case doesn't apply to our codebase, but the mempool trimming does.

Backport of core#28251 and core#27127.
Includes a commit from core#26657:
https://github.com/bitcoin/bitcoin/pull/26657/commits/d0a909ae54a34ecd925c9d5064d530eaeeba46eb

Depends on D16443 and D16444.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Subscribers: PiRK

Differential Revision: https://reviews.bitcoinabc.org/D16447

Details

Provenance
Miles Liu <miles@bung.cc>Authored on Dec 15 2022, 14:50
FabienCommitted on Jul 12 2024, 09:55
FabienPushed on Jul 12 2024, 09:55
Reviewer
Restricted Project
Differential Revision
D16447: validation: fix coins disappearing mid-package evaluation
Parents
rABC8a5202b62d2d: test: use MiniWallet for mining_prioritisetransaction.py
Branches
Unknown
Tags
Unknown