High-performance Electrum protocol server written in Rust for Bitcoin SV
ElectrumR is a ground-up rewrite of the Electrum server concept, built to handle the unique demands of high-throughput blockchains like Bitcoin SV. Where ElectrumX processes blocks sequentially in Python, ElectrumR leverages Rust's zero-cost abstractions, concurrency, and modern async I/O to achieve dramatically higher performance.
Reads blocks directly from bitcoind's .blk files via mmap, bypassing JSON-RPC entirely. 100x faster block retrieval.
4-stage pipeline overlaps I/O with computation: Fetcher → Parser → Prefetcher → Applier.
Data distributed across 16 RocksDB column families for parallel I/O at every layer.
4-level pressure system (Normal/Warning/Critical/Emergency) prevents OOM under pressure.
flushed_height tracking with undo data enables complete state recovery after crashes.
94M cache entries saved in 15s, loaded at 2.8M/sec. >97% hit rate on restart.
Real-time block notifications via ZMQ v2 topics, eliminating 5-second polling delay.
Support for 50,000 concurrent Electrum client sessions via tokio async runtime.
| Aspect | ElectrumX | ElectrumR |
|---|---|---|
| Language | Python 3 | Rust |
| Concurrency | asyncio (single-threaded) | tokio + rayon (multi-threaded) |
| Block Fetching | JSON-RPC only | Direct .blk file reading |
| Sync Architecture | Sequential | Pipelined (fetch→parse→prefetch→apply) |
| Database | LevelDB | RocksDB with 16 shards |
| UTXO Cache | Single-threaded dict | 16-shard LRU with per-shard locks |
| DB Writes | Sequential | Parallel per-shard WriteBatch via rayon |
| Memory Management | Python GC | Manual + adaptive pressure handling |
| Sync Speed | ~1,000-5,000 TPS | 35,000-100,000 TPS |
| CPU Utilization | Single core | All available cores |
| Metric | ElectrumX | ElectrumR | Improvement |
|---|---|---|---|
| Peak TPS | ~5,000 | ~100,000 | 20x |
| Sustained TPS | ~2,000 | ~50,000 | 25x |
| Full Sync Time | ~14 days | ~45 hours | 7x |
| CPU Utilization | 1 core | All cores | N/A |
| Cache Hit Rate | N/A | >97% | N/A |
ElectrumR uses a 5-tier agent architecture where each tier handles a distinct responsibility layer, from low-level storage to client-facing protocols.
+---------------------------------------------------------------+
| Tier 5: Data Access |
| QueryRouter (shard-aware) | MerkleAgent (proofs) |
+---------------------------------------------------------------+
| Tier 4: Client Protocol |
| SessionManager (50K sessions) | ProtocolHandler (JSON-RPC)|
+---------------------------------------------------------------+
| Tier 3: Mempool Pipeline |
| MempoolSync (ZMQ) | MempoolIndex | FeeEstimator |
+---------------------------------------------------------------+
| Tier 2: Block Processing |
| SyncManager | Pipeline | BlockFetcher | BlockParser | UTXO |
+---------------------------------------------------------------+
| Tier 1: Core Infrastructure |
| ShardedDb (RocksDB) | DaemonClient | CacheManager | MemMon |
+---------------------------------------------------------------+
Explore the source code, read the documentation, or dive into the technical architecture behind ElectrumR.