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 in https://github.com/bitcoin/bitcoin/commit/faeed687e5cde5e32750d93818dd1d4add837f24 on top of the v3 PR.