Skip to content

Gossip and Verifiable Aggregation

This layer separates transport from truth. L1 nodes gossip signed events and store nothing durably. L2 nodes order them in sharded, replicated logs, build a searchable state, and prove every answer.

Publishing

An L1 node accepts events over WebSocket, remembers them for ten minutes to prevent rebroadcast loops, gossips them over encrypted Hyperswarm streams, and acknowledges to the author only when at least MIN_ACKS aggregators confirmed durable storage.

L1 nodes do not answer queries. A REQ is closed with a hint to query an aggregator.

Sharding and order

An event belongs to the shard given by the hash of its author's key. The number of shards is a power of two up to 256. Each shard is an Autobase that all L2 nodes write to. Only finalized entries reach the projection.

Projection and proofs

A worker reads the finalized log and writes a SQLite projection with a search index. For every entry it updates a sparse Merkle tree that maps addr/<kind>:<pubkey>:<d> or event/<id> to the current event id, or to deleted. The root combines the tree roots of all shards at their positions.

Verified reads

The verifying client trusts neither the API it asks nor any single indexer:

  1. It queries one L2 API and receives results, a checkpoint and a proof for each result.
  2. It verifies signatures, checks that each result matches the query, and checks each proof against the checkpoint.
  3. It asks several L2 nodes to attest the checkpoint's root, and requires a quorum, which must be a majority of the pinned node keys.
  4. It rejects answers that lag more than MAX_LAG entries (1000) behind.

State queries also prove deletion and absence. Search results report "completeness": "not-proven": proofs show that returned results are correct, not that nothing was left out.

L1 configuration

Variable Meaning
NODE_SEED, CLUSTER, NODES, DHT_BOOTSTRAP Identity and cluster
L1_NODES Keys of all L1 nodes
MIN_ACKS Aggregators that must confirm. 1 by default

GET / reports the node key and the number of connected aggregators and relays.

L2 configuration

As for a sidecar, with L1_NODES and SHARDS.

L2 API

Available over HTTP, and over WebSocket at /v1/ws with messages of the form {"id", "method", "path", "body"}.

Method and path Purpose
GET /v1/status Node, cluster, shards
GET /v1/search q, author, kind, sha256, tag (letter:value), limit (20, max 100). Returns checkpoint, items and proofs
GET /v1/state?key=&author= Value and proof of one key
POST /v1/root Attest the root at a position: {"shards": {"s00": 12}}
POST /v1/members/revoke Revoke a node (admin node, HTTP only, with NODE_TOKEN)

Search page and command line

ui serves a search page and /api/search and /api/state, all through the verifying client. hn is the command-line client:

deploy/scripts/hn.sh search "q=widget"
deploy/scripts/hn.sh state "addr/30500:<author>:<name>"

Publishing a repository

hn author commits a directory with Git, archives it, uploads it by hash, and publishes a signed pointer with the commit, its parent and a change summary. Publishing again replaces the pointer.

deploy/scripts/hn.sh author --repo /work/repo --id my-repo --title "My repo" --store http://assets-0:8080 --relay ws://l1-0:8080
deploy/scripts/hn.sh author --delete --id my-repo --relay ws://l1-0:8080