$ show celestiaorg/celestia-node
celestia-node is a Go implementation of Celestia's data availability (DA) node, supporting Bridge, Light, and Full node types. It ingests blocks from a Celestia consensus network (CometBFT), erasure-codes them into Extended Data Squares (EDS), and makes shares available via libp2p-based protocols (Shwap/Shrex, Bitswap). Light nodes perform Data Availability Sampling (DAS) to probabilistically verify block availability without downloading full blocks. The system exposes a JSON-RPC API for blob submission/retrieval, header sync, state queries, and node administration. Architecturally, the application is built with Uber FX dependency injection, composing modules for P2P networking (libp2p with DHT discovery), share exchange, header syncing, state/tx client (gRPC to core), blob service, DAS coordinator, EDS store (file-based with caching), and telemetry (OpenTelemetry, Prometheus). It includes a comprehensive test suite with in-memory mock networks and Docker-based end-to-end tests. While primarily a production blockchain node, it also serves as a reference implementation for Celestia's research protocols (NMT-based proofs, erasure coding, DAS).
The LLM identified 5 files worth highlighting for reuse:
Implements a thread-safe peer pool with EWMA throughput scoring, cooldown, blacklisting, and automatic cleanup of stale peers. Supports multiple input sources (ShrexSub and DHT discovery). The score-based selection and done-callback pattern for updating scores are reusable in any peer-to-peer system that needs adaptive peer ranking.
An LRU cache with reference counting, eviction callbacks, and configurable striped locking for high-concurrency access. Generic interface allows easy integration with any accessor type. Demonstrates non-obvious Go patterns like `sync.Map`-compatible striping and safe concurrent eviction.
Provides a session-based execution pool that serializes operations per key (e.g., per block height) while allowing concurrency across different keys. Uses a `sync.Map` of job channels. Extractable as a general-purpose ordered work queue for systems with per-key ordering requirements.
A configurable exponential backoff implementation with jitter, supporting initial delay, max delay, and multiplier. Provides a simple `Backoff()` method that returns the next delay. Decoupled from any specific use case, making it directly reusable for any retry logic in Go.
Thread-safe JWT token management with permission extraction. Supports token creation with custom claims and verification using HMAC. The permission system is decoupled from the token format. Could be extracted as a standalone library for service authentication.