Skip to content

test(e2e): add G-NODE-08 authorized-origin recognition (opaque backend fetch) - #1366

Merged
alpergundogdu merged 3 commits into
mainfrom
test/1035-e2e-g-node-08-authorized-origin
Jul 22, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
test/1035-e2e-g-node-08-authorized-origin

Conversation

@yigitdot

Copy link
Copy Markdown
Contributor

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-e2e is publish = false test infrastructure).

Shape

One node, one opaque fs backend, 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-backed ChainOriginDirectory (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:

  • the node still serves a blob it already holds — the control, proving the channel is live and the node is willing to deliver, so the refusal below cannot be a channel or liveness artifact;
  • the backend-only hash is refused, typed as UpstreamRefused { error: NotFound } — the gate refuses to initiate the fill;
  • a follow-up probe shows has_blob: false, so the gated miss wrote nothing to the store;
  • the ranged shape is refused identically (the gate sits above the range tier).

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_offset returns the exact requested tail, bao-verified against the whole-blob hash.

Wire opacity. A raw cdn/client/v1 tap (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 (signed ok response, true total_bytes, redirect: None, whole delivery captured) and that the backend root, each of its path components, the derived object key, and file:// 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:

  1. Authorization gate bypassed. Patching the fixture to render pull_through_require_authorized_origin = false (leaving everything else identical) makes the unauthorized node serve the backend-only blob, and the journey fails at an unauthorized node must not serve from its backend. Reverted.
  2. Wire scan discriminates. Adding the blob hash — a byte string genuinely on the wire — to the must-be-absent needle list makes the journey fail at 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 wire NotFound), so asserting on a single refusal needs a channel the node has already registered. fetch is 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 in g_origin_01_publish/slash_appeal and predate this branch)
  • cargo fmt -- --check — clean
  • cargo doc --no-deps --workspace — clean
  • cargo nextest run --workspace --no-fail-fast — 2624 passed
  • cargo nextest run -p decdn-e2e --features anvil-e2e --no-fail-fast — 20 passed, including the refactored fetch's existing consumers (g_origin_04, g_node_04, slash_appeal, …). The new journey runs in ~11s.

Closes #1035

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]>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@yigitdot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: bd495f49-6dff-4639-92b8-016cbbaf9193

📥 Commits

Reviewing files that changed from the base of the PR and between e73fa04 and fbf2e83.

📒 Files selected for processing (3)
  • crates/e2e/src/client.rs
  • crates/e2e/src/node.rs
  • crates/e2e/tests/g_node_08_authorized_origin.rs

Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

@yigitdot yigitdot changed the title test(e2e): G-NODE-08 authorized-origin recognition (opaque backend fetch) test(e2e): add G-NODE-08 authorized-origin recognition (opaque backend fetch) Jul 22, 2026
@github-actions

github-actions Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.35% (was 81.55%, ▼ 0.20%) — 53777/66103 lines

File Coverage Lines Δ
crates/e2e/src/client.rs 0.00% 0/279 ● 0.00%
crates/e2e/src/node.rs 19.43% 68/350 ▼ 2.44%
History
Commit Total Δ vs base
59c79cb 81.44% ▼ 0.17%
a85275c 81.43% ▼ 0.18%
fbf2e83 (HEAD) 81.35% ▼ 0.20%

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]>

Copy link
Copy Markdown
Contributor

Review — G-NODE-08 authorized-origin journey

Read 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, delivered > len rather than >=, and the signed-NotFound downcast instead of a bare expect_err all close the usual "passes vacuously" holes. No blockers; CI is green (anvil-e2e 20/20).

I re-verified each load-bearing coupling against the tree rather than taking the comments' word, and they all hold:

  • fs layout — write_fs_origin_blob's {root}/{hex[..2]}/{hex} matches FilesystemOrigin::path_for (crates/cache/src/origin/fs.rs:83-84), and new canonicalizes at construction (fs.rs:61), so origin_root's "search both forms" note is warranted.
  • range degradation — no .obao4 ⇒ fetch_range returns Unsupported (fs.rs:252-266), so the RANGE_OFFSET comment ("degrades to whole-blob + export_range, does not exercise the range tier") is accurate.
  • wire-tap timing — VOUCHER_READ_TIMEOUT = 10s (crates/node/src/handlers/client/mod.rs:90) > WIRE_TAP_IDLE = 5s. Coupling is correct and the load-bearing comment is right to flag it.
  • flag coupling — render_config drives both node_to_node_pull_through_enabled and pull_through_require_authorized_origin off the same bool, so the "no discovery peers is what isolates the backend, not n2n being off" caveat is correct.
  • gate scope (Clarify authorized-origin gate scope: namespace-wide vs per-operator #1368) — pull_origin_gate_blocks → has_origin → has_any(hash, …) (mod.rs:293, crates/node/src/dht/chain_origin_directory.rs:650) is namespace-scoped; it never compares this node's operator address. The docs describing it without asserting it's correct is the right call.
  • pre-observation window — register_open_channel (mod.rs:954) does the spawn_blocking(store.record) fsync and only then inserts into the in-memory channels map, so wait_for_channel (persisted store) genuinely can return one step ahead of the serve path's map. The window is real and small.

Three non-blocking observations:

  1. The single-shot success paths ride on that same window. The whole-blob positive uses fetch (retries), so it's immune — but the two fetch_once successes are the first op on a fresh session with no control ahead of them: the cached control on unauthorized, and the ranged fetch on authorized. If the fsync→map-insert gap is ever wider than a poll cycle, either surfaces as UnknownChannel→NotFound and fails loudly — never a vacuous pass, so this is a latent flake, not a soundness hole. Just flagging it as the first suspect if anvil-e2e ever goes intermittent on this journey. (The AssignmentActivated "safely" argument at the ranged fetch justifies gate-readiness, but the fresh authorized channel's in-memory registration is a separate fact that argument doesn't cover.)

  2. Clarify authorized-origin gate scope: namespace-wide vs per-operator #1368 is the one semantic question worth resolving, since it defines what the journey actually proves: today it's "the namespace has an active origin," not "this operator was recognized." Writing the test to hold under either answer is the right hedge, but the assertion's meaning changes materially depending on how Clarify authorized-origin gate scope: namespace-wide vs per-operator #1368 lands.

  3. Coverage delta is expected noise — client.rs 0% / node.rs 19% is because these fixtures only execute under the anvil-e2e gated job, which the coverage harness doesn't run. Not a regression.

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]>
@yigitdot

Copy link
Copy Markdown
Contributor Author

Fixed observation 1 in fbf2e83; observations 2 and 3 need no code change.

1 — single-shot successes riding the pre-observation window. Verified: register_open_channel (mod.rs:962-976) awaits the spawn_blocking(store.record) fsync and only then inserts into self.channels, and refresh_channel_metrics (mod.rs:1043) reads that map afterwards — so the store genuinely leads the serve path. You're right that both exposed calls are the fetch_once successes, and right that they fail loudly rather than vacuously.

Rather than document the gap, I closed 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, since the serve path had to read it. It returns the warm-up bytes, so the journey's existing cached-blob control is the warm-up: the assertion it always made is now also what establishes readiness, rather than an extra delivery.

The authorized session warms on the same cached blob, which is the point you made in the parenthetical — the AssignmentActivated argument justifies gate-readiness but says nothing about that fresh channel's in-memory registration.

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 anvil e2e on smoke_compose_fixtures, asserting served bytes 2105280 != 2097152. That delta is exactly 8128 = the bao proof overhead for a 2 MiB payload (127 parents × 64 B), i.e. the accumulator held wire bytes while the assertion expects content bytes. It re-ran green and reproduces 0/3 locally, and there's already a prior commit about that same poll, so I filed #1381 rather than re-running it away — the open question is which quantity FeeRouter.bytesPerEpoch is meant to accumulate under ADR 036.

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.58% (2657/2966 lines)
▲ +0.00pp vs base (89.58% → 89.58%)
Run: 29894650848

@alpergundogdu
alpergundogdu merged commit f704e4a into main Jul 22, 2026
23 checks passed
@alpergundogdu
alpergundogdu deleted the test/1035-e2e-g-node-08-authorized-origin branch July 22, 2026 13:07
thiras added a commit that referenced this pull request Jul 23, 2026
…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]>
thiras added a commit that referenced this pull request Jul 24, 2026
…) (#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

e2e G-NODE-08: authorized-origin recognition (opaque backend fetch)

3 participants