HomePhabricator

[Chronik] Fix: "Inconsistent mempool" when reorging with chained txs

Description

[Chronik] Fix: "Inconsistent mempool" when reorging with chained txs

Summary:
Currently, Chronik crashes when disconnecting a block with children in the mempool, because the order of removal of transactions in the node is not in reverse topological order.

This problem was introduced in D13133, specifically where TransactionRemovedFromMempool is called in topological order (i.e. parents first), but should've been called in reverse-topological order (i.e. children first), which this diff fixes.

Chronik depends on the removal to happen in reverse-topological order (i.e. children first), otherwise, it might remove UTXOs from the index before they're added, crashing the node. This is what happened a few times on both NNG and in-node Chronik.

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

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
tobias_ruckAuthored on Dec 7 2023, 01:00
tobias_ruckPushed on Dec 7 2023, 10:09
Reviewer
Restricted Project
Differential Revision
D14939: [Chronik] Fix: "Inconsistent mempool" when reorging with chained txs
Parents
rABC05979e63631c: [Chronik] Improve error message when a UTXO couldn't be removed from the mempool
Branches
Unknown
Tags
Unknown