Skip to main content

Module traits

Module traits 

Source
Expand description

External integration traits: CoinLookup and BlockSigner.

§Requirements trace

  • STR-004 — trait definitions, method signatures, object safety.
  • NORMATIVE § STR-004CoinLookup uses chia-protocol::CoinState directly; BlockSigner returns chia-bls::Signature.
  • SPEC §7.2 — validation context traits.

§Design decisions

  • CoinLookup returns Option<CoinState>, not Result: A missing coin is a normal validation condition (Tier 3 checks for ephemeral coins — STV-002), not an I/O error. Implementors that wrap a database should map DB errors to None or propagate them through a higher-level API.

  • CoinState from chia-protocol: Reuses the same type Chia’s peer protocol returns for register_for_coin_updates responses (chia_protocol::CoinState). This means dig-coinstore can implement CoinLookup without type conversion. Reference: chia-blockchain/chia/protocols/wallet_protocol.py.

  • BlockSigner is object-safe: Both traits can be used as dyn CoinLookup / dyn BlockSigner so validation and builder code can be generic over the signing backend (HSM, in-memory key, remote signer).

  • SignerError: Kept minimal (one variant) because the signing failure reason is opaque to block validation — it only matters for logging. crate::BlockBuilder::build maps failures to BuilderError::SigningFailed using [SignerError::to_string] (BLD-006 / ERR-004 — the BuilderError variant carries a String, not a nested SignerError, so integration tests assert diagnostic text rather than type equality).

§Downstream implementors

dig-coinstore  ──► implements CoinLookup  (returns chia-protocol::CoinState)
proposer       ──► implements BlockSigner (returns chia-bls::Signature)
tests/common   ──► MockCoinLookup, MockBlockSigner (STR-005)

Enums§

SignerError
Signing failure from a BlockSigner implementation.

Traits§

BlockSigner
Block header signing hook for [crate::builder::BlockBuilder::build] (SPEC §7.2, BLD-006).
CoinLookup
Coin state lookup for Tier 3 (state) validation (SPEC §7.2, STV-001).