A production-grade Rust toolkit for Solana infrastructure diagnostics, validator optimization, RPC health checks, caching, metrics, and production-readiness workflows.
solana-validator-optimizer is a modular enhancement suite for Solana validator infrastructure. It helps operators by:
- Prefetching ledger snapshots from trusted mirrors
- Validating snapshot integrity via SHA-256
- Auto-tuning validator configuration based on hardware resources
- Adding an in-memory LRU cache for frequently used RPC calls
- Exposing Prometheus metrics via a
/metricsendpoint
This project targets the Solana / Agave v3 validator era.
- Solana crate line: 3.0.x
- Recommended validator line: v3.0.14 (Mainnet-Beta recommended)
- Tested against:
- Mainnet RPC: https://api.mainnet-beta.solana.com
- solana-test-validator (local)
- Solana Validator Operators
- RPC Infrastructure Maintainers
- Performance-Focused Mainnet/Devnet Deployments
| Feature | Description |
|---|---|
| Snapshot Prefetching | Downloads or copies snapshots locally with optional SHA-256 validation |
| RPC LRU Cache | Reduces redundant RPC calls like getBalance, getEpochInfo, etc. |
| Prometheus Metrics | /metrics endpoint for cache hits, misses, request counts, and latency |
| Config Auto-Tuner | Adjusts validator configuration based on CPU, RAM, disk, and network |
| RPC Health Checker | Checks RPC endpoint health, Solana version, current slot, latest blockhash availability, and latency across key RPC calls |
git clone https://github.com/0rlych1kk4/solana-validator-optimizer.git
cd solana-validator-optimizerCreate a Config.toml file in the project root:
# Config.toml
# Snapshot settings
snapshot_url = "" # e.g. "https://snapshots.myvalidator.com/latest.tar.zst"
snapshot_sha256 = "" # optional SHA-256 checksum for validation
# RPC and Metrics
rpc_url = "https://api.mainnet-beta.solana.com"
metrics_port = 9090 # Prometheus scrapes at http://<host>:9090/metrics
# Cache settings
cache_size = 128 # Number of entries in the RPC LRU cacheRun all modules (snapshot, RPC cache, auto-tuner, metrics):
cargo run -p solana-validator-optimizer-cli --releaseAdd this to your Cargo.toml:
[dependencies]
solana-validator-optimizer = "1.2"
tokio = { version = "1", features = ["full"] }
anyhow = "1"Example usage:
use solana_validator_optimizer::{
config::AppConfig,
snapshot_prefetcher,
rpc_cache_layer,
metrics,
config_autotuner,
};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Load configuration from Config.toml and/or OPTIMIZER_* env vars
let cfg = AppConfig::load()?;
// Prefetch snapshot (no-op if snapshot_url is empty)
snapshot_prefetcher::run(&cfg).await?;
// Auto-tune configuration (currently informational)
config_autotuner::autotune_config(&cfg).await?;
// Start background RPC cache workers
rpc_cache_layer::start_rpc_cache(&cfg).await?;
// Start Prometheus metrics server (blocks)
metrics::start_metrics_server(&cfg).await?;
Ok(())
}Check the configured Solana RPC endpoint from Config.toml:
cargo run -p solana-validator-optimizer-cli -- rpc-healthExample output:
Solana RPC Health Report
Endpoint: https://api.mainnet-beta.solana.com
Healthy: true
Health Status: ok
Solana Version: 4.0.0
Current Slot: 422507351
Latest Blockhash: C5cWMY4npRumFBVjaGF1Su3xQHyXshF7LL93S7yCo29m
getHealth Latency: 622 ms
getVersion Latency: 216 ms
getSlot Latency: 207 ms
getLatestBlockhash Latency: 306 msUse a custom endpoint:
cargo run -p solana-validator-optimizer-cli -- rpc-health \
--endpoint https://api.mainnet-beta.solana.comOutput as JSON:
cargo run -p solana-validator-optimizer-cli -- rpc-health --jsonThe RPC Health Checker helps Solana infrastructure teams validate endpoint health, blockhash availability, and latency before transaction submission or production deployment.
Any Config.toml value can be overridden using the OPTIMIZER_ prefix.
| Config Key | Environment Variable |
|---|---|
| snapshot_url | OPTIMIZER_SNAPSHOT_URL |
| snapshot_sha256 | OPTIMIZER_SNAPSHOT_SHA256 |
| rpc_url | OPTIMIZER_RPC_URL |
| metrics_port | OPTIMIZER_METRICS_PORT |
| cache_size | OPTIMIZER_CACHE_SIZE |
Example:
OPTIMIZER_RPC_URL=https://api.mainnet-beta.solana.com \
OPTIMIZER_CACHE_SIZE=256 \
cargo run --releasePrometheus endpoint:
http://<host>:<metrics_port>/metricsrpc_requests_totalrpc_cache_hits_totalrpc_cache_misses_total
Enable Prometheus metrics endpoint:
cargo run -p solana-validator-optimizer-cli --release --features metrics -- --config Config.toml run
curl -s http://127.0.0.1:9090/metrics | grep rpc_Contributions are welcome!
Feel free to open issues, feature requests, or pull requests.
Licensed under the MIT License.
