Skip to content
blockchain-compression cargo add →

// architecture

A trait, some algorithms, and a dictionary.

The crate is deliberately layered. A generic core knows nothing about chains. A Solana preset sits on top and supplies the dictionary. Zstandard does the encoding. Nothing here talks to a validator.

input bytes account / tx data SolanaCompressor presets/solana.rs CompressionStrategy core/ pattern engine Zstd encoder back-references compressed 10–60:1 SOLANA_DICTIONARY built at ::new() ✓ decompress() returns the exact original bytes — round-trip verified on every operation

// the layers

Three modules, one direction of dependency.

// src/core/

Chain-agnostic core

The CompressionStrategy trait and a generic pattern engine. No chain knowledge — reusable machinery for any dictionary.

// src/algorithms/

Aggressive algorithms

EnhancedCTW (context tree weighting), MultiPassCompressor, and PracticalMaxCompression, used mostly by the higher presets and the pattern engine.

// src/presets/solana.rs

The Solana production path

SolanaCompressor constructs a Zstandard dictionary from a hardcoded list of Solana byte patterns at initialization and passes it to the encoder/decoder.

// the dictionary

What Zstandard gets to reference.

The dictionary is a hardcoded constant. There is no online training and no per-customer model, which is what keeps decompression deterministic and the binary self-contained.

Program IDsSystem, Token, Associated Token, Serum DEX, BPF Loader, Config, Vote, Stake
Instruction markersTransfer, Initialize, Close, Approve discriminators
Common amounts0.01, 0.1, 1, and 10 SOL, encoded in lamports
Structure markersSignature-count headers
Character setBase58 alphabet used in Solana address encoding

// backends

Feature-gated codecs.

Backends are Cargo features. The Solana presets require zstd; the trait layer works with whatever you enable.

Feature Default Notes
deflate Yes DEFLATE via flate2. The default backend for the trait layer.
lz4 No LZ4 for throughput-first use. Enable explicitly.
zstd No Required for the Solana dictionary presets. Enable for the headline ratios.

See it against the alternatives.

The dictionary is the whole difference from vanilla zstd and DEFLATE / gzip.