Skip to main content

Module state

Module state 

Source
Expand description

Tier 3 state validation (STV-*): coin existence, puzzle hash cross-checks, lock evaluation, proposer signature, and state root verification.

§Requirements trace

  • STV-001validate_state() API + validate_full() composite.
  • STV-002 — coin existence checks: removals must exist and be unspent, or be ephemeral (created in same block). Also handles ASSERT_EPHEMERAL condition.
  • STV-003 — puzzle hash cross-check: CoinState.coin.puzzle_hash == CoinSpend.coin.puzzle_hash.
  • STV-004 — addition non-existence: created coins must not already exist in coin set (exception: ephemeral spent in same block).
  • STV-005 — height/time lock evaluation: 8 assertion types from PendingAssertion (EXE-009) evaluated against chain context from crate::CoinLookup.
  • STV-006 — proposer signature: chia-bls::verify(pubkey, header.hash(), block.proposer_signature).
  • STV-007 — state root verification: apply additions/removals, recompute Merkle root, compare to header.state_root.
  • NORMATIVE — full state validation domain.
  • SPEC §7.5 — Tier 3 state validation pipeline.

§API signatures (STV-001)

L2Block::validate_state(&self, exec: &ExecutionResult, coins: &dyn CoinLookup, proposer_pubkey: &PublicKey)
    -> Result<Bytes32, BlockError>
    // Returns computed state_root on success

L2Block::validate_full(&self, config: &ValidationConfig, genesis: &Bytes32, coins: &dyn CoinLookup, pubkey: &PublicKey)
    -> Result<Bytes32, BlockError>
    // Chains: validate_structure() → validate_execution() → validate_state()
    // Returns first error or Ok(state_root)

§Height/time lock assertion types (STV-005)

AssertionEvaluation
ASSERT_HEIGHT_ABSOLUTE(h)chain_height >= h
ASSERT_HEIGHT_RELATIVE(h)chain_height >= coin_confirmed_height + h
ASSERT_SECONDS_ABSOLUTE(t)chain_timestamp >= t
ASSERT_SECONDS_RELATIVE(t)chain_timestamp >= coin_timestamp + t
BEFORE_HEIGHT_ABSOLUTE(h)chain_height < h
BEFORE_HEIGHT_RELATIVE(h)chain_height < coin_confirmed_height + h
BEFORE_SECONDS_ABSOLUTE(t)chain_timestamp < t
BEFORE_SECONDS_RELATIVE(t)chain_timestamp < coin_timestamp + t

Relative assertions require looking up the coin’s created_height / timestamp from crate::CoinLookup. For ephemeral coins (created in the same block), created_height is the current block height.

§Chia parity

§Status

Stub — full implementation in STV-001 through STV-007.