Expand description
Cache engine for deCDN.
Wraps iroh-blobs with origin pull-through logic. The buffered entry
points (engine::CacheEngine::get / populate) fetch from a configured
Origin backend on a cache miss, verify the BLAKE3 hash, and insert the
bytes before returning them to the caller. The streaming entry points do
not buffer whole-blob first: engine::CacheEngine::origin_range_wire
streams one verified sub-range per draw, window by window, for the node’s
two-leg serve-miss spine. Node-to-node pull-through is one
such backend — the
node crate supplies an Origin (NodeOrigin, #831) that pays a peer
over cdn/client/v1 — so this crate needs no knowledge of the paid path.
Leaf crate per adr/appendix-poc-production-seams.md — no #[cfg(...)]
mode branching or feature flags here. The node crate’s wiring layer
selects which origin backend to construct.
Re-exports§
pub use circuit_breaker::Admission;pub use circuit_breaker::BreakerState;pub use circuit_breaker::Clock;pub use circuit_breaker::ManualClock;pub use circuit_breaker::OriginBreaker;pub use circuit_breaker::OriginOutcome;pub use circuit_breaker::SystemClock;pub use engine::CacheEngine;pub use engine::EvictionCandidates;pub use engine::EvictionPreview;pub use engine::OriginHeldReport;pub use engine::OriginPresence;pub use engine::PresentRanges;pub use engine::ServeAudit;pub use error::CacheError;pub use error::CacheResult;pub use error::ErrorChain;pub use error::OriginError;pub use error::OriginPullError;pub use error::SupportedEncoding;pub use fill_session::Demand;pub use fill_session::DemandSlot;pub use fill_session::DownstreamWatch;pub use fill_session::FillClaim;pub use fill_session::FillError;pub use fill_session::FillRegistry;pub use fill_session::FillSession;pub use fill_session::Frontier;pub use fill_session::HashOutboard;pub use fill_session::ObserverLease;pub use fill_session::SessionOutboardReader;pub use metrics::CacheMetrics;pub use origin::FilesystemOrigin;pub use origin::HttpOrigin;pub use origin::Origin;pub use origin::OriginFetch;pub use origin::OriginRangeFetch;pub use origin::OriginRangeRequest;pub use origin::OutboardFetch;pub use origin::S3Credentials;pub use origin::S3Origin;pub use origin::S3OriginConfig;pub use origin_range::MAX_CONCURRENT_RANGE_PULLS;pub use origin_range::OriginRangeWire;pub use origin_range::RANGE_PULL_WINDOW_BYTES;pub use policy::AdmissionContext;pub use policy::AdmissionDecision;pub use policy::AdmissionPolicy;pub use policy::AlwaysAdmit;pub use policy::EvictionContext;pub use policy::EvictionPlan;pub use policy::EvictionPolicy;pub use policy::FrequencyEstimator;pub use policy::LruEviction;pub use policy::Segment;pub use probe_hold::PROBE_HOLD_DURATION;pub use probe_hold::PROBE_HOLD_MARGIN;pub use probe_hold::PROBE_SLASH_WINDOW;pub use probe_hold::ProbeHoldOutcome;pub use ranged_store::NodeRangedStore;pub use serve_store::EncodeStream;pub use serve_store::PresentRangeWatch;pub use serve_store::ServeStore;
Modules§
- circuit_
breaker - Per-origin half-open circuit-breaker for pull-through (#963).
- engine
- Cache engine: local iroh-blobs store fronted by an
Originfor misses. - error
- Error type for the cache engine.
- fill_
session FillSession— the cache-resident fill-coordination primitive the serve-miss legs share (ADR 038).- metrics
- Cache-engine
OpenMetricsmetrics. - origin
- Origin backends — the source of truth a node falls back to on a cache miss.
- origin_
probe - Live-origin probe memo (#1130 pt3): a bounded, TTL’d cache of
HEAD/HeadObjectexistence answers so a per-probe origin existence check does not hammer the backend. - origin_
range - Windowed origin range pulls (#2065): the requested span is fetched in bounded
windows of
RANGE_PULL_WINDOW_BYTESagainst an{H}.obao4outboard that the engine caches per hash, so a range pull holdsO(window + outboard)bytes whatever its length. Each origin read runs under a time budget (seecrate::CacheEngine::set_origin_read_budget). - policy
- Pluggable cache admission and eviction policy traits (ADR 040).
- probe_
hold - Probe-triggered eviction-hold constants (ADR 005 §Probe-triggered eviction hold, §Hold budget; ADR 040 §Pinning, durable operator-evict, and the probe-hold stay engine-enforced).
- range_
pull - Bao verified-range helpers — re-exported from the iroh-blobs-free
decdn_bao_rangeleaf crate (#578) sodecdn-clientcan share the exact same alignment / encoded-size / verify logic without linking iroh-blobs. The serve (engine::export_bao_range), origin range encode (engine::origin_range_wire), and client-receive paths therefore all agree by construction. See ADR 038 §Wire format. - ranged_
store NodeRangedStore: the node-sideRangedStorebackend over the iroh-blobs cache (#1621).- retry
- Origin pull-through retry policy with exponential backoff and jitter (#285).
- serve_
store ServeStore: node-only extension ofRangedStorefor progressive serve-while-filling (#1621).
Structs§
- Bytes
- A quantity of bytes. Wraps
u64; the wire form is a bare integer. - Circuit
Breaker Policy - Per-origin circuit-breaker policy (#963). Field-level validation
lives at config-resolve time
(
crates/common/src/config/mod.rs::resolve_circuit_breaker); this struct just carries the values. - Denied
Hashes - Operator-denied blob hashes — the local denylist from ADR 011 §Local
Denylist (
[content] denied_hashes). A hash here is refused at the delivery path immediately, whether or not the node holds it. - Hash
- The blob-store hash.
decdn_cache::Hashcontinues to meaniroh_blobs::Hash(the BLAKE3 digest the iroh-blobs store keys on) so every existingdecdn_cache::Hashpath indecdn-nodeand the cache crate is unchanged. The config-vocabulary hash that crosses operator-facing config/admin surfaces is the distinctdecdn_config_types::Hash;to_store_hash/from_store_hashconvert between the two (both are the same 32 bytes — issue #578). Hash type used throughout. - Leaf
Hash - The config-vocabulary hash type (
decdn_config_types::Hash), re-exported so callers can build aDeniedHashes/PinnedHasheswithout taking a direct dependency on the leaf crate. Distinct fromHash, which is the iroh-blobs store hash — see thehash_bridgeconversions. 32-byte BLAKE3 content address. The serde representation is the lowercase 64-char hex string — byte-identical to the formiroh_blobs::Hashproduces, so admin JSON-RPC and config TOML stay wire-compatible.decdn-cacheconverts between this andiroh_blobs::Hashat its public boundary (both are the same 32-byte digest). - Origin
Url - Parsed, scheme-validated, and path-normalized origin base URL. The
only way to construct one is
parse_origin_url— once you have anOriginUrl, the following invariants are guaranteed by the type: - PinDiff
- Cheap diff of two hash-set snapshots (
PinnedHashesorDeniedHashes), for the reload log line. - Pinned
Hashes - Operator-pinned blob hashes (#276). Hashes here are excluded from the
LRU eviction-candidate snapshot. Constructing this type is the only
way to feed pinned hashes into
CacheEngine::open_with_pinnedorCacheEngine::set_pinned, so a future “blocklist” or similarHashSet<Hash>-shaped feature can’t be silently passed into the pinning slot. - Retry
Policy - Origin retry policy. Field-level validation lives at config-resolve
time (
crates/common/src/config/mod.rs::resolve_origin_retry); this struct just carries the values.
Enums§
- Decompress
Mode - How the HTTP origin handles
Content-Encodingon the response. - Hash
Parse Error - Error returned when a string is not a valid 64-char lowercase-or-mixed hex BLAKE3 digest.
- Origin
Kind - Tag identifying which origin backend a cache engine is configured
against (#439). Surfaced through the admin eviction-preview so
dry-run callers can estimate origin egress cost — re-fetching from a
Filesystemorigin is a local read;HttpandS3may consume metered bandwidth.
Constants§
- CHUNK_
GROUP_ BYTES - Bao chunk-group granularity (16 KiB, ADR 038), re-exported because it is a
billing-visible property of
CacheEngine::export_bao_range_stream: the export snaps a requested range out to the enclosing group boundaries and the serve path does not trim back, so the payer is charged for the aligned superset. Any caller pricing a range before serving it must align first or it under-reserves by up to two groups. Bytes per chunk group, derived fromIROH_BLOCK_SIZE(2^chunk_log1 KiB chunks) — the granularity an origin range must snap to, because a bao proof anchors whole chunk groups to the root. - DEFAULT_
MAX_ PROBE_ HOLDS - Default ceiling on concurrently-held probe slots before the cache engine starts rejecting new probe holds (#276 / ADR 005). Shared so the config default and the cache engine’s own default cannot drift.
- DEFAULT_
USER_ AGENT - Default
User-Agentheader set on every origin request unless overridden via the operator-configuredcache.user_agent. EmbedsCARGO_PKG_VERSIONof this crate (decdn-config-types). The workspace does not version-link its members, so this can drift from the runningdecdn-nodebinary’s version — that is acceptable: thedecdn-node/prefix is the stable contract operators grep on in access logs; the version segment is best-effort attribution (#435, #578). Lets origin operators attribute CDN pull-through traffic and apply origin-side rate limits or routing rules separately from anonymous client traffic.
Functions§
- from_
store_ hash - Convert a blob-store
Hashinto a config-vocabularydecdn_config_types::Hash. - parse_
origin_ url - Parse and normalize an origin base URL. This is the single source of
truth for origin-URL validation — config resolution and test helpers
both go through it, and the returned
OriginUrlcarries the scheme/path/query invariants in the type. - redact_
for_ log - Return a loggable form of an origin URL with userinfo (
user:pass@) stripped. Operators may legitimately use basic-auth-in-URL for internal origins, but those credentials must not reach logs or error messages. - to_
store_ hash - Convert a config-vocabulary
decdn_config_types::Hashinto the blob-storeHash. Both are 32-byte BLAKE3 digests; this is a pure byte-for-byte reinterpretation (issue #578). Used at the node’s admin boundary whereparse_hash_argyields the config-vocabulary hash that must then index the store.