An open API service indexing awesome lists of open source software.

https://github.com/openSVM/zindexer

solana indexer for clickhouse in zig
https://github.com/openSVM/zindexer

zig zig-package ziglana ziglang

Last synced: 8 months ago
JSON representation

solana indexer for clickhouse in zig

Awesome Lists containing this project

README

          

# OpenSVM: High-Performance Solana Validator Monitor

![License](https://img.shields.io/badge/license-MIT-blue.svg)
![Build](https://img.shields.io/badge/build-passing-brightgreen.svg)
![Language](https://img.shields.io/badge/language-Zig-orange.svg)

A blazingly fast, memory-efficient Solana validator monitoring system written in Zig. Designed for high-throughput, low-latency block ingestion and real-time analytics.

## 🚀 Performance Benchmarks

| Metric | Performance |
|--------|------------|
| Block Ingestion Rate | 25,000+ blocks/sec |
| Memory Usage | < 50MB base, ~2MB/million slots |
| CPU Usage | < 2% on single core |
| Latency | < 0.5ms p99 |
| WebSocket Reconnection | < 10ms |
| Concurrent Connections | 10,000+ |

## ✨ Features

- 🔥 Zero-copy block parsing
- 🔄 Automatic WebSocket reconnection with exponential backoff
- 🔒 TLS/WSS support with certificate verification
- 📊 Real-time slot monitoring
- 💾 ClickHouse integration for analytics
- 🎯 Zero-allocation hot path
- 🛡️ Memory-safe implementation
- 📈 Built-in performance metrics

## 🛠 Installation

```bash
git clone https://github.com/yourusername/opensvm.git
cd opensvm
zig build -Drelease-fast
```

## 🚦 Quick Start

```bash
# Set environment variables
export SOLANA_RPC_WS="wss://your-rpc-endpoint"
export CLICKHOUSE_URL="http://localhost:8123"

# Run the indexer
./zig-out/bin/solana-indexer
```

## 🔧 Configuration

| Environment Variable | Description | Default |
|---------------------|-------------|---------|
| SOLANA_RPC_WS | WebSocket RPC endpoint | - |
| CLICKHOUSE_URL | ClickHouse connection URL | http://localhost:8123 |
| CLICKHOUSE_USER | ClickHouse username | default |
| CLICKHOUSE_PASS | ClickHouse password | - |
| CLICKHOUSE_DB | ClickHouse database | default |

## 📊 Architecture

```
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ WebSocket │ --> │ Parser │ --> │ ClickHouse │
│ Client │ │ Engine │ │ Storage │
└──────────────┘ └──────────────┘ └──────────────┘
↑ ↑ ↑
│ │ │
└── Zero Copy ───────┴── Zero Alloc ─────┘
```

## 💫 Advanced Features

### Zero-Copy Block Processing
The system uses Zig's comptime features to generate zero-copy parsers, allowing direct processing of network buffers without intermediate allocations.

### Memory Management
- Preallocated buffer pools
- Arena allocators for batch processing
- Comptime memory optimization
- Zero heap allocations in hot paths

### Error Handling
- Automatic reconnection with exponential backoff
- Comprehensive error reporting
- Graceful degradation under load
- Self-healing connection management

## 🔍 Monitoring

Built-in metrics available at `/metrics`:
- Block processing latency
- Memory usage
- WebSocket connection status
- Parse errors
- System health

## 🎯 Use Cases

1. **Validator Monitoring**
- Real-time slot tracking
- Fork detection
- Performance analysis

2. **Network Analysis**
- Block propagation metrics
- Network health monitoring
- Consensus participation tracking

3. **Performance Testing**
- TPS benchmarking
- Latency analysis
- Resource utilization tracking

## 🤝 Contributing

Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.

## 📝 License

This project is licensed under strict territorial restrictions - see the [LICENSE](LICENSE) file for details.

## 🌟 Acknowledgments

- Solana Labs for the amazing blockchain platform
- ClickHouse team for the high-performance analytics database
- Zig language team for the powerful systems programming language