Skip to content
Merged
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
21 changes: 21 additions & 0 deletions .commitlintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extends:
- '@commitlint/config-conventional'

rules:
# Allow slightly longer subjects; we have descriptive messages.
header-max-length: [2, always, 100]
# Enforce lowercase type (feat, fix, ...) and allow common scopes.
type-enum:
- 2
- always
- - build
- chore
- ci
- docs
- feat
- fix
- perf
- refactor
- revert
- style
- test
55 changes: 53 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,64 @@ env:

jobs:
test:
name: Test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --verbose
- run: cargo test --verbose

features:
name: Feature matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Build default
run: cargo build --verbose
- name: Build no_std (no default features)
run: cargo build --verbose --no-default-features
- name: Build with hash-idx
run: cargo build --verbose --features hash-idx
- name: Check wasm target
run: cargo check --verbose --target wasm32-unknown-unknown --no-default-features --features wasm

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check
- run: cargo clippy --all-targets --all-features -- -D warnings

docs:
name: Docs
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -D warnings
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo doc --no-deps --all-features

msrv:
name: MSRV (1.85)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.85.0
- uses: Swatinem/rust-cache@v2
- run: cargo check --all-features
16 changes: 16 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Commitlint

on:
pull_request:
types: [opened, reopened, edited, synchronize]

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v6
with:
configFile: .commitlintrc.yml
49 changes: 49 additions & 0 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release-plz

permissions:
pull-requests: write
contents: write

on:
push:
branches: [main]

jobs:
# Opens / updates the "release PR" that bumps versions and edits the CHANGELOG.
release-plz-pr:
name: Release-plz PR
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'spacesprotocol' }}
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: release-plz/action@v0.5
with:
command: release-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

# Tags + publishes to crates.io when a release commit lands on main.
release-plz-release:
name: Release-plz publish
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'spacesprotocol' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: release-plz/action@v0.5
with:
command: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2026-04-16

Initial release on crates.io.

### Features

- Merkle-ized binary trie with MVCC concurrency (multi-reader, single-writer).
- Subtree accumulators with inclusion and exclusion proofs.
- `no_std` support (RISC0 zkVM compatible) via `default-features = false`.
- Optional wasm bindings behind the `wasm` feature.
- Optional sqlite-backed hash index sidecar behind the `hash-idx` feature for fast `prove` and `compute_root` on large trees.
- Snapshot iteration and rollback.
22 changes: 20 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@ workspace = { members = ["example"] }

[package]
name = "spacedb"
version = "0.0.12"
edition = "2021"
version = "0.1.0"
edition = "2024"
rust-version = "1.85"
description = "A cryptographically verifiable data store and universal accumulator for the Spaces protocol."
repository = "https://github.com/spacesprotocol/spacedb"
homepage = "https://spacesprotocol.org"
documentation = "https://docs.rs/spacedb"
readme = "README.md"
license = "Apache-2.0"
keywords = ["merkle", "trie", "accumulator", "verifiable", "no-std"]
categories = ["database-implementations", "cryptography", "data-structures"]
exclude = [
"example/*",
"tests/data/*",
"target/*",
".github/*",
".commitlintrc.yml",
"release-plz.toml",
]

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down Expand Up @@ -35,3 +49,7 @@ std = ["libc", "hex", "bincode"]
wasm = ["wasm-bindgen", "js-sys"]
extras = []
hash-idx = ["std", "rusqlite"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ Subtrees work in `no_std` environments utilizing the SHA256 accelerator when run
spacedb = { version = "0.1", default-features = false }
```

The `hash-idx` feature enables an optional sqlite-backed sidecar that accelerates `prove` and `compute_root` on large trees:

```toml
[dependencies]
spacedb = { version = "0.1", features = ["hash-idx"] }
```


## Using Subtrees in wasm

Expand Down
7 changes: 5 additions & 2 deletions example/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use spacedb::{Result, db::Database };
use spacedb::tx::ProofType;
use spacedb::{db::Database, Result};

fn main() -> Result<()> {
let db = Database::memory()?;
Expand Down Expand Up @@ -29,7 +29,10 @@ fn main() -> Result<()> {
let subtree = snapshot.prove(&keys_to_prove, ProofType::Standard)?;

// Will have the exact same root as the snapshot
println!("Subtree root: {}", hex::encode(subtree.compute_root().unwrap()));
println!(
"Subtree root: {}",
hex::encode(subtree.compute_root().unwrap())
);

// Prove inclusion
assert!(subtree.contains(&db.hash("key0".as_bytes())).unwrap());
Expand Down
56 changes: 56 additions & 0 deletions release-plz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[workspace]
# Changelog lives at repo root alongside Cargo.toml.
changelog_path = "CHANGELOG.md"
# Always regenerate the changelog from conventional commits.
changelog_update = true
# Open a single release PR per push to main.
pr_draft = false
# Commit messages released by release-plz itself (should not trigger commitlint recursion).
pr_name = "chore(release): {{ version }}"

[changelog]
header = """# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
"""

body = """
## [{{ version | trim_start_matches(pat=\"v\") }}]\
{%- if release_link -%}\
({{ release_link }})\
{% endif %} - {{ timestamp | date(format=\"%Y-%m-%d\") }}
{% for group, commits in commits | group_by(attribute=\"group\") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}
"""

commit_parsers = [
{ message = "^feat", group = "Features" },
{ message = "^fix", group = "Bug Fixes" },
{ message = "^perf", group = "Performance" },
{ message = "^refactor", group = "Refactor" },
{ message = "^docs", group = "Documentation" },
{ message = "^test", group = "Tests" },
{ message = "^build", group = "Build" },
{ message = "^ci", group = "CI" },
{ message = "^chore\\(release\\)", skip = true },
{ message = "^chore", group = "Chore" },
{ message = "^revert", group = "Revert" },
]

[[package]]
name = "spacedb"
# Publish to crates.io on release commits.
publish = true
# Create a GitHub release alongside the tag.
git_release_enable = true
# Use the commit subject as the GitHub release title.
git_tag_name = "v{{ version }}"
Loading
Loading