Skip to main content

Module origin

Module origin 

Source
Expand description

On-chain origin-directory fallback (ADR 022 §FIND_VALUE Flow “Origin discovery” and §Bootstrap “the on-chain origin directory provides the deterministic fallback”).

When a DHT lookup for a namespaceId != 0 request returns no providers, or the probed holders do not cover every block of the blob, the requester reads the deterministic chain-derived directory keyed on the request’s namespace:

OriginAssignment.getOrigins(namespace_id) → [operator...] → CapacityBond.nodeIdOf(operator) → (NodeId, active) → filter active == true

The bare hash carries no origin information (ADR 002 §Retrieval by namespace): a request supplies the namespace its content is published under, and origin authorization is a namespace-level property. namespaceId == 0 has no authorized origins, so the directory resolves nothing for it.

This trait abstracts the directory so callers consume a single lookup_origins(namespace_id) -> Vec<NodeId> call without caring whether the implementation resolves from chain (production), from a fixed in-memory map (tests), or resolves nothing at all (the fallback installed when the chain contracts aren’t configured).

Three implementations exist:

  • crate::dht::ChainOriginDirectory — the production path, and the only one that can resolve anything. It yields the same candidate set the chain above specifies, but does not perform that literal call sequence: the namespace → operators view is fetched lazily on a cold-namespace miss and cached with a split TTL, and the active filter is applied from the shared StakerSet at lookup time rather than taken from the nodeIdOf tuple. A live cache hit resolves with no RPC; a miss issues one on-demand getOrigins call.
  • EmptyOriginDirectory (this module) — resolves nothing. What the runtime installs when the chain contracts aren’t configured.
  • StaticOriginDirectory (this module) — a fixed in-memory map, for tests and any caller wiring a known origin set without a live chain. No config key populates it; it has no production call site.

The runtime picks between them at bring-up: it constructs a ChainOriginDirectory when blockchain.origin_assignment_address is set, and otherwise installs an EmptyOriginDirectory (see crate::runtime). With that fallback in place every lookup miss yields no origin candidates — see EmptyOriginDirectory for what that means for each consumer.

Structs§

EmptyOriginDirectory
OriginDirectory that resolves nothing.
StaticOriginDirectory
Static, in-memory OriginDirectory over a fixed namespace → origin-NodeId map. Used by tests and any caller wiring a known origin set without a live chain.

Traits§

OriginDirectory
Read-only view of the on-chain origin directory, keyed by the namespace a request is published under (ADR 002 §Retrieval by namespace).