ElectrumR

High-performance Electrum protocol server written in Rust for Bitcoin SV

50,000+ Transactions/sec
50K Concurrent Sessions
7x Faster Sync

Overview

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.

Features

Direct Block Reading

Reads blocks directly from bitcoind's .blk files via mmap, bypassing JSON-RPC entirely. 100x faster block retrieval.

Pipelined Sync

4-stage pipeline overlaps I/O with computation: Fetcher → Parser → Prefetcher → Applier.

16-Shard Architecture

Data distributed across 16 RocksDB column families for parallel I/O at every layer.

Adaptive Memory

4-level pressure system (Normal/Warning/Critical/Emergency) prevents OOM under pressure.

Crash Recovery

flushed_height tracking with undo data enables complete state recovery after crashes.

UTXO Persistence

94M cache entries saved in 15s, loaded at 2.8M/sec. >97% hit rate on restart.

ZMQ Notifications

Real-time block notifications via ZMQ v2 topics, eliminating 5-second polling delay.

50K Sessions

Support for 50,000 concurrent Electrum client sessions via tokio async runtime.

Performance

ElectrumR vs ElectrumX

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

Sync Speed Metrics

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

Architecture

ElectrumR uses a 5-tier agent architecture where each tier handles a distinct responsibility layer, from low-level storage to client-facing protocols.

ElectrumR Agent Architecture
+---------------------------------------------------------------+
|                    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  |
+---------------------------------------------------------------+

Ready to Get Started?

Explore the source code, read the documentation, or dive into the technical architecture behind ElectrumR.