GuardianDB: High-performance, local-first decentralized database built on Rust and Iroh
GuardianDB is a decentralized database designed for applications that require transparent peer-to-peer synchronization, offline-first operation, and extreme performance. It leverages the power of the Iroh stack to offer a robust alternative to centralized cloud databases.
Evolution: Beyond OrbitDB
GuardianDB's development began as a Rust implementation of OrbitDB. However, as we sought better performance on mobile and edge devices, the limitations of the legacy stack (IPFS, CIDs, generic libp2p DHTs) became evident.
We moved away from IPFS completely.
GuardianDB is no longer "OrbitDB in Rust". It is a distinct and modernized database. We removed the legacy OrbitDB architecture, IPFS, CIDs, and generic libp2p networking in favor of Iroh, a next-generation P2P protocol.
What makes GuardianDB different now?
No Global DHT: We use direct and encrypted connections via Iroh's Magicsock. No Garbage Collection pauses: We replaced heavy JSON serialization with zero-copy binary formats. Speed: Exclusive use of BLAKE3 hashing and QUIC transport protocol.
⚡Powered by Iroh
GuardianDB is built on top of Iroh, leveraging state-of-the-art protocols to handle the heavy lifting of networking and data reconciliation. Understanding GuardianDB means understanding these core concepts:
Magicsock & NAT Traversal: Built on technology adapted from Tailscale, instead of traditional addressing, we use Iroh's Magicsock. It automatically handles NAT traversal, hole punching, and roaming. A device can switch from Wi-Fi to 5G without breaking the connection, creating a direct and encrypted QUIC tunnel between peers.
Iroh Endpoint (Node): The Endpoint binds to a single UDP socket and manages all peer connections. It utilizes QUIC's native stream multiplexing and ALPN (Application-Layer Protocol Negotiation) to route traffic. This architecture allows Blobs (data transfer), Docs (state sync), and Gossip (real-time signals) to share the same encrypted connection simultaneously.
EndpointID ((NodeID)Ed25519): Security is not an afterthought. Each peer is identified by a cryptographic public key. No PeerIDs or multiaddrs, identity is the address.
Willow Protocol: GuardianDB uses Iroh's Willow protocol for data synchronization. Willow enables efficient and bandwidth-economical synchronization by treating data as a three-dimensional space: Entry, Author and Namespace.
Range-Based Reconciliation: Instead of exchanging complete file lists to discover what's missing, Willow uses 3D range-based reconciliation. It identifies and transfers only the missing data differences between two peers in milliseconds, even with millions of records.
Epidemic Broadcast Trees: For real-time updates (like "User is typing..."), we use iroh-gossip. The hybrid Epidemic Broadcast Trees algorithm combines the robustness of random (epidemic) gossip with the efficiency of multicast trees, ensuring messages reach all peers with minimal latency and low bandwidth redundancy.
Architecture Comparison
Terminology Shift
If you're coming from IPFS/OrbitDB, here are the GuardianDB/Iroh concept differences:
| Concept | Legacy (IPFS / OrbitDB) | GuardianDB (Iroh) | Benefit |
|---|---|---|---|
| Identity | PeerID (Multihash) | NodeID (Ed25519 Key) | Faster verification, smaller keys (32 bytes) |
| Content ID | CID (SHA-256 + Codecs) | Hash (BLAKE3) | Extreme hashing performance, simplified references. |
| Network | Libp2p Swarm (TCP/WS) | Iroh Endpoint (QUIC) | Native encryption, lower latency, better mobile roaming. |
| Discovery | DHT Kademlia (Global) | Relay / Direct | Private and segmented discovery. No leakage to public DHTs. |
| Data Format | IPLD DAG (JSON) | Binary (Postcard / Bao) | Zero-copy serialization, storage reduction over 50%. |
Stack Comparison: Libp2p/IPFS vs Iroh
| Feature | Libp2p + IPFS (OrbitDB) | Iroh (GuardianDB) |
|---|---|---|
| Philosophy | Modular "Lego" blocks. Extremely flexible, but complex to tune. | Vertical integration. Opinionated, optimized for performance and ease of use. |
| Transport | Negotiates transport (TCP, WS, QUIC, etc). | QUIC only. Optimized for unstable networks. |
| Storage | Blockstore | Blobs |
| Synchronization | Bitswap (block-by-block exchange). | Willow (range-based reconciliation). |
Internal Architecture and Roadmap
GuardianDB orchestrates three main Iroh primitives to deliver a complete database experience:
1. Iroh-Blobs: The lowest layer. Stores raw data (images, logs, binary payloads) addressed by BLAKE3 hashes. 2. Iroh-Docs: The mutable layer. Manages key-value storage and synchronization using Last-Write-Wins (LWW) conflict resolution. 3. Iroh-Gossip: The ephemeral layer. Handles transient messages and signals between peers.
⚠️Migration in Progress: Pure Iroh
We are currently in the final stages of a major architectural shift:
KV Store and Document Store: Are being migrated to run exclusively on Iroh-Docs. This moves CRDT logic to the protocol layer, enabling instant synchronization using Willow's range-based reconciliation. Event Log Store (Chat/Feed): We kept the original ipfs-log logic (DAG structure) for strict ordering, but completely refactored the engine:
No IPFS: Disconnected from IPFS Blockstore. No JSON: We replaced JSON with binary serialization (Postcard). No CIDs: All linking logic was migrated to 32-byte BLAKE3 hashes.
This hybrid approach gives us the best of both worlds: Iroh's speed for key-value data and the auditability of a causal log for transaction history.
GuardianDB v0.14.0
├── Core Database
│ ├── GuardianDB (guardian/mod.rs) # Main database API facade
│ ├── BaseGuardianDB (guardian/core.rs) # Core implementation
│ ├── Error Handling (guardian/error.rs) # Error types
│ └── Serializer (guardian/serializer.rs) # Data serialization
│
├── Store Implementations (stores/)
│ ├── EventLogStore # Immutable append-only logs
│ ├── KeyValueStore # Distributed key-value pairs
│ ├── DocumentStore # JSON documents with queries
│ ├── BaseStore # Common store functionality
│ └── Operations # Store operations & parsing
│
├── Networking Layer (p2p/)
│ ├── IrohClient (network/client.rs) # Native Iroh IPFS Client
│ ├── Network Core (network/core/) # IrohBackend
│ │ ├── BatchProcessor # Batch operation handling
│ │ ├── Blobs # Blob storage management
│ │ ├── ConnectionPool # Connection pooling
│ │ ├── Docs # Document replication (Willow Protocol)
│ │ ├── Gossip # Gossipsub protocol
│ │ ├── KeySynchronizer # Key distribution
│ │ ├── NetworkingMetrics # Network telemetry
│ │ └── OptimizedCache # Performance caching
│ ├── Messaging (messaging/)
│ │ ├── DirectChannel # Peer-to-peer messaging
│ │ └── OneOnOneChannel # Direct peer communication
│ ├── EventBus # Type-safe event system
│ └── Config (network/config.rs) # Network configuration
│
├── Access Control Layer (access_control/)
│ ├── GuardianDBAccessController (acl_guardian.rs) # Signature-based ACL
│ ├── IrohAccessController (acl_iroh.rs) # Iroh-based ACL
│ ├── SimpleAccessController (acl_simple.rs) # Open access (dev)
│ ├── Manifest (manifest.rs) # ACL configuration
│ └── Traits (traits.rs) # ACL traits
│
├── CRDT Log System (log/)
│ ├── Entry (entry.rs) # CRDT log entries
│ ├── Identity (identity.rs) # Peer identity
│ ├── IdentityProvider (identity_provider.rs) # Identity management
│ ├── LamportClock (lamport_clock.rs) # Distributed time ordering
│ ├── AccessControl (access_control.rs) # Log-level ACL
│ └── Traits (traits.rs) # Log traits
│
├── Data & Storage Layer
│ ├── Cache (cache/)
│ │ └── LevelDown (level_down.rs) # Sled-based storage
│ ├── DataStore (data_store.rs) # Pluggable storage interface
│ ├── Keystore (keystore.rs) # Ed25519 cryptographic keys
│ ├── MessageMarshaler (message_marshaler.rs) # Message Serialization
│ ├── DBManifest (db_manifest.rs) # Database configuration
│ └── Address (address.rs) # Address resolution
│
├── Reactive Systems
│ ├── ReactiveSynchronizer (reactive_synchronizer.rs) # State sync
│ └── Events (events.rs) # Event emission system
│
└── Core Traits & Types
└── Traits (traits.rs) # Common traits & types
Current Implementation Status
Networking & Discovery:
Data Stores & Operations:
Store Types
use ;
use IrohClient;
use ;
async
use ;
use IrohClient;
use KeyValueStore;
async
use ;
use IrohClient;
use json;
async
use IrohClient;
use ClientConfig;
use AsyncReadExt;
async
Configuration
use ;
use ClientConfig;
use ;
async
use ;
use ;
use ;
use Duration;
async
Development
Prerequisites
- Rust 1.90+ (edition 2024)
- Git
Build
# Run all tests (776 passing tests)
# Run only unit tests (in src/)
# Run only integration tests (in tests/)
# Run specific test files
# Run specific unit test modules
# Run with detailed output
RUST_LOG=debug
# Run with single thread (for P2P tests)
# Run tests in release mode (faster)
# Build with all features (default)
# Build optimized release version
# Check code quality and formatting
# Build documentation
# Development tools
Community & Support
GuardianDB is an open-source project welcoming contributions and discussions from developers interested in decentralized systems, Iroh, and Rust programming.
If you are excited about the project, don't hesitate to join our Discord! We try to be as welcoming as possible to everybody from any background. You can ask your questions and share what you built with the community! Follow updates on Twitter and LinkedIn!
Get Involved:
- Issues: Report bugs and request features on GitHub Issues
- Discussions: Technical discussions and Q&A on GitHub Discussions
- Documentation: Contribute to docs and examples
- Code: Submit PRs for bug fixes and new features
We welcome developers from all backgrounds and experience levels!
Status
GuardianDB is currently in active development, and there will be breaking changes. While any resulting issues are likely to be easy to fix, there are no guarantees at this stage.
Contributing
See CONTRIBUTING.md for contribution instructions.
License
GuardianDB is dual-licensed under the terms of both the MIT license and the Apache License 2.0.
See LICENSE-MIT and LICENSE-APACHE for details. Opening a pull request is assumed to signal agreement with these licensing terms.
Acknowledgments
- ipfs-log-rs - CRDT Log implementation foundation
- Iroh - QUIC-based P2P data synchronization
This project incorporates and builds upon code from ipfs-log-rs, licensed under the MIT License © EQLabs. Significant enhancements and optimizations have been added for production use in decentralized applications.
Useful Links
- Iroh Documentation - QUIC-based P2P data synchronization
GuardianDB - A secure, performant, and fully decentralized peer-to-peer database for the modern Web.