HomePhabricator

[Chronik] Fix plugin mempool by storing spent outputs

Description

[Chronik] Fix plugin mempool by storing spent outputs

Summary:
There's a bug in MempoolPlugins, where the plugin_outputs fed into self.group_utxos.{remove,remove_mined} are incorrect—they are missing the outputs spent by the inputs, because we only store the outputs created by the plugins.

However, the remove functions also require the data of the spent inputs to be present, otherwise we get an inconsistent state.

We fix this by storing spent outputs of each tx by txid, and remove it when mined or removed from the mempool.

This is much simpler and probably faster than fetching inputs each time we remove a tx.

Note how the WebSocket test changes; it previously skipped tx3 removing because it *spent* the tx input, which was not detected. Also, we forgot to test tx3 to be added to the mempool there.

It's hard to find a good test for this, so for now the WS change will do, however, in D16708 we add tests for /unconfirmed-txs, which would fail without this fix.

Test Plan: ./test/functional/test_runner.py chronik_plugins

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

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

Details

Provenance
tobias_ruckAuthored on Sep 5 2024, 16:48
tobias_ruckPushed on Sep 5 2024, 20:05
Reviewer
Restricted Project
Differential Revision
D16723: [Chronik] Fix plugin mempool by storing spent outputs
Parents
rABC3e825e7454b2: [electrum] bump version to 5.3.0, add release notes
Branches
Unknown
Tags
Unknown