Repository navigation
feat!: origin attestations are namespace-scoped, expiring and required to serve - #2921
Merged
Merged
Conversation
…d to serve (#2914) An origin attestation is its own EIP-712 type, OriginAttestation(bytes32 hash,uint256 namespaceId,uint64 timestampUs,uint32 ttlSec), signed by a seated origin under the SlashJudge domain and checked off-chain only. It is valid while its signer holds a seat in the attested namespace, its TTL lies in [1 h, 24 h], and it is live. The origin picks the TTL with cache.attestation_ttl_sec (default 12 h), so every verifier agrees on expiry with no on-chain parameter. A node serves a hash only while it holds a live attestation for it; a hit without one is Declined (Unattested). A seated origin attests its own backend content on demand. Every ok: true carries the node's attestation, and the pull path drops an upstream that offers none. From TTL/2 plus up to TTL/4 of per-hash jitter, a holder refreshes from its own seat, the freshest attestation in the DHT, or a voucher-less open to a seated origin of the namespace; an attestation that expires with nothing fresher is dropped. DHT STORE rejects expired attestations, a re-publish keeps the one that expires last, and FIND_VALUE leaves out expired records. MAX_DHT_FRAME grows to 72 KiB for the larger attestation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
… the protocol API snapshot A node whose own backend holds a hash it cannot attest asks for an early seat-set read (rate-limited to one a minute), so an operator seated after boot attests its content without waiting out the 10-minute interval. The G-NODE-01 journey seats its operator once `decdn setup` bonds it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Expired or revoked attestations can still allow successful served responses and continued delivery because validity is not rechecked at the response and pre-send boundaries.
5 open issues
Check attestation validity before sending each response · New Refuse served responses when no live attestation remains · New Serialize attestation replacement to prevent stale overwrites · New Avoid removing a concurrently renewed attestation · New Retain expired hashes for retryable attestation refresh · New
What changed in this PR
This PR makes origin attestations namespace-scoped and time-limited, connecting deCDN’s serving and discovery rules to live origin authorization. It changes the wire format without changing the signed StreamResponse body or contracts.
Changes:
- Adds a separate EIP-712 attestation type with a configurable 1–24-hour lifetime.
- Adds serving and upstream-selection gates, attestation refresh, DHT expiry filtering, and metrics.
- Updates protocol bounds, tests, onboarding fixtures, configuration, and architecture documentation.
| File | Description |
|---|---|
crates/protocol/tests/snapshots/public_api__public_api.snap |
Updates the public attestation API snapshot. |
crates/protocol/src/lib.rs |
Exports attestation lifetime constants. |
crates/protocol/src/dht/tests.rs |
Tests lifetime bounds and larger frames. |
crates/protocol/src/dht.rs |
Defines expiring attestations and raises the frame ceiling. |
crates/protocol/src/client/tests.rs |
Updates response-size assertions. |
crates/protocol/src/client.rs |
Documents forwarding live attestations. |
crates/node/tests/support/mod.rs |
Supplies valid fixture attestations. |
crates/node/tests/sighup_signal.rs |
Adds TTL to configuration fixtures. |
crates/node/tests/partial_serve.rs |
Registers payloads for fixture attestations. |
crates/node/tests/origin_range_pull.rs |
Attests range-test payloads. |
crates/node/tests/node_origin_pull.rs |
Includes attestations in served fixtures. |
crates/node/tests/dht_loopback.rs |
Adapts record-validation callbacks. |
crates/node/tests/dht_bootstrap.rs |
Seeds attestations for publishing tests. |
crates/node/tests/client_loopback.rs |
Attests partial-serving payloads. |
crates/node/tests/anvil_bringup_shutdown_e2e.rs |
Adds TTL to daemon configuration. |
crates/node/src/runtime/tests.rs |
Updates runtime configuration fixtures. |
crates/node/src/runtime/reload/tests.rs |
Updates reload configuration fixtures. |
crates/node/src/runtime/reload.rs |
Marks attestation TTL as restart-required. |
crates/node/src/runtime/mod.rs |
Wires TTL and the refresh task. |
crates/node/src/origin_seat_watcher/tests.rs |
Tests namespace-specific seat checks. |
crates/node/src/node_origin/timed_source/tests.rs |
Tests invalid-attestation rejection. |
crates/node/src/node_origin/timed_source.rs |
Gates source opens on attestation availability. |
crates/node/src/node_origin/tests.rs |
Covers unattested discovery-drop accounting. |
crates/node/src/node_origin/pull_leg.rs |
Checks attestations during pull handshakes. |
crates/node/src/node_origin/mod.rs |
Adds attestation checks to upstream selection. |
crates/node/src/node_origin/attestation_refresh/tests.rs |
Tests self-refresh, retries, and expiry. |
crates/node/src/node_origin/attestation_refresh.rs |
Refreshes from self, DHT, or origins. |
crates/node/src/metrics/tests.rs |
Tests rejection and refresh counters. |
crates/node/src/metrics.rs |
Defines attestation lifecycle metrics. |
crates/node/src/handlers/dht.rs |
Validates attestation lifetime and namespace seats. |
crates/node/src/handlers/client/wire.rs |
Checks serve eligibility and forwards live attestations. |
crates/node/src/handlers/client/tests.rs |
Tests the Unattested refusal mapping. |
crates/node/src/handlers/client/outcome/tests.rs |
Covers unattested outcome accounting. |
crates/node/src/handlers/client/outcome.rs |
Labels and meters unattested refusals. |
crates/node/src/handlers/client/mod.rs |
Adds Unattested and documents handler wiring. |
crates/node/src/handlers/client/dispatch.rs |
Gates cache hits and own-backend serving. |
crates/node/src/dht/seated_origins/tests.rs |
Tests namespace isolation and seat selection. |
crates/node/src/dht/seated_origins.rs |
Exposes namespace-scoped seat queries. |
crates/node/src/dht/records/tests.rs |
Tests latest-expiry record retention. |
crates/node/src/dht/records.rs |
Retains later-expiring attestations on republish. |
crates/node/src/dht/publish.rs |
Requires live attestations for publishing. |
crates/node/src/dht/lookup.rs |
Collects the latest-expiring valid attestation. |
crates/node/src/dht/attestation/tests.rs |
Tests namespace, expiry, skew, and TTL validity. |
crates/node/src/dht/attestation/test_support.rs |
Provides live namespace-scoped fixtures. |
crates/node/src/dht/attestation.rs |
Implements shared signing and validity checks. |
crates/node/src/attestations/tests.rs |
Tests retention, refresh timing, and persistence. |
crates/node/src/attestations.rs |
Stores live attestations and refresh scheduling state. |
crates/incentive/src/stream_sig.rs |
Removes response-derived attestation recovery. |
crates/incentive/src/origin_attestation/tests.rs |
Tests typed signatures and field binding. |
crates/incentive/src/origin_attestation.rs |
Implements dedicated EIP-712 attestation signatures. |
crates/incentive/src/lib.rs |
Exports attestation signing helpers. |
crates/e2e/tests/g_node_01_onboarding.rs |
Seats the operator before testing serving. |
crates/e2e/src/node.rs |
Seats onboarded fixture operators as origins. |
crates/common/src/config/types.rs |
Adds the optional attestation TTL setting. |
crates/common/src/config/tests.rs |
Tests TTL defaults and bounds. |
crates/common/src/config/resolved.rs |
Carries the resolved TTL. |
crates/common/src/config/mod.rs |
Resolves and validates TTL configuration. |
crates/client/src/opened.rs |
Uses only explicit forwarded attestations. |
crates/client/src/lib.rs |
Documents upstream attestation requirements. |
crates/cli/tests/config_validate.rs |
Updates resolved configuration fixtures. |
crates/cli/tests/admin_rpc.rs |
Updates DHT attestation fixtures. |
crates/cli/src/commands/config/tests.rs |
Checks template coverage for TTL. |
crates/cli/src/commands/config.rs |
Adds TTL to the configuration template. |
adr/glossary.md |
Updates namespace and attestation definitions. |
adr/architecture.md |
Summarizes attestation-based serving and discovery. |
adr/appendix-observability.md |
Documents rejection and refresh metrics. |
adr/040-cache-policy.md |
Clarifies that pins do not grant serve rights. |
adr/019-node-onboarding.md |
Documents origin-seat requirements. |
adr/017-privacy.md |
Updates attestation data-exposure analysis. |
adr/014-on-chain-verification.md |
Distinguishes attestations from stream signatures. |
adr/013-schema-evolution.md |
Updates frame sizes and memory bounds. |
adr/011-content-takedown.md |
Describes expiry and unseating consequences. |
adr/005-protocol.md |
Defines serving gates and attestation forwarding. |
adr/002-content-addressing.md |
Explains namespace scope and availability dependencies. |
adr/001-network.md |
Conditions cached serving on live attestations. |
Review effort: Balanced
…eep a lapsed one for a held blob - sign_served reads the live attestation once and refuses Unattested when none remains, so no ok: true answer goes out without one. The buffered fill tiers now pass the serving rule before they answer. - pre_send_checks stops a delivery whose attestation lapsed, counted on decdn_serve_stream_terminated_unattested_total. - The store compares and replaces under one write lock, serializes its file writes, and skips a file whose signer does not recover at load. - A failed refresh keeps an expired attestation while the node holds the blob and retries it; it drops one only when the held entry is still expired and the blob is gone. Live refreshes run before lapsed ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l-config-b2a4bc # Conflicts: # adr/appendix-observability.md
- A DHT re-publish keeps the held attestation only while it is still valid, so a valid replacement wins over a later-expiring dead one. - Refresh runs only while the node holds the blob; an attestation for a blob it does not hold is dropped (compare-and-remove) instead. - A served hash with no attestation at all is marked wanted, and the refresh task recovers one from the DHT (at most 4,096 wanted hashes, one lookup per 10 min each). - Each refresh tick runs up to 256 jobs, 8 at a time, and a stop cancels a tick in flight. - An upstream leg with no valid attestation is a typed error ruled a transient refusal, never scored Unreachable. - A failed re-sign past half-life falls back to the live attestation. - The store loads only files named for their hash and removes leftover .tmp, old-format and forged files with one warning. - Docs: qualify the upstream-refusal claim, document the unseated-origin and empty-blob exemptions, the hash-to-namespace exposure, the deny-set in rejection lists, and fix stale frame-size and error text. - Tests: mid-stream termination on unseating, expired STORE refusal, keep replacing a dead attestation, empty-blob serving, wanted hashes, .tmp cleanup, and the unattested-leg verdict. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thiras
approved these changes
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Closes #2914.
What changes
Attestation type. An origin attestation is its own EIP-712 struct,
OriginAttestation(bytes32 hash,uint256 namespaceId,uint64 timestampUs,uint32 ttlSec). A seated origin signs it with its operator key under theSlashJudgedomain. Only nodes check it; no contract reads it. TheStreamResponsetype andSlashJudgedo not change. The origin stamps the timestamp from its own clock, so the request-timestamp bound plays no part in the attestation's lifetime.Validity. An attestation is valid when all of these hold:
(namespace, operator));ttlSecis in[3600, 86400];now − ttl < timestamp ≤ now + 30 s.TTL. Each origin sets its TTL in
cache.attestation_ttl_sec(default 12 h, range 1 h to 24 h) and signs it into every attestation. Every verifier then reads the same expiry, and no on-chain parameter is needed. The publisher sets its takedown latency through the config of the origins it seats.Serving gate. A node serves a hash only while it holds a live attestation for it. A cache hit, whole or partial, without one is refused
Declined, under the new reasonUnattested. A seated origin signs its own attestation for content its backend holds. Everyok: trueresponse carries the node's attestation inStreamResponseExt.origin_attestation. A puller that holds no live attestation of its own for the hash drops an upstream whose served answer has no valid attestation, before it ranks or pays it. A later leg that hits the same check is a transient refusal, never scoredUnreachable. Pinned hashes follow the same rule. The empty blob is exempt because it has no content.The node checks the rule again at two later points:
sign_servedreads the live attestation once and signs it into the answer. With none, it signs nothing and the node refusesUnattested. Every fill tier also runs the gate once its blob lands, so a seated origin signs its own there.NO_ERROR, as a takedown does. A lapse is an attestation that expired with no fresher one found, or whose signer lost its seat or came onto the origin deny-set. The check reads no signature: the store keeps the signer it recovered when it accepted the attestation.Refresh (
node_origin/attestation_refresh.rs). Refresh starts at TTL/2 plus a per-hash jitter of up to TTL/4. Sources are tried in this order:A refresh runs only while the node holds the blob. An attestation for a blob the node does not hold (a pull that never landed, an eviction) is dropped instead of refreshed. A failed refresh retries after 10 min. Each tick runs up to 256 jobs, 8 at a time: live attestations first, soonest to expire first, then expired ones, then wanted hashes. A stop cancels a tick in flight. When an attestation expires with nothing fresher found, the node stops serving and publishing that hash, keeps the expired attestation, and keeps retrying, so the hash serves again once an origin of its namespace returns.
Wanted hashes. A node can hold a blob with no attestation at all, for example after it loses its attestation store. A request for such a hash is refused
Unattested, and the node marks the hash wanted. The refresh task looks it up in the DHT at most every 10 min and keeps the freshest valid attestation it finds. The node tracks at most 4,096 wanted hashes, and stops wanting one once it keeps an attestation or no longer holds the blob.Store (
attestations.rs). The store compares and replaces under one write lock, so a concurrent older offer never displaces a newer attestation. File writes go one at a time, and each writes the entry in memory at that moment. At load, only files named for their hash load. Leftover.tmpfiles, old-format files and files whose stored signer does not recover from the signature are removed, with one warning.DHT. STORE rejects attestations that are not live. A re-publish keeps the valid attestation that expires last, so a valid replacement always wins over a dead one that expires later. FIND_VALUE leaves out records whose attestation is no longer valid. The larger attestation (113 B at its widest) pushes
MAX_DHT_FRAMEfrom 64 KiB to 72 KiB.Metrics:
decdn_serve_stream_rejected_unattested_totaldecdn_serve_stream_terminated_unattested_total(a delivery stopped mid-stream by a lapse)decdn_attestation_refreshed_{self,dht,origin}_totaldecdn_attestation_refresh_failed_totaldecdn_attestation_expired_total(counted once per expiry)Docs. ADRs 001, 002, 005, 011, 013, 014, 017, 019, 022 and 040, plus the observability appendix, architecture and glossary.
Wire-breaking for the DHT and
StreamResponseExt, with no compatibility path (pre-mainnet).Where this differs from the issue text
namespaceto the signedStreamResponsebody. This leavesSlashJudgeand every stream response unchanged. It also means an origin cannot get a long-lived attestation by echoing a requester's future timestamp.Testing
cargo nextest runon node, protocol, incentive, common, client and cli: 5280 passed.EOF while parsingfrom a fresh submodule checkout, which this change does not touch.cargo docwith warnings denied, crate-edges, and the ADR hygiene hooks pass.NodeFixturenow seats each onboarded operator as an origin of a fresh namespace.cargo nextest run -p decdn-nodepasses 1684/1684. Workspace clippy (--all-targets --all-features), fmt,cargo docwith warnings denied andmake -C adr check-refspass. New tests cover concurrent keeps, the compare-and-remove on expiry, an expired attestation kept for a held blob, refresh ordering, a forged signer at load, andsign_servedwith and without a live attestation.keepand DHT re-publish replacing a later-expiring dead attestation, the empty blob served with no attestation, the wanted-hash lifecycle,.tmpcleanup at load, and the unattested-leg verdict.Follow-ups
🤖 Generated with Claude Code