From 5ad9d9093fcbe7037e5474a9d8fa20a0b64fb79a Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 25 Feb 2026 15:07:40 +0000 Subject: drop nostr-db backend support, keep only lmdb and memory --- .env.example | 3 +-- README.md | 1 - docs/explanation/architecture.md | 2 +- docs/explanation/comparison.md | 10 +++++----- docs/explanation/deletion-requests.md | 2 +- docs/how-to/deploy.md | 4 ++-- docs/learnings/grasp-01-implementation.md | 4 ++-- docs/reference/configuration.md | 28 +++++++++++----------------- nix/module.nix | 3 +-- src/config.rs | 4 ---- src/nostr/builder.rs | 10 ---------- 11 files changed, 24 insertions(+), 47 deletions(-) diff --git a/.env.example b/.env.example index 01854f4..43f8f6f 100644 --- a/.env.example +++ b/.env.example @@ -67,11 +67,10 @@ # Database backend for Nostr events # CLI: --database-backend -# Options: lmdb, memory, nostrdb +# Options: lmdb, memory # Default: lmdb # - lmdb: LMDB backend (persistent, general purpose) - RECOMMENDED # - memory: In-memory database (fastest, no persistence, uses temp dirs) -# - nostrdb: NostrDB backend (persistent, Nostr-optimized) [Not yet implemented] # # Note: When using 'memory' backend, git_data_path and relay_data_path # are automatically set to temporary directories for ephemeral testing. diff --git a/README.md b/README.md index 189478c..506bc53 100644 --- a/README.md +++ b/README.md @@ -477,7 +477,6 @@ NGIT_RELAY_OWNER_NSEC=nsec1... ngit-grasp --domain relay.example.com - `lmdb`: LMDB backend (default, persistent, general purpose) - `memory`: In-memory database (fastest, no persistence - uses temp directories) -- `nostrdb`: NostrDB backend (persistent, optimized for Nostr) [Not yet implemented] > **Note:** When using the `memory` backend, git data are automatically stored in temporary directories for ephemeral testing. diff --git a/docs/explanation/architecture.md b/docs/explanation/architecture.md index e101425..e0a57e5 100644 --- a/docs/explanation/architecture.md +++ b/docs/explanation/architecture.md @@ -101,7 +101,7 @@ After examining both the reference implementation and HTTP server options, we ha - Initialize configuration from environment (clap + dotenvy) - Set up Hyper HTTP server with request routing - Initialize Nostr relay builder with custom [`Nip34WritePolicy`](src/nostr/builder.rs:51) -- Set up shared storage (LMDB, NostrDB, or Memory) +- Set up shared storage (LMDB or Memory) - Handle WebSocket upgrades for Nostr relay - Handle graceful shutdown diff --git a/docs/explanation/comparison.md b/docs/explanation/comparison.md index 090e0eb..315f091 100644 --- a/docs/explanation/comparison.md +++ b/docs/explanation/comparison.md @@ -11,7 +11,7 @@ This document compares ngit-grasp (this project) with ngit-relay (the reference | **Git Protocol** | git-http-backend (C via fcgiwrap) | HTTP layer in Rust + git subprocess | | **Authorization** | Pre-receive Git hook | Inline HTTP handler validation | | **Nostr Relay** | Khatru (Go library) | nostr-relay-builder (Rust library) | -| **Event Store** | Badger (Go KV database) | LMDB or NostrDB (Rust) | +| **Event Store** | Badger (Go KV database) | LMDB (Rust) | | **Proactive Sync** | Git-only (polls DB + fetches from git servers) | Nostr event sync + git sync (event-driven) | | **Process Management** | supervisord (4 processes) | Single tokio runtime | | **Packaging** | Docker with supervisord | Single static binary or Docker | @@ -78,7 +78,7 @@ This document compares ngit-grasp (this project) with ngit-relay (the reference │ │ │ │ builder library) │ │ │ │ - info/refs │ │ - NIP-34 Policy │ │ │ │ - upload-pk │◀─────┤ (inline query) │ │ -│ │ - receive-pk │ auth │ - LMDB/NostrDB │ │ +│ │ - receive-pk │ auth │ - LMDB/Memory │ │ │ │ + inline │ check│ - WebSocket │ │ │ │ validation │ │ - NIP-11 endpoint │ │ │ └──────┬───────┘ └──────────┬─────────┘ │ @@ -100,7 +100,7 @@ This document compares ngit-grasp (this project) with ngit-relay (the reference │ │ │ ┌──────────────────────────────────────────────────┐ │ │ │ Shared State (Arc) │ │ -│ │ - Database (LMDB/NostrDB/Memory) │ │ +│ │ - Database (LMDB/Memory) │ │ │ │ - Purgatory (DashMap - concurrent queue) │ │ │ │ - Metrics (Prometheus) │ │ │ └──────────────────────────────────────────────────┘ │ @@ -161,7 +161,7 @@ This is why ngit-grasp has ~13x more code - the majority is implementing GRASP-0 | Feature | ngit-relay | ngit-grasp | |---------|-----------|-----------| | **Implementation** | Khatru (Go library) | nostr-relay-builder (Rust library) | -| **Database** | Badger (Go KV store) | LMDB or NostrDB (Rust) | +| **Database** | Badger (Go KV store) | LMDB (Rust) | | **Process** | Separate process on :3334 | Integrated (same binary) | | **Policies** | Go functions in `policies.go` | Rust traits (modular sub-policies) | | **Event Validation** | Single function with branches | 4 separate policy modules | @@ -287,7 +287,7 @@ For users of ngit-relay, migration to ngit-grasp involves: ### Data Migration -1. **Events**: Export from Badger → Import to LMDB/NostrDB +1. **Events**: Export from Badger → Import to LMDB - No direct migration tool yet (would need to be built) - Alternative: Use proactive sync to re-fetch from other relays 2. **Git Repositories**: Direct copy (same structure) diff --git a/docs/explanation/deletion-requests.md b/docs/explanation/deletion-requests.md index 7660774..4b4cd88 100644 --- a/docs/explanation/deletion-requests.md +++ b/docs/explanation/deletion-requests.md @@ -28,7 +28,7 @@ The deletion system uses three separate data stores: ┌─────────────────────────────────────────────────────────┐ │ Main Database │ │ (Live events - actively served) │ -│ LMDB/NostrDB/Memory backend │ +│ LMDB/Memory backend │ └─────────────────────────────────────────────────────────┘ ↓ deletion request ┌─────────────────────────────────────────────────────────┐ diff --git a/docs/how-to/deploy.md b/docs/how-to/deploy.md index 157e5f8..9117fe2 100644 --- a/docs/how-to/deploy.md +++ b/docs/how-to/deploy.md @@ -233,7 +233,7 @@ git ls-remote https://ngit.example.com//.git ### Storage - `dataDir` - Base directory for data (default: /var/lib/ngit-grasp-{name}) -- `databaseBackend` - "lmdb" | "nostr-db" | "memory" (default: "lmdb") +- `databaseBackend` - "lmdb" | "memory" (default: "lmdb") ### Identity - `relayName` - Relay name for NIP-11 (default: "{domain} grasp relay") @@ -363,7 +363,7 @@ curl http://localhost:8082/metrics **Tune configuration:** - Reduce `metricsTopNRepos` - Increase `syncMaxBackoffSecs` -- Switch to `databaseBackend = "nostr-db"` for better performance +- Tune `syncMaxBackoffSecs` for your network conditions --- diff --git a/docs/learnings/grasp-01-implementation.md b/docs/learnings/grasp-01-implementation.md index 27124af..f893d78 100644 --- a/docs/learnings/grasp-01-implementation.md +++ b/docs/learnings/grasp-01-implementation.md @@ -20,7 +20,7 @@ |-----------|--------|-----------| | HTTP Server | Hyper (not actix-web) | Better control over WebSocket upgrade handling | | Nostr Relay | nostr-relay-builder | Mature, well-tested, supports custom policies | -| Database | LMDB (default), NostrDB, Memory | LMDB for production, Memory for testing | +| Database | LMDB (default), Memory | LMDB for production, Memory for testing | | Configuration | clap + dotenvy | CLI flags > env vars > .env > defaults | --- @@ -125,7 +125,7 @@ The decision to validate pushes **before** spawning git-receive-pack worked extr Using rust-nostr's relay builder was the right call: - Handles NIP-01 protocol correctly - Custom `WritePolicy` trait for our validation -- Database abstraction (LMDB, NostrDB, Memory) +- Database abstraction (LMDB, Memory) - Active maintenance and updates ### 3. Separate Audit Tool diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index b09b20f..a05aeee 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -245,44 +245,38 @@ NGIT_RELAY_DATA_PATH=/mnt/ssd/relay-data #### `NGIT_DATABASE_BACKEND` **Description:** Database backend type for storing Nostr events -**Type:** String (enum: memory, nostrdb, lmdb) -**Default:** `memory` +**Type:** String (enum: memory, lmdb) +**Default:** `lmdb` **Required:** No **Valid Values:** -- `memory` - In-memory database (default, fastest, no persistence) -- `nostrdb` - NostrDB backend (persistent, optimized for Nostr) [Not yet implemented] -- `lmdb` - LMDB backend (persistent, general purpose) [Not yet implemented] +- `lmdb` - LMDB backend (persistent, general purpose) +- `memory` - In-memory database (fastest, no persistence) **Examples:** ```bash -# Development (default, no persistence) -NGIT_DATABASE_BACKEND=memory - -# Production with NostrDB (when implemented) -NGIT_DATABASE_BACKEND=nostrdb - -# Production with LMDB (when implemented) +# Production (default, persistent) NGIT_DATABASE_BACKEND=lmdb + +# Development/testing (no persistence) +NGIT_DATABASE_BACKEND=memory ``` **Comparison:** | Backend | Persistence | Performance | Use Case | | ------- | ----------- | ----------- | ---------------------------- | -| memory | No | Fastest | Development, testing | -| nostrdb | Yes | High | Production (Nostr-optimized) | | lmdb | Yes | High | Production (general purpose) | +| memory | No | Fastest | Development, testing | **Notes:** - `memory` backend loses all data on restart -- NostrDB and LMDB backends will use `NGIT_RELAY_DATA_PATH` for storage -- NostrDB and LMDB are planned features, not yet available +- `lmdb` backend uses `NGIT_RELAY_DATA_PATH` for storage - Default `memory` backend suitable for development and testing only -- Production deployments should use persistent backends when available +- Production deployments should use `lmdb` --- diff --git a/nix/module.nix b/nix/module.nix index 89d58de..7354ab6 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -97,12 +97,11 @@ let }; databaseBackend = mkOption { - type = types.enum [ "lmdb" "nostr-db" "memory" ]; + type = types.enum [ "lmdb" "memory" ]; default = "lmdb"; description = '' Database backend type: - lmdb: LMDB backend (persistent, general purpose) - - nostr-db: NostrDB backend (persistent, optimized for Nostr) - memory: In-memory database (fastest, no persistence) ''; }; diff --git a/src/config.rs b/src/config.rs index dd7b1e3..5c9303c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -280,8 +280,6 @@ pub enum DatabaseBackend { /// LMDB backend (persistent, general purpose) #[default] Lmdb, - /// NostrDB backend (persistent, optimized for Nostr) - NostrDb, /// In-memory database (fastest, no persistence - uses temp directory for git data) Memory, } @@ -290,7 +288,6 @@ impl std::fmt::Display for DatabaseBackend { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Memory => write!(f, "memory"), - Self::NostrDb => write!(f, "nostrdb"), Self::Lmdb => write!(f, "lmdb"), } } @@ -821,7 +818,6 @@ mod tests { #[test] fn test_database_backend_display() { assert_eq!(DatabaseBackend::Memory.to_string(), "memory"); - assert_eq!(DatabaseBackend::NostrDb.to_string(), "nostrdb"); assert_eq!(DatabaseBackend::Lmdb.to_string(), "lmdb"); } diff --git a/src/nostr/builder.rs b/src/nostr/builder.rs index 7a05348..a0088e1 100644 --- a/src/nostr/builder.rs +++ b/src/nostr/builder.rs @@ -689,16 +689,6 @@ pub async fn create_relay( max_events: Some(NonZeroUsize::new(100_000).unwrap()), })) } - DatabaseBackend::NostrDb => { - tracing::info!("Using NostrDB backend at: {}", db_path.display()); - // TODO: Implement NostrDB backend once nostr-relay-builder supports it - // For now, fall back to memory database - tracing::warn!("NostrDB backend not yet implemented, using in-memory database"); - Arc::new(MemoryDatabase::with_opts(MemoryDatabaseOptions { - events: true, - max_events: Some(NonZeroUsize::new(100_000).unwrap()), - })) - } DatabaseBackend::Lmdb => { tracing::info!("Using LMDB backend at: {}", db_path.display()); // Ensure the database directory exists -- cgit v1.2.3