Core principle
HDP proves:- The on-chain data your module accessed is authentic for the specified chain/block.
- Your Cairo logic ran correctly over that data.
Pattern: “Gather off-chain, constrain in HDP”
When working with subsets (“all events matching X”), use this shape:- Gather candidates off-chain (indexer/API/backend).
- Pass them to HDP.
- In Cairo, enforce:
- membership authenticity,
- uniqueness,
- completeness commitment (counter/root/range/accumulator).
Useful constraint patterns
- Monotonic counters: contract-level counters that must match processed counts.
- Root commitments: Merkle/MMR roots committed on-chain, then matched in HDP (see Verification model).
- Uniqueness guards: nonce/order constraints to prevent duplicates.
- Range commitments: explicit
(start, end)bounds and deterministic traversal checks.
Multi-chain and finality caveat
Even with successful local stages (dry-run/fetch-proofs/sound-run), settlement depends on chain data being present in settlement MMRs.
Always confirm your target blocks and chain combination are supported by the relevant MMR state.
Practical sizing guidance
Throughput depends on your actual computation and resulting step count, not only on payload shape. Start with a narrow prototype, measure steps/resources, then scale (including splitting and recursive composition when needed).Debugging and iteration tips
- Keep modules small at first, then add constraints incrementally.
- Print intermediate values during development (
println!). - Use fixed known blocks and deterministic test inputs early.
- Keep assumptions explicit in code and docs.

