Skip to content

Switch BDK persistence from file store to SQLite#87

Open
markuslevonyak wants to merge 1 commit into
RGB-Tools:masterfrom
markuslevonyak:bdk-sqlite-persistence
Open

Switch BDK persistence from file store to SQLite#87
markuslevonyak wants to merge 1 commit into
RGB-Tools:masterfrom
markuslevonyak:bdk-sqlite-persistence

Conversation

@markuslevonyak

Copy link
Copy Markdown

rgb-lib currently persists BDK wallet data with bdk_file_store, which upstream explicitly documents as unfit for production:

bdk_file_store is a development/testing database. It does not natively support backwards compatible BDK version upgrades so should not be used in production.

This already caused breakage: the file store format changed in the BDK upgrade from 2.0 to 3.0, leaving existing databases unreadable. SQLite is the production-oriented, upgrade-migratable backend.

This PR moves BDK persistence to bdk_sqlite (BDK's sqlx-based SQLite store). Using it rather than bdk_wallet's built-in rusqlite feature also avoids a native-library conflict: rusqlite and rgb-lib's existing sea-orm/sqlx stack pull different libsqlite3-sys versions, and two crates linking sqlite3 can't coexist. bdk_sqlite shares sea-orm's sqlx, so the dependency graph resolves cleanly.

Note on existing wallets

This switch (like the BDK 2.0 to 3.0 upgrade before it) is not backwards compatible: existing BDK file-store databases are not read, so on first open the wallet creates a fresh SQLite store and repopulates via the normal scan. This is unavoidable when changing persistence backends and is the motivation for moving to a properly migratable one going forward.

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.73%. Comparing base (1e6353d) to head (6568548).

Files with missing lines Patch % Lines
src/wallet/core.rs 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #87      +/-   ##
==========================================
- Coverage   95.74%   95.73%   -0.02%     
==========================================
  Files          23       23              
  Lines       12835    12818      -17     
==========================================
- Hits        12289    12271      -18     
- Misses        546      547       +1     
Flag Coverage Δ
rust 95.73% <96.15%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zoedberg

Copy link
Copy Markdown
Member

Thank you for this PR, we really appreciate the detailed explanation of the dependency and migration tradeoffs.
FYI, I've added a warning about the BDK storage backwards compatibility issue to the 0.3.0 beta 6 release notes here.
At the moment, we don't have the bandwidth to review this properly, but we will take a closer look in a couple of weeks. We'll get back to you as soon as we can. Thanks for your patience and contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants