Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 33 additions & 25 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,51 @@
on: [push, pull_request]

name: Code Coverage

permissions: {}
# Generates code coverage reports using cargo-llvm-cov and uploads results to Codecov.
# Runs on every push and pull request to track test coverage metrics.
# Uploads coverage data to Codecov for tracking and produces an HTML report artifact for download.

on: [push, pull_request]

permissions:
contents: read
pull-requests: write

jobs:
Codecov:
Coverage:
name: Code Coverage
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install lcov tools
run: sudo apt-get install lcov -y
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
components: llvm-tools-preview
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.8
toolchain: nightly
components: llvm-tools-preview
cache: true
- name: Install cargo-llvm-cov
run: if [[ ! -e ~/.cargo/bin/cargo-llvm-cov ]]; then cargo install cargo-llvm-cov; fi
- name: Make coverage directory
run: mkdir coverage
- name: Test and report coverage
run: cargo +nightly llvm-cov -q --doctests --branch --all-features --lcov --output-path ./coverage/lcov.info
run: cargo install cargo-llvm-cov
- name: Generate coverage data
run: cargo llvm-cov --all-features --branch --quiet --lcov --output-path lcov.info
env:
RUSTFLAGS: "--cfg coverage_nightly"
- name: Generate HTML coverage report
run: genhtml -o coverage-report.html --ignore-errors unmapped ./coverage/lcov.info
- name: Coveralls upload
uses: coverallsapp/github-action@master
run: cargo llvm-cov --all-features --branch --quiet --html
env:
RUSTFLAGS: "--cfg coverage_nightly"
- name: Codecov upload
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: ./lcov.info
flags: rust
name: codecov-bdk-redb
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: coverage-report.html
path: target/llvm-cov/html
121 changes: 72 additions & 49 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
@@ -1,97 +1,120 @@
on: [push, pull_request]

# Main continuous integration workflow that runs build, test, and code quality checks.
# Runs on every push and pull request, testing against both MSRV and stable Rust.
# Includes formatting validation, and clippy linting.

name: CI

permissions: {}

jobs:
env:
CARGO_TERM_COLOR: always

prepare:
runs-on: ubuntu-latest
outputs:
rust_version: ${{ steps.read_toolchain.outputs.rust_version }}
jobs:
build-test-msrv:
name: Build & Test MSRV
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
features:
- --no-default-features
- --all-features
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: "Read rust version"
id: read_toolchain
run: echo "rust_version=$(cat rust-version)" >> $GITHUB_OUTPUT
- name: Read MSRV
id: msrv
uses: actions-rust-lang/msrv@b95a3a81b0efee6438b858b41a84aff627e01351 #v0.1.1
# The 'toolchain' argument on this action overrides the Rust compiler version set in rust-toolchain.toml
# in order to test our MSRV.
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ steps.msrv.outputs.msrv }}
cache: true
- name: Build + Test
run: |
cargo build --all-targets ${{ matrix.features }}
cargo test ${{ matrix.features }}

build-test:
needs: prepare
name: Build & Test
build-test-stable:
name: Build & Test Rust Stable
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
rust:
- version: ${{ needs.prepare.outputs.rust_version }}
clippy: true
- version: 1.85.0 # Overall MSRV
features:
- --no-default-features
- --all-features
steps:
- name: checkout
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
# This action will honor the Rust compiler version set in rust-toolchain.toml. We aim to keep it in sync with
# Rust stable.
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust.version }}
override: true
profile: minimal
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.8
cache: true
- name: Build + Test
env:
MATRIX_RUST_VERSION: ${{ matrix.rust.version }}
run: |
cargo build ${{ matrix.features }}
cargo build --all-targets ${{ matrix.features }}
cargo test ${{ matrix.features }}

fmt:
name: Rust fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
components: rustfmt
toolchain: nightly
cache: true
components: rustfmt
- name: Check fmt
run: cargo fmt --check
run: cargo fmt --all --check

clippy_check:
needs: prepare
name: Rust clippy
runs-on: ubuntu-latest
permissions:
checks: write
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions-rs/toolchain@v1
# This action automatically reads and applies rust-toolchain.toml
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ needs.prepare.outputs.rust_version }}
components: clippy
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.8
- uses: actions-rs/clippy-check@v1
cache: true
- name: Clippy
run: cargo clippy --all-features --all-targets -- -D warnings

docs_check:
name: Check cargo doc
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
# This action automatically reads and applies rust-toolchain.toml
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Clippy Results
args: --all-features --all-targets -- -D warnings
cache: true
- name: Check docs
run: RUSTDOCFLAGS='-D warnings' cargo doc --all-features --no-deps
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
[package]
name = "bdk_redb"
version = "0.2.0"
version = "0.3.0"
edition = "2024"
license = "MIT OR Apache-2.0"
description = "Persistence backend for bdk using redb"
repository = "https://github.com/110CodingP/bdk_redb"
readme = "README.md"
rust-version = "1.85.0"
rust-version = "1.89.0"

[dependencies]
bdk_wallet = {version = "3", optional = true}
bdk_chain = {version = "0.23", features = ["serde"]}
ciborium = "0.2.2"
redb = "2.5.0"
thiserror = "2.0.12"
redb = "4.1"
thiserror = "2.0"

[features]
default = ["wallet"]
wallet = ["bdk_wallet"]

[dev-dependencies]
anyhow = "1.0.98"
anyhow = "1.0"
bdk_testenv = { version = "0.13.0" }
tempfile = "3.20.0"
tempfile = "3.20"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }
1 change: 0 additions & 1 deletion clippy.toml

This file was deleted.

15 changes: 4 additions & 11 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ default:

# Build the project
build:
cargo build
cargo build --no-default-features
cargo build --all-features

# Check code: formatting, compilation, linting, and commit signature
check:
Expand All @@ -34,17 +33,11 @@ test:
# Generate doc
doc:
cargo doc --open --all-features
cargo doc --open
cargo doc --open --no-default-features

# Generate code coverage
code_cov:
mkdir coverage
touch coverage/lcov.info
cargo +nightly llvm-cov -q --doctests --branch --all-features --lcov --output-path ./coverage/lcov.info
@genhtml -o coverage-report.html --ignore-errors unmapped ./coverage/lcov.info
open ./coverage-report.html/index.html
rm -rf coverage
cargo +nightly llvm-cov -q --doctests --branch --all-features --html
open target/llvm-cov/html/index.html

# Run pre-push suite: format, check, and test
pre-push: fmt check test
pre-push: fmt check test
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.97.0"
components = ["clippy", "rustfmt"]
1 change: 0 additions & 1 deletion rust-version

This file was deleted.

15 changes: 7 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
//!
//! ```toml
//! [dependencies]
//! anyhow = "1.0.98"
//! bdk_redb = "0.1.1"
//! bdk_wallet = "2.0.0"
//! tempfile = "3.20.0"
//! bdk_redb = "0.3.0"
//! ```
//!
//! Now:
Expand All @@ -27,6 +24,7 @@
//! use bdk_wallet::{KeychainKind, Wallet};
//! use std::sync::Arc;
//! use tempfile::NamedTempFile;
//! use bdk_redb::{redb::Database, Store};
//!
//! use anyhow::Result;
//!
Expand All @@ -38,13 +36,12 @@
//! fn main() -> Result<()> {
//! let network = Network::Signet;
//! let file_path = NamedTempFile::new()?;
//! let db = Arc::new(bdk_redb::redb::Database::create(file_path.path())?);
//! let mut store = bdk_redb::Store::new(db, "wallet1".to_string())?;
//! let db = Arc::new(Database::create(file_path.path())?);
//! let mut store = Store::new(db, "wallet1".to_string())?;
//!
//! let wallet_opt = Wallet::load()
//! .descriptor(KeychainKind::External, Some(EXTERNAL_DESCRIPTOR))
//! .descriptor(KeychainKind::Internal, Some(INTERNAL_DESCRIPTOR))
//! .extract_keys()
//! .check_network(network)
//! .load_wallet(&mut store)?;
//!
Expand Down Expand Up @@ -88,7 +85,9 @@ use bdk_chain::{BlockId, DescriptorId, keychain_txout, local_chain, tx_graph};
#[cfg(feature = "wallet")]
use bdk_wallet::{ChangeSet, WalletPersister};
use error::StoreError;
use redb::{Database, ReadTransaction, ReadableTable, TableDefinition, WriteTransaction};
use redb::{
Database, ReadTransaction, ReadableDatabase, ReadableTable, TableDefinition, WriteTransaction,
};
use std::collections::{BTreeMap, BTreeSet};
use std::str::FromStr;
use std::sync::Arc;
Expand Down