DOCS / PROTOCOL / ARCHITECTURE

Architecture

ShardoChain is a Rust core wrapped by a Go API layer. The two communicate through a stable C ABI generated from the Rust side, giving the Go layer zero-copy access to the consensus state without compromising the single-source-of-truth nature of the Rust code.

Layered view

┌─────────────────────────────────────────────────────────────┐
│  Go API Layer                                               │
│  ──────────────────────                                     │
│  • JSON-RPC :8545 (public)        • REST + Explorer :8080   │
│  • gRPC     :9090                  • WebSocket    :8546     │
└──────────────────────┬──────────────────────────────────────┘
                       │ CGo / FFI (libshardo_ffi.so)
┌──────────────────────┴──────────────────────────────────────┐
│  Rust Core (13 crates, ~42 K LOC)                           │
│  ──────────────────────                                     │
│  shardo-node      — producer + importer + sync + fork-det.  │
│  shardo-consensus — PoH engine, slot schedule, slashing     │
│  shardo-execution — parallel exec, mempool, sig-cache, WASM │
│  shardo-storage   — RocksDB wrapper, block_db, state_db     │
│  shardo-p2p       — libp2p QUIC, gossipsub, peer-cache      │
│  shardo-poh       — SHA-256 verifiable delay function       │
│  shardo-light     — light-client header + QC verifier       │
│  shardo-wallet    — CLI wallet                              │
│  shardo-sdk       — WASM contract macros                    │
│  shardo-ffi       — C ABI for Go bridge                     │
│  shardo-core      — types, crypto, config, consensus_types  │
│  shardo-tools     — stress, soak, smooth-load tools         │
│  shardo-bench     — criterion benchmarks                    │
└─────────────────────────────────────────────────────────────┘

Lifecycle of a transaction

  1. Submit. Client signs SignedTransaction (Ed25519) and POSTs shard_sendRawTransaction to the JSON-RPC endpoint.
  2. Mempool admission. Go API forwards to the embedded RPC at :8547. Rust mempool verifies signature, chain_id, fee floor, sender quota, then appends to the in-memory pool.
  3. Gossip. A GossipMessage::Tx is published on libp2p gossipsub; peers replay the same admission checks.
  4. Block production. Slot leader (computed from (height + view) % active_set.len()) drains TX from mempool, executes them in parallel via Union-Find conflict tracking, and broadcasts a CompactBlock.
  5. Validation. Each peer verifies the block header (parent_hash, state_root, transactions_root, leader_signature, justify_qc), then re-executes locally and confirms the same state_root.
  6. Vote. Each validator emits a PohVote(slot, block_hash, view) Ed25519-signed over the payload.
  7. Quorum + finality. The next block carries the previous block's QC in its justify_qc field. With 2f+1 votes accumulated, the parent is committed.

Storage layout

RocksDB with 25 column families, atomic write batches. Key tables:

TableKeyValue
blocksheight (u64 BE)borsh(BlockHeader)
block_headers_by_hashblock_hash (32 B)borsh(BlockHeader) — append-only
block_bodiesblock_hash (32 B)borsh(transactions)
stateaddress (20 B)borsh(AccountState)
transactionstx_hash (32 B)borsh(SignedTransaction)
receiptstx_hash (32 B)borsh(TxReceipt)
validatorsepoch (u64 BE)borsh(ValidatorSet)
contract_codeaddress (20 B)raw WASM
contract_stateaddress + keyraw bytes
metadataconst keyschain_tip, state_root_xor, …

P2P networking

libp2p QUIC transport on port 30303. Key behaviours:

Consensus

HotStuff-2-style BFT with Proof-of-History clock — see the dedicated pages for full detail:

Determinism guarantees