Repository navigation
test(e2e): add G-NODE-08 authorized-origin recognition (opaque backend fetch) - #1366
Conversation
One node, one opaque `fs` backend, one config: the only thing that changes between the negative and positive halves is on-chain truth. - negative: with nothing claiming H and namespace 0's default-open set empty, the `pull_through_require_authorized_origin` gate refuses the backend fill (signed wire `NotFound`) while the same node still serves a blob it holds in cache — proving it is a cache, not a recognized origin. The gated miss also writes nothing to the store, and the ranged shape is gated identically. - ratification: publisher creates a namespace, claims the backend-only hashes, proposes the operator set; the DAO activates through the assignment timelock. - positive: the same node now fills opaquely from its own backend and serves bao-verified bytes, and a ranged origin fetch returns the exact requested tail. - wire opacity: a raw `cdn/client/v1` tap captures every frame of a backend-fed delivery and asserts the backend root, each of its path components, the derived object key, and `file://` appear nowhere in them — with a positive control (the requested hash IS on the wire) so the scan cannot pass vacuously. Fixture support (test-only crate): - `NodeFixture::launch_authorized_origin` / `seed_origin_blob` / `origin_root` — a gated node whose backend can be seeded after launch, so a blob can exist in the backend without ever entering the cache. - `NodeFixture::wait_for_channel` + `ClientFixture::open_session` / `fetch_once` / `capture_delivery_wire` — `fetch`'s retry loop cannot tell the pre-observation window from a real refusal, so asserting on a single refusal needs a channel the node has already registered. 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. |
|
Warning Review limit reached
Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (3)
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 |
Coverage reportTotal: 81.35% (was 81.55%, ▼ 0.20%) — 53777/66103 lines
History
|
Review follow-ups on the G-NODE-08 journey. The test passed before this, but
several of its assertions could pass vacuously or fail spuriously.
Could pass while a real leak went unseen:
- `frames_contain` searched each frame in isolation. Frames are 1 KiB
(`CHUNK_SIZE`) and the composite path needle is ~110 bytes, so a leak
straddled a frame boundary — and was missed — about 10% of the time. Scan
the concatenation instead; for a negative assertion that can only ever
false-alarm, never false-pass.
- The positive control searched for the blob hash, which is echoed in the
`StreamResponse` (frame 0). It stayed green under every possible truncation,
so it proved the byte search ran but nothing about coverage. Probe the
payload's final 32 bytes instead: those live in the last chunk group, so
finding them proves the capture reached the end.
- `delivered >= payload.len()` had exactly one frame of slack, at the tail:
TAPPED_LEN is an exact multiple of the wire frame, so the full frames alone
sum to payload.len(). Require `>` — a complete delivery strictly exceeds the
content length by its bao proof overhead.
- The ranged refusal was a bare `expect_err`, satisfied by a transport error,
a stale nonce or a timeout. Assert the signed `NotFound` and the unwarmed
store, same standard as the whole-blob case.
- The wire tap folded a genuine `FrameError` into its idle terminator,
silently returning a truncated capture. Match the three outcomes and
propagate real read errors.
Could fail with nothing wrong:
- The needle sweep admitted 2-char path components. Captured frames carry
several hundred bytes of uniformly random bao parent hashes and signatures,
so on macOS (`/var/folders/xy/…`) a 2-byte needle matched by chance ~1% of
runs. Require 6+ chars; a real leak surfaces the root, object key or tempdir
leaf, all far longer.
- `WIRE_TAP_IDLE` (5s) doubled as the first-frame budget, which must cover the
node's entire reactive backend fill. Split out a 30s first-frame deadline.
Comment corrections, each verified against the source:
- The claim that the timelock advanced chain time past the old channel's
usefulness was wrong — a 3-day assignment timelock against a 90-day channel
duration. `fetch` is used because it retries, pending the directory watcher.
- The ranged half does not reach the origin range tier: `seed_origin_blob`
writes no `{H}.obao4`, so `FilesystemOrigin::fetch_range` reports
`Unsupported` and it degrades to a whole-blob fill plus `export_range`.
- `capture_delivery_wire` cannot capture `VoucherAck`/`StreamEnd` (emitted only
after payment), returns frame payloads rather than raw stream bytes, and
leaves the tapped blob warmed in the node's store.
- `wait_for_channel` narrows the pre-observation window but does not close it:
it polls the persisted store while the serve path gates on the in-memory map,
and `register_open_channel` fsyncs before inserting.
- The gate is namespace-scoped, not operator-scoped — `pull_origin_gate_blocks`
never compares this node's operator address. Docs now state that without
asserting it is correct; tracked in #1368.
Fixture hygiene: rename `ChannelSession::provider` to `operator_addr` (the
alloy RPC handle is what "provider" means in this file), drop the `channel_id`
field duplicating `ctx.channel_id`, and fold both watermark copy-backs into
`record_progress` with a monotonicity check.
Follow-ups filed: #1368 (gate scope), #1371 (metrics-pinned refusal), #1372
(seed .obao4 for real range-tier coverage), #1373 (revocation/deactivation),
#1374 (fail-closed on RPC loss), #1376 (RenderConfig flag coupling).
Verified: full anvil-e2e suite 20/20, cargo clippy --workspace --all-targets
-D warnings, cargo fmt --check, cargo doc.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Review — G-NODE-08 authorized-origin journeyRead the full diff plus the source it leans on. This is very careful test engineering — the load-bearing verification in the description (gate-off → serves; hash-in-needles → trips), the tail-based positive control, the concatenated (not per-frame) needle scan, I re-verified each load-bearing coupling against the tree rather than taking the comments' word, and they all hold:
Three non-blocking observations:
LGTM. Generated by Claude Code |
Review follow-up on #1366. `open_session` waited on `wait_for_channel`, which polls the admin API — and that reads the *persisted* channel store, while `serve_stream` / `pull_authorized` gate on `ClientHandler`'s in-memory map. `register_open_channel` awaits the store fsync before inserting into that map, so the wait could return one step ahead of the serve path. Every session's first `fetch_once` therefore rode that gap. The two single-shot *successes* were the exposed ones: the cached control on `unauthorized`, and the ranged fetch on the fresh `authorized` channel. Neither could pass vacuously — both fail loudly as `UnknownChannel` → `NotFound` — so this was a latent flake rather than a soundness hole, but the guarantee `open_session` advertised was not one it delivered. Close it where the claim is made: `open_session` now takes a `warmup` hash the node is known to hold and retries fetching it until it succeeds. A served blob is what actually proves the live map is populated, because the serve path had to read it. The warm-up bytes are returned, so the journey's existing cached-blob control *is* the warm-up rather than an extra delivery — the assertion it always made is now also what establishes readiness. The `authorized` session warms on the same cached blob, since the `AssignmentActivated` argument that justifies its ranged fetch covers gate-readiness but not channel registration, which is a separate fact. `wait_for_channel` keeps its caveat and now points at `open_session` as the predicate to prefer. Costs one extra ~96 KiB loopback fetch on the second session: the journey goes from ~10.2s to ~10.5s, measured over four runs. Verified: full anvil-e2e suite 20/20, cargo clippy --workspace --all-targets -D warnings, cargo fmt --check, cargo doc (including the pre-commit hook's --document-private-items pass). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Fixed observation 1 in fbf2e83; observations 2 and 3 need no code change. 1 — single-shot successes riding the pre-observation window. Verified: Rather than document the gap, I closed it where the claim is made. The Cost is one extra ~96 KiB loopback fetch on the second session: ~10.2s → ~10.5s, measured over four runs. anvil-e2e 20/20 locally. 2 — #1368. Agreed that it defines what the journey proves. Left as the hedge you describe, tracked there. 3 — coverage delta. Agreed, no action. One thing worth flagging from this round, unrelated to the diff: the first CI run on a85275c failed |
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 89.58% (2657/2966 lines) |
…1367 follow-ups) (#1404) * test(e2e): harden authorized-origin & slash-evidence journeys (#1366/#1367 follow-ups) Batch of six test-only follow-ups from the reviews of #1366 (authorized-origin gate, G-NODE-08) and #1367 (G-GOV-03 real-evidence slashing). Turns circumstantial e2e assertions into direct ones and hardens fixture diagnostics. - #1376: split RenderConfig's single bool into node_to_node_pull_through + require_authorized_origin; the render_config test sets them to distinct values. - #1371: NodeFixture::scrape_metric; G-NODE-08 pins the refusal to the unauthorized-origin reject counter (0->1) instead of the collapsed wire NotFound that ServeRejectReason::wire_error folds seven reasons onto. - #1372: seed_origin_blob_with_outboard so the ranged fetch reaches the real origin range tier, with a partial-presence control distinguishing it from a whole-blob fill. - #1373: revokeAssignment binding + ChainFixture wrapper; new g_node_08_revocation journey (gate re-closes on revoke; already-held content survives). Staker-deactivation leg documented as a tracked follow-up. - #1378: real-evidence EvidenceAlreadyUsed + InvalidStreamSignature negatives; client-pull mid_stream_refusal + unit tests; set_rate_per_mb round-trip test. - #1379: hardened extract_slash_id (address+topic0 filter, propagates decode errors, asserts offenseType/evidenceHash); UpstreamVoucherRejected arm in refused_stream; node-B refusal pinned to the cache-miss counter; fixed the backwards refusal() message. The only production change is in client-pull: a private mid_stream_refusal constructor (behavior-preserving extraction of four identical sites) and a corrected error message; public API unchanged. Verified: cargo nextest (101 unit tests) + anvil journeys g_node_08_authorized_origin, g_node_08_revocation, g_gov_03, smoke, slash_appeal all pass; fmt + clippy --workspace --all-targets clean. Closes #1371 Closes #1372 Closes #1373 Closes #1376 Closes #1378 Closes #1379 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * docs(e2e): warn scrape_metric is delta-only (review follow-up) Two reviewers noted scrape_metric's return-0-on-missing contract makes an absolute assertion (== 0) pass vacuously on a typo'd/unregistered name. All current callers assert a 0->1 delta, which stays non-vacuous; document the constraint so a future absolute check isn't written by mistake. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(e2e): bound smoke served-bytes to [content, wire] (#1381) The anvil-e2e 'smoke_compose_fixtures' served-bytes check was flaky: it asserted on-chain served-bytes == payload.len() (content), but the paid path meters WIRE bytes (content + interleaved bao proof, ADR 038 §Payment metering), so a fully settled 2 MiB delivery lands content + ~0.4% proof overhead. Root cause of the flake: the client pays a cumulative voucher at each voucher_interval_mb boundary (each >= redeem_threshold_micro_usdc, so each redeems) plus a final closing voucher for the last partial group. That closing delta is only ~8 KiB of trailing proof, far below the redeem threshold, so whether it has settled on-chain when the test reads is a race: not-yet -> content total (observed locally), settled -> full wire total (observed on CI run 29881984765). Both are correct transient states of the same delivery, so any exact-equality assertion is inherently racy. Bound served-bytes to [content_bytes, wire_bytes] instead, computing the wire total via the canonical decdn_bao_range::align_range(..).wire_len() the client itself pays against. '< content' still catches a redeem that never landed; '> wire' catches over-accounting past the paid wire bytes. Deterministic 3/3 locally. Closes #1381 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- 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]>
Adds
crates/e2e/tests/g_node_08_authorized_origin.rs— the G-NODE-08 journey. Test-only: the whole diff is the new journey plus the fixture primitives it needs (decdn-e2eispublish = falsetest infrastructure).Shape
One node, one opaque
fsbackend, one config. The only thing that changes between the negative and positive halves is on-chain truth, so the two halves are directly comparable — same process, same backend, same TOML.The node runs with
cache.pull_through_require_authorized_origin, which puts its reactive cache-miss fill behind the chain-backedChainOriginDirectory(ContentClaimed→OriginAssignment.getOrigins→ active operator). It has no discovery peers, so a served backend-only blob can only have come from its own[cache.origin].Four payloads: one pre-warmed into the store, three written into the backend after launch (
seed_origin_blob) so they exist in the backend and have never been cached.What is asserted
Negative — unauthorized node serves only as cache. Chain truth is asserted first (nothing claims H; namespace 0's default-open set is empty), then:
UpstreamRefused { error: NotFound }— the gate refuses to initiate the fill;has_blob: false, so the gated miss wrote nothing to the store;Setup / ratification. Publisher creates a namespace, claims the three backend-only hashes, proposes this operator; the DAO activates through the assignment timelock (
activate_assignment_after_timelock).Happy path. The same node now fills opaquely from its own backend and serves bao-verified bytes byte-identical to the backend copy; a follow-up probe shows the reactive fill landed the blob locally.
Ranged origin fetch. A never-cached hash fetched at a deliberately unaligned
byte_offsetreturns the exact requested tail, bao-verified against the whole-blob hash.Wire opacity. A raw
cdn/client/v1tap (capture_delivery_wire) drives a delivery the node can only satisfy from its backend and captures every frame verbatim — no client-side decoding, the exact bytes the node put on the QUIC stream. It asserts the delivery was real (signedokresponse, truetotal_bytes,redirect: None, whole delivery captured) and that the backend root, each of its path components, the derived object key, andfile://appear nowhere in those bytes. Per CLAUDE.md §Key Design Decisions: no external origin URLs are ever exposed.Load-bearing evidence
Both halves were verified to fail when the thing they assert is removed:
pull_through_require_authorized_origin = false(leaving everything else identical) makes the unauthorized node serve the backend-only blob, and the journey fails atan unauthorized node must not serve from its backend. Reverted.opaque backend leaked onto the wire. Reverted. The same fact is kept permanently in the test as a positive control: the scan must find the requested hash in the captured frames, so the absence assertions can never pass vacuously.Fixture primitives added
NodeFixture::launch_authorized_origin/seed_origin_blob/origin_root— a gated node whose opaque backend can be seeded after launch, so a blob can exist in the backend without ever entering the cache (the existing constructors always warm what they seed).NodeFixture::wait_for_channel+ClientFixture::open_session/fetch_once/capture_delivery_wire—ClientFixture::fetch's retry loop cannot tell the node's pre-observation window from a real refusal (both are wireNotFound), so asserting on a single refusal needs a channel the node has already registered.fetchis refactored to share the channel-open step; its behaviour is unchanged.Verification
cargo clippy --workspace --all-targets -- -D warnings— clean (also clean for this test with--features decdn-e2e/anvil-e2e; the two pre-existing lint failures under that feature are ing_origin_01_publish/slash_appealand predate this branch)cargo fmt -- --check— cleancargo doc --no-deps --workspace— cleancargo nextest run --workspace --no-fail-fast— 2624 passedcargo nextest run -p decdn-e2e --features anvil-e2e --no-fail-fast— 20 passed, including the refactoredfetch's existing consumers (g_origin_04,g_node_04,slash_appeal, …). The new journey runs in ~11s.Closes #1035