Source: docs/lotus-v2/decisions/commitments-and-state.md
🎯 Why: Authenticate every transaction, unspent coin, monetary counter, and historical block header with one hash primitive (BLAKE3) designed for horizontal CPU sharding.

In Practice: Every 134-byte block header acts as a cryptographic vault receipt for the entire blockchain—letting mobile and browser wallets verify any coin balance or past block in ~1 KB.

Under the Hood: Prefix-sharded Subtree A transaction tree, single-leaf-collapsed 256-bit sparse UTXO tree (~27 hashes at 10^8 coins), 56-byte MonetaryState, and O(ctz(H)) binary carry-chain HeaderHistoryFrontier.

Hash commitments and authenticated state

On this page

Decision packet P02. Recommended candidate, not frozen or implemented. Refines D02/D13 and the commitment part of D14. Defines separate branch, ordered-vector and keyed-map commitments rather than one ambiguous “Merklix” API.

Hash registry

B3 is unkeyed BLAKE3 with exactly 32 output bytes. H_name(x)=B3(ASCII(tag) || 00 || x). All tags are case-sensitive ASCII strings below. Prefix bytes such as 00 in node encodings are bytes, not characters. Integer encodings are P01 little-endian; where two hashes are ordered they are read as unsigned little-endian integers. No hash function accepts arbitrary C++ struct memory.

name Exact tag
branch Lotus/v2/branch
txid Lotus/v2/txid
txhash Lotus/v2/txhash
sighash Lotus/v2/sighash
inputcore Lotus/v2/inputcore
inputfull Lotus/v2/inputfull
coinentry Lotus/v2/coinentry
owninput Lotus/v2/owninput
output Lotus/v2/output
txroot Lotus/v2/txroot
utxo Lotus/v2/utxo
state Lotus/v2/state
contractstate Lotus/v2/contractstate
headerbody Lotus/v2/header/body
headerwork Lotus/v2/header/work
header/history Lotus/v2/header/history
blockid Lotus/v2/blockid
merkleidx Lotus/v2/merkleidx

The BLAKE3 primitive follows its specification; application tags and tree rules are Lotus choices. Because H_name(x) is ordinary unkeyed BLAKE3 over the ASCII prefix tag || 0x00 || x (C08), any script can compute and verify any domain-tagged hash (H_txid, H_inputcore, H_output, H_coinentry, H_merkleidx, etc.) in three instructions (<"Lotus/v2/...\x00"> SWAP CAT BLAKE3) without needing a dedicated opcode per domain tag. P04 specifies a recursive BlockID/PoW candidate and its additional headerbody/headerwork domains; final choice remains D12. Hash collision resistance is an assumption, not a theorem about these tags.

Branch MAST: unordered membership

Leaf(script) = H_branch(00 || Bytes(script))
BranchNode(a,b) = H_branch(01 || min(a,b) || max(a,b))
LegacyBridgeLeaf(coin_script, witness_script)
                = H_branch(03 || Bytes(coin_script) || Bytes(witness_script))

LegacyBridgeLeaf is never a member of a branch tree. It is only the selector leaf of an input spending a legacy coin (P01 "Spending a legacy coin"), and its prefix 03 keeps it distinct from every leaf and node preimage.

min and max compare the two 32-byte hashes as unsigned little-endian 256-bit integers: the last byte is the most significant. This is the same reading of a hash that P04 uses to compare a BlockID with its target, and the byte order of every integer in the transaction format and the VM.

Spend and mint invocations use the same leaf function. Consensus therefore does not distinguish a mint script from a spend script: any leaf of a tree can be proven in either kind of invocation. A design that needs both must keep them in separate trees. A token's mint scripts form the tree whose root is the token ID; rules that must run on every spend form a second tree that appears on outputs as a branch, and the mint scripts name that second root as a constant. A mint script placed in a tree that outputs use as a required branch could be offered to satisfy that branch. Consume siblings bottom-up, hashing once per sibling. Empty sibling vector means root=Leaf(script). A proof only asserts membership; it has no direction bits, method index, hidden leaf-count claim or hidden uniqueness claim. Consensus limits proof depth; no unverified tree metadata enlarges that bound.

For reproducible wallet construction, recommend: sort distinct leaf hashes as unsigned little-endian integers, ascending; split a list of n>1 at the greatest power of two less than n; recursively build and sort each child pair at hashing. This construction is a wallet convention, not a property enforceable from a single proof. An owner may commit another finite binary tree. Duplicated leaves or alternative shapes provide no independent authorization and receive no accounting discount.

Storing data and Merkle roots in branches: three patterns

Apart from the optional 32-byte state_root of a HAS_STATE output (C05), contracts and protocols commit data or Merkle roots in branches and verify Merkle proofs against them (MERKLEROOT_SORTED, MERKLEROOT_INDEXED, LEAFHASH, NODEHASH) in three complementary ways:

  1. On a pruneable burn / OP_RETURN output (flags = 0x02 native or 0x03 token, paths = []):
  2. Setting bit 1 (0x02 IS_BURN) requires path_count == 0 (paths = []) and 1 <= branch_count <= 16 pairwise distinct 32-byte entries in branches (up to 512 bytes of commitment hashes, Merkle roots, or topic/data words).
  3. 100% of value on an IS_BURN output is permanently burned (included in O_a, never claimable by miners as fees; value = 0 is also valid), and validators never insert IS_BURN outputs into UtxoRoot (C17), so they consume zero UTXO memory forever.
  4. Scripts in the creating transaction can inspect an IS_BURN output j via OUTPUTFLAGS(j), OUTPUTVALUE(j), OUTPUTTOKENID(j), OUTPUTBRANCHCOUNT(j), and OUTPUTBRANCH(j, k)—and can verify Merkle proofs against OUTPUTBRANCH(j, k) using MERKLEROOT_SORTED or MERKLEROOT_INDEXED—making IS_BURN outputs ideal for Frank/Stamp topic broadcasts, burn-weighted votes, and verified on-chain data commitments.
  5. As a dedicated unexecuted data branch on a spendable coin (branches = [CodeRoot, StateMerkleRoot], paths = [[0]]):
  6. Because paths = [[0]] requires only branch[0] (CodeRoot), branch[1] (StateMerkleRoot) is never executed as a script—it acts as a direct 32-byte state or Merkle-root register on the coin (or up to 15 registers branch[1..15]).
  7. Methods in CodeRoot read the current root in $O(1)$ via INPUTINDEX <1> UTXOBRANCH, verify or update leaves using MERKLEROOT_INDEXED or MERKLEROOT_SORTED, and require the successor output j to carry the updated root at OUTPUTBRANCH(j, 1) while branch[0] (CodeRoot) never changes.
  8. Inside the executing branch tree itself (BranchNode(DataLeaf, M), the data-leaf convention):
  9. For the most compact 1-branch coin (45 bytes native / 77 bytes token, branches = [root], paths = [[0]]), a contract places its state as one leaf beside the subtree M of its methods: ``text DataLeaf(values) = Leaf(data_script(values)) # pushes of the values, then RETURN root = BranchNode(DataLeaf(values), M) # M = root of the methods subtree ``
  10. M never changes; root changes whenever values do. The data script ends in RETURN so that it can never be run as a method. The spender supplies the current values and M as witness arguments, and the method checks BranchNode(Leaf(data_script(values)), M) == BRANCHROOT using LEAFHASH and NODEHASH, then requires BranchNode(Leaf(data_script(new_values)), M) on the successor output with OUTPUTCONTINUESBRANCH or OUTPUTEXCLUSIVEBRANCH. The cost is two leaf hashes and two node hashes per spend, whatever the number of methods, and a method's membership proof is one sibling longer than it would be without state.

Patterns 2 and 3 are compiler/application conventions recorded in the contract's ABI; pattern 1 (IS_BURN (0x02/0x03)) has consensus-enforced path_count == 0 and UTXO pruning (C05, C09, C17).

Indexed binary Merkle tree: transaction inputs, outputs, and coins (IndexedTreeRoot)

Following Lotus v1's Malfix design (101-implement-malfix.patch), transaction inputs, outputs, and resolved coins are committed via a canonical bottom-up indexed binary Merkle tree (IndexedTreeRoot) so that smart contracts can prove any individual input or output of a parent/injected transaction (OUTPOINTTXID(i)) in $O(\log N)$ space using MERKLEROOT_INDEXED (0xc1, hash_alg = 0) without pushing the entire parent transaction onto the stack.

For a vector of $n \ge 0$ 32-byte leaf hashes L[0 .. n - 1]:

EmptyIndexedRoot         = H_merkleidx(02)
IndexedNode(s, l, r)     = H_merkleidx(01 || u16(s) || l || r)
Zero32                   = 00^32

Because layer index $s$ runs bottom-up from $0$ (leaves) to $k - 1$ (root), for any leaf index idx in 0 .. n - 1, at step $s = 0 \dots k - 1$, bit $s$ of idx ((idx >> s) & 1) is 0 when the node is the left child (cur[2j]) and 1 when the node is the right child (cur[2j + 1]). Consequently, MERKLEROOT_INDEXED (0xc1, hash_alg = 0) verifies any leaf L[idx] against IndexedTreeRoot(L) in a single instruction (<L[idx]> <u16(idx)> <proof_bytes> <0> MERKLEROOT_INDEXED), while the outer transaction header in TxID (input_count:u16 and output_count:u16 in P01) binds the exact vector lengths.

Block transaction commitment: prefix-sharded Merklix Subtree A and top-level CoinbaseLeaf

Following the sharding architecture of Sharding Bitcoin Cash (September 6, 2018), scaling block construction, mempool acceptance, and transaction commitment across horizontal CPU cores and processes requires consistent key-prefix range partitioning rather than positional array-index splitting.

Let transaction $i$ ($0 \le i < n$) have identity pair (TxID_i, TxHash_i), with vtx[0] as the block's coinbase transaction and vtx[1 .. n - 1] as the block's non-coinbase transactions. All TxID_i in a block (or commitment vector) MUST be pairwise distinct. Define:

TxLeaf(TxID, TxHash) = H_txroot(00 || TxID || TxHash)
TxNode(d, l, r)      = H_txroot(01 || u16(d) || l || r)       # d=0..255
EmptyTxRoot          = H_txroot(02)

Key bit d of TxID is bit(TxID, d) = (TxID[d//8] >> (d%8)) & 1 (the exact same 256-bit little-endian bit order as UtxoRoot). For a set of distinct (TxID, TxHash) non-coinbase entries inside the subtree at depth d (0 <= d <= 256), the single-leaf-collapsed Merklix subtree root tx_smt(entries, d) is:

The top-level block transaction commitment TxRoot(xs) is:

Each leaf commits to both identities of its transaction (TxID first, then TxHash). TxHash fixes the complete witness bytes as the leaf value at key TxID, while TxID alone defines the 256-bit prefix path through Subtree A. Because Subtree A partitions strictly by the bits of TxID, any $2^k$ mempool/validation shards (where Shard $s \in [0, 2^k - 1]$ owns the $k$-bit TxID prefix $s$) can maintain their mempool subtrees and pre-compute (TxSubtreeRoot[s], fee_sum[s], cost_sum[s]) 100% independently with zero cross-shard count synchronization, and Subtree A is naturally ordered by ascending TxID (matching Canonical Transaction Ordering, CTOR, in block wire format vtx[1 .. n - 1] with two-phase outputs-then-inputs intra-block UTXO resolution per C12). On getblocktemplate, the coordinator aggregates the $2^k$ shard roots into Subtree A (32 bytes), constructs vtx[0], and combines CoinbaseLeaf with Subtree A in one single top-level hash ($O(1)$) without re-entering any shard.

Canonical transaction membership and absence proof

A transaction proof against TxRoot begins with a 1-byte selector is_coinbase:u8:

UTXO map: prefix-compressed binary tree

Use a 256-bit keyed binary tree with shared-prefix compression as the normative UtxoRoot algorithm: an interior node exists only where two non-empty subtrees split, a subtree of one entry is its leaf hash, and a node with one non-empty child is never formed. Updating or proving a key therefore hashes its leaf and one node per actual split on its path, about $\log_2 n + 1.3$ hashes for $n$ coins with random transaction IDs (about 23 at $3 \times 10^6$ coins, 28 at $10^8$, 31 at $10^9$), however long the prefix a key shares with its neighbours. This commitment is strictly for block headers, RPC queries, snapshot verification, and optional transport-layer ProvenTx relay packages—never a VM opcode (OP_UTXOPROOFVERIFY is rejected; see rationale).

Outpoint = txid:h32 || output_index:u32
OutpointKey(txid, output_index) = txid[0..28] || u32_le(u32_le(txid[28..32]) ^ output_index)
key = OutpointKey(txid, output_index)
Coin = Outpoint || Bytes(Output) || creation_height:u64
       || creation_parent_mtp:u64 || coinbase:u8
       || encoding_version:u8 || fee_per_output:u64 || expiration_height:u64
UtxoLeaf(key,coin) = H_utxo(00 || key || Bytes(Coin))
UtxoNode(d,P,l,r)  = H_utxo(03 || u16(d) || P || l || r)   # d=0..255
EmptyRoot = H_utxo(02)

Bytes(x) is the shortest CompactSize of len(x) followed by x, so the leaf hashes the Coin record's own length prefix, and the record holds its Output's. There is one Coin encoding, and every field is always present: encoding_version is 2; fee_per_output is the creating transaction's native fee (native inputs less native outputs, burns included) divided by its number of spendable outputs, rounded down, and 0 for a coinbase coin; expiration_height is creation_height + lifespan, saturating at $2^{64} - 1$, where lifespan is UTXO_MAX_LIFESPAN_BLOCKS = 21,024,000 for a coinbase coin and otherwise min(21,024,000, UTXO_MIN_LIFESPAN_BLOCKS + fee_per_output / UTXO_RENT_ATOMS_PER_BLOCK) with UTXO_MIN_LIFESPAN_BLOCKS = 131,400 and UTXO_RENT_ATOMS_PER_BLOCK = 1. Block connection computes fee_per_output and expiration_height when it creates the coin, and they never change. A record is canonical only if it decodes completely, coinbase is 0 or 1, encoding_version is 2, expiration_height is nonzero, and it re-encodes to the same bytes. A decoder does not recompute expiration_height (the minimum lifespan is a network parameter); a record received with a proof is authenticated by its leaf. This is the encoding EncodeCoin produces and DecodeCoinBytes accepts (src/lotus_v2/sparse_state.cpp), and the reference model's coin.py. The shared vector in both test suites is the 116-byte Coin for outpoint 00..1f:5, value 1000 on one branch of 11 bytes, height 7, parent MTP 1234, not a coinbase, fee_per_output = 250,000 (so expiration_height = 381,407):

000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 05000000
2d 00e803000000000000 01 1111111111111111111111111111111111111111111111111111111111111111 01 01 00
0700000000000000 d204000000000000 00 02 90d0030000000000 dfd1050000000000
UtxoLeaf = 2fd68aeaeea74d4a0be91d2efc702dcf69e0a008e358c04a635ca19115f144b3

Preserving the first 28 bytes (224 bits) of txid and XORing the trailing 32-bit little-endian word txid[28..32] with output_index keeps all outputs of a single transaction co-located under the same 224-bit prefix in UtxoRoot, on the same horizontal shard as txid in Subtree A, and adjacent in B+Tree storage (dbi_coins and dbi_smt_nodes), while guaranteeing distinct 256-bit keys for distinct output_index values of the same txid. Under prefix compression this co-location costs nothing: the outputs of one transaction share their 224-bit prefix without a hashed node at each of its levels.

Key bit d is bit(key, d) = (key[d//8] >> (d%8)) & 1: bit d of the key read as an unsigned little-endian 256-bit integer, least significant bit first, in keeping with the byte-order convention used everywhere else. prefix(key, d) is the 32-byte value whose bits 0 .. d - 1 are those of key and whose bits d .. 255 are zero. For a set of distinct (key, coin) entries, the subtree root smt(entries) is:

UtxoRoot is smt(all_entries). Its top node's d is greater than 0 when every key shares bit 0. Domain byte 01 is not used by UtxoRoot. Only spendable outputs ((flags & 0x02) == 0) are inserted into UtxoRoot; burn/commitment outputs ((flags & 0x02) != 0, which have path_count == 0) are pruned at transaction application and never enter UtxoRoot (C17). Coin's outpoint must derive its key, coinbase must be 0 or 1, flags must not include IS_BURN (so 0x00, 0x01, 0x04 or 0x05), and its output must satisfy spendable output well-formedness (including MAX_OUTPUT_BRANCHES = 16 and MAX_OUTPUT_PATHS = 16, which bounds every native Coin record to $\le 885\text{ bytes}$, or 917 with HAS_STATE). A coin carried over from a legacy output instead holds Bytes(LegacyCoinOutput) with LegacyCoinOutput = 80 || value:u64 || Bytes(scriptPubKey) and a script of at most 10,000 bytes: 1 + 8 + 3 + 10,000 = 10,012 output bytes, so 36 + 3 + 10,012 + 34 = 10,085 bytes, which is MAX_COIN_BYTES. A record is told apart by the first byte of its output: 80 is a LegacyCoinOutput, any other byte a V2 Output. P01 "Spending a legacy coin" gives that encoding's canonical form, its role in CoinEntry and OwnInputHash, and the only scripts and witnesses that spend it. Height/time and coinbase flag are consensus metadata, not database hints. Inserting a different outpoint at an occupied key rejects; never overwrite or merge such entries.

The map root is independent of insertion order. Deleting an entry removes its leaf; a node left with one non-empty child is removed, and that child (a leaf, or a node with its own d and P) takes its place unchanged. Duplicate-key snapshot entries reject even when identical. Pre/post roots alone do not establish that the intervening transaction set was valid.

Canonical membership and absence proof

For a queried Outpoint = txid:h32 || output_index:u32 with query_key = OutpointKey(txid, output_index), encode:

presence:u8 || [Bytes(Coin) if presence in (1, 2)]
            || [u16(d_t) || P_t:32bytes || l_t:h32 || r_t:h32 if presence == 3]
            || bitmap:32bytes || siblings

Following query_key from the root visits nodes at strictly increasing split depths, taking the child selected by bit(query_key, d) at each, until it reaches a leaf, or a node whose prefix disagrees with query_key below its split depth, or (only for an empty map) EmptyRoot. Therefore:

presence is 0, 1, 2, or 3, determining the terminal hash acc:

For each set bit d of bitmap, from the highest down to the lowest, consume the next hash sib from siblings and set acc = UtxoNode(d, prefix(query_key, d), acc, sib) when bit(query_key, d) == 0, or UtxoNode(d, prefix(query_key, d), sib, acc) when bit(query_key, d) == 1. Unset bits contribute no hash. Finally require acc == UtxoRoot. Every hash field (P_t, l_t, r_t, each sibling, and the expected root) is exactly 32 bytes; the node preimage is a fixed-width concatenation, so this is what prevents re-partitioning bytes between neighbouring fields.

Two of these rules carry soundness. That a presence = 3 node's prefix P_t differs from query_key somewhere in k .. d_t - 1 is what makes it an absence proof: without it, a member's proof cut short after any split, ending at the real node below with its true (d_t, P_t, l_t, r_t), folds to the true root and would show the member absent. That the Coin.Outpoint equals (presence = 1) or differs from (presence = 2) the queried outpoint is the other. The remaining rules enforce canonical form only: a proof that breaks them folds to a root of no well-formed tree, so the hash binding already rejects it against a real root, and the rule makes every accepted proof the unique canonical one. These are: no EmptyRoot sibling or terminal child; an all-zero bitmap for presence = 0; a terminal leaf or P_t agreeing with query_key below k; P_t having no bit at or above d_t; and k <= d_t, which the divergence rule already implies.

Verification performs one node hash per set bit of bitmap, plus one leaf hash (presence in (1, 2)) or node hash (presence = 3). For random transaction IDs that averages about $\log_2 n + 1.3$: about 28 hashes at $10^8$ coins. A proof is then about 1 to 1.8 KB: 27 siblings (864 bytes), the bitmap (32 bytes), and the Coin (up to 885 bytes). Shape can raise it. The outputs a transaction keeps unspent split from one another below their shared 224-bit prefix, so clustered indices (for example a transaction's surviving outputs 0, 1, 2, 4, ..., 128) add up to about $\log_2(\text{outputs})$ splits to each of their paths, and transaction IDs ground to share leading bits add one split per shared bit. The bound is 256 splits on any path, so 257 hashes and 256 siblings. Fee and resource calibration must use the worst permitted shapes, not the average.

Absence (presence = 0, 2 or 3) proves that the queried outpoint has no coin at UtxoRoot, under the hash assumptions. It does not show that query_key is unused: another outpoint can have the same key, because (T', i'), with T' being T with its last 32-bit word XORed with w and i' = i ^ w, has the key of (T, i). Such a proof ends at that coin's leaf with presence = 2 and k up to 256. It also does not prove that an outpoint was never created, or spent, at another root. Multiproofs and snapshot range proofs may be designed later as transport/RPC encodings reproducing the same root.

Candidate input-proof relay package (not consensus)

A wallet may relay a transaction together with its coins and their membership proofs, so that a node holding recent headers and recent block deltas can validate it without a database lookup. The package is transport only: none of it enters TxID, TxHash, the signature message or a block, so it can change without a consensus change.

ProvenTx  = Tx || anchor:h32 || UtxoRoot:h32 || Bytes(MonetaryState)
            || Vec(CoinProof)
CoinProof = Bytes(Coin) || bitmap:32bytes || siblings

CoinProof is the membership proof above with presence fixed at 1 and its byte omitted. There is exactly one per spend input, in input order; mint and coinbase inputs have none. anchor is a BlockID. The envelope fields are those of the full state root below, with height taken from the anchor header.

A node accepts the package only if: the anchor is on its best chain and at most PROOF_WINDOW blocks behind the tip (a node policy value, not chosen here); the envelope reproduces the anchor header's state_root; each Coin's Outpoint equals its input's outpoint and its proof reconstructs UtxoRoot; and no proved outpoint is spent by a block after the anchor or by a conflicting mempool transaction. The node must therefore retain, in memory, the outpoints spent and coins created by the last PROOF_WINDOW blocks. An input whose coin was created after the anchor, or by an unconfirmed transaction, is resolved from that retained data and its CoinProof slot is replaced by a zero-length marker to be specified with the encoding. Ordinary validation then runs on the supplied coins; creation_height, creation_parent_mtp and coinbase come from the proved Coin.

A TxID-based proof is not a substitute: a TxID with its transaction-tree path and output-tree path shows only that an output was created in some block, not that it remains unspent at the current tip.

Limits of this candidate. Proof size is about one sibling per doubling of the coin set (about 27 siblings at 10^8 coins, 1 to 1.8 KB per input with the Coin). A proof expires when its anchor leaves the window; any state-holding node can reissue it and need not be trusted. Checking a block's new state_root without state additionally needs the paths of every key the block inserts; these are absence proofs (presence 2 or 3) for each inserted key against the parent root, from which the verifier rebuilds the new root. All outputs of a transaction share a 224-bit txid prefix and are co-located on the shard owning that prefix; the levels of that prefix where no other coin's key splits off contain no node, so a transaction's outputs add hashed nodes only where they split from one another or from other coins. Block producers need the coin set or a complete set of proofs.

Full state root and canonical MonetaryState (56B at Genesis, 88B at $h \ge 1$)

A UTXO root alone omits the protocol's stateful issuance, dynamic fee-burn recurrences, and historical header accumulator (P05, P06, Header History Tree). Commit a versioned state envelope:

CoreMonetaryState = bootstrap_reserve:u64     # R_n (remaining unissued bootstrap atoms, P06)
                    || tail_subsidy:u64       # T_n (current adaptive tail subsidy atoms, P06)
                    || prev_work:u256         # W_{n-1} (32-byte little-endian unsigned per-block work, P04/P06)
                    || ema_block_cost:u64     # E_n (rolling integer EMA of block cost units, P05)

MonetaryState(h)  = CoreMonetaryState                         (56 bytes at Genesis h = 0, where history_root == 0x00^32)
                  | CoreMonetaryState || history_root:h32     (88 bytes at every post-genesis height h >= 1)

StateRoot         = H_state(00 || ChainID || height:u64
                            || UtxoRoot:h32 || Bytes(MonetaryState(h)))

CoreMonetaryState is a canonical fixed-width 56-byte record (8 + 8 + 32 + 8 = 56 bytes). At Genesis ($h = 0$, count == 0, history_root == 0x00^32), MonetaryState is 56 bytes (Bytes(MonetaryState) = 0x38 || CoreMonetaryState, making the StateRoot preimage 130 bytes after the domain tag). At every post-genesis block ($h \ge 1$, count = h >= 1), the non-zero 32-byte history_root (HeaderHistoryRoot over blocks $0 \dots h - 1$) is appended, making MonetaryState 88 bytes (Bytes(MonetaryState) = 0x58 || CoreMonetaryState || history_root, and the StateRoot preimage 162 bytes after the domain tag). It retains bootstrap/EMA continuation state, checked tail/work redundancy, and the authenticated header history root (D11 uses Avalanche coordination policy, so no faucet or treasury state exists):

  1. bootstrap_reserve:u64 ($R_n$): remaining unissued bootstrap reserve in native atoms; issuance step $n$ emits $B_n = \max(1, R_n \gg k_{\text{boot}})$ when $R_n > 0$ (or $0$ when $R_n = 0$) and updates $R_{n+1} = R_n - B_n$ (P06).
  2. tail_subsidy:u64 ($T_n$), checked cache of F(authenticated_parent_work): issuance step $n$'s adaptive tail subsidy in native atoms (total issuance step $n$ subsidy entitlement is $S_n = B_n + T_n$); after accepting issuance step $n$ with per-block work $W_n$, updates to $T_{n+1} = \text{isqrt}(\lfloor T_g^2 W_n / W_g \rfloor)$, with no floor or ceiling (P06; a tail that does not fit u64 is an open item there).
  3. prev_work:u256 ($W_{n-1}$), checked against the authenticated parent target: 32-byte unsigned little-endian per-block chainwork of the parent block (initialized at genesis to $W_{-1} > 0$ from the genesis target, updated to $W'_n = W_n$ after issuance step $n$).
  4. ema_block_cost:u64 ($E_n$): rolling integer exponential moving average of whole-block frozen accounting cost units $C_{\text{block}}$, updated after issuance step $n$ via $E_{n+1} = E_n - (E_n \gg w) + (C_{\text{block}} \gg w)$ and used to enforce issuance step $n$'s required fee-burn floor (P05).

The header's former hashUtxoMerklixRoot is therefore renamed state_root. RPCs must expose both the 56-byte MonetaryState envelope and UTXO proofs so clients can connect a coin proof to the header's state_root. height must match the validated block context.

Header ancestry supplies validated time/target context; a standalone UTXO snapshot does not. Snapshot admission must check the envelope, unique entries, canonical Coin encodings, root reconstruction, the MonetaryState record and selected chain context, and clearly state which historical transitions were actually verified. Retained undo data must restore every field of the prior MonetaryState envelope on disconnect.

Header History Merkle Tree (HeaderHistoryFrontier and history_root)

So that light clients, bridges, and FastSync / Snapshot verifiers can authenticate any historical block header at height $h < H$ against the current block header at height $H$ in $O(\log H)$ space and time, every post-genesis block ($H \ge 1$) commits to history_root inside MonetaryState: the root of an append-only binary Merkle mountain / carry-chain frontier over all prior canonical block hashes $(0, \text{BlockID}_0), (1, \text{BlockID}_1), \dots, (H-1, \text{BlockID}_{H-1})$.

The header history tree specification defines the leaf, internal-node and count-binding hashes, the frontier and its append, the root fold and the inclusion-proof check (its §3). It is the only definition; this section does not restate it. In particular, history_root = HeaderCountBinding(ChainID, count, tree_root) binds the leaf count, and genesis (count == 0) has the null root, which MonetaryStateHash omits.

Genesis and monetary indexing

Monetary equations use issuance-step index n >= 0, not header height: step n is block height n + 1. Genesis (height 0) initializes and commits (R_0, T_0, W_-1, E_0) unchanged. Here W_-1 is genesis target work. Genesis does not run bootstrap decay, tail adjustment, EMA update or recurring fee deduction. Its coinbase has zero total native value; no genesis endowment or treasury allocation exists. Its exact output/commitment bytes remain a genesis-manifest input. Ordinary C17 output insertion/pruning still applies, including for zero-valued outputs.

Height 1 executes step 0 using the genesis state: B_0 = max(1, R_0 >> k_boot) when R_0 > 0, S_0 = B_0 + T_0, then commits (R_1, T_1, W_0, E_1) with height 1 in StateRoot. Height 2 executes step 1. In general the header at height h commits (R_h, T_h, W_(h-1), E_h) after initialization/transition. Thus the bootstrap conservation identity sums over steps n >= 0 (heights 1 onward), and the recommended initial 150,378 XPI (P06) is height 1's gross entitlement, before coinbase resource deductions. Disconnecting height 1 restores the exact genesis state. All target/lock/header-height rules continue to use actual height; this notation changes none of those fields.

Coinbase and root dependency order

For non-genesis blocks ($h \ge 1$): insert parent block $h - 1$'s spendable coinbase outputs into the UTXO tree and apply block $h$'s non-coinbase transactions vtx[1 .. n - 1] in two-phase outputs-then-inputs CTOR order (C12, C17) → calculate resource charges and reduce the coinbase claim under P05 (C16, C25) → construct coinbase vtx[0] using parent ID/height and the parent's MonetaryState ($S_n = B_n + T_n$) → derive TxID/TxHash → evaluate transitions, total block cost $C_{\text{block}} = C_{\text{envelope}} + C(vtx[1..n-1]) + C(vtx[0])$, mandatory fee-burn floor against $E_n$, and the post-block 88-byte MonetaryState ($R_{n+1}, T_{n+1}, W_n, E_{n+1}, \text{HistoryRoot}_h$) → compute transaction/state roots → construct header → compute BlockID/PoW. Because block $h$'s own spendable coinbase outputs are inserted into UtxoRoot at height $h + 1$ (C17, delayed 1-block pipelining), UtxoRoot at height $h \ge 1$ is 100% invariant to block $h$'s coinbase transaction (enabling Snowstorm's $O(1)$ SnapBlock fast path), while the containing header hash is never embedded in its own coin records. Genesis (height = 0) has no prior block ($h - 1$) to pipeline from, so it uses zero parent (parent_id = 00^32), an explicitly initialized 56-byte MonetaryState ($R_0, T_0, W_{-1}, E_0$ with history_root == 00^32 omitted), and inserts every spendable output ((flags & 0x02) == 0) of Block 0's coinbase directly into the Genesis UtxoRoot (with creation_height = 0, creation_parent_mtp = 0, coinbase = 1, spendable after coinbase maturity C13), while any unspendable Genesis timestamp/headline message uses an IS_BURN (flags = 0x02, paths = []) output that is excluded from UtxoRoot.

Acceptance obligations

Pin test vectors for empty/one/two/odd transaction trees, every proof direction, empty/single-leaf/multi-leaf/deleted prefix-compressed state maps (including a top node with d > 0, outputs of one transaction splitting at depth 224 or deeper, and deletion leaving a node to replace its parent), all four proof presence modes (0, 1, 2, 3) and their rejections (presence 0 with a non-zero bitmap, presence 3 with d_t < k, a non-zero P_t bit at or above d_t, a P_t agreeing with query_key through d_t - 1, or an EmptyRoot child), same map built in different orders, coin metadata changes, 56-byte MonetaryState transitions and StateRoot envelope restoration. Check both scalar and incremental implementations against the same vectors. Initial genesis parameter values ($R_0, T_0, W_{-1}, E_0$) remain to be confirmed by simulation before genesis freeze.

The absolute tail preserves these 56 serialized bytes and the 134-byte header. Immutable genesis tail/work anchors and formula version 1 belong to the consensus profile identity; a snapshot cannot supply or reset them. Validate both cached fields against authenticated header work and the profile formula before accepting continuation state. See P06 for exact rounding and migration.


References

  1. [Merkle 1987] Ralph C. Merkle, "A Digital Signature Based on a Conventional Encryption Function", in Advances in Cryptology — CRYPTO '87, Lecture Notes in Computer Science, vol. 293, pp. 369–378, Springer, 1988.
  2. [Vermorel, Séchet, Chancellor, & van der Wansem 2018] Joannes Vermorel, Amaury Séchet, Shammah Chancellor, and Tomas van der Wansem, "Canonical Transaction Ordering for Bitcoin", June 12, 2018.
  3. [Vermorel, Séchet, Chancellor, & Cox 2018] Joannes Vermorel, Amaury Séchet, Shammah Chancellor, and Jason Cox, "Merklix Tree for Bitcoin", July 2018.
  4. [Dahlberg, Pulls, & Peeters 2016] Rasmus Dahlberg, Tobias Pulls, and Roel Peeters, "Efficient Sparse Merkle Trees: Caching Strategies and Secure (Non-)Membership Proofs", in Proceedings of the 21st Nordic Conference on Secure IT Systems (NordSec 2016), LNCS vol. 10014, pp. 199–215, 2016 (IACR ePrint 2016/683).
  5. [Crosby & Wallach 2009] Scott A. Crosby and Dan S. Wallach, "Efficient Data Structures for Tamper-Evident Logging", in Proceedings of the 18th USENIX Security Symposium, pp. 317–334, August 2009.
  6. [Todd 2012/2016] Peter Todd, "Merkle Mountain Ranges", OpenTimestamps / Bitcoin Core developer notes, 2012–2016.
  7. [O'Connor, Aumasson, Neves, & Wilcox-O'Hearn 2020] Jack O'Connor, Jean-Philippe Aumasson, Samuel Neves, and Zooko Wilcox-O'Hearn, "BLAKE3: One Function, Fast Everywhere", January 2020 (https://github.com/BLAKE3-team/BLAKE3-specs).
  8. [Nakamoto 2008] Satoshi Nakamoto, "Bitcoin: A Peer-to-Peer Electronic Cash System", October 2008 (https://bitcoin.org/bitcoin.pdf).