Page MenuHomePhabricator

[Chronik] Fix plugin mempool by storing spent outputs
ClosedPublic

Authored by tobias_ruck on Sep 5 2024, 16:49.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCa676e3913ff1: [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