Skip to content

Conversation

@dokpark21
Copy link
Collaborator

Summary

Implement the foundational MDBX storage backend for CipherBFT per ADR-010. This PR adds the basic structure and skeleton
implementation using reth-db (MDBX) as the persistent storage layer.

Changes

New Files

  • crates/storage/src/mdbx/mod.rs - Module definition and re-exports
  • crates/storage/src/mdbx/database.rs - Database wrapper with configuration
  • crates/storage/src/mdbx/tables.rs - Table key/value type definitions with Encode/Decode
  • crates/storage/src/mdbx/provider.rs - MdbxDclStore implementing DclStore trait
  • crates/storage/src/mdbx/wal.rs - MdbxWal implementing Wal trait
  • crates/storage/MDBX_IMPLEMENTATION.md - Implementation status and TODO documentation

Modified Files

  • Cargo.toml - Added reth-db workspace dependencies
  • crates/storage/Cargo.toml - Added mdbx feature flag and dependencies
  • crates/storage/src/lib.rs - Exposed mdbx module under feature flag

What's Implemented

  • DatabaseConfig and Database wrapper for MDBX environment
  • Table key types (CarTableKey, HashKey, HeightRoundKey) with proper encoding
  • Stored value types with bincode serialization
  • Skeleton MdbxDclStore with type conversion helpers between domain types and stored types
  • Skeleton MdbxWal for write-ahead logging
  • Feature-gated module (mdbx feature required)

What's NOT Implemented (Future Work)

  • Actual MDBX read/write operations (currently returns Ok(None) or Ok(()))
  • Table definitions using define_tables! macro
  • Cursor-based range queries
  • Transaction support (DclStoreTx)
  • Pruning logic
  • Crash recovery

Testing

Build without mdbx (default)

cargo check -p cipherbft-storage

Build with mdbx feature

cargo check -p cipherbft-storage --features mdbx

Run tests

cargo test -p cipherbft-storage

All existing tests pass. The mdbx module compiles successfully with the feature flag enabled.

- Added MDBX-backed implementation for DCL storage operations.
- Introduced `Database`, `MdbxDclStore`, and `MdbxWal` for persistent storage.
- Created custom table definitions for DCL and consensus data.
- Implemented serialization and deserialization for WAL entries.
- Added feature flag for enabling MDBX support.
- Updated documentation to reflect new usage and configuration options.
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