Skip to content

Add an alternative storage back-end implementation using redb#1914

Closed
pingu-73 wants to merge 3 commits intobitcoindevkit:masterfrom
pingu-73:redb
Closed

Add an alternative storage back-end implementation using redb#1914
pingu-73 wants to merge 3 commits intobitcoindevkit:masterfrom
pingu-73:redb

Conversation

@pingu-73
Copy link
Copy Markdown

@pingu-73 pingu-73 commented Mar 25, 2025

Description

Adds a new storage backend implementation for BDK wallet using redb, a pure-Rust key-value store. This implementation provides an alternative to the existing SQLite and file_store backends, giving users more flexibility in how they store their wallet data.
The implementation includes:

  • new bdk_redb crate with an implementation of the WalletPersister trait
  • basic tests to verify data is accurately stored and retrieved

Related to issue: bitcoindevkit/bdk_wallet#420, #691, bitcoindevkit/bdk_wallet#34

Notes to the reviewers

The implementation follows a similar pattern to the existing file_store backend. I chose to implement the redb backend in a separate crate to avoid adding direct dependencies to the wallet crate and to maintain separation of concerns.

The redb implementation stores each component of the ChangeSet separately, which allows for efficient updates and retrieval. I've added basic tests to verify the implementation works correctly, but would appreciate feedback on edge cases that should be tested.

Changelog notice

uses unsafe rust !! [compulsory because redb v0.8.0 had marked some functions unsafe they are not unsafe in latest version of redb]

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Todo:

  • add a feature flag for redb in the main wallet crate
  • create a new example similar to example_wallet_esplora_blocking that demonstrates using the redb backend
  • add more comprehensive tests
    • test edge cases and error handling
    • test with more complex wallet data
  • add documentation for your new implementation
  • update the project's README to mention the new storage backend

Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
@pingu-73
Copy link
Copy Markdown
Author

@evanlinjin can you please approve workflow to run on this draft

@pingu-73
Copy link
Copy Markdown
Author

@evanlinjin i'm failing test_reorg_is_detected_in_electrsd during ci tests could you give me an idea why this might be failing?

@pingu-73 pingu-73 closed this Mar 26, 2025
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.

1 participant