Skip to content

Crate vyrn log

Amp edited this page Nov 18, 2026 · 1 revision

vyrn-log

Path: crates/vyrn-log · Layer 2 (11 §1.4) · Pinned: no (11 §1.3)

Purpose

vyrn-log is the VYRN log: order-stream encoding with LEB128 deltas, block assembly, the hash chain, block storage, and the readers replay uses. Its byte formats are a contract that every client, the Vx client included, reproduces bit for bit; each module documents its format before its code. Decoding is strict: a decoder accepts exactly the bytes the encoder produces from the same state. Every rejection is a sequencer fault (RepErr), and nothing panics on input bytes.

Spec sections it implements

  • 07 §2, §3, §6.1, §8 (order stream, frames, blocks, storage)
  • 07 §3.8 (step kind payloads), §3.12 (decoder errors stop the vote), §15 (REP_E_* codes)
  • 01 §6.6 (StepRecord), 01 §10 (stream-A on core 4, stream-B on core 7, per 11 §1.3)

Main public types

Type Role
StreamEncoder, StreamDecoder Frame one substream (stream core); decode it in frame_seq order (replica). Both fail closed
Frame, FrameHeader, FrameKind A frame and its 24-byte header
Layout Which lanes each substream carries
StepMerger, MergedStep Join substream A's and B's step halves into whole StepRecords
BlockAssembler, header_hash, check_link Build unsigned 190-byte headers from closed half-blocks; chain rules
BlockStore, MemStore, FileStore Block storage trait; in-memory store; one file per drive, block h on drive h mod drives
LogReader Reads stored blocks in height order, checking order_root and the link
TenureStart, BlockMark Stream records that start a tenure and mark a block
RepErr, StoreError Decoder/stream errors; storage errors

Status on main (a9f0d61)

Implemented. Version 0.1.0 from the workspace; publish = false. The crate docs name no missing piece or follow-up. One error is out of its scope by design: "REP_E_HASHLAG is time-based and raised by the replica, not by this decoder." seq_sig and certificates are the caller's to check. The crate is #![forbid(unsafe_code)].

Tests: tests/golden.rs (9 #[test]), tests/store.rs (12), tests/props.rs (3, proptest), and unit tests in src/leb.rs and src/merge.rs (4). Total: 28 #[test] functions. Golden vectors for independent implementations: tests/golden/vyrn_log_vectors.py and .out.

Depends on

Workspace: vyrn-types, vyrn-crypto. External: thiserror; dev: proptest. This matches 11 §1.4 (layer 2, vyrn-log → vyrn-crypto).

Links

Clone this wiki locally