Chaincraft Rust
Overview
A high-performance Rust-based platform for blockchain education and prototyping. Chaincraft Rust provides a clean, well-documented implementation of core blockchain concepts with a focus on performance, security, and educational value.
Features
- High Performance: Built with Rust for maximum performance and memory safety
- Educational Focus: Well-documented code with clear explanations of blockchain concepts
- Modular Design: Pluggable consensus mechanisms, storage backends, and network protocols
- Cryptographic Primitives: Support for multiple signature schemes (Ed25519, ECDSA/secp256k1)
- Network Protocol: P2P networking with peer discovery and message propagation
- Flexible Storage: Memory and persistent storage options with optional SQLite indexing
- CLI Interface: Easy-to-use command-line interface for node management
Quick Start
Installation
From Crates.io
From Source
Running a Node
Start a Chaincraft node with default settings:
Or with custom configuration:
Generate a Keypair
Usage as a Library
Add Chaincraft Rust to your Cargo.toml
:
[]
= "0.1.0"
Basic Example
use ;
async
Advanced Configuration
use ;
use KeyType;
async
Architecture
Chaincraft Rust is built with a modular architecture:
- Core: Basic blockchain data structures and validation logic
- Consensus: Pluggable consensus mechanisms (currently implementing PoS)
- Network: P2P networking layer with peer discovery
- Storage: Flexible storage backends (memory, persistent, indexed)
- Crypto: Cryptographic primitives and utilities
- CLI: Command-line interface for node management
Features
Default Features
compression
: Enable message compression for network efficiency
Optional Features
persistent
: Enable persistent storage using sledindexing
: Enable SQLite-based transaction indexingvdf-crypto
: Enable VDF (Verifiable Delay Function) support
Enable features in your Cargo.toml
:
[]
= { = "0.1.0", = ["persistent", "indexing"] }
Development
Prerequisites
- Rust 1.70 or later
- Git
Building
Running Tests
# Run all tests
# Run tests with all features enabled
# Run integration tests
Running Benchmarks
Code Coverage
API Documentation
Full API documentation is available on docs.rs.
To build documentation locally:
Examples
Check out the examples/
directory for more usage examples:
basic_node.rs
: Simple node setup and operationcustom_consensus.rs
: Implementing custom consensus mechanismsnetwork_simulation.rs
: Multi-node network simulation
Run examples with:
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Workflow
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Add tests for your changes
- Ensure all tests pass (
cargo test --all-features
) - Run clippy (
cargo clippy --all-features
) - Format your code (
cargo fmt
) - Commit your changes (
git commit -am 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Performance
Chaincraft Rust is designed for high performance:
- Zero-copy serialization where possible
- Efficient async networking with tokio
- Optimized cryptographic operations
- Configurable resource limits
Security
Security is a top priority:
- Memory-safe Rust implementation
- Cryptographic operations use well-audited libraries
- Network protocol includes message authentication
- Input validation and sanitization throughout
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with Tokio for async runtime
- Cryptography powered by RustCrypto
- P2P networking with libp2p
Roadmap
- Advanced consensus mechanisms (PBFT)
- Smart contract support
- Enhanced monitoring and metrics
- WebAssembly runtime integration
For more information, visit our documentation or repository.