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
Test Plan:
ninja all check-all
Reviewers: #bitcoin_abc, PiRK
Reviewed By: #bitcoin_abc, PiRK
Subscribers: PiRK
Differential Revision: https://reviews.bitcoinabc.org/D16447