Bilateral signed interaction ledger implementing IETF draft-pouwelse-trustchain-01, extended with pluggable Sybil-resistant trust computation (NetFlow + MeritRank). No blockchain, offline-capable.
cargo build # debug build
cargo build --release --bin trustchain-node # release binary
cargo test --workspace # run all tests (currently 304)
cargo test --workspace --features mcp # include MCP feature tests
cargo test --workspace --features meritrank # include MeritRank tests
cargo test --workspace --features ipv8 # include IPv8 transport tests
cargo clippy --workspace --all-targets -- -D warnings
cargo fmt --allCI runs tests on ubuntu, windows, macos. Requires protoc on PATH (needed by tonic-build).
| Crate | Role |
|---|---|
trustchain-core |
Identity, HalfBlock, BlockStore, NetFlow trust, MeritRank trust, protocol state machine, delegation |
trustchain-transport |
QUIC (quinn), gRPC (tonic), HTTP REST (axum), transparent proxy (port 8203), IPv8 UDP, MCP server (rmcp) |
trustchain-node |
Binary entry point -- CLI, config, sidecar lifecycle |
trustchain-wasm |
WASM bindings for browser/Node.js |
trustchain-transport feature mcp is optional (rmcp, schemars). Default features off.
trustchain-transport feature ipv8 is optional (sha1). Enables IPv8 UDP transport.
trustchain-core feature meritrank is optional (meritrank crate). Enables MeritRank algorithm.
trustchain-core feature sqlite is on by default; WASM builds disable it.
All timestamps are u64 milliseconds since Unix epoch -- no f64, no seconds. Wire-compatible
with Python SDK (int ms) and TypeScript SDK.
Serialize the block as a BTreeMap<String, Value> (sorted keys), set "signature": "",
serialize with compact separators (serde_json::to_string), SHA-256 the UTF-8 bytes.
Ed25519 signature is over the UTF-8 bytes of the hex-encoded block_hash.
GENESIS_HASH = "0000...0000" // 64 hex zeros -- previous_hash of first block
GENESIS_SEQ = 1 // first valid sequence number
UNKNOWN_SEQ = 0 // proposal's link_sequence_number before agreement replies
MAX_DELEGATION_TTL_MS = 30 * 24 * 3600 * 1000 // 30-day cap, enforced in coreBlockStoreisSendbut NOTSync. Do not add aSyncbound.SqliteBlockStoreusesMutex<Connection>internally.DelegationStoreuses a separatedelegations.dbfile alongsidetrustchain.db.AppStateinhttp.rsis generic:AppState<S: BlockStore, D: DelegationStore>.
- Sub-delegation with empty scope under a restricted parent is scope escalation -> reject.
MAX_DELEGATION_TTL_MSis enforced increate_delegation_proposal()at the core layer, not just the HTTP API, so callers cannot bypass the cap.
- 8000/UDP -- IPv8 peer-to-peer (feature
ipv8, py-ipv8 compatible) - 8200/UDP -- QUIC peer-to-peer
- 8201/TCP -- gRPC
- 8202/TCP -- HTTP REST API
- 8203/TCP -- transparent HTTP proxy (sidecar)
QUIC port offset relative to HTTP port is a configurable constant (QUIC_PORT_OFFSET).
- Run
cargo fmt --allandcargo clippy --workspace --all-targets -- -D warningsbefore every commit. Zero warnings policy -- CI enforces-D warnings. - Use
thiserrorfor library errors,anyhowfor binary/application errors. - Log with
log::warn!/error!(noteprintln!) so the subscriber controls output.
Any change to block field names, hash computation, serialization order, or BlockType string
values MUST be coordinated with the Python SDK (trustchain-py) and TypeScript SDK
(trustchain-js). The canonical JSON format is the cross-language contract.
- Do not change
GENESIS_HASH,GENESIS_SEQ, orUNKNOWN_SEQvalues. - Do not use
f64or seconds for any timestamp field. - Do not add
SynctoBlockStore--SqliteBlockStorecannot satisfy it. - Do not auto-accept delegations or successions on crawl -- require explicit
POST /accept_delegationorPOST /accept_succession. - Do not skip
cargo clippyorcargo fmtbefore committing.