Repository navigation
feat(node): delivery-path deny gates for ADR 011 takedowns (#1168, #1179) - #1380
Conversation
…n blacklist enforcement The protocol could record a takedown but the delivery path never asked. Two issues, batched because they add the same gate, the same wire append, and share one public-api snapshot regen and one `classify_refusal` decision. **#1168 — local operator denylist.** New `[content]` section with `denied_hashes` / `denied_origins`, hot-reloadable via SIGHUP or `decdn node reload`. Reloadability is the point, not a convenience: ADR 011 § One-hour removal orders sizes this mechanism to the EU TCO one-hour clock, and a restart-only denylist would put a daemon bounce — dropping every in-flight paid stream — on the critical path of discharging a legal order. `DeniedHashes` is a distinct newtype from `PinnedHashes` for the reason `PinnedHashes`' own doc gives: both are `HashSet<Hash>` meaning opposite things, and a mix-up would pin the content an operator was ordered to remove. **#1179 — origin blacklist enforcement.** `OriginBlacklistUpdated` and `isOriginBlacklisted` were absent from the Rust ABI entirely (zero hits across `crates/`), and nothing in the delivery path consulted the blacklist watcher at all — its projection was private and hash-only, reaching `serve_stream` solely as a cache eviction. Adds the event to the watcher's scan, a `ContentDenylist` the delivery path reads, and a durable origin projection alongside the existing entry store. That durability is load-bearing: origin events carry no version, nothing enumerates the set on-chain, and the scan cursor is persisted — so without it a restart brings the gate up silently EMPTY. Gates land at three call sites, not one. The hash gate goes *above* the availability check, because `is_evicted` is only consulted on the cache-miss arm and a denylisted hash the node still holds would otherwise sail past it. The origin gate goes right after channel resolution, and again inside `pull_authorized` — that one runs earliest and decides whether to front upstream USDC, so omitting it would have the node pay on a blacklisted origin's behalf before refusing the delivery. `OriginBlacklisted` and `HashBlacklisted` are appended to `StreamError` (ADR 013 Tier 2 — `StreamResponse.error` is outside the signed field set, so no ALPN bump). They deliberately do NOT join the seven-reason `NotFound` collapse: a client told `NotFound` retries elsewhere and pays again, which for `OriginBlacklisted` can never succeed. `HashBlacklisted` still refuses to say whether the entry is governance or local — a client able to tell would be able to map an operator's private legal exposure by probing. Peer-table removal (`PeerTable::remove`) is wired to origin blacklisting, and its limits are documented rather than papered over: it is advisory (the deny-set is what stops us *serving*; this only stops us *selecting*), and re-entry is closed only on the `addOperator` path, where ejection from `CapacityBond` takes the operator out of the announce gate's staked set. The origin-only path does not eject, so that peer re-enters on its next announce — closing it needs an origin deny-set inside `decdn_gossip`'s `AnnounceGate`. ADR 011 § Local Denylist's TOML example used a `blake3:` prefix that no config parser in the repo accepts; amended in place to the bare lowercase hex `cache.pinned_hashes` already uses, so operators have one hash spelling. Closes #1168 Closes #1179 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (15)
🚧 Files skipped from review as they are similar to previous changes (5)
WalkthroughAdds local content denylist configuration and hot reload, durable on-chain origin blacklist tracking, delivery-time enforcement, distinct protocol errors and metrics, and updated takedown documentation. ChangesContent takedown enforcement
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Operator
participant RuntimeReloadState
participant ContentDenylist
participant BlacklistWatcher
participant CacheEngine
participant ClientHandler
participant StreamClient
Operator->>RuntimeReloadState: reload [content] denylist
RuntimeReloadState->>ContentDenylist: apply local origins
RuntimeReloadState->>CacheEngine: set denied hashes
BlacklistWatcher->>ContentDenylist: apply on-chain origin update
BlacklistWatcher->>CacheEngine: set governance-denied hash
StreamClient->>ClientHandler: request content
ClientHandler->>CacheEngine: check hash refusal
ClientHandler->>ContentDenylist: check funding origin
ClientHandler-->>StreamClient: HashBlacklisted or OriginBlacklisted
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Pull request overview
This PR implements ADR 011 takedown enforcement in the node’s delivery path by adding (1) a hot-reloadable local [content] denylist for hashes and origins and (2) full origin-blacklist enforcement backed by a durable on-disk projection, including new wire-level StreamError variants to distinguish takedown refusals from cache misses.
Changes:
- Append
OriginBlacklistedandHashBlacklistedtoStreamError(protocol) and wire them through node refusal handling and upstream-refusal classification. - Add reloadable
[content]config (denied_hashes,denied_origins) with parsing/validation and a newContentDenylistshared viaArcbetween runtime reload and handlers. - Extend the blacklist watcher to scan
OriginBlacklistUpdated, persist a durable origin projection, update the live deny-set, and advisory-remove the operator’sNodeIdfrom the peer table.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/protocol/tests/snapshots/public_api__public_api.snap | Public API snapshot updated for new StreamError variants. |
| crates/protocol/src/client.rs | Adds OriginBlacklisted/HashBlacklisted with wire-order invariants and tests. |
| crates/node/tests/sighup_signal.rs | Updates resolved-config test fixture to include content. |
| crates/node/src/runtime/reload.rs | Adds reloadable [content] section and exposes a shared ContentDenylist. |
| crates/node/src/runtime/mod.rs | Wires ContentDenylist into ClientHandler and blacklist watcher spawn. |
| crates/node/src/node_origin.rs | Classifies new takedown refusal errors for routing/suppression behavior. |
| crates/node/src/metrics.rs | Adds counters for local-hash deny and origin-deny rejections. |
| crates/node/src/lib.rs | Exposes new content_deny module. |
| crates/node/src/handlers/client/wire.rs | Maps new reject reasons to the new metrics counters. |
| crates/node/src/handlers/client/window.rs | Documents the “deny gates must already have run” invariant for spend-and-serve path. |
| crates/node/src/handlers/client/mod.rs | Adds ServeRejectReason variants and maps them to new wire errors. |
| crates/node/src/handlers/client/fill.rs | Adds earliest origin-deny check to prevent upstream spend on blacklisted origins. |
| crates/node/src/handlers/client/dispatch.rs | Adds hash deny gate before cache availability and origin deny gate after channel resolution. |
| crates/node/src/content_deny.rs | Introduces ContentDenylist with independent local/chain slots and lock-free reads. |
| crates/node/src/channel_store.rs | Adds durable blacklist_origin_v1 table and CRUD for origin projection. |
| crates/node/src/blacklist_watcher.rs | Scans/applies OriginBlacklistUpdated, restores durable origin set, and drops blacklisted peers. |
| crates/incentive/src/store.rs | Extends BlacklistEntryStore trait with origin projection persistence APIs. |
| crates/incentive/src/content_blacklist.rs | Adds Rust ABI for isOriginBlacklisted and OriginBlacklistUpdated event. |
| crates/gossip/src/peer_table.rs | Adds PeerTable::remove and tests, to support advisory blacklisted-peer removal. |
| crates/config-types/src/lib.rs | Re-exports new DeniedHashes type. |
| crates/config-types/src/hash.rs | Adds DeniedHashes newtype distinct from PinnedHashes to prevent semantic mix-ups. |
| crates/common/src/config/types.rs | Adds [content] section schema (ContentConfig). |
| crates/common/src/config/resolved.rs | Adds ResolvedContent to resolved config state. |
| crates/common/src/config/mod.rs | Parses/resolves content.denied_hashes / content.denied_origins and adds tests. |
| crates/cli/tests/config_validate.rs | Updates resolved-config test fixture to include content. |
| crates/cli/src/commands/config.rs | Prints denylist counts in config validate and adds [content] to default config template. |
| adr/011-content-takedown.md | Amends ADR TOML example to bare-hex hashes and documents hot-reload + privacy semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let Some(client) = verified_client else { | ||
| return false; | ||
| }; | ||
| if self.content_deny.is_origin_denied(&client) { | ||
| return false; | ||
| } |
Coverage reportTotal: 81.60% (was 81.32%, ▲ +0.28%) — 55098/67524 lines
History
|
alpergundogdu
left a comment
There was a problem hiding this comment.
Automated correctness review (4 adversarial passes). The refuse-to-serve core for new requests is complete and correct — hash gate sits above the store lookup so it covers every fill/range/node-to-node/window path, the origin gate is authenticated (channel funder + signed binding) and unions local with on-chain, and the config/reload mechanics (strict validation + startup abort, atomic ArcSwap swap, all-or-nothing reload, SIGHUP serialization) all hold. Below are the medium-and-higher findings, all on the completeness/privacy half of ADR 011 rather than the refuse-to-serve half. Lower-severity notes (origin-denied metric undercount on cache miss; ContentConfig doc says duplicates fail but they are silently collapsed; OriginBlacklisted retry advice ignores local denied_origins) are omitted here.
| /// | ||
| /// Governance hash entries are NOT covered here — they arrive as cache | ||
| /// evictions and are answered by `CacheEngine::is_evicted`. Both refuse with | ||
| /// the same wire code, so the split is invisible to a client. |
There was a problem hiding this comment.
Local vs governance hash takedown is wire-distinguishable (Med–High). This comment (and its twins at dispatch.rs:191 and the HashBlacklisted doc in protocol/src/client.rs) says the two sources share a wire code — but they don't. A local denied_hashes hit returns HashDenied → StreamError::HashBlacklisted, while a governance blacklist evicts and returns EvictedSinceProbe. Governance hashes never enter this type, so HashBlacklisted is emitted only for local entries, which means it uniquely fingerprints an operator's private legal exposure — exactly what ADR 011 §643 says must be impossible ("map an operator's private legal exposure by probing"). The same-PR test local_denylist_and_eviction_are_distinct_reasons (mod.rs:1714) assert_ne!s the two codes, contradicting this comment. The origin path does honor indistinguishability (both local and chain → OriginBlacklisted), which is what makes the hash path clearly the odd one out.
Fix (pick one): converge both hash sources on a single wire code (evict on local deny, or return EvictedSinceProbe for local denies too), or — if the distinction is intended — correct §643 and these comments to state that governance→EvictedSinceProbe and local→HashBlacklisted. As written the PR ships a documented-false invariant.
| ) -> anyhow::Result<()> { | ||
| // ADR 011 deny gates are already discharged on the only path that | ||
| // reaches here: `serve_stream` refuses a denylisted hash before the | ||
| // availability check, and this branch is entered only behind |
There was a problem hiding this comment.
In-flight streams aren't terminated on a mid-stream takedown (High vs. ADR). This comment correctly notes the deny gates are discharged at stream-open — but ADR 011 line 599 requires more: "In-flight streams for a blacklisted hash are terminated at the next MB boundary. The client receives a HashBlacklisted error." Neither this window_forward_loop nor the buffered delivery.rs path re-checks the denylist at its collect_voucher boundary, so a hash (or origin) blacklisted after a stream opens keeps flowing to completion — e.g. a large multi-GB blob delivered in full, minutes after a one-hour removal order took effect (and post-compliance-window serving is slashable under ADR 026).
Fix: re-check self.content_deny.is_hash_denied(&req.hash) / is_origin_denied(funder) / self.cache.is_evicted(hash) at each MB boundary in both deliver and window_forward_loop; on a hit, stop forwarding and reset the send side (no StreamEnd sentinel, mirroring the mid-stream fault convention). Note the ADR's promised mid-stream HashBlacklisted frame also does not exist today (the ADR-005 domain split has no mid-stream error frame), so the client-notification half needs a protocol decision. If in-flight termination is intentionally a follow-up, line 599 should say so.
| /// only ever tests set membership. | ||
| #[derive(Debug)] | ||
| pub struct ContentDenylist { | ||
| /// `[content] denied_hashes`. There is no on-chain counterpart slot here: |
There was a problem hiding this comment.
Probe path still advertises locally-denied content (Med). Because a local denied_hashes entry is a serve-gate only — this type holds no CacheEngine handle and set_local never evicts — a hash added to denied_hashes stays in the store. The probe availability handler (probe.rs, try_probe_hold) does not consult content_deny, so it still signs has_blob: true for a held-but-locally-denied hash. (Governance blacklists are safe here only because they go through CacheEngine::evict, which makes try_probe_hold return Unavailable.)
Effects: (a) the node keeps cryptographically attesting availability of content it was ordered to remove, undercutting the takedown even though the follow-up StreamRequest is refused; and (b) probe → has_blob:true followed by StreamRequest → HashBlacklisted fingerprints "locally denied but still held", compounding the wire-distinguishability finding above.
Fix: consult is_hash_denied in the probe availability path (sign has_blob:false for denied hashes), and/or have a local denied_hashes reload also CacheEngine::evict the hash so probe, delivery, and wire-code all converge on the governance behavior.
…tested Multi-agent review of #1380 found the feature was well-built as a data structure and barely connected as an enforcement mechanism. Mutation-testing settled it: all three deny gates could be short-circuited and 1540 tests stayed green. **A locally-denied hash was still probe-signed `has_blob: true` and still DHT-republished.** Only `serve_stream` consulted the denylist, while the governance path gets suppression free because the watcher calls `CacheEngine::evict` — the one lever the probe hold, the republisher, and `populate` all honour. So the path ADR 011 promotes as the fastest, most operator-controlled removal was the one that manufactured slash evidence against the operator: a signed probe plus a signed `ok:false` refusal is exactly the ADR 005 § Probe response phantom-announcement pair, and the error code that distinguishes them is unsigned. Fixed by giving the cache a second, REVERSIBLE refusal set beside `evicted` and routing every "should I expose this blob" decision through one predicate, `CacheEngine::refuses`. Reversibility is why it could not simply reuse `evict`, which is sticky by design; a wrongful takedown has to be undoable without editing a log file and restarting. A fifth consumer now inherits the check instead of forgetting it, which is the failure mode this bug was. That also closes the wire-code leak the same review caught: governance entries refused as `EvictedSinceProbe` while local ones refused as `HashBlacklisted`, so one request told a client which list a hash was on — the exact probe ADR 011 § StreamRequest Response forecloses, and which nine comments in this PR asserted was impossible. Both now sign `HashBlacklisted`; the operator-side metric split survives, since no client can read it. **`addOperator` — the primary governance origin path — never reached the gate.** It writes a separate mapping and emits `OperatorBlacklisted`, never `OriginBlacklistUpdated`. `OriginAssignment.sol` unions the two on-chain; the node watched only one, leaving the voted, ejecting path unenforced while the softer one worked. Both events now feed the same deny-set. **Every upgrading node would have come up with a permanently empty origin deny-set.** The origin projection is new; the blacklist scan cursor is not, so `TableDoesNotExist -> Ok(vec![])` let the scan resume past every origin event ever emitted, with no recovery path — these events carry no version and nothing enumerates the set on-chain. `load_blacklist_origins` now returns `Option`, and absent forces a replay from the deploy block. **A blacklisted funder got `NotFound` on a cache miss.** Every miss arm returns before the old gate position, so the refusal depended on cache state. `NotFound` is the one answer that must not be given here — it tells the client to retry elsewhere and pay again. Gate hoisted above the availability check; the compliance metric no longer under-counts by the cache-miss fraction. **An undecodable origin log was skipped with the error discarded.** For hash events skip-and-continue is survivable (re-scoped every pass, sticky eviction); for origin events there is no backstop, so a skipped log is gone permanently. Now aborts the tick and holds the cursor. Tests: both delivery-path gates are exercised through a real `StreamRequest` and verified to FAIL when the gate is short-circuited; the watcher's origin path gains durable-write-failure, undecodable-log, operator-event, restart-restore, and absent-vs-empty-projection coverage. Also corrects the doc claims the review falsified (duplicate entries are de-duplicated not rejected; address parsing is checksum-agnostic; a DEFAULT_CONFIG example the parser rejects) and the ADR self-contradiction this PR introduced between "immediately" and "on reload". Verified: clippy -D warnings, 2658 workspace tests, 19/19 anvil e2e, cargo doc.
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 89.63% (2663/2971 lines) |
… streams Two findings from the automated review of #1380, both on the completeness half of ADR 011 rather than the refuse-to-serve half. **A governance takedown and a private local denylist entry were still distinguishable in one request.** The previous commit claimed to have closed this and did not: `set_denied` is fed only by the config reload, while the blacklist watcher calls `CacheEngine::evict`, so governance answered `EvictedSinceProbe` and the local list answered `HashBlacklisted`. Since the governance blacklist is public on-chain, a client that got `HashBlacklisted` for a hash with no on-chain entry had positively identified an operator's PRIVATE legal exposure — the probe ADR 011 § StreamRequest Response forecloses, and which the dispatch comment, the `local_denylist_and_eviction_are_distinct_reasons` test, and ADR 011 § 643 all asserted was impossible. Governance hashes now land in their own `CacheEngine` deny-set, gated above the availability check alongside the local one, and both sign `HashBlacklisted`. `EvictedSinceProbe` narrows to what it should always have meant: an eviction with no blacklist entry behind it. The operator-side metric split survives as a new `chain_hash_denied` counter, which no client can read. A second slot rather than reusing `denied` because the lifecycles are independent — a config reload must not lift a governance takedown. And it needs its OWN durable projection, which is the part the sketch of this fix missed: `evicted.log` records that a hash was evicted but never why, and `known` drops a hash the moment it is evicted, so a restart would have silently reverted every pre-existing takedown to the distinguishing code. `recheck` back-fills hashes evicted by an older build, so the upgrade replay heals rather than stranding them. The deny is written BEFORE the eviction and the eviction is skipped if it fails, because eviction is what retires the hash from the retry worklist. **In-flight streams ignored takedowns entirely.** ADR 011 line 599 requires termination at the next MB boundary; neither delivery loop re-checked, so a multi-GB blob kept flowing minutes into a one-hour removal order — and serving past the compliance window is slashable under ADR 026. Both loops now re-check at each `collect_voucher` boundary, after the voucher, so bytes already on the wire are still paid for. Termination is a stream reset under `NO_ERROR`: ADR 005 has no mid-stream error frame but `VoucherRejected`, and coding it as a fault would have clients penalise a node for discharging a takedown. ADR 011's promise of a mid-stream `HashBlacklisted` frame is corrected to match. Tests: both new gates verified to FAIL when short-circuited. The e2e's post-restart assertion now demands `HashBlacklisted`, which is the cross-layer proof of the durable projection. Watcher coverage for deny-and-evict ordering, failed-deny retryability, the upgrade back-fill and its non-repetition, removal lifting the deny only on a definitive out-of-scope read, and absent-vs-empty projection semantics at the redb layer. Also collapses the three copies of the blacklist-table write transaction into one generic helper, and the two projection loaders into one — the third copy is what prompted it. Verified: clippy -D warnings, fmt, 2675 workspace tests, 19/19 anvil e2e, cargo doc -D warnings. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…) (#1426) * fix(node): origin deny-set & authorized-origin gate correctness (#1398, #1368) Batch of tightly-coupled follow-ups from the #1380 / #1366 reviews on the origin deny-set and authorized-origin gate. Node-side fixes + ADR clarifications + the e2e write-surface; remaining e2e journeys tracked as follow-ups. Deny-set correctness (#1398): - set_origin applies the in-memory deny BEFORE the durable write, so a store error no longer skips it and leaves a just-blacklisted origin serving (fail-open -> fail-closed). Test updated to assert the new behavior. - ClientHandlerDeps.content_deny is now a required new() parameter; the empty seed + runtime overwrite was itself a silent fail-open-by-omission. - Drop the dead isOriginBlacklisted ABI + correct the stale boot-reconcile comments (the set is not enumerable on-chain; the durable projection is the guarantee). - resolve_config rejects a hash that is both pinned and denied (held-forever yet serve-refused). Remove the dead DeniedHashes::diff; parse_denied_origins now gives operator-EOA-appropriate zero-address advice. AnnounceGate origin deny-set (#1398 item 6, folds in the inert-retry item 1): - New AnnounceOriginDenySet (ArcSwap, NodeId-keyed). NodeStakedNodeSet refuses an origin-blacklisted operator even while CapacityBond still lists it active (setOriginBlacklist/emergencyAddOrigin do not eject), closing the peer re-entry gap PeerTable::remove only papered over. - apply_origin_peer feeds both directions; a failed nodeIdOf now queues a real retry in pending_origin_peer_ops (drained each tick) instead of the previously inert Recheck::Failed. Boot rebuilds the derived NodeId set from the durable origin projection via seeded pending ops. #1368: ADR 037 and ADR 022 now state the gate is namespace-scoped, not operator-scoped — a non-assigned operator holding the bytes may still serve them. No gate-logic change (matches the implementation). e2e (#1398 item 8): setOriginBlacklist sol! binding + ChainFixture helpers, and a new origin_blacklist_compliance journey (serve -> blacklist -> refuse with OriginBlacklisted -> un-blacklist -> serve) — the ABI-drift guard for the watcher's hand-written origin declarations. #1398 item 5 (in-flight stream termination) was verified already implemented by #1380; unchanged here. Verified: cargo clippy --all-targets clean, cargo fmt --check clean, 876 node + 1009 (gossip/common/config-types/incentive/cache) unit tests pass, and the new anvil journey passes. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * test(e2e): pin the namespace-scoped authorized-origin gate (#1368) Executable companion to the ADR 022 / ADR 037 §85 clarification: node A runs the armed authorized-origin gate and holds H backend-only; a distinct, onboarded operator B is the SOLE authorized origin of namespace N. A still serves H under N even though the DAO assigned N to a different operator — pinning that authorization is a property of the namespace, not of the operator holding the bytes. A negative control (N unauthorized → A refuses) keeps the positive from passing vacuously. Passes against anvil. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * docs(adr): clarify authorized-origin fail-closed is cold-path only (#1374) The gate's authorization check is entirely cache-backed (cached origin set + cached active-staker set; no live RPC read) and the caches are not invalidated on a failed refresh. So the ADR 022 "fails closed on RPC loss" guarantee is the COLD case — an empty or never-resolved namespace resolves to no authorized origin. A WARM namespace (already resolved before the outage) serves stale through a transient RPC blip, favoring availability; the staleness window is bounded by the outage and its conservative direction is a lagging de-authorization, not an un-authorized origin admitted. Documents the behavior #1374 probed. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(cache): deny wins over pin on the LRU eviction path too (#1398 item 7) Defense-in-depth for the runtime deny-set ∩ pinned-hash collision. The takedown path already handled it — the blacklist watcher's cache.evict() ignores the pin, drops tags (GC-reclaimable) and durably logs, and is_chain_denied blocks serving immediately. But the LRU/space-eviction path excluded pinned hashes WITHOUT consulting refuses, so a pinned + governance-denied hash could sit on disk (unservable) if the takedown evict() ever lagged or failed. Carve the pin exemption out for a deny-listed hash on both space seams in CacheEngine: - eviction_candidates: a pinned hash that is is_denied/is_chain_denied stays a candidate (lock-free deny checks, not full refuses, to avoid inverting evict's access_times/evicted lock order — an evicted hash has no access_times entry anyway). - release_for_eviction: the is_pinned early-return no longer exempts a refuses() hash from reclaim. is_pinned itself is unchanged (it feeds the operator-visible inspect flag). No watcher or cache.evict() change. This closes the last deferred item — nothing left as a follow-up. +2 unit tests; full decdn-cache suite (279) green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * test+docs: address PR review — close integration-test gaps, fix comments Follow-up from the multi-agent PR review (no correctness bugs were found). Test hardening (the review's main finding — leaf functions were tested but the integration seams were not): - on_tick_complete_drains_pending_ops_into_the_deny_set: covers the actual retry DRIVER + the boot-rebuild reconstruction path (prior tests called apply_origin_peer directly, bypassing the tick drain). - failed_nodeidof_on_clear_queues_a_retry_that_later_unbars: the clear-direction retry twin (was add-only). - zero_node_id_is_a_settled_no_op_that_clears_pending: the ZERO branch the origin e2e silently takes. - resolve_config_errors_when_a_hash_is_pinned_and_denied: drives the pinned∩denied check through resolve_config, guarding the wiring line (prior tests used the cfg(test) shim). - local_denied_pinned_hash_is_also_an_eviction_candidate: the is_denied (local) half of the cache carve-out. - Extracted origin_watcher_state test helper; deduped the two existing tests. Comment/doc corrections: - content_blacklist.rs: "removed as dead surface" now scoped to the node sol! binding — the on-chain isOriginBlacklisted view is alive (OriginAssignment unions against it; e2e binds it). - engine.rs eviction_candidates: dropped the unfounded "invert evict's lock order" rationale (evict never nests those mutexes); kept the real redundancy+cheapness reason and hoisted the denied/chain_denied loads out of the loop. Documented that held wins over deny deliberately (transient hold; evict() is the actuator). - config/mod.rs: softened "held forever" now that deny-wins-over-pin makes a denied+pinned hash reclaimable at runtime. - blacklist_watcher.rs: "durably" → "reliably" for the in-memory (boot-rebuilt) announce deny-set; documented the blacklisted-before-registration ZERO limitation (bounded — delivery still refused by address). - apply_origin_peer now consumes the AnnounceOriginDenySet insert/remove "changed" return to gate its log (was ignored despite the doc); split out apply_resolved_origin to keep cognitive complexity under the clippy gate. Verified: clippy --all-targets clean, fmt clean, 1813 tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * review: address Copilot — move pending map, typed refusal assertion - blacklist_watcher.rs: the resumable_watcher::spawn factory is FnOnce (constructed once), so move pending_origin_peer_ops into WatcherState instead of cloning the whole map. - origin_blacklist_compliance.rs: assert on the typed UpstreamRefused / StreamError::OriginBlacklisted (as g_node_08_namespace_scope does) rather than a brittle formatted-string match, so a channel/connect/payment regression can't green the check for the wrong reason. Verified against anvil (55s). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…rot again (#1473) `crates/node/tests/anvil_bringup_shutdown_e2e.rs` has not compiled since 2026-07-23. `ResolvedConfig` gained a `content` field in #1380 and `ResolvedCache` gained `max_rate_per_mb` in #1420; neither threaded the new field into this builder. Adding the two initializers is the whole fix — the test then passes on the first run, so nothing about the behaviour it asserts had actually regressed. The interesting part is why nobody noticed for three days. The `anvil e2e (settlement)` job ran `--test anvil_settlement_e2e`, a single-target filter, so this file was never built by any job in CI. It was even edited in its broken state by #1465 the day before this fix, because touching a file that no job compiles produces no signal. `cargo build --workspace --all-targets` does not catch it either: the target is behind the off-by-default `anvil-e2e` feature. So the job now names both anvil targets explicitly rather than filtering to one. A bare `-p decdn-node --features anvil-e2e` would have been shorter but drags the full unit suite in behind the feature flag and duplicates the `test` job; the explicit list keeps the job scoped while making a missing target a build failure instead of silence. The added target needs only `anvil` + `forge`, both already on PATH in that job, and drives `runtime::run` in-process, so it fits the "no daemon binary on disk" property the split relies on. Adds ~25s. Both targets pass together locally: 5 tests across 2 binaries. Incidental, found while auditing the metric registry for #1443: `decdn_probe_holds_disabled_total` was documented twice in `adr/appendix-observability.md` — once under § Slash-Safety Metrics and again under § Probe Metrics — and the two copies had already drifted in wording. The § Slash-Safety Metrics row is canonical (that section's preamble states the probe-hold capacity metrics are grouped there deliberately), so the § Probe Metrics copy is removed and replaced with a pointer naming all five probe-hold metrics and why they live elsewhere. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The protocol could record a takedown but the delivery path never asked. Two issues, batched because they add the same gate, the same wire append, and share one public-api snapshot regen and one
classify_refusaldecision.Independent of #1364 (the contracts half) — the on-chain surface this consumes already exists.
#1168 — local operator denylist
New
[content]section:Hot-reloadable via SIGHUP or
decdn node reload. That is the point, not a convenience: ADR 011 § One-hour removal orders makes this the only mechanism sized to a sub-day statutory deadline (the EU TCO one-hour clock), and a restart-only denylist would put a daemon bounce — dropping every in-flight paid stream — on the critical path of discharging a legal order.DeniedHashesis a distinct newtype fromPinnedHashes, for the reasonPinnedHashes' own doc already gives: both areHashSet<Hash>meaning opposite things, so a mix-up would pin the content an operator was ordered to remove. No conversion between them exists.Surfaced at all 11 sites of the config-knob convention, including
decdn config validate(counts only — printing the hashes would put the subject of a legal order into terminal scrollback) and theDEFAULT_CONFIGtemplate.#1179 — origin blacklist enforcement
Two things were missing, not one:
OriginBlacklistUpdated/isOriginBlacklistedwere absent from the Rust ABI entirely — zero hits acrosscrates/.serve_streamwasCacheEngine::is_evicted.So this adds the event to the watcher's scan, a
ContentDenylistthe delivery path reads, and a durable origin projection alongside the existing entry store. The durability is load-bearing rather than tidy: origin events carry noversion(ADR 011 § Polling puts them outside the counter deliberately), nothing enumerates the blacklisted set on-chain, and the scan cursor is persisted — so without it, a resumed boot brings the gate up silently empty.Gates land at three call sites, not one
dispatch.rs, abovecache.hasis_evictedis only consulted on theOk(false)arm. A denylisted hash the node still holds would sail past it into delivery.dispatch.rs, after channel resolutionfill.rs::pull_authorizedwindow.rsis a fourth ladder but is reachable only behindpull_authorizedand below the hash gate; the invariant is recorded there so a future second caller inherits the obligation.Wire errors
OriginBlacklisted(6) andHashBlacklisted(7) appended toStreamError. ADR 013 Tier 2 —StreamResponse.erroris outside theslash_sig-signed field set, so no ALPN bump. Appended afterVoucherRejectedrather than beside their delivery-side neighbours, because inserting would renumber it on the wire.They deliberately do not join the seven-reason
NotFoundcollapse: a client toldNotFoundretries elsewhere and pays again, which forOriginBlacklistedcan never succeed. The collapse itself is untouched — it is a privacy property protecting channel balances, and widening it was never the point.HashBlacklistedstill refuses to say whether the entry is governance or local (ADR 011's explicit requirement — a client able to tell could map an operator's private legal exposure by probing). The distinction survives only in operator-side metrics, which no client can read.classify_refusalverdicts:HashBlacklisted→DurableMiss(policy, not cache state, won't lapse inside the TTL);OriginBlacklisted→OurFault(says nothing about the peer — every peer refuses identically, so scoring or suppressing it would be wrong twice over).Peer-table removal, and what it does not do
PeerTable::remove()is added and wired to origin blacklisting. Its limits are documented rather than papered over:addOperatorpath, where blacklisting ejects the operator fromCapacityBondand the existing announce gate's staked set stops recognising it. The origin-only path (setOriginBlacklist/emergencyAddOrigin) does not eject, so that peer re-enters on its next announce. Closing it needs an origin deny-set insidedecdn_gossip'sAnnounceGate— deliberately out of scope here, and a test (removed_peer_is_readmitted_by_its_next_announce) pins the gap so it can't quietly be assumed closed.nodeIdOfread is best-effort: a blip pulls the next pass forward rather than rolling back the durable deny-set write. Trading the enforcing half for the advisory one would be the wrong direction.ADR amendment
ADR 011 § Local Denylist's TOML example used a
blake3:prefix that no config parser in this repo accepts. Amended in place to the bare lowercase hexcache.pinned_hashesalready uses — one hash spelling per config file beats fidelity to an illustrative snippet. A test pins the rejection so the two can't drift back apart.Verification
New coverage:
ContentDenylist(local/chain slot independence — a reload must not clobber what the watcher learned, and an address on both lists must survive removal from one), config parsing (bare hex accepted,blake3:rejected, errors namingcontent.denied_hashesnotcache.pinned_hashes), reload (applies without restart, malformed entry keeps the prior set rather than committing an empty one, emptying un-denies),PeerTable::removeincl. the re-admission gap, and the wire-error mapping incl. an assertion that the existingNotFoundcollapse is unchanged.Closes #1168
Closes #1179
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
[content]for denied hashes and denied origins (funder/origin gate).Documentation
Bug Fixes
Tests