Repository navigation
feat(cli): namespace pointers give a namespace a stable host on a public gateway - #2614
Conversation
…nce, decdn publish point Co-Authored-By: Claude Fable 5.1 <[email protected]>
…lic gateway `decdn publish point <ns> decdn:<hash>/ --gateway <origin>` signs an EIP-712 pointer with the namespace owner's keystore and PUTs it to `/_pointer`; the gateway verifies the signer against `PublisherRegistry.ownerOf`, stores it under `<data-dir>/pointers/<ns>.json`, and serves the bundle as a website at `<ns>.<host>`. `--allowance <ns>=<bytes>` gives a namespace its own daily allowance for the requests its pointer serves. Part of #2593. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Allowance isolation, persisted deployment binding, and ownership-check ordering remain unresolved.
3 open issues
What changed in this PR
Adds owner-signed namespace pointers so public gateways can serve each namespace at a stable hostname across bundle updates, using the existing paid-pull infrastructure.
Changes:
- Adds signed pointer submission, ownership verification, persistence, and namespace-host routing.
- Introduces namespace-specific daily allowances and pointer-update metrics.
- Adds
decdn publish point, operator documentation, and unit and end-to-end coverage.
| File | Description |
|---|---|
docker/README.decdn.md |
Documents stable hosts and namespace allowances. |
crates/e2e/tests/gateway_pointer.rs |
Exercises publishing, serving, allowances, and rejected updates. |
crates/common/src/cli/publish/tests.rs |
Tests pointer command parsing. |
crates/common/src/cli/publish.rs |
Defines publish point arguments. |
crates/common/src/cli/mod.rs |
Exports pointer command arguments. |
crates/common/src/cli/gateway/tests.rs |
Tests allowance and registry flags. |
crates/common/src/cli/gateway.rs |
Adds namespace allowance and registry options. |
crates/cli/src/commands/publish/tests.rs |
Tests pointer receipt formats. |
crates/cli/src/commands/publish.rs |
Signs and submits namespace pointers. |
crates/cli/src/commands/gateway/worker/tests.rs |
Updates pool-payment fixtures. |
crates/cli/src/commands/gateway/worker.rs |
Carries namespace allowance selection. |
crates/cli/src/commands/gateway/tests.rs |
Tests pointer routing, validation, and allowances. |
crates/cli/src/commands/gateway/site/tests.rs |
Tests namespace hostname construction and routing. |
crates/cli/src/commands/gateway/site.rs |
Constructs namespace hostnames. |
crates/cli/src/commands/gateway/pointer/tests.rs |
Tests signatures, sequencing, and persistence. |
crates/cli/src/commands/gateway/pointer.rs |
Implements signed pointers and their store. |
crates/cli/src/commands/gateway/metrics/tests.rs |
Tests pointer-update metric exposition. |
crates/cli/src/commands/gateway/metrics.rs |
Counts stored pointer updates. |
crates/cli/src/commands/gateway/allowance/tests.rs |
Tests namespace and shared buckets. |
crates/cli/src/commands/gateway/allowance.rs |
Implements namespace allowance overrides. |
crates/cli/src/commands/gateway.rs |
Integrates pointer updates, routing, and accounting. |
crates/cli/README.md |
Introduces stable namespace hosts. |
CHANGELOG.md |
Records the new gateway functionality. |
adr/appendix-gateway.md |
Specifies pointers, allowances, and responses. |
adr/appendix-bundles.md |
Links namespace hosts to pointer documentation. |
Review effort: Balanced
| file, | ||
| chain_id, | ||
| )?; | ||
| let pointers = Pointers::load(&root.join("pointers"))?; |
There was a problem hiding this comment.
Confirmed: Pointers::load bound the store to nothing, so the same data dir on another chain or registry served pointers nobody there signed. Fixed in #2620: each record carries the chain id and registry the owner was read on, and the gateway refuses to start on a store written for another deployment, naming both and the way out (another --data-dir, or remove the pointers). Covered by a_store_from_another_deployment_is_refused.
| UriTarget::Blob => { | ||
| self.paid(&page_host, pointer, &uri, Present::Download, range) | ||
| .await |
There was a problem hiding this comment.
Fixed in 9df2b80 (before the merge): on a namespace host, /_decdn/<hash>… charges the namespace's bucket only when <hash> is the pointed bundle itself (pointer.filter(|_| uri.hash == site.hash)), in both the navigation and the non-navigation branch. Any other blob or bundle through /_decdn/ spends the shared bucket. The namespace's own bundle keeps its own bucket there on purpose: that is the pointer's content, however the page reaches it. Covered by a_namespace_allowance_pays_for_its_own_bundle_only.
| let (root, seq) = (pointer.root, pointer.seq); | ||
| match public.pointers.set(pointer, signer) { |
There was a problem hiding this comment.
Fixed in 9167b00 (before the merge): put_pointer takes Public::pointer_writes (a tokio mutex) before the ownerOf read and holds it through Pointers::set, so the owner read and the store are one step and a read from before a transfer cannot land after one from after it. The lookup has a 15 s timeout (OWNER_LOOKUP_TIMEOUT) and the lookup budget is taken before the lock, so a spent budget or a hung RPC holds no other write. One gateway-wide lock rather than per namespace: writes are bounded by the 60/min budget. No delayed-RPC regression test: the unit fixtures have no controllable RPC; this is recorded as a known gap.
…ialize and are reused for an hour A signer's highest stored seq outlives a change of hands, so a captured pointer cannot roll a returned namespace back. The owner read and the store run under one lock, so a read from before a transfer cannot overtake one from after it. The holder's own next pointer within the hour reuses its verification, so a flood on the lookup budget does not block a publisher's updates. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…kups time out and precede the write lock `/_decdn/` content from another bundle on a namespace host spends the shared allowance. The owner lookup has a 15 s timeout and the budget is taken before the write lock, so a hung RPC or a spent budget holds no other pointer write. The hour-long reuse of a verification is gone: every stored pointer is verified on-chain. `decdn publish point` refuses a `--gateway` with a path, reports a redirect instead of following it, and gives up after 30 s. Co-Authored-By: Claude Fable 5.1 <[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 |
…et per namespace A flood of strangers spends the shared 60/min budget; a publisher whose pointer the gateway already holds draws on 10/min for that namespace instead, still read on-chain each time, so the flood does not keep it from updating. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>

Part of #2593 (PR 5 of 6). A namespace gets a stable host on a public gateway:
https://<ns>.<host>/serves the bundle its owner-signed pointer names, so the GitHub Action (#2596) and anyone else has one URL per namespace that survives each publish.What
gateway/pointer.rs: the EIP-712Pointer(uint256 namespaceId,bytes32 root,uint64 seq)record, domaindecdn-pointer/1with thePublisherRegistryasverifyingContract(ids repeat across chains and redeploys),SignedPointersign/recover (high-srefused), and thePointersstore: one<data-dir>/pointers/<ns>.jsonper namespace, written through aNamedTempFile, read at start, a damaged file stops the gateway.PUT /_pointeron the public bare host (and the listen address): body ≤ 64 KiB → JSON → signature → held-seqcheck →PublisherRegistry.ownerOf→ store →201 {namespace, root, seq, url}. 409 with the heldseqfor a replay (before any RPC), 422 malformed, 403 wrong owner, 404 no such namespace, 502 chain unreachable, 429 +Retry-Afterpast the per-minute owner-lookup budget. Loopback gateways and site hosts answer 404.Route::Namespace(ns)now serves the pointed bundle through the site path with the site CSP;HEADworks; the page host is<ns>.<host>.--allowance <ns>=<bytes>(repeatable) gives one namespace a bucket that replaces the shared one for requests on its own host. A?ns=or<ns>.<hash32>.label is anyone's and keeps spending the shared bucket. Threaded throughworker::Payment::Pool { namespace }into every charge/refusal site.decdn publish point <ns> decdn:<hash>/ --gateway <origin> [--seq N]: signs with the publisher keystore under the resolved chain id + registry,PUTs with reqwest, printskey=valueor--json;--dry-runloads no keystore. No RPC call.--publisher-registry-addressondecdn gateway(flag → config file → built-in testnet when the chain id matches, else an error naming the flag).decdn_gateway_pointer_updates_total.adr/appendix-gateway.md§ Namespace pointer, a cross-reference inappendix-bundles.md§decdn:URIs,docker/README.decdn.md,crates/cli/README.md, CHANGELOG.Calls beyond the plan (from the review passes)
seq; if that signer owns the namespace now, it replaces the held pointer. Otherwise a former owner's highseqwould hold the host forever after a transfer. Each signer's highest storedseqsurvives in the record, so when a namespace comes back to a former owner a captured old pointer cannot roll it back.PUTflood would be an RPC amplifier against the operator's endpoint. Residual, documented in the appendix: while the budget is spent, other pointers wait for the next minute; per-client limits belong on the proxy, since the gateway does not trustX-Forwarded-*by design. A signer the gateway already stored a pointer from (so, a verified owner at some point) draws on a 10/min budget of its own per namespace instead, still read on-chain each time, so the flood does not keep a publisher from updating. An hour-long reuse of a verification was tried and reverted: it opened a stale-authorization window after a transfer for little real benefit./_decdn/content from another bundle on<ns>.<host>spends the shared bucket, so strangers cannot drain a partner's budget with unrelated content.publish pointrefuses a--gatewaywith a path, reports a redirect instead of following it (reqwest would turn the PUT into a GET), and gives up after 30 s.Tests
pointer/tests.rs: sign/recover, wrong chain/registry, tampered fields, malformed + high-s, JSON shape, store seq order, another-signer replacement, a returning signer's old pointer stays stale, reload after restart, bad/misnamed file fails load, dir 0o700 with no temp leftovers.allowance/tests.rs: namespace bucket replaces, non-override shares.gateway/tests.rs: namespace host 404 → 200 + CSP + HEAD → moves with a newer pointer;PUT /_pointerloopback/site 404, 413/422, same-signer 409 before the chain, other-signer reaches the chain, lookup budget 429, a known signer's own per-namespace budget, valid pointer → 502 with no chain; per-namespace bucket 402 with?ns=7inLinkwhile the hash site still serves;/_decdn/on the namespace host spends the shared bucket.--allowance,--publisher-registry-address,publish point), outcome formats.crates/e2e/tests/gateway_pointer.rs(anvil):publish namespace create→publish point→<ns>.decdn.testserves byte-exact → the 3 MiB namespace allowance refuses the second 2 MiB pull with?ns=inLinkwhile the bundle's site still serves → sameseqexits non-zero with 409 → the operator keystore gets 403. Passes locally.Gates run locally: clippy
--workspace --all-targets --all-features -D warnings,cargo docwith warnings denied,cargo fmt --check,cargo nextest run -p decdn-cli -p decdn-common(1502 passed),make -C adr check-refs check-book-list,pre-commit run --all-files(cargo-deny advisories are pre-existing lockfile findings).🤖 Generated with Claude Code