Documentation Index
Fetch the complete documentation index at: https://mintlify.com/estebanrfp/gdb/llms.txt
Use this file to discover all available pages before exploring further.
GDB’s Advanced Synchronization and Security Architecture
A Technical Deep Dive into the Hybrid Delta Protocol and the Zero-Trust Security Layer
GenosDB (GDB) is engineered to provide a seamless, secure, and highly efficient environment for real-time, distributed applications. This document provides a detailed technical breakdown of its core synchronization engine and the integrated security layer. By examining the implementation, we can understand how GDB achieves both high performance and robust, decentralized data integrity.1. The Hybrid Synchronization Engine: Optimizing for Speed and Reliability
GDB’s synchronization protocol is designed to handle the reality of distributed networks where peers can have vastly different states. The engine intelligently switches between two modes—high-efficiency delta updates and a guaranteed full-state fallback—to ensure eventual consistency with optimal performance.A. High-Efficiency Delta Sync: The Primary Path
For peers that are frequently communicating, transmitting the entire graph for minor changes is inefficient. GDB’s primary synchronization method is based on delta updates, powered by a persistent, local Operation Log (Oplog). The Process, Step-by-Step:-
Operation Logging (Oplog): Every local mutation (
put,remove,link) is recorded as an entry in a capped, sliding-window log persisted inlocalStorage. Each entry contains the operation’s essential metadata: itstype, the affected nodeid, and a precise Hybrid Logical Clock (HLC)timestampensuring causal ordering. -
Sync Handshake: When a peer connects or wants to catch up, it broadcasts a
syncrequest. This message contains the HLC timestamp of the last operation it successfully processed (itsglobalTimestamp). A brand-new peer, having no history, will send aglobalTimestampofnull. -
Delta Calculation & Hydration: Upon receiving a
syncrequest, a peer consults its Oplog. It calculates the “delta” by filtering its log for all operations with a timestamp greater than theglobalTimestampsent by the requesting peer.- Hydration: Since the Oplog only stores minimal metadata for efficiency, the peer then “hydrates” any
upsertoperations in the delta set. It fetches the full, currentvalueof the corresponding node from its main graph and attaches it to the operation. This ensures the delta is a self-contained, complete set of changes.
- Hydration: Since the Oplog only stores minimal metadata for efficiency, the peer then “hydrates” any
-
Minimal & Compressed Transfer: This array of hydrated delta operations is serialized using MessagePack and compressed with pako (deflate). This minimal binary payload is then sent to the requesting peer inside a
deltaSyncmessage. - Efficient Application: The receiving peer decompresses the payload and applies the batch of operations, rapidly bringing its graph state up to date with minimal bandwidth and processing overhead.
B. Guaranteed Consistency Fallback: The Infallible Safety Net
A delta update is only possible if a peer’s history overlaps with the Oplog of its peers. GDB’s engine gracefully handles scenarios where this is not the case by automatically triggering a Full-State Fallback. Fallback Triggers: A full-state sync is initiated under two specific conditions:- A peer receives a
syncrequest with aglobalTimestampthat is older than the oldest operation in its Oplog, indicating the requesting peer is too far behind. - A peer receives a
syncrequest from a new peer, where theglobalTimestampisnull.
-
Full-State Transmission: Instead of a delta, the up-to-date peer serializes and compresses its entire current graph state. This is sent in a
syncReceivemessage. -
State Reconciliation & Reset: The desynchronized peer receives the full graph and performs a critical reconciliation process:
- It completely discards its outdated local graph state, replacing it with the new one.
- It clears its own Oplog, as its previous history is now invalid.
- It scans the newly received graph to find the highest HLC timestamp among all nodes. It updates its own
HybridClockand sets itsglobalTimestampto this value. This crucial step ensures it is correctly “fast-forwarded” in time and can immediately participate in future delta syncs from a known-good state.
2. The Integrated Zero-Trust Security Layer: The Security Manager (SM) Module
The synchronization engine is data-agnostic. The Security Manager (SM) module transforms GDB into a secure, zero-trust platform by integrating a complete security model directly into the data pipeline. This module is the central security component, incorporating several key functions, including a flexible Role-Based Access Control (RBAC) system for authorization, alongside robust identity management and end-to-end encryption.A. Identity: Cryptographic & Sovereign
User identity is established through a cryptographically secure Ethereum wallet.- Management (
SoftwareWalletManager): The SWM factory handles the creation, recovery, and management of these identities. It supports high-security WebAuthn (hardware-bound keys) for seamless sessions and traditional Mnemonic Phrases for account recovery. - Sovereignty: This model provides users with true ownership of their digital identity, free from any central authority.
B. Authorization: Distributed, In-Graph RBAC
The SM enforces permissions using a decentralized model where rules are embedded and synchronized as part of the graph data itself.-
Role-Based Access Control (RBAC): The system uses a configurable set of roles (e.g.,
superadmin,admin,user) with explicit permissions (can: ['write', 'deleteAny']). -
In-Graph Roles: A user’s role is stored in a publicly readable
user:[eth_address]node within the GDB graph. Security rules are distributed and agreed upon with the same eventual consistency as the data they protect. -
The
SoftwareSecurityManager(SSM) - The Enforcement Engine: The SSM is the core enforcement point on every peer. It operates through a GDB middleware that intercepts all incoming data.-
Signing at Origin: Before any batch of operations is sent over the network, the
syncChannel.sendmethod is wrapped. This wrapper callsssm.signOutgoingOperations, which cryptographically signs each operation with the user’s private key and embeds the signature and public address. This provides an unforgeable proof of origin. -
Verification at Destination (The Middleware): Upon receiving any message containing operations (including a decompressed
deltaSyncpackage), the SSM middleware on the receiving peer executes a rigorous, multi-step verification for every single operation in the batch:- Verify Signature: It confirms the cryptographic signature matches the operation’s content and the sender’s public address. If invalid, the operation is discarded.
- Resolve Permissions: It looks up the sender’s role in its local copy of the GDB graph (
user:[eth_address]node). - Authorize Action: It checks if the resolved role has permission for the requested action (e.g., does a
'user'have'delete'permission?). - Sanitization: Any operation that fails verification is silently filtered out of the batch. Only the sanitized, fully-verified set of operations is passed to the core GDB engine for application.
-
Signing at Origin: Before any batch of operations is sent over the network, the
C. Privacy: Transparent End-to-End Encryption
The SM module provides transparent, user-controlled end-to-end encryption.- Secure Wrappers: When a developer uses
db.sm.put(), the data is not stored in plaintext. It is first encrypted using a key derived from the user’s unique private key. - Secure Payload Format: The value stored in the GDB graph is a specific wrapper object,
_gdbSecurePayloadV1. This object contains the_payload(the ciphertext) and public_metadata, including the owner’s Ethereum address. - Conditional Decryption: When
db.sm.get()is called, the module inspects the wrapper. If the currently logged-in user’s address matches the owner in the metadata, it derives the correct key and decrypts the ciphertext on the fly. For all other users, the method returns the unintelligible ciphertext along with adecrypted: falseflag, allowing applications to handle the protected data appropriately.
