System overview
The architecture consists of three main layers:Core components
Context
TheContext is the runtime environment that manages async operations and resources.
The Context handles internal resource management, threading, and async task coordination. Create one Context per application instance.
Implementation details
The Context wraps an opaque pointer (TVContext) to the underlying C library’s runtime:
src/context.rs
Socket
TheSocket represents a bound network address for peer-to-peer communication. It uses an async binding model:
Socket binding is fully async and returns a
Future. The address must be an IPv4 or IPv6 address with port — DNS resolution is not performed.Async implementation
The Socket implements a custom Future that polls the FFI layer:src/socket.rs
Engine
TheEngine is the consensus runtime that orchestrates all operations:
Engine lifecycle
The Engine:- Consumes ownership of Socket, Options, and Peers (they’re transferred to the C layer)
- Starts the consensus algorithm and networking threads
- Provides methods to send transactions and receive consensus messages
- Manages peer connections, gossip protocol, and virtual voting
src/engine.rs
FFI layer
The Rust SDK wraps the Tashi Vertex C library using a safe FFI (Foreign Function Interface) design.Opaque pointers
All C types are represented as opaque pointers wrapped in Rust’s type system:Pointer<T> wrapper ensures:
- Type safety: Rust’s type system prevents mixing pointer types
- Automatic cleanup:
Dropimplementations free resources - Null safety: Pointers are verified before use
Memory safety
The SDK provides several safety guarantees:No unsafe in public API
All
unsafe code is encapsulated within the libraryAutomatic cleanup
Resources are freed via
Drop implementationsZero runtime dependencies
Only dynamic linking to the C library
Safe concurrency
Thread-safe by design with proper synchronization
FFI callback pattern
Async operations use a callback pattern to bridge C and Rust:Peer-to-peer networking
Tashi Vertex uses direct peer-to-peer connections for gossip communication.Peer configuration
- Network address: IP and port for connection
- Public key: Ed25519 public key for authentication and signature verification
- Capabilities: Optional flags for special node roles
Connection management
The engine automatically:- Establishes connections to configured peers
- Maintains keep-alive heartbeats
- Reconnects on network failures
- Authenticates all messages cryptographically
Gossip protocol
Peers exchange events using an efficient gossip protocol:- Sync initiation: Node A requests sync with Node B
- DAG comparison: Nodes identify missing events
- Event exchange: Missing events are transmitted
- Signature verification: All events are cryptographically validated
Configuration and tuning
TheOptions type provides 15+ tunable parameters:
Key configuration parameters
Key configuration parameters
Timing controls:
heartbeat_us: Empty event interval when idletarget_ack_latency_ms: Throughput increase thresholdmax_ack_latency_ms: Throughput decrease thresholdthrottle_ack_latency_ms: Emergency throttle threshold
max_unacknowledged_bytes: Buffer size before backpressuretransaction_channel_size: Transaction queue depth
max_blocking_verify_threads: Signature verification threads
enable_dynamic_epoch_size: Auto-adjust epoch length (1-3s)enable_state_sharing: State sync for fallen-behind nodesenable_hole_punching: NAT traversal support
Thread model
Tashi Vertex uses a hybrid threading model:Async runtime threads
Managed by your async runtime (e.g., Tokio):- Socket binding operations
- Message receiving
- Transaction sending
Background threads
Managed internally by the C library:- Gossip protocol execution
- Consensus algorithm computation
- Cryptographic signature verification (when events exceed threshold)
- Network I/O handling
You don’t need to manage these threads directly. The engine coordinates everything automatically.
Error handling
All operations returnResult<T, Error> with detailed error information:
Result type, providing:
- Type-safe error propagation
- Composable error handling with
?operator - Integration with Rust’s error ecosystem
Next steps
Events and transactions
Learn how data flows through the system
Configuration
Explore all engine configuration options