HomePhabricator

[Chronik] Add `PluginsWriter::update_sync_height`, enforce plugins are synced

Description

[Chronik] Add PluginsWriter::update_sync_height, enforce plugins are synced

Summary:
Currently, if a plugin desyncs with the DB, nothing happens, but this could lead to an inconsistent state of Chronik, e.g. where a plugin seems to be up-to-date but actually skipped a few blocks resulting in wrong data being reported to the user.

To avoid this, we previously already added a field sync_height to store the plugin's synced height, but it was unused. In this diff, we enforce that all plugins must be synced at startup, or instruct the user to either reindex Chronik or disable the plugin.

In the future, we can automatically reindex only the transactions that are relevant for the plugin using the LOKAD ID index, but since this is non-trivial this will be implemented later. Prioritizing getting a plugin system with mediocre UX out sooner.

Depends on D16532.

Test Plan: cargo test -p chronik-db && ./test/functional/test_runner.py chronik_plugins_setup

Reviewers: Fabien, #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

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

Details

Provenance
tobias_ruckAuthored on Jul 27 2024, 15:01
tobias_ruckPushed on Jul 29 2024, 12:38
Reviewer
Restricted Project
Differential Revision
D16535: [Chronik] Add `PluginsWriter::update_sync_height`, enforce plugins are synced
Parents
rABC23ebe92a9b71: [Chronik] Add PluginsWrite::{insert, delete}
Branches
Unknown
Tags
Unknown