Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Node Implementation Overview

The node implementation (blvm-node) is a minimal, production-ready Bitcoin node that adds only non-consensus infrastructure to the consensus and protocol layers. Consensus logic comes from blvm-consensus, and protocol abstraction from blvm-protocol.

Architecture

The node follows a layered architecture:

graph TB subgraph "blvm-node" NM[Network Manager
P2P networking, peer management] SL[Storage Layer
Block/UTXO storage] RS[RPC Server
JSON-RPC 2.0 API] MM[Module Manager
Process-isolated modules] MP[Mempool Manager
Transaction mempool] MC[Mining Coordinator
Block template generation] PP[Payment Processor
CTV support] end PROTO[blvm-protocol
Protocol abstraction] CONS[blvm-consensus
Consensus validation] NM --> PROTO SL --> PROTO MP --> PROTO MC --> PROTO PP --> PROTO PROTO --> CONS MM --> NM MM --> SL MM --> MP RS --> SL RS --> MP RS --> MC style NM fill:#bbf,stroke:#333,stroke-width:2px style SL fill:#bfb,stroke:#333,stroke-width:2px style RS fill:#fbf,stroke:#333,stroke-width:2px style MM fill:#ffb,stroke:#333,stroke-width:2px style MP fill:#fbb,stroke:#333,stroke-width:2px style MC fill:#bbf,stroke:#333,stroke-width:2px style PROTO fill:#bfb,stroke:#333,stroke-width:3px style CONS fill:#fbb,stroke:#333,stroke-width:3px

Key Components

Network Manager

  • P2P protocol implementation (Bitcoin wire protocol)
  • Multi-transport support (TCP, Quinn QUIC, Iroh)
  • Peer connection management
  • Message routing and relay
  • Privacy protocols (Dandelion++, Fibre)
  • Package relay (BIP331)

Code: mod.rs

Storage Layer

  • Database abstraction with multiple backends (see Storage Backends)
  • Automatic backend fallback on failure
  • Block storage and indexing
  • UTXO set management
  • Chain state tracking
  • Transaction indexing
  • Pruning support

Code: mod.rs

RPC Server

  • JSON-RPC 2.0 compliant API (see RPC API Reference)
  • REST API (optional feature, runs alongside JSON-RPC)
  • Optional QUIC transport support (see QUIC RPC)
  • Authentication and rate limiting
  • Method coverage

Code: mod.rs

Module System

Code: manager.rs

Mempool Manager

  • Transaction validation and storage
  • Fee-based transaction selection
  • RBF (Replace-By-Fee) support with 4 configurable modes (Disabled, Conservative, Standard, Aggressive)
  • Comprehensive mempool policies and limits
  • Transaction expiry
  • Advanced indexing (address and value range indexing)

Code: mempool.rs

Mining Coordinator

  • Block template generation
  • Stratum V2 protocol support
  • Mining job distribution

Code: miner.rs

Payment Processing

  • CTV (CheckTemplateVerify) support
  • Lightning Network integration
  • Payment vaults
  • Covenant support
  • Payment state management

Code: mod.rs

Governance Integration

  • P2P governance message relay
  • Webhook handlers for governance events
  • User signaling support

Code: mod.rs

Design Principles

  1. Zero Consensus Re-implementation: All consensus logic delegated to blvm-consensus
  2. Protocol Abstraction: Uses blvm-protocol for variant support (mainnet, testnet, regtest)
  3. Pure Infrastructure: Adds storage, networking, RPC, orchestration only
  4. Production Ready: Full Bitcoin node functionality with performance optimizations

Features

Network Features

Storage Features

Security Features

Module Features

Mining Features

Payment Features

  • Lightning Network module support
  • Payment vault management
  • Covenant enforcement
  • Payment state machines

Integration Features

  • Governance webhook integration
  • ZeroMQ notifications (optional)
  • REST API alongside JSON-RPC
  • Module registry (P2P discovery)

Node Lifecycle

  1. Initialization: Load configuration, initialize storage, create network manager
  2. Startup: Connect to P2P network, discover peers, load modules
  3. Sync: Download and validate blockchain history
  4. Running: Validate blocks/transactions, relay messages, serve RPC requests
  5. Shutdown: Graceful shutdown of all components

Code: mod.rs

Metrics and Monitoring

The node includes metrics collection:

  • Network Metrics: Peer count, bytes sent/received, connection statistics
  • Storage Metrics: Block count, UTXO count, database size
  • RPC Metrics: Request count, error rate, response times
  • Performance Metrics: Block validation time, transaction processing time
  • System Metrics: CPU usage, memory usage, disk I/O

Code: metrics.rs

See Also