Skip to content

cryptuon/blockchain-compression

Repository files navigation

blockchain-compression

Lossless compression for blockchain data -- up to 60:1 ratios with Zstandard and custom dictionaries, built in Rust.

Crates.io docs.rs License: MIT CI

🌐 Site · 📚 Docs · 📦 crates.io · 🔬 Cryptuon Research


Why blockchain-compression?

As chains grow, the cost of storing and moving their history grows with them. Archival nodes, indexers, RPC providers, and DePIN storage networks all pay that bill — and it only goes up. Blockchain data is full of repeated structures -- program IDs, public keys, signatures, common lamport amounts -- that general-purpose compressors don't exploit. This library uses Zstandard with custom dictionaries trained on Solana-specific byte patterns to achieve dramatically better compression ratios while guaranteeing perfect, lossless data integrity.

The measured headline is up to 60:1 on archival workloads with the MaxCompression preset. Ratios elsewhere are workload-dependent — the tables below are honest about that.

Why this matters in 2026

State bloat and data movement are the unglamorous core of blockchain scaling. The 2026 conversation is dominated by agentic payments, verifiable and on-chain AI, RWA, parallel EVM, and atomic composability — but every one of those produces more on-chain state and more history that somebody has to keep. DePIN storage networks and archival infrastructure are where that cost lands. A dictionary-aware, lossless, dependency-light compressor sits squarely in that lane: cheaper archives, cheaper backfills, cheaper cold storage, cheaper data egress between nodes.

See the Roadmap for where this is headed and the cheapest path to a production-grade crate.

How it compares

Run both encoders on a sample of your data — the ratio you measure on your workload is the only one that matters. As a starting point:

Approach Dictionary support Chain-data ratio Tradeoff Maturity
blockchain-compression Solana-tuned dictionaries Highest on Solana-shaped data (up to 60:1 archival, MaxCompression) Ratio gain is largest on repetitive chain data; on arbitrary blobs it falls back to plain zstd Young crate, actively developed
Raw Zstandard Generic dictionaries only Strong general-purpose; no chain-specific priors Excellent all-rounder; leaves chain-pattern ratio on the table Mature, battle-tested
gzip / DEFLATE None; small history window Weakest of the three on chain data Ubiquitous, tiny footprint, decades of track record Very mature (shipped here behind the deflate flag)
No compression 1:1 Zero CPU, maximum storage and egress cost N/A

On arbitrary, non-chain data the custom dictionary neither helps nor hurts — you get vanilla Zstandard. The win is concentrated exactly where chain workloads are repetitive: account snapshots, batched transactions, and archival history.

Quick Start

Add to your Cargo.toml:

[dependencies]
blockchain-compression = { version = "0.1", features = ["zstd"] }

Compress and decompress:

use blockchain_compression::presets::solana::{SolanaCompressor, SolanaPreset};
use blockchain_compression::core::traits::CompressionStrategy;

let mut compressor = SolanaCompressor::new(SolanaPreset::Transactions);

let compressed = compressor.compress(data)?;
let decompressed = compressor.decompress(&compressed)?;
assert_eq!(data, decompressed.as_slice());

Features

  • Blockchain-optimized dictionaries -- custom Zstandard dictionaries for Solana program IDs, signatures, and common patterns
  • 6 compression presets -- from real-time (FastCompression) to archival (MaxCompression)
  • Multiple backends -- Zstandard, DEFLATE, and LZ4 support via feature flags
  • 100% lossless -- rigorous roundtrip validation on every operation
  • Thread-safe -- safe for concurrent usage across threads
  • Trait-based architecture -- composable CompressionStrategy trait for custom implementations

Presets

Preset Zstd Level Compression Ratio Best For
FastCompression 3 5--15:1 Real-time processing
Transactions 3 10--30:1 Transaction data
Instructions 6 10--25:1 Program instructions
Accounts 6 15--40:1 Account state snapshots
Mixed 6 12--35:1 General-purpose
MaxCompression 19 20--60:1 Archival storage

Installation

Enable the compression backend you need:

# Zstandard (recommended)
blockchain-compression = { version = "0.1", features = ["zstd"] }

# DEFLATE
blockchain-compression = { version = "0.1", features = ["deflate"] }

# LZ4
blockchain-compression = { version = "0.1", features = ["lz4"] }

Building and Testing

# Build
cargo build --features zstd

# Run tests
cargo test --features zstd

# Run examples
cargo run --example basic_usage --features zstd
cargo run --example performance_benchmark --features zstd

# Benchmarks
cargo bench --features zstd

Documentation

License

MIT


Part of Cryptuon Research

blockchain-compression is one of 20 open-source blockchain-infrastructure projects from Cryptuon Research — blockchain theory, shipped as protocols.

Related projects: commit-reveal · SolanaVault · Zig-EVM

Docs: docs.cryptuon.com/blockchain-compression · Contact: contact@cryptuon.com

About

Lossless compression for blockchain data — up to 60:1 with Zstandard and custom dictionaries, in Rust.

Topics

Resources

License

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages