synor/crates/synor-storage/src/lib.rs
Gulshan Yadav a7a4a7effc test: add comprehensive test suite (1,357 tests total)
Phase 1 - Test Writing (8 parallel agents):
- synord: Added 133 unit tests for node, config, services
- synor-rpc: Expanded to 207 tests for API endpoints
- synor-bridge: Added 144 tests for transfer lifecycle
- synor-zk: Added 279 tests for circuits, proofs, state
- synor-mining: Added 147 tests for kHeavyHash, miner
- synor-types: Added 146 tests for hash, amount, address
- cross-crate: Created 75 integration tests
- byzantine: Created 40+ fault scenario tests

Key additions:
- tests/cross_crate_integration.rs (new)
- apps/synord/tests/byzantine_fault_tests.rs (new)
- crates/synor-storage/src/cf.rs (new)
- src/lib.rs for workspace integration tests

Fixes during testing:
- synor-compute: Added Default impl for GpuVariant
- synor-bridge: Fixed replay protection in process_lock_event
- synor-storage: Added cf module and database exports

All 1,357 tests pass with 0 failures.
2026-01-20 06:35:28 +05:30

97 lines
2.7 KiB
Rust

//! Synor Storage Layer
//!
//! Decentralized storage network for the Synor blockchain ecosystem.
//! Enables permanent, censorship-resistant storage of any file type.
//!
//! # Architecture
//!
//! The storage layer operates as L2 alongside the Synor blockchain (L1):
//! - **Content Addressing**: Files identified by cryptographic hash (CID)
//! - **Erasure Coding**: Data split with redundancy for fault tolerance
//! - **Storage Proofs**: Nodes prove they're storing data to earn rewards
//! - **Gateways**: HTTP access for web browsers
//!
//! # Example
//!
//! ```rust,ignore
//! use synor_storage::{ContentId, Chunker, StorageClient};
//!
//! // Upload a file
//! let data = std::fs::read("myfile.zip")?;
//! let cid = ContentId::from_content(&data);
//! client.store(cid, &data).await?;
//!
//! // Retrieve by CID
//! let retrieved = client.retrieve(&cid).await?;
//! ```
pub mod cid;
pub mod chunker;
pub mod erasure;
pub mod proof;
pub mod deal;
pub mod error;
// Database layer for blockchain state
pub mod cf;
pub mod db;
pub mod stores;
// CAR file support for trustless verification
pub mod car;
// Multi-pin redundancy service
pub mod pinning;
// Node module - storage node implementation
pub mod node;
// Gateway module - HTTP access to stored content
pub mod gateway;
pub use cid::ContentId;
pub use chunker::{Chunk, Chunker};
pub use error::{Error, Result};
pub use node::{NodeConfig, StorageNode, NodeState, NodeStats};
pub use gateway::{Gateway, GatewayConfig, GatewayStats, CdnConfig, CdnProvider, SubdomainRoute};
// CAR exports
pub use car::{CarFile, CarBlock, CarBuilder, CarHeader, TrustlessResponse};
// Pinning exports
pub use pinning::{
PinManager, PinManagerConfig, PinRecord, PinRequest, PinSummary, PinStatus,
RedundancyLevel, Region, StorageNode as PinStorageNode,
};
// Database exports for blockchain state storage
pub use db::{Database, DatabaseConfig, DbError, keys};
pub use stores::{
BlockBody, BlockStore, ChainState, ContractStateStore, ContractStore, GhostdagStore,
HeaderStore, MetadataStore, RelationsStore, StoredContract, StoredGhostdagData,
StoredRelations, StoredUtxo, TransactionStore, UtxoStore,
};
/// Storage layer configuration
#[derive(Debug, Clone)]
pub struct StorageConfig {
/// Chunk size in bytes (default: 1MB)
pub chunk_size: usize,
/// Number of data shards for erasure coding
pub data_shards: usize,
/// Number of parity shards for erasure coding
pub parity_shards: usize,
/// Replication factor (copies per shard)
pub replication_factor: usize,
}
impl Default for StorageConfig {
fn default() -> Self {
Self {
chunk_size: 1024 * 1024, // 1 MB
data_shards: 10,
parity_shards: 4,
replication_factor: 3,
}
}
}