# SLNN Communication Protocol Date: 2026-08-29 (status corrected 2026-09-06) Status: implemented and tested over both the in-memory (Aether) transport and a real TCP socket transport (`src/network/tcp.ts`). Frames are sealed with the session key. Block sync is implemented (Verdandi). See `docs/book/NETWORK.md` for the authoritative, line-cited reference; where this document and the code disagreed, the code was ground truth and this document has been corrected to match it. The node-to-node protocol for the SourceLess network. It is assembled from components already in the tree — Praeco for discovery, hybrid PQ signatures for identity, ML-KEM for session keys, the recursive checkpoint for following the chain — rather than bolted on. --- ## 1. Addressing — `str://` The architecture requires non-HTTP/HTTPS addressing, so a peer is named by identity first: ``` str://@/: str://STR.GENESIS0022@tcp/node.slnn:9111 ``` The node id is the address. `host:port` is only where it currently answers, so a node that moves keeps its identity. Transports: `tcp`, `ws`, `wss`, `mesh` (SLNN Mesh), `memory`. ## 2. Protocol ids `str.dom.host` in the SourceLess org is a libp2p fork, so SLNN follows libp2p conventions — versioned ids negotiated per stream, letting two versions coexist during a rollout: | Protocol | Purpose | Payload cap | |----------|---------|-------------| | `/sourceless/handshake/1.0.0` | mutual authentication | 16 KB | | `/sourceless/praeco/1.0.0` | peer exchange | 128 KB | | `/sourceless/tx/1.0.0` | transaction gossip | 64 KB (65,536) | | `/sourceless/identity/1.0.0` | STR.domain allocations and registrations | 4 KB (4,096) | | `/sourceless/ghost/1.0.0` | Ghost Ledger pre-confirmations | 32 KB (32,768) | | `/sourceless/block/1.0.0` | block propagation | 523,235 | | `/sourceless/attest/1.0.0` | PoE witness attestations | 16 KB (16,384) | | `/sourceless/sync/1.0.0` | block-range sync (Verdandi) | 523,235 | | `/sourceless/ping/1.0.0` | liveness | 1 KB (1,024) | Caps are `PROTOCOL_LIMITS` in `src/network/protocol.ts`. The earlier draft omitted the `identity` protocol entirely and gave `sync` a 64 KB cap; `sync` carries block ranges and its cap is `MAX_FRAME_BYTES - SEALING_HEADROOM_BYTES = 523,235`, the same ceiling as `block`. ## 3. Frame format ``` magic 4 bytes "SLNN" version 1 byte ttl 1 byte protoLen 1 byte + protocol id (utf8) messageId 16 bytes bodyLen 4 bytes (big endian) body canonical JSON (utf8) ``` Three properties matter more than the layout: - **The length prefix precedes the body**, so a node rejects an oversized frame from the header alone, without allocating for it. This is what keeps a small node safe on an open port — and it is a bound on the *unallocated* refusal, not a bound on the node's memory: the reassembly buffer a frame does legitimately reach is 524,292 bytes per connection and appears in no budget (§5). - **The message id commits to the payload** (`sha256(protocol|canonical(payload))`). A relay that alters a body while keeping the id produces a frame that fails to decode — tested. - **TTL bounds propagation.** A frame at 0 hops is delivered but never forwarded, so a cycle in the peer graph terminates even when two peers both consider a message new. ## 4. Handshake — three legs, mutual ``` A ──── challenge (nonce_A, identity_A, chainId, genesisHash) ───▶ B A ◀─── response (nonce_B, identity_B, KEM ct, checkpoint, sig) ── B A ──── confirm (nonce_A, nonce_B, identity_A, sig) ───────────▶ B ``` Each side signs a nonce the **other** chose, with a hybrid ed25519 + ML-DSA signature where both halves must verify. > The first implementation had only two legs. The dialer never proved anything, yet the > responder had to accept its frames — an unauthenticated peer with a live channel. The > integration test caught it. The responder now opens no session until the confirm leg > verifies, and the confirm identity must match the one that issued the challenge. Also established before any application byte: - **Network agreement** — chain id and genesis hash must match exactly; a mismatch disconnects rather than partially trusting. - **Rule agreement** — `consensusRuleVersions`, the consensus rule versions each build can APPLY, compared as an exact set rather than intersected. This is a different question from network agreement and was the one that was missing: chain id and genesis say two nodes follow the same history, and say nothing about whether the two will fold the next block into the same state root. Measured before it existed: `protocol.ts`, `bifrost.ts`, `praeco.ts` and `rhea.ts` were byte-identical between a deployed build and the tree, so the version matched, the genesis matched, the protocol intersection was complete — and the two builds could not agree on a state root. Every gate that worked was one that could not see it. It is inside the signed transcript, so adding it changed what both sides sign: a node on `slnn-handshake-3.0.0` holds no session with one on `2.0.0`, in either direction, and neither spends lattice cryptography on the other. That is a flag day and it was taken deliberately — a mesh upgrades in one window, because a partially upgraded mesh is partitioned by build. **Since the tolerant release (`docs/design/TOLERANT_RULE_HANDSHAKE.md`) the exact-set rule is the fallback, not the rule.** A node that knows its realm's schedule — every node `hestia.ts` starts — declares only the versions it implements that are not newer than the one in force at its next height, and refuses a peer only for a version the NEXT block needs: this node lacks it and the peer has it, or the peer lacks it where that cannot be a peer that is merely behind. Implementing more than a peer is no longer a refusal, so a build carrying a rule version that is not yet in force — scheduled or not — joins the live mesh on the wire it already speaks, and a seat on a build from before the tolerant release is refused only from the height before the activation, the first height at which it cannot follow the chain anyway. No wire field, transcript byte or `BIFROST_VERSION` changed; `src/network/bifrost-rules.ts`. What it does **not** buy: a build difference that is not registered in `src/core/logretta.ts` does not move `implementedRuleVersions()` and is therefore not refused by this field. The mechanism turns a REGISTERED divergence into a named refusal; registering one is a core and governance act, not a network one. - **Capabilities** — tier, protocols and validation power, so a mini node is never asked to serve chain sync. - **Session key** — **hybrid ML-KEM-768 + X25519** encapsulation against the peer's KEM key (`encapsulateHybrid`, imported by `src/network/bifrost.ts`), bound to both nonces and both node ids, so the same KEM secret in another context yields a different key. Breaking it means breaking **both** primitives, not either. A quantum adversary recording the link today does not recover it later. *(This said bare ML-KEM-768 until 2026-09-13; the combiner landed and the sentence did not move. The version field records the change.)* `BIFROST_VERSION` is `slnn-handshake-3.0.0`. Replay is bounded by a 30-second challenge window, and a response is refused if it echoes a different nonce. ## 5. Node tiers and the under-1MB claim The architecture specifies compact nodes "strictly maintained under 1 MB" for edge and IoT hardware, with STARW Worker Nodes as the validation engine and STARW Super Nodes above them. **Which quantity, because four are possible and two of them are false.** Measured 2026-09-12 on darwin 25.6.0 / Node v22.22.3, from `dist/` at the head of `main` (`docs/reality/NODE_AND_HOSTLESS.md`): | What a reader could understand by "a node under 1 MB" | Measured | Under 1,048,576 bytes? | |---|---|---| | the **process's resident memory** | **94,224,384 bytes** (`strblk node --class pulsar --dev`, separate process, `ps -o rss`) | **no — by ~90×**, and nothing in this repository measures or bounds it | | the **accounted retention**, which is what `MnemosyneAccount` reports and what the table below budgets | 0 at rest; **20,659 → 25,853 bytes** following 61 real blocks with one peer; **649,861 bytes** at the worst case the class's own caps allow, re-measured 2026-09-12 from the real structures rather than from five constants | **yes**, with 66,939 bytes of a 716,800-byte budget to spare | | the **data directory** | **20,221 bytes** (`identity.json` 19,903 + `.cerberus.lock` 318), constant while a supernova at the same height held 131,469 | **yes** | | the **download** | `dist/` **13,365,248 bytes** + `node_modules` 71,503,872; the packaged binary is recorded at 131.1 MB in `docs/BUILD_STATUS.md` and was not re-measured | **no — by ~12×** | Everything below this table is about the second row. The sentence the architecture wrote is about the first, and on the first this implementation does not hold. | | mini | worker | super | |---|---|---|---| | retention budget | 700 KB | 256 MB | 4 GB | | max peers | 24 | 128 | 512 | | retained blocks | 0 | 4,096 | all | | full state | no | yes | yes | | produces blocks | no | yes | yes | | serves sync | no | yes | yes | | default power | 10 | 50 | 100 | **The accounted retention is measured, not asserted.** `MnemosyneAccount` (the renamed `RetentionAccount`, `src/network/mnemosyne.ts`) sizes each bucket from its canonical serialization — the same bytes that would hit disk or the wire. It has two write paths: `setBytes`, which *refuses* a write that would breach the cap and leaves no residue, and `observeBytes`, which *records what a bucket actually holds* and lets `withinBudget` report a breach without refusing anything. Every production caller on the running node path in `src/network/` uses `observe*`, not `setBytes`, because the accounting runs inside the transport's receive handler where a thrown or silently refused write is worse than an honest over-budget report (`mnemosyne.ts:167-183`). So on the running path the budget is a **report**, and what actually holds a node inside it is the structural caps (`maxPeers`, `maxDirectoryRecords`, `maxSeenMessages`, `maxBuckets`, the gossip mempool bounds). The earlier claim that the account "refuses the write" on the network path was false. **That is a settled decision as of 2026-09-12, not an open gap, and it is recorded where a build checks it.** `setBytes`, `wouldFit`, `MnemosyneBudgetExceeded` and `urdCheckpointBytes` each carry a `dormant` row in `src/ops/control-register.ts`, so wiring one turns the build red until somebody records which disposition it came back with. Two things decided it. First, a refusal at the nine `observeBytes` sites could not refuse anything: every one of them reports the size of a structure that is already in memory, so the only available behaviours are a throw inside the transport's receive handler — where every honest node running this code stops at the same frame a peer sent — or a bucket left at its old value, which makes `withinBudget` say yes about a node that is over. Second, the caps the node relies on instead were measured and are livable: driving the real `RatatoskrRouter` and the real `VerdandiSync` to a Pulsar's own caps produces **649,861 bytes**, or **90.7%** of the 716,800-byte budget, with 66,939 to spare. Enforcing the byte total on top of that would convert a report into a remotely-triggerable halt with 9% of margin. **The worst case is 26,240 bytes higher than the figure previously quoted here**, and the reason is worth keeping: 623,232 was a product of five class constants, and the structures themselves charge 40 bytes a remembered message where that arithmetic charged 32, 56 bytes a Gleipnir bucket where it charged 40, and 320 bytes a sync peer where it charged 160. It was a lower bound being read as a ceiling. Both figures and the method are in `tests/integration/mnemosyne-retention-disposition.integration.test.ts`. A mini node's **chain-derived** retention stays constant forever because the recursive checkpoint is constant size: a test follows 40 blocks and the retained checkpoint changes by under 16 bytes, and on a real socket over 61 real blocks the bucket moved 387 → 389 bytes — the digits in the height and folded-block count. The rest of the accounted retention does grow, with peer traffic rather than with height, and is capped by the class: the `gossip` bucket went 496 → 5,688 bytes over those same 61 blocks as the seen cache filled toward its 512-message ceiling. Peer counts are sized from the observed topology — ~26,260 links across 1313 nodes is about 20 peers each. What is **outside** the accounted retention, and therefore outside every figure in this section: the TCP reassembly buffers (`MAX_REASSEMBLY_BYTES` is 524,292 per connection and `RuneReassembler.capacity` is exposed and read by nothing), the socket write queues (`MAX_WRITE_QUEUE_BYTES` is 4,194,304 per peer), the in-flight handshake tables, and the Node and V8 heap — of which a ~60 MiB baseline was observed before any node object existed. Those are products of code constants rather than measurements of a running node, and the peak memory of a saturated Pulsar is **unmeasured**. `docs/book/NETWORK.md` §10.3 carries the arithmetic. Granted power (the 21 special domains carry 70–100) is honoured but capped by tier, so a mini node handed supernode weight still validates at its tier. ## 6. Gossip Every structure is bounded, because uptime must not become memory growth: - **Seen cache** — bounded FIFO, oldest evicted. A node running for a year uses the same memory as one started an hour ago. - **Per-peer token buckets** — one flooding peer is throttled without touching another's budget; tokens refill over time. - **Propagation tracking** — a message is never relayed back to a peer already known to have it. ## 7. Validation before relay A payload is validated for its protocol before it is forwarded. An invalid transaction or a forged attestation is dropped at the first honest node, so bad data does not consume the network's bandwidth: - `tx` — full stateless validation, including signature and chain-id binding - `attest` — the witness signature must verify against the block hash - `praeco` — records are re-verified by the directory, never trusted because a peer relayed them - `sync` — the checkpoint must deserialize into a well-formed proof ## 8. What is not built Three items listed here in the original draft have since shipped and are struck from the list: a TCP socket transport (`src/network/tcp.ts`, exercised over real sockets in `tests/integration/tcp.integration.test.ts`); frame sealing with the session key (`sealFrame` / `openFrame` in `src/network/bifrost.ts`, applied to every application frame through `StarwNode.deliver`); and block-range sync (`src/network/verdandi.ts`, which requests and streams bounded ranges of blocks, not merely head advertisements). What remains not built: - **WebSocket (`ws`/`wss`) and SLNN Mesh transports.** `TransportKind` names them and `parseStrAddress` accepts them, but only `tcp` and `memory` have implementations; an address naming one of the other three parses and then cannot be dialled. - **No forward secrecy in the sealed link.** The session key rests on the node's long-lived, on-disk KEM keypair; there is no ephemeral key and no rekey. ~~Confidentiality also rests on bare ML-KEM-768 rather than the hybrid combiner.~~ **That second clause is no longer true and is struck rather than deleted: the hybrid combiner shipped, and confidentiality now rests on ML-KEM-768 **and** X25519 together.** The forward-secrecy limit above is unaffected and stands — a hybrid key with no ephemeral half is still a key that does not rotate. Set out in `docs/book/NETWORK.md` §4.2 and §11.2 and, for the forward-secrecy cost, next to `deriveSessionKey` in `bifrost.ts`. - **No NAT traversal, no connection pooling, no backpressure** beyond rate limiting and the outbound write-queue bound.