Documentation
¶
Overview ¶
Package commitment defines the sequence store's commitment chain: a running keccak256 hash over the entry sequence, advanced by a per-item fold
head' = keccak256(head ‖ tag ‖ item)
where an item is an open record's context fields, one transaction, or a sealed block hash, and tag is the item's entry-class domain tag. The fold operates over the canonical byte encodings defined here — never over serialized protobuf, which is not canonical across implementations. Producers, the store ingress, and consumers must compute bit-identical heads; this package is the normative definition for all three.
Index ¶
Constants ¶
const ( TagOpen byte = 0x01 TagTx byte = 0x02 TagSeal byte = 0x03 )
Entry-class domain-separation tags. One per entry class, so no folded item can collide across types. Normative.
const Domain = "polygon-pos/sequence-store"
Domain seeds the chain's genesis head; it never varies at runtime.
const FormatVersion uint32 = 1
FormatVersion is folded into the genesis seed; bump it on any change to the wire format or to the canonical encodings below, so streams from different revisions fail structurally at the first head check.
Variables ¶
var ErrInvalidBaseFee = errors.New("base fee must be a non-negative integer of at most 256 bits")
ErrInvalidBaseFee reports an open context whose base fee is nil, negative, or wider than 256 bits.
Functions ¶
func SealedHash ¶
SealedHash returns keccak256 of a sealed RLP header — the block hash a seal record commits to and the item FoldSeal folds.
Types ¶
type Head ¶
type Head [32]byte
Head is a commitment-chain head — the post-fold state after some prefix of the sequence.
func FoldOpen ¶
func FoldOpen(head Head, open OpenContext) (Head, error)
FoldOpen folds a block-open record's context, producing C_open(N). The canonical encoding is fixed-width so concatenation is unambiguous: number and timestamp as 8-byte big-endian, the parent hash as 32 bytes, gas limit as 8-byte big-endian, base fee as 32-byte big-endian. It errors if the base fee is nil, negative, or wider than 256 bits.
func FoldSeal ¶
FoldSeal folds a block's sealed hash (keccak256 of its sealed header), producing C_seal(N) — the head the next block's open record extends on the normal path.
func FoldTx ¶
FoldTx folds one raw signed transaction. Folding per transaction — not per record — is normative: it makes the chain independent of how transactions are batched into records.
func FoldTxs ¶
FoldTxs folds transactions in order, one at a time; after a block's last transaction the head is C_block(N).