HomePhabricator

[Chronik] Add metadata and schema version to DB

Description

[Chronik] Add metadata and schema version to DB

Summary:

  1. Add a column family meta to store metadata about the DB
  2. Add a field SCHEMA_VERSION in that CF, which tells us which version the database is
  3. If the compiled version doesn't match the version in the db, return with an error

Generally, it seems to be a bad idea to allow running an old Chronik version on a new database, unless we define some clear stability guarantees.

The current behavior is very strict, where the version has to match exactly, to prevent invalid states where e.g. the txs in the database are at a different height than the blocks.

Newer Chronik versions could always be more relaxed, and/or allow upgrading the existing database without reindexing.

Test Plan: ninja check-crates, also all the chronik_* functional tests

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

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

Details

Provenance
tobias_ruckAuthored on Mar 14 2023, 21:52
tobias_ruckPushed on Mar 16 2023, 14:37
Reviewer
Restricted Project
Differential Revision
D13337: [Chronik] Add metadata and schema version to DB
Parents
rABCb6b54747fb0f: [Cashtab] Bump webpack to resolve dependabot issue
Branches
Unknown
Tags
Unknown