Page MenuHomePhabricator

validation: fix coins disappearing mid-package evaluation
ClosedPublic

Authored by Fabien on Jul 11 2024, 15:38.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC8de49c3ef86a: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Jul 11 2024, 15:38

Actually backport PR27127

PiRK requested changes to this revision.Jul 12 2024, 09:31
PiRK added a subscriber: PiRK.
PiRK added inline comments.
test/functional/mempool_limit.py
145 ↗(On Diff #48586)

debugging print

This revision now requires changes to proceed.Jul 12 2024, 09:31
This revision is now accepted and ready to land.Jul 12 2024, 09:40
This revision was landed with ongoing or failed builds.Jul 12 2024, 09:55
This revision was automatically updated to reflect the committed changes.