mirror of
https://github.com/luxfi/node.git
synced 2026-10-30 15:24:05 +00:00
Three structs — the signature preimage, the envelope over it, and the block — stated their offsets by hand in wire.hpp and used them by hand in wire.cpp. They are now schema/wire.zap, and zapgen prints the readers and the builders. 340 lines become 43 of schema and what is left of wire.cpp, which is the canonicality rule, the size bound, and the walk over the length vector — the things that are about a Q-chain block rather than about a buffer. One behaviour changed, and it is the one the schema buys. TxLens is a run of u32, so the generated reader takes the stride and the wire layer now refuses a length word the message cannot hold — where the strideless read accepted it and left every element accessor answering zero. The chain's own bound still names a count the BLOB cannot back; the wire's bound now names one the MESSAGE cannot hold, and parse_tx_set tells the two apart by the absent list rather than losing the reason to a later non-canonical. Both refuse; both say why. The regeneration target moved into zap.cmake as zap_schema(), so a chain declares its schema in one line and no chain spells the generator invocation twice. Green, and the two that matter are Go's own bytes: AnUnsignedTransactionSerializesAsGoDoes and ABlockCarryingAnUnsignedTransactionHasGosID. 13/13, and xvm still 59/59.
48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
# SPDX-License-Identifier: BSD-3-Clause-Eco
|
|
# The Q-chain's wire, as a schema.
|
|
#
|
|
# These offsets are the ones the Go reference states in
|
|
# chains/quantumvm/wire.go. Written down once here, the readers and the
|
|
# builders come out of zapgen, and a block written in either language hashes
|
|
# to the same id because both are the same arithmetic over the same layout.
|
|
#
|
|
# The transaction set is a length vector beside a blob, not a list of
|
|
# transactions: a transaction is variable-width, and a length the blob cannot
|
|
# back is a refusal rather than a truncation. Both halves come from the peer
|
|
# and both are checked, in wire.cpp, where meaning lives.
|
|
|
|
package lux.quantumvm.wire
|
|
|
|
type id32 = bytes_fixed[32]
|
|
|
|
# What a signature covers, and what a transaction id is taken over. It
|
|
# excludes the signature, which is the whole point of it being its own byte
|
|
# string.
|
|
struct TxBody {
|
|
Timestamp i64 @0
|
|
Nonce u64 @8
|
|
Data bytes @16
|
|
}
|
|
|
|
# The preimage plus the signature over it. CoronaKey is not here: signing sets
|
|
# it from the public key, so a second copy on the wire is a second thing to
|
|
# disagree.
|
|
struct TxEnvelope {
|
|
Body bytes @0
|
|
Algorithm u32 @8
|
|
Stamped i64 @16
|
|
PublicKey bytes @24
|
|
Signature bytes @32
|
|
Stamp bytes @40
|
|
}
|
|
|
|
struct Block {
|
|
Timestamp i64 @0
|
|
Height u64 @8
|
|
ParentID id32 @16
|
|
ChainID id32 @48
|
|
NetworkID u32 @80
|
|
TxLens list<u32> @88
|
|
TxBlob bytes @96
|
|
}
|