Skip to content

owl-sol/OWLSOL_CLI

Repository files navigation

🦉 Why OWLSOL?

  • 💰 Save Money: Reduce Solana account rent by 60-80%
  • 🧠 Smart Selection: Automatically chooses the best compression algorithm
  • ⚡ Blazing Fast: Written in Rust for maximum performance
  • 🔒 Data Integrity: Built-in checksums and validation
  • 🎯 Solana-Native: Purpose-built for blockchain data pattern
  • 🔄 Multi-Algorithm: Custom + industry-standard algorithms (LZ4/Zstd)
  • 📦 Minimal Dependencies: Core library stays lean and efficientL-CLI

Intelligent Compression for Solana Account Data

Rust Solana License Build Status

Reduce Solana storage costs by up to 80% with intelligent compression algorithms

FeaturesQuick StartArchitectureBenchmarksDocumentation


🌟 Overview

OWLSOL-CLI is a high-performance, production-ready compression toolkit specifically designed for Solana blockchain applications. It intelligently analyzes your data and automatically selects the optimal compression algorithm, reducing on-chain storage costs while maintaining data integrity.

💡 Why OWLSOL?

  • 💰 Save Money: Reduce Solana account rent by 60-80%
  • 🧠 Smart Selection: Automatically chooses the best compression algorithm
  • ⚡ Blazing Fast: Written in Rust for maximum performance
  • 🔒 Data Integrity: Built-in checksums and validation
  • 🎯 Solana-Native: Purpose-built for blockchain data patterns
  • � Dual-Layer Approach: Combines custom algorithms + Solana-compatible compression (LZ4/Zstd)
  • �📦 Zero Dependencies: Core library has minimal external dependencies

✨ Features

🎨 Multiple Compression Algorithms

Custom Blockchain-Optimized Layer

Algorithm Best For Typical Ratio Speed
Huffman Text, JSON, varied symbols 40-60% ⚡⚡⚡ Fast
Dictionary Repeated patterns, structured data 50-70% ⚡⚡ Medium
RLE Long runs, simple repetition 70-90% ⚡⚡⚡⚡ Fastest

Solana-Compatible Layer

Algorithm Best For Typical Ratio Speed
LZ4 General purpose, balanced 45-65% ⚡⚡⚡⚡ Ultra-fast
Zstd Maximum compression 55-75% ⚡⚡ Medium
Hybrid Mixed data types Best of all ⚡⚡ Medium

💡 Smart Selection: OWLSOL automatically picks the optimal algorithm based on data analysis

🔥 Core Capabilities

  • Intelligent Analysis: Shannon entropy, pattern detection, run-length analysis
  • Auto-Selection: Heuristic-based algorithm selection
  • Data Validation: Checksum verification, size validation
  • Solana Integration: Cost estimation, devnet deployment simulation
  • CLI Interface: Beautiful progress bars, colored output
  • Batch Processing: Compress multiple files efficiently
  • Benchmarking: Performance metrics and reports

🚀 Quick Start

OWLSOL CLI

Install

  • Quick (Linux/macOS):
curl -fsSL https://raw.githubusercontent.com/owl-sol/OWLSOL_CLI/main/scripts/install.sh | bash
  • Manual:
    • Download a tarball from the Nightly release matching your platform:
      • Linux: x86_64-unknown-linux-musl, aarch64-unknown-linux-musl
      • macOS: x86_64-apple-darwin, aarch64-apple-darwin
    • Extract and place owlsol in your PATH.

Usage

owlsol --help
owlsol compress file.txt
owlsol decompress file.txt.owlsol
owlsol --version


#### For Developers

**From source:**
```bash
# Clone the repository
git clone https://github.com/owl-sol/OWLSOL_CLI.git
cd OWLSOL_CLI

# Build the project
cargo build --release

# Run the CLI
./target/release/owlsol --help

# Or install to cargo bin
cargo install --path cli

Basic Usage

# Compress a file (auto-select algorithm)
owlsol compress -i data.json

# Compress with specific algorithm
owlsol compress -i data.json -a huffman

# Compress and show Solana cost savings
owlsol compress -i nft-metadata.json --deploy

# Decompress a file
owlsol decompress -i data.json.owlsol -o restored.json

# Analyze file without compressing
owlsol stats -i data.json --verbose

# Run benchmarks
owlsol benchmark -i data.json -n 100

Example Output

🦉 OWLSOL Compression

✓ Read 2,456 bytes
✓ Compressed in 12.34ms

╔════════════════════════════════════════════════════════════╗
║                  Compression Results                        ║
╠════════════════════════════════════════════════════════════╣
║  Algorithm:          Huffman                                ║
║  Original Size:      2,456 bytes                            ║
║  Compressed Size:    987 bytes                              ║
║  Compression Ratio:  59.81%                                 ║
║  Space Saved:        1,469 bytes                            ║
║  Checksum:           a3f2c891                                ║
╚════════════════════════════════════════════════════════════╝

✓ Saved to data.json.owlsol
  Metadata: data.json.owlsol.meta.json

📡 Solana Cost Analysis
  Compressed:     0.000007 SOL
  Uncompressed:   0.000017 SOL
  💰 Savings:     0.000010 SOL (59.81%)

🏗️ Architecture

System Design

┌─────────────────────────────────────────────────────────────┐
│                      CLI Layer                               │
│  • Argument parsing (Clap)                                   │
│  • User interface & formatting                               │
│  • Progress indicators                                       │
└─────────────────────┬────────────────────────────────────────┘
                      │
┌─────────────────────▼────────────────────────────────────────┐
│                   Core Library                               │
│  ┌───────────────────────────────────────────────────────┐  │
│  │  Compressor (Orchestrator)                            │  │
│  │  • Data validation                                    │  │
│  │  • Analysis → Selection → Compression                │  │
│  │  • Metadata generation                                │  │
│  └───────────────────────────────────────────────────────┘  │
│                                                              │
│  ┌───────────────────────────────────────────────────────┐  │
│  │  Custom Algorithms Layer                              │  │
│  │  • Huffman  • Dictionary  • RLE                       │  │
│  │  (OWLSOL-optimized for blockchain data)               │  │
│  └───────────────────────────────────────────────────────┘  │
│                                                              │
│  ┌───────────────────────────────────────────────────────┐  │
│  │  Industry-Standard Compression Layer                  │  │
│  │  • LZ4 (Facebook's fast compression)                  │  │
│  │  • Zstd (Facebook's high-ratio compression)           │  │
│  │  ⚡ Same algorithms used by Solana internally         │  │
│  └───────────────────────────────────────────────────────┘  │
│                                                              │
│  ┌───────────────────────────────────────────────────────┐  │
│  │  Analyzer & Selector                                  │  │
│  │  • Entropy calculation                                │  │
│  │  • Pattern detection                                  │  │
│  │  • Intelligent algorithm selection                    │  │
│  └───────────────────────────────────────────────────────┘  │
└─────────────────────┬────────────────────────────────────────┘
                      │
┌─────────────────────▼────────────────────────────────────────┐
│                Solana Integration                            │
│  • RPC client wrapper                                        │
│  • Cost calculation                                          │
│  • Devnet deployment                                         │
│  • Compatible with Solana's native compression              │
└──────────────────────────────────────────────────────────────┘

Project Structure

owlsol-cli/
├── cli/                    # 💻 CLI application
│   ├── commands/           # Command implementations
│   │   ├── compress.rs
│   │   ├── decompress.rs
│   │   ├── stats.rs
│   │   └── benchmark.rs
│   └── ui/                 # User interface
│       └── formatter.rs
│
├── core/                   # 🧠 Compression engine
│   ├── algorithms/         # Compression algorithms
│   │   ├── huffman.rs
│   │   ├── dictionary.rs
│   │   ├── rle.rs
│   │   ├── lz4.rs
│   │   └── zstd.rs
│   ├── compressor.rs       # Main orchestrator
│   ├── decompressor.rs     # Decompression logic
│   ├── analyzer.rs         # Data analysis
│   ├── selector.rs         # Algorithm selection
│   ├── metadata.rs         # Metadata structures
│   └── utils/              # Utilities
│       └── bitstream.rs
│
├── solana/                 # 🔗 Solana integration
│   ├── client.rs           # RPC client wrapper
│   └── account.rs          # Account structures
│
└── program/                # 📜 On-chain program (Future)
    └── ...                 # Anchor program

🎯 Algorithm Selection Logic

OWLSOL uses intelligent heuristics to automatically select the best compression algorithm from both layers:

┌──────────────────────────────────────────────────────┐
│         Dual-Layer Algorithm Decision Tree            │
└──────────────────────────────────────────────────────┘

Is entropy > 7.5?
    ├─ YESNONE (random/encrypted data)
    │
    └─ NOContinue analysis
           │
           ├─ Has many repeated sequences? (>5% of data)
           │  └─ YESDICTIONARY (Custom Layer)
           │
           ├─ Has long runs? (max_run > 10 OR avg_run > 3)
           │  └─ YESRLE (Custom Layer)
           │
           ├─ Text-like? (unique_bytes < 128)
           │  └─ YESHUFFMAN (Custom Layer)
           │
           ├─ Need maximum speed?
           │  └─ YESLZ4 (Solana-Compatible Layer) ⚡
           │
           ├─ Need maximum compression?
           │  └─ YESZSTD (Solana-Compatible Layer) 🗜️
           │
           ├─ Mixed patterns?
           │  └─ YESHYBRID (try all, pick best)
           │
           └─ DefaultLZ4 (Solana-Compatible Layer)

Legend:
  Custom Layer          - Optimized for blockchain data patterns
  Solana-Compatible     - Same as Solana internal compression

📊 Benchmarks

Performance metrics on real-world Solana data:

NFT Metadata (500 bytes → 198 bytes)

Algorithm:      Huffman
Compression:    60.4%
Speed:          8.2ms
Solana Savings: 0.000002 SOL

Game Profile (2.4 KB → 640 bytes)

Algorithm:      Dictionary
Compression:    73.3%
Speed:          15.7ms
Solana Savings: 0.000013 SOL

AMM Pool State (8 KB → 1.2 KB)

Algorithm:      Zstd
Compression:    85.0%
Speed:          23.4ms
Solana Savings: 0.000048 SOL

Throughput

Algorithm Compression Decompression
Huffman 45 MB/s 78 MB/s
Dictionary 62 MB/s 85 MB/s
RLE 120 MB/s 150 MB/s
LZ4 95 MB/s 180 MB/s
Zstd 38 MB/s 92 MB/s

Tested on AMD Ryzen 7 5800X, 16GB RAM


🔧 Advanced Usage

Batch Processing

# Compress all JSON files in a directory
for file in solana-accounts/*.json; do
    owlsol compress -i "$file" -a auto
done

Custom Scripts

# Setup Solana devnet
./scripts/setup-devnet.sh

# Run comprehensive benchmarks
./scripts/benchmark-all.sh

# Generate test data
./scripts/generate-test-data.sh

# Run all tests
./scripts/run-tests.sh

Integration with Rust Code

use owlsol_core::{Compressor, CompressionAlgorithm};

fn main() -> anyhow::Result<()> {
    // Auto-select algorithm
    let compressor = Compressor::new();
    let result = compressor.compress(&data)?;
    
    println!("Compressed: {} bytes → {} bytes", 
        result.metadata.original_size,
        result.metadata.compressed_size
    );
    
    // Force specific algorithm
    let result = compressor.compress_with_algorithm(
        &data, 
        Some(CompressionAlgorithm::Huffman)
    )?;
    
    Ok(())
}

🧪 Testing

OWLSOL has comprehensive test coverage:

# Run all tests
cargo test

# Run with output
cargo test -- --nocapture

# Run specific test suite
cargo test --package owlsol-core

# Run benchmarks
cargo bench

Test Coverage

  • ✅ Unit tests for each algorithm
  • ✅ Integration tests for roundtrip compression
  • ✅ Property-based tests with random data
  • ✅ Edge case handling (empty data, corrupted data, etc.)
  • ✅ Performance regression tests

📚 Documentation

API Documentation

# Generate and open documentation
cargo doc --open

Additional Resources


🛣️ Roadmap

✅ Completed (v0.1.0)

  • Core compression engine
  • Huffman, Dictionary, RLE algorithms
  • LZ4, Zstd integration
  • CLI interface
  • Solana cost estimation
  • Comprehensive test suite

🔄 In Progress (v0.2.0)

  • On-chain Solana program (Anchor)
  • Actual on-chain deployment
  • Web dashboard for visualization
  • Performance optimizations
  • Additional algorithms (Brotli, LZ77)

🔮 Future (v1.0.0)

  • Real-time compression for RPC responses
  • Compression-aware Solana SDK
  • Multi-threaded batch processing
  • WASM support for browser use
  • Native macOS/Windows/Linux binaries

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Clone and build
git clone https://github.com/owl-sol/OWLSOL_CLI.git
cd OWLSOL_CLI
cargo build

# Run tests
cargo test

# Check code quality
cargo clippy
cargo fmt --check

Ways to Contribute

  • 🐛 Report bugs
  • 💡 Suggest features
  • 📝 Improve documentation
  • 🔧 Submit pull requests
  • ⭐ Star the repository

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🙏 Acknowledgments

  • Solana Foundation - For the amazing blockchain platform
  • Rust Community - For the excellent ecosystem
  • Data Compression Research - Standing on the shoulders of giants

📞 Contact & Support


🌟 Star History

Star History Chart


Built with ❤️ by the OWLSOL Team

Making Solana storage affordable, one byte at a time 🦉

⬆ Back to Top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published