Expand description
§dig-store — the DIG Network DataLayer store manager
A store is the composition of two planes:
- an on-chain anchor — a CHIP-0035 DataLayer singleton (owned by
dig-merkle) whose metadata carries the.digmerkle root plus its label / description / size bucket / program hash; and - an off-chain data plane — the
.digcapsule format (owned bydig-capsule).
dig-store composes the two into ONE curated abstraction, with three concerns:
- Lifecycle — a store is a coin that gets SPENT:
create_store,modify_store,melt_store. Each returns an UNSIGNEDMerkleCoinSpend; the wallet-backend / node signs + broadcasts.dig-storenever holds a key, never signs, never dials the network. - Size proof — a store anchors its
.digSIZE on chain as a power-of-2SizeBucket(1 MB..1 GB, NC-8 minimal encoding). Before keeping a downloaded.dig, a client runsSizeProof::verify: a real size that does not match the anchored bucket isSizeVerdict::Discarded — a dig-node MUST NOT store or serve a size-mismatched capsule. - Getters — a comprehensive read surface over both planes:
- on-chain (chain-proven, NC-9):
get_store_did_owner,get_store_singleton_tip,get_root_history,get_latest_root,get_latest_root_urn,get_store_urn, and the label / description / size / program-hash getters; - off-chain (from a compiled
.digmodule’s bytes, wasmtime-free):get_capsule_identityrecovers a capsule’s declared(store_id, root_hash), andopen_capsuleadditionally cross-checks the declaredstore_idagainst a trusted anchor (fail-closed).
- on-chain (chain-proven, NC-9):
The coin/identity types (Bytes32, Coin, CoinSpend, DataStore, DidRef,
DigDataStoreMetadata, MerkleCoinSpend) and the owner type (StoreOwner) are re-exported
VERBATIM from dig-merkle, and ChainSource from dig-chainsource-interface, so a consumer
depends on ONE canonical shape across the whole DataLayer surface.
§Invariants
- INV-1 — No network.
dig-storeperforms no chain I/O itself; on-chain getters take aChainSourcethe caller supplies (the user’s verified node or a trusted provider set, NC-9), and lifecycle operations are pure transforms of their inputs. - INV-2 — No keys, unsigned output. Lifecycle operations return unsigned spends; signing is
always the caller’s responsibility (inherited from
dig-merkle). - INV-3 — Minimal on-chain encoding (NC-8). The store’s on-chain footprint is delegated
wholesale to
dig-merkle, which owns the minimal byte layout; the size is a single-byte bucket. - INV-4 — On-chain proof always (NC-9). Every getter that returns chain-anchored data proves it against the chain; trust never comes from a self-declared field or an unverified peer.
- INV-5 —
.digback-compat (§5.1). The capsule surface reads every older.digformat identically (inherited fromdig-capsule’s reader, which dispatches on the DIGS blob version); the public API is extended additively, never broken.
§The store_id trust boundary (off-chain capsule getters)
get_capsule_identity recovers a capsule’s DECLARED store_id from module bytes. That id is the
store’s on-chain launcher id and is NOT self-verifiable from the bytes alone — treat it as a CLAIM
until cross-checked against a trusted anchor. open_capsule does that cross-check against a
caller-supplied anchor and fails closed on mismatch. The root_hash is always proven internally
consistent by the reader (it recomputes the merkle root and rejects a forged one).
Re-exports§
pub use capsule::get_capsule_identity;pub use capsule::open_capsule;pub use error::DigStoreError;pub use error::DigStoreResult;pub use lifecycle::create_store;pub use lifecycle::melt_store;pub use lifecycle::modify_store;pub use lifecycle::CreateStoreParams;pub use size::SizeProof;pub use size::SizeVerdict;pub use store::get_latest_root;pub use store::get_latest_root_urn;pub use store::get_root_history;pub use store::get_store_description;pub use store::get_store_did_owner;pub use store::get_store_label;pub use store::get_store_program_hash;pub use store::get_store_singleton_tip;pub use store::get_store_size_bucket;pub use store::get_store_urn;pub use types::CapsuleIdentity;pub use types::RootHistory;pub use urn::capsule_urn;pub use urn::retrieval_key;pub use urn::store_urn;pub use urn::URN_PREFIX;
Modules§
- capsule
- The OFF-CHAIN
.digcapsule getters (SPEC §5/§11): recover a capsule’s declared identity from a compiled.digmodule’s bytes, WITHOUT the on-chain suite and WITHOUT the full wasmtime serve runtime. - chain
- The on-chain read boundary (SPEC §7, NC-9).
- error
- The
dig-storeerror taxonomy (SPEC §6). - lifecycle
- The store LIFECYCLE (SPEC §3): a store is a coin that gets SPENT.
- size
- The store SIZE and the SIZE PROOF (SPEC §4) — the download-gating core of this crate.
- store
- The comprehensive on-chain GETTER surface (SPEC §5/§7): every chain-anchored store property.
- types
- The shared identifier + value types of the store surface.
- urn
- Store + capsule URN formatting (SPEC §5).
Structs§
- Coin
- Coin
Spend - Data
Store - Everything that is required to spend a
DataStorecoin. - DidRef
- A reference to a DID, identified by its immutable
launcher_id(the DID’s on-chain identity). - DigData
Store Metadata - The DIG DataLayer metadata: the SDK’s
DataStoreMetadatashape with the exact byte count ("b") REPLACED by a power-of-2size_bucket("sz"), plus the additiveprogram_hash("p"). - Merkle
Coin Spend - The result of building a DataLayer-coin operation: the unsigned coin spends plus the recreated child DataStore.
- Size
Bucket - A
.digstore size quantised to a power-of-2 bucket: exponentk ∈ 0..=10↔2^k MiB(1 MB..1 GB). See the module docs for the full ladder and the canonical unit (1 MB = 1 MiB).
Enums§
- Store
Owner - Who is authorized to spend a store coin — the p2 (“inner”) puzzle that guards it.
Traits§
- Chain
Source - A reads-only view of Chia chain state — the single canonical contract every provider implements and every consumer depends on.