Files
zeekay ca4572759c Every Rust chain reads and writes the wire a schema states
The P-chain, the Z-chain and the F-chain join the Q and X chains: what each
puts on a wire is stated once in chains/schema, and zapgen writes the
accessors. Five schemas, five emitted modules, and one runtime under all of
them — chains/rust/zap, also emitted. The five hand-written copies of that
runtime are gone: 4,056 lines that were the same reader written out five
times, three of them byte-identical and two variants nobody had reconciled.

WHAT THE VARIANTS DISAGREED ABOUT, and it was not cosmetic. Every hand copy
defaulted `Builder::new` to wire version 2; the emitted runtime keeps `new`
at version 1 and names `new_v2` for the other. So the swap silently moved
byte 4 of every message the P-chain wrote outside a generated builder, and
the warp differential caught it against the bytes Go wrote — a one-byte
divergence in a header nobody reads by hand. Every P-chain writer now says
new_v2, which is what it always wrote.

THE SCHEMA WAS PROVED BEFORE THE TABLE WAS DELETED. A test asserted every
offset and every size in pchain.zap against the constant the chain had been
using — 27 structs, every field — and it passed before a line was removed.
What replaces it now compares schema to schema: every kind's envelope is
Base's envelope, checked field by field against the emitted constants, so
`read_envelope` reading any transaction through Base's accessors is a thing
that is checked rather than a convention to remember.

THE BYTES DID NOT MOVE, and every chain says so against the corpus the Go
chain generated: 68 P transactions and 4 P blocks, 19 X transactions and 6 X
blocks, 12 Q blocks, 22 Z blocks, 43 F transactions, each re-encoded from the
values that were read and compared to Go's hex. Those are every vector the
corpus expects to parse; the rest are the deliberately malformed ones, and
they are still refused. `make chains` is 725 vectors, 4 implementations, 13
evaluators, AGREED on every compared field, exit 0, nothing under NOT
ANSWERED.

Two fields of one name and a struct named but not declared are now refused by
zapgen's front end, once, for every backend. The P-chain hit the first:
an envelope's owner-address POOL and the owner group a transaction hands
ownership TO were both called OwnerAddrs, and the emitted Rust had the same
struct member twice. They are named apart now — NewOwner on a chain
ownership transfer, NetworkOwner on a network being created.

WHAT IS STILL HAND-WRITTEN, and it is the P-chain only: warp.rs and
warpmsg.rs (the warp envelope and its payloads), genesis.rs, persist.rs (the
disk state), and components.rs (the fx primitives it spends). Those are real
remaining offsets and they are next.

The fx primitives belong in neither chain's schema — the X-chain makes them
and the P-chain spends them, so xchain.zap and a P-chain statement of the
same TransferOutput would be two statements of one format. Lifting them into
a shared fx.zap needs an import across schemas that zapgen does not have; the
attempt is what found the undeclared-struct hole, and the refusal now says so
at the schema rather than in emitted Rust.

378 platformvm, 290 xvm, 110 quantumvm, 150 zkvm and 97 fhevm unit tests, the
five corpus byte tests, the golden vectors and the differentials all pass.
2026-09-06 13:54:26 -07:00

52 lines
2.3 KiB
TOML

# SPDX-License-Identifier: BSD-3-Clause-Eco
[package]
name = "lux-zkvm"
version = "0.1.0"
edition = "2021"
description = "The Lux Z-Chain in Rust: the shielded pool, its spent set and its strict-PQ proof profile, ZAP on the wire."
license = "BSD-3-Clause-Eco"
repository = "https://github.com/luxfi/node2"
publish = false
[dependencies]
# The ZAP runtime, emitted by zapgen into `chains/rust/zap` — one copy for
# every chain here, so the reader a chain calls is the reader the Go and C++
# chains call. A path dependency because it is generated in this tree from
# `chains/schema`, and a version between them would be a way to disagree
# about what a byte means.
lux-zap = { path = "../zap" }
# The host. `vm::Vm` and `vm::Block` are the node's OWN trait definitions, not a
# copy of them. A chain that restated the seam would compile against a shape the
# node never sees, and would keep compiling on the day the node changed a
# method. A path dependency because `lux-node` is not published.
lux-node = { path = "../../../../../lux-rs/node" }
# `Id` — `lux_consensus::finality::Id`, `[u8; 32]`. Named from the crate the
# host names it from, so a block this chain builds is named the way the node
# that certifies it names it, with nothing in between to translate.
lux-consensus = "1.23.0"
# Named, not used: `lux-node` reaches `libluxcrypto` through this crate, and
# only a DIRECT dependent is handed the `links` metadata that says where that
# library was resolved. Naming it here is what lets `build.rs` repeat the one
# answer instead of searching for a second one, so this crate's test binaries —
# which run the node — can load.
lux-pq = { path = "../../../../../lux-rs/sdk/lux-pq" }
# SHA-256 is the whole of this chain's arithmetic on identity. A block id, a
# transaction id, the state root and the chain binding are all folds of it, and
# writing any of them by hand would be a second implementation to keep in step
# with Go and C++.
sha2 = "0.10"
# The one boundary where a chain answers a caller in a shape it did not choose:
# the genesis file, and the JSON-RPC calls the host routes here. A hand-written
# parser at a boundary is a vulnerability with a schedule.
serde_json = "1"
[dev-dependencies]
# Golden vectors are hex, because that is how the Go generator prints them.
hex = "0.4"