Skip to main content

Crate tensor_chain

Crate tensor_chain 

Source
Expand description

TensorChain - Tensor-Native Blockchain for Neumann

A blockchain where transactions have semantic meaning:

  • Query chain by similarity
  • Compress history 100x via quantization
  • Detect semantic conflicts before they happen
  • Smart contracts as geometric constraints

§Architecture

TensorChain
  ├── Chain (block linking via graph edges)
  ├── TransactionManager (workspace isolation)
  ├── Codebook (hierarchical VQ for state discretization)
  ├── ConsensusManager (semantic conflict detection + merge)
  └── Network (distributed consensus via Tensor-Raft)

§Quick Start

use std::sync::Arc;
use graph_engine::GraphEngine;
use tensor_chain::{Chain, Transaction};

// Create a chain backed by a graph engine
let graph = Arc::new(GraphEngine::new());
let chain = Chain::new(graph, "node1".to_string());
chain.initialize().unwrap();

// Build a new block with transactions
let builder = chain.new_block()
    .add_transaction(Transaction::Put {
        key: "users:1".into(),
        data: vec![1, 2, 3],
    });

// Append the block to the chain
let block = builder.build();
chain.append(block).unwrap();

assert_eq!(chain.height(), 1);

Re-exports§

pub use atomic_io::atomic_truncate;
pub use atomic_io::atomic_write;
pub use atomic_io::AtomicIoError;
pub use atomic_io::AtomicWriter;
pub use block::Block;
pub use block::BlockHash;
pub use block::BlockHeader;
pub use block::NodeId;
pub use block::Transaction;
pub use block::ValidatorSignature;
pub use chain::BlockBuilder;
pub use chain::Chain;
pub use chain::ChainIterator;
pub use cluster::ClusterOrchestrator;
pub use cluster::LocalNodeConfig as ClusterNodeConfig;
pub use cluster::OrchestratorConfig;
pub use cluster::PeerConfig as ClusterPeerConfig;
pub use codebook::CodebookConfig;
pub use codebook::CodebookEntry;
pub use codebook::CodebookManager;
pub use codebook::GlobalCodebook;
pub use codebook::GlobalCodebookSnapshot;
pub use codebook::HierarchicalQuantization;
pub use codebook::LocalCodebook;
pub use codebook::LocalCodebookStats;
pub use codebook::PruningStrategy;
pub use consensus::BatchConflict;
pub use consensus::ConflictClass;
pub use consensus::ConflictResult;
pub use consensus::ConsensusConfig;
pub use consensus::ConsensusManager;
pub use consensus::DeltaVector;
pub use consensus::MergeAction;
pub use consensus::MergeResult;
pub use deadlock::DeadlockDetector;
pub use deadlock::DeadlockDetectorConfig;
pub use deadlock::DeadlockInfo;
pub use deadlock::DeadlockStats;
pub use deadlock::DeadlockStatsSnapshot;
pub use deadlock::VictimSelectionPolicy;
pub use deadlock::WaitForGraph;
pub use deadlock::WaitInfo;
pub use delta_replication::DeltaBatch;
pub use delta_replication::DeltaReplicationConfig;
pub use delta_replication::DeltaReplicationManager;
pub use delta_replication::DeltaUpdate;
pub use delta_replication::ReplicationStats;
pub use delta_replication::ReplicationStatsSnapshot;
pub use distributed_tx::lock_handle_current;
pub use distributed_tx::lock_handle_high_water_threshold;
pub use distributed_tx::lock_handle_high_water_warnings;
pub use distributed_tx::AbortRequest;
pub use distributed_tx::CommitRequest;
pub use distributed_tx::CoordinatorState;
pub use distributed_tx::DistributedTransaction;
pub use distributed_tx::DistributedTxConfig;
pub use distributed_tx::DistributedTxCoordinator;
pub use distributed_tx::DistributedTxStats;
pub use distributed_tx::DistributedTxStatsSnapshot;
pub use distributed_tx::EpochMillis;
pub use distributed_tx::KeyLock;
pub use distributed_tx::LockManager;
pub use distributed_tx::ParticipantState;
pub use distributed_tx::PrepareRequest;
pub use distributed_tx::PrepareVote;
pub use distributed_tx::PreparedTx;
pub use distributed_tx::RecoveryStats;
pub use distributed_tx::SerializableLockState;
pub use distributed_tx::ShardId;
pub use distributed_tx::TxParticipant;
pub use distributed_tx::TxPhase;
pub use distributed_tx::TxResponse;
pub use distributed_tx::VoteRecordError;
pub use embedding::EmbeddingError;
pub use embedding::EmbeddingState;
pub use error::ChainError;
pub use error::Result;
pub use geometric_membership::GeometricMembershipConfig;
pub use geometric_membership::GeometricMembershipManager;
pub use geometric_membership::RankedPeer;
pub use gossip::ConnectivityEntry;
pub use gossip::GossipConfig;
pub use gossip::GossipMembershipManager;
pub use gossip::GossipMessage;
pub use gossip::GossipNodeState;
pub use gossip::LWWMembershipState;
pub use hlc::HLCTimestamp;
pub use hlc::HybridLogicalClock;
pub use membership::ClusterConfig;
pub use membership::ClusterView;
pub use membership::HealthConfig;
pub use membership::LocalNodeConfig;
pub use membership::MembershipCallback;
pub use membership::MembershipManager;
pub use membership::MembershipStats;
pub use membership::MembershipStatsSnapshot;
pub use membership::NodeHealth;
pub use membership::NodeStatus;
pub use membership::PartitionStatus;
pub use membership::PeerNodeConfig;
pub use message_validation::CompositeValidator;
pub use message_validation::EmbeddingValidator;
pub use message_validation::MessageValidationConfig;
pub use message_validation::MessageValidator;
pub use metrics::TimingSnapshot;
pub use metrics::TimingStats;
pub use network::AppendEntries;
pub use network::AppendEntriesResponse;
pub use network::BlockRequest;
pub use network::BlockResponse;
pub use network::ChaosStats;
pub use network::CodebookChange;
pub use network::ConfigChange;
pub use network::DataMergeRequest;
pub use network::DataMergeResponse;
pub use network::GeometricTransport;
pub use network::JointConfig;
pub use network::LogEntry;
pub use network::LogEntryData;
pub use network::MemoryTransport;
pub use network::MergeAck;
pub use network::MergeDeltaEntry;
pub use network::MergeFinalize;
pub use network::MergeInit;
pub use network::MergeOpType;
pub use network::MergeViewExchange;
pub use network::Message;
pub use network::MessageHandler;
pub use network::NetworkManager;
pub use network::PeerConfig;
pub use network::PreVote;
pub use network::PreVoteResponse;
pub use network::QueryExecutor;
pub use network::QueryHandler;
pub use network::QueryRequest;
pub use network::QueryResponse;
pub use network::RaftMembershipConfig;
pub use network::RequestVote;
pub use network::RequestVoteResponse;
pub use network::SnapshotRequest;
pub use network::SnapshotResponse;
pub use network::TimeoutNow;
pub use network::Transport;
pub use network::TxAbortMsg;
pub use network::TxAckMsg;
pub use network::TxCommitMsg;
pub use network::TxHandler;
pub use network::TxPrepareMsg;
pub use network::TxPrepareResponseMsg;
pub use network::TxReconcileRequest;
pub use network::TxReconcileResponse;
pub use network::TxVote;
pub use partition_merge::ConflictResolution;
pub use partition_merge::ConflictType;
pub use partition_merge::DataReconcileResult;
pub use partition_merge::DataReconciler;
pub use partition_merge::MembershipReconciler;
pub use partition_merge::MembershipViewSummary;
pub use partition_merge::MergeConflict;
pub use partition_merge::MergePhase;
pub use partition_merge::MergeSession;
pub use partition_merge::PartitionMergeConfig;
pub use partition_merge::PartitionMergeManager;
pub use partition_merge::PartitionMergeStats;
pub use partition_merge::PartitionMergeStatsSnapshot;
pub use partition_merge::PartitionStateSummary;
pub use partition_merge::PendingTxState;
pub use partition_merge::TransactionReconciler;
pub use partition_merge::TxReconcileResult;
pub use raft::FastPathState;
pub use raft::FastPathStats;
pub use raft::HeartbeatStats;
pub use raft::HeartbeatStatsSnapshot;
pub use raft::QuorumTracker;
pub use raft::RaftConfig;
pub use raft::RaftNode;
pub use raft::RaftState;
pub use raft::RaftStats;
pub use raft::RaftStatsSnapshot;
pub use raft::SnapshotMetadata;
pub use raft::TransferState;
pub use raft_wal::RaftRecoveryState;
pub use raft_wal::RaftWal;
pub use raft_wal::RaftWalEntry;
pub use signing::Identity;
pub use signing::PublicIdentity;
pub use signing::SequenceTracker;
pub use signing::SequenceTrackerConfig;
pub use signing::SignedGossipMessage;
pub use signing::SignedMessage;
pub use signing::ValidatorRegistry;
pub use snapshot_buffer::SnapshotBuffer;
pub use snapshot_buffer::SnapshotBufferConfig;
pub use snapshot_buffer::SnapshotBufferError;
pub use snapshot_streaming::deserialize_entries;
pub use snapshot_streaming::serialize_entries;
pub use snapshot_streaming::SnapshotReader;
pub use snapshot_streaming::SnapshotWriter;
pub use snapshot_streaming::StreamingError;
pub use state_machine::TensorStateMachine;
pub use state_root::compute_state_root;
pub use tcp::Handshake;
pub use tcp::LengthDelimitedCodec;
pub use tcp::NodeIdVerification;
pub use tcp::ReconnectConfig;
pub use tcp::SecurityConfig;
pub use tcp::SecurityMode;
pub use tcp::TcpError;
pub use tcp::TcpResult;
pub use tcp::TcpTransport;
pub use tcp::TcpTransportConfig;
pub use tcp::TlsConfig;
pub use tcp::TransportStats;
pub use transaction::apply_transaction_to_store;
pub use transaction::TransactionDelta;
pub use transaction::TransactionManager;
pub use transaction::TransactionState;
pub use transaction::TransactionWorkspace;
pub use tx_id::extract_timestamp_hint;
pub use tx_id::generate_tx_id;
pub use tx_id::is_plausible_tx_id;
pub use tx_wal::OrphanedLock;
pub use tx_wal::PrepareVoteKind;
pub use tx_wal::RecoveredPreparedTx;
pub use tx_wal::TxOutcome;
pub use tx_wal::TxRecoveryState;
pub use tx_wal::TxWal;
pub use tx_wal::TxWalEntry;
pub use validation::FastPathResult;
pub use validation::FastPathValidator;
pub use validation::StateValidation;
pub use validation::TransitionValidation;
pub use validation::TransitionValidator;
pub use validation::ValidationConfig;
pub use validation::ValidationMode;

Modules§

atomic_io
Atomic file operations for crash-safe writes.
block
Block structure for the tensor chain.
chain
Chain structure linking blocks via graph edges.
cluster
Cluster orchestration for distributed Neumann nodes.
codebook
Hierarchical codebook system for state discretization.
consensus
Semantic conflict detection and auto-merge for transactions.
deadlock
Wait-for graph tracking with DFS-based cycle detection for distributed transactions.
delta_replication
Delta-compressed replication for bandwidth-efficient state transfer.
distributed_tx
Cross-shard distributed transactions with 2PC and delta-based conflict detection.
embedding
Embedding state machine for transaction workspaces.
error
Error types for tensor_chain.
geometric_membership
Embedding-aware peer ranking for geometric routing in cluster membership.
gossip
SWIM gossip protocol for scalable cluster membership and failure detection.
hlc
Hybrid Logical Clock (HLC) for distributed timestamp ordering.
membership
Cluster membership management with health checking.
message_validation
Defense-in-depth validation layer for all cluster messages.
metrics
Centralized metrics infrastructure for tensor_chain observability.
network
Network transport abstraction for distributed consensus.
partition_merge
Partition merge protocol for automatic state reconciliation after network heal.
raft
Tensor-Raft consensus implementation.
raft_wal
Write-Ahead Log (WAL) for Raft consensus.
signing
Ed25519 identity management with geometric embedding derivation.
snapshot_buffer
Adaptive memory/disk buffer for snapshot assembly with bounded memory usage.
snapshot_streaming
Memory-efficient streaming serialization for large Raft snapshots.
state_machine
State machine for applying Raft log entries to TensorChain.
state_root
Utilities for computing and validating state roots.
tcp
TCP transport implementation for distributed consensus.
transaction
Transaction workspace for isolated execution and atomic commit.
tx_id
Cryptographically secure transaction ID generation with time ordering.
tx_wal
Write-Ahead Log (WAL) for Two-Phase Commit (2PC) transactions.
validation
Codebook-based transition validation for the tensor chain.

Structs§

AutoMergeConfig
Configuration for automatic merging of orthogonal transactions.
ChainConfig
ChainMetrics
Aggregated metrics from all tensor_chain components.
ChainMetricsSnapshot
Point-in-time snapshot of all chain metrics.
GeometricRoutingConfig
Configuration for geometric routing in distributed operations.
RaftHandle
Handle for a running Raft consensus node.
TensorChain
The main TensorChain interface.

Functions§

quorum_size
Calculate quorum size for a cluster of N nodes.