Skip to main content

Crate tenzro_storage

Crate tenzro_storage 

Source
Expand description

State storage layer for Tenzro Network

This crate provides the storage infrastructure for the Tenzro Network blockchain, including:

  • Key-Value Store: Abstract storage layer with RocksDB and in-memory implementations
  • Merkle Patricia Trie: Efficient state commitment and proof generation
  • Block Storage: Indexing and retrieval of blocks by hash and height
  • Account Storage: Management of account state and balances
  • Snapshots: State snapshot creation and restoration

§Architecture

The storage layer uses RocksDB with multiple column families to organize different data types. It provides async/await interfaces for all storage operations.

§Example

use tenzro_storage::{
    config::StorageConfig,
    kv::{RocksDbStore, MemoryStore},
    block_store::BlockStoreImpl,
    account_store::AccountStoreImpl,
    traits::{BlockStore, AccountStore},
};
use std::sync::Arc;
use std::path::PathBuf;

// Create a storage configuration
let config = StorageConfig::new(PathBuf::from("./data/tenzro-db"));

// Open the RocksDB store
let kv_store = Arc::new(RocksDbStore::open(&config)?);

// Create block and account stores
let block_store = BlockStoreImpl::new(kv_store.clone())?;
let account_store = AccountStoreImpl::new(kv_store.clone());

// Use the stores...

Re-exports§

pub use config::StorageConfig;
pub use error::Result;
pub use error::StorageError;
pub use traits::AccountStore;
pub use traits::BlockStore;
pub use traits::StateStore;
pub use kv::KvStore;
pub use kv::RocksDbStore;
pub use kv::MemoryStore;
pub use kv::WriteOp;
pub use kv::CF_BLOCKS;
pub use kv::CF_STATE;
pub use kv::CF_ACCOUNTS;
pub use kv::CF_TRANSACTIONS;
pub use kv::CF_METADATA;
pub use kv::CF_SNAPSHOTS;
pub use kv::CF_IDENTITIES;
pub use kv::CF_DELEGATIONS;
pub use kv::CF_CREDENTIALS;
pub use kv::CF_CHANNELS;
pub use kv::CF_AGENTS;
pub use kv::CF_MODELS;
pub use kv::CF_PROVIDERS;
pub use kv::CF_TASKS;
pub use kv::CF_AGENT_TEMPLATES;
pub use kv::CF_SKILLS;
pub use kv::CF_TOOLS;
pub use kv::CF_KNOWLEDGE;
pub use kv::CF_WORKFLOW_TEMPLATES;
pub use kv::CF_TOKENS;
pub use kv::CF_SETTLEMENTS;
pub use kv::CF_MODEL_SERVICES;
pub use kv::CF_NFTS;
pub use kv::CF_EVENTS;
pub use kv::CF_WEBHOOKS;
pub use kv::CF_COMPLIANCE;
pub use kv::CF_TRAINING_RUNS;
pub use kv::CF_TRAINING_RECEIPTS;
pub use kv::CF_AUDIT;
pub use kv::CF_APPROVALS;
pub use kv::CF_API_KEYS;
pub use kv::CF_MPC_KEYSHARES;
pub use kv::CF_CANTON_ANALYTICS;
pub use kv::CF_BRIDGE_ANALYTICS;
pub use kv::CF_VALIDATOR_MODULES;
pub use merkle::MerklePatriciaTrie;
pub use merkle::MerkleProof;
pub use merkle::ProofNode;
pub use block_store::BlockStoreImpl;
pub use account_store::AccountStoreImpl;
pub use account_store::StateStoreImpl;
pub use snapshot::Snapshot;
pub use snapshot::SnapshotManager;
pub use snapshot::SnapshotMetadata;
pub use snapshot::CompressionType;
pub use snapshot::SnapshotRestorer;
pub use snapshot::RestoredState;
pub use snapshot::SnapshotEntry;
pub use snapshot::serialize_snapshot_entries;
pub use da::compute_commitment;
pub use da::DaBackend;
pub use da::DaBackendId;
pub use da::DaBackendStatus;
pub use da::DaPointer;
pub use da::InlineFallbackBackend;
pub use da::MandateRef;
pub use da::ReceiptEnvelope;
pub use da::ReceiptKind;
pub use da::ReceiptStorageMode;
pub use da::ReceiptSummary;

Modules§

account_store
Account state storage implementation for Tenzro Network
block_store
Block storage implementation for Tenzro Network
config
Storage configuration for Tenzro Network
da
Data availability primitives for receipt offload (Spec 7).
error
Error types for Tenzro Network storage layer
kv
Key-value store abstraction for Tenzro Network
merkle
Merkle Patricia Trie implementation for Tenzro Network
snapshot
State snapshot management for Tenzro Network
traits
Storage trait definitions for Tenzro Network

Constants§

DEFAULT_SNAPSHOT_RETENTION
Default snapshot retention count
MAX_CACHE_SIZE
Maximum cache size for the storage layer (in bytes)
STORAGE_VERSION
Storage version for compatibility tracking