Skip to main content

Module execution

Module execution 

Source
Expand description

Tier 2 execution validation (EXE-*): CLVM execution, condition parsing, signatures, conservation.

§Requirements trace

  • EXE-001validate_execution() API accepting ValidationConfig + genesis_challenge.
  • EXE-002 — puzzle hash verification via clvm-utils::tree_hash().
  • EXE-003 — CLVM execution via dig_clvm::validate_spend_bundle() (not raw chia-consensus).
  • EXE-004 — two-pass condition validation: collect (Pass 1) then assert (Pass 2). Height/time/ephemeral assertions deferred to Tier 3.
  • EXE-005 — BLS aggregate signature verification (inside dig-clvm, not separate).
  • EXE-006 — coin conservation per-bundle (dig-clvm) + block-level fee consistency.
  • EXE-007 — cost consistency: sum(SpendResult.conditions.cost) == header.total_cost.
  • EXE-008ExecutionResult output struct carrying additions, removals, assertions, cost, fees, receipts.
  • EXE-009PendingAssertion type: AssertionKind enum (8 height/time variants) + from_condition() factory.
  • SER-001Serialize / Deserialize on ExecutionResult, AssertionKind, PendingAssertion for bincode.
  • NORMATIVE — full execution validation domain.
  • SPEC §7.4 — Tier 2 execution validation pipeline.

§Pipeline (per SpendBundle, in block order)

for each SpendBundle in block.spend_bundles:
  1. For each CoinSpend: tree_hash(puzzle_reveal) == coin.puzzle_hash         [EXE-002]
  2. dig_clvm::validate_spend_bundle(bundle, config, genesis_challenge)       [EXE-003]
     ├── CLVM execution (clvmr)
     ├── condition parsing (chia-sdk-types::Condition)                        [EXE-004]
     ├── BLS aggregate signature verification (chia-bls::aggregate_verify)    [EXE-005]
     └── per-bundle conservation check (total_input >= total_output)          [EXE-006]
  3. Accumulate SpendResult: additions, removals, conditions, cost, fee
  4. Collect height/time/ephemeral assertions → PendingAssertion              [EXE-004/009]
after all bundles:
  5. Check computed_total_fees == header.total_fees                           [EXE-006]
  6. Check computed_total_cost == header.total_cost                           [EXE-007]
  7. Build ExecutionResult                                                    [EXE-008]

§Chia parity

§Status

Stub — ExecutionResult placeholder defined; full pipeline implementation in EXE-001 through EXE-009.

§Serialization (SER-001)

ExecutionResult, AssertionKind, and PendingAssertion derive serde::Serialize / Deserialize so Tier-2 outputs and deferred assertions use the same bincode wire discipline as block types (SPEC §8.1).

Structs§

ExecutionResult
Validated output from Tier 2 execution, bridging to Tier 3 state validation (EXE-008, SPEC §7.4.7).
PendingAssertion
Deferred height/time assertion collected in Tier 2 and evaluated in Tier 3 (EXE-009).

Enums§

AssertionKind
Height / time assertion opcode mirrored as a stable, bincode-friendly enum (EXE-009).

Functions§

collect_pending_assertions_from_conditions
Collect the height / time / before-height / before-time assertions carried by a chia_consensus::owned_conditions::OwnedSpendBundleConditions into a flat Vec<PendingAssertion> for Tier-3 evaluation (EXE-004, SPEC §7.4.4).
compute_state_root_from_delta
Compute the crate::EMPTY_ROOT-anchored state-delta root for a block’s additions + removals (STV-007, SPEC §7.5.6).
map_clvm_validation_error
Map a dig_clvm::ValidationError to the appropriate crate::BlockError variant (EXE-003, SPEC §7.4.3).
verify_coin_spend_puzzle_hash
Verify that tree_hash(coin_spend.puzzle_reveal) == coin_spend.coin.puzzle_hash (EXE-002, SPEC §7.4.2).