Skip to content

test(e2e): harden authorized-origin & slash-evidence journeys (#1366/#1367 follow-ups) - #1404

Merged
thiras merged 3 commits into
mainfrom
e2e-review-followups-1366-1367
Jul 23, 2026
Merged

thiras merged 3 commits into
mainfrom
e2e-review-followups-1366-1367

Conversation

@thiras

@thiras thiras commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Six test-only follow-up issues from the reviews of #1366 (authorized-origin gate) and #1367 (G-GOV-03 real-evidence slashing). All changes are e2e fixtures / journeys plus #[cfg(test)] unit cases; the one production change is a behavior-preserving extraction in client-pull.

The theme is turning circumstantial e2e assertions into direct ones — chiefly by reading per-reason Prometheus reject counters (bumped before the network write) instead of the wire NotFound that ServeRejectReason::wire_error collapses seven reasons onto.

Issues

# Change
#1376 Split RenderConfig's single bool into node_to_node_pull_through + require_authorized_origin; the round-trip test sets them to distinct values so the pre-#1376 re-tie regresses loudly.
#1371 New NodeFixture::scrape_metric (the fixture allocated metrics_port then discarded it); G-NODE-08 asserts ..._unauthorized_origin_total steps 0→1, pinning the refusal to the gate.
#1372 New seed_origin_blob_with_outboard writes the {H}.obao4; G-NODE-08's ranged half now reaches the real origin range tier, with a partial-presence control (has_blob == false) separating it from a whole-blob fill.
#1373 New revokeAssignment binding + ChainFixture::revoke_assignment; new g_node_08_revocation journey pins gate re-closes on revoke (distinct fresh hashes per poll attempt to avoid cache-masking) and already-held content survives.
#1378 Real-evidence EvidenceAlreadyUsed (salted replay) + InvalidStreamSignature (forged stream) negatives; client-pull mid_stream_refusal constructor + unit tests pinning response: None and preserved.error == refused.error; set_rate_per_mb round-trip test.
#1379 Hardened extract_slash_id (filters by address+topic0, propagates decode errors instead of swallowing them, asserts offenseType/evidenceHash); UpstreamVoucherRejected arm in refused_stream; node-B refusal pinned to the cache-miss counter; fixed the backwards refusal() message.
#1381 Fixed the flaky smoke_compose_fixtures served-bytes assertion. ADR 038 §Payment metering already rules paid bytes are wire bytes (content + interleaved bao proof); the flake was the sub-threshold closing voucher racing on-chain settlement (content total observed locally, wire total on CI). Bounded served-bytes to [content, wire] via the canonical decdn_bao_range::align_range(..).wire_len().

Production change

crates/client-pull/src/lib.rs: a private const fn mid_stream_refusal that the four mid-stream refusal sites now route through (they previously built the identical UpstreamRefused { error, response: None } inline), plus a corrected message in refusal()'s unreachable None arm. Public API unchanged.

Not in scope (tracked follow-ups)

Testing

  • cargo nextest run -p decdn-client-pull -p decdn-e2e — 101/101
  • cargo nextest run -p decdn-e2e --features anvil-e2e — g_node_08_authorized_origin, g_node_08_revocation, g_gov_03_real_evidence, smoke (3/3 deterministic), slash_appeal all pass locally (anvil + forge); full anvil e2e CI job green
  • cargo fmt --check + cargo clippy --workspace --all-targets clean
  • Reviewed by code-reviewer, pr-test-analyzer, comment-analyzer, silent-failure-hunter — no blockers

Closes #1371
Closes #1372
Closes #1373
Closes #1376
Closes #1378
Closes #1379
Closes #1381

…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]>
Copilot AI review requested due to automatic review settings July 23, 2026 02:03
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 32 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: f322b4d8-ef7d-4ecb-83e4-a0b5c03e3dd4

📥 Commits

Reviewing files that changed from the base of the PR and between effca5e and 6c15770.

📒 Files selected for processing (1)
  • crates/e2e/tests/smoke.rs

Walkthrough

The PR centralizes typed mid-stream refusal construction, expands node fixtures for metrics and range-origin setup, strengthens slash-evidence validation, and adds authorized-origin range and assignment-revocation e2e scenarios.

Changes

Refusal and authorized-origin validation

Layer / File(s) Summary
Typed refusal semantics
crates/client-pull/src/lib.rs, crates/e2e/src/client.rs
Mid-stream errors use mid_stream_refusal, open-stage invariant failures are clarified, and tests verify wire-code and evidence consistency.
Node fixture configuration and origin helpers
crates/e2e/Cargo.toml, crates/e2e/src/node.rs
Node launch configuration separates origin authorization from pull-through, adds metric scraping, supports rate rewriting, and seeds range origins with outboards.
Chain evidence and challenge validation
crates/e2e/src/bindings.rs, crates/e2e/src/chain.rs, crates/e2e/tests/g_gov_03_real_evidence.rs
Bindings and chain helpers support assignment revocation and centralized slash extraction; governance tests cover cache-miss attribution, forged stream signatures, and replay rejection.
Authorized-origin range and gate assertions
crates/e2e/tests/g_node_08_authorized_origin.rs
Tests identify gate-specific refusals through metrics, exercise range-tier origin fetches, and verify partial range imports.
Assignment revocation and gate re-closure
crates/e2e/tests/g_node_08_revocation.rs
A new scenario verifies that revocation re-closes the origin gate while previously held content remains servable.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test
  participant ChainFixture
  participant OriginAssignment
  participant NodeFixture
  Test->>ChainFixture: revoke_assignment(namespace, operator)
  ChainFixture->>OriginAssignment: revokeAssignment(namespace, operator)
  OriginAssignment-->>ChainFixture: mined transaction
  Test->>NodeFixture: probe fresh backend-only hash
  NodeFixture-->>Test: NotFound refusal and metric increment
  Test->>NodeFixture: fetch previously held hash
  NodeFixture-->>Test: original payload bytes
Loading

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens deCDN’s e2e “authorized-origin” and “real-evidence slashing” journeys by converting previously circumstantial assertions into direct, cause-specific checks (notably via per-reason Prometheus reject counters), and by strengthening fixtures so tests exercise the intended tiers (e.g., true origin range fetch via {H}.obao4 outboards). It also includes a small, behavior-preserving refactor in decdn-client-pull to centralize mid-stream refusal construction.

Changes:

  • Add fixture support to scrape Prometheus metrics and use per-reason reject counters to disambiguate NotFound refusals in journeys.
  • Extend origin seeding to also write {H}.obao4 outboards so ranged requests reach the origin range tier, with a control asserting partial presence.
  • Harden real-evidence slashing coverage with new negatives (forged stream sig, evidence replay) and improve log scanning robustness; factor client-pull mid-stream refusal construction into a single helper + unit tests.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/e2e/tests/g_node_08_revocation.rs New journey asserting authorized-origin gate re-closes on revoke while already-cached content remains serveable; uses metric deltas to pin refusal cause.
crates/e2e/tests/g_node_08_authorized_origin.rs Strengthens G-NODE-08 by seeding outboards for true range-tier exercise and by pinning unauthorized refusals via reject-counter deltas.
crates/e2e/tests/g_gov_03_real_evidence.rs Adds forged-stream-signature and replay negatives; pins node-B refusal to a cache miss via the per-reason metric.
crates/e2e/src/node.rs Persists metrics_port, adds scrape_metric, splits render knobs, adds outboard seeding, extracts rate rewrite helper and adds round-trip unit test.
crates/e2e/src/client.rs Improves diagnosis when an expected refusal instead becomes a voucher rejection (induced condition didn’t take).
crates/e2e/src/chain.rs Adds revoke_assignment and hardens Slashed log extraction (address+topic0 filtering, decode error propagation, asserts offense/evidence hash).
crates/e2e/src/bindings.rs Extends generated bindings for revokeAssignment and new SlashJudge errors used by the new negatives.
crates/e2e/Cargo.toml Adds deps needed to build {H}.obao4 outboards in fixtures (decdn-bao-range, bao-tree).
crates/client-pull/src/lib.rs Centralizes mid-stream refusal construction (mid_stream_refusal), corrects unreachable error message, and adds unit tests to pin invariants.
Cargo.lock Locks new workspace dependencies pulled in by crates/e2e.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/e2e/src/node.rs Resolved
@github-actions

github-actions Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.18% (was 81.24%, ▼ 0.06%) — 54179/66742 lines

File Coverage Lines Δ
crates/client-pull/src/lib.rs 89.11% 998/1120 ▲ +0.56%
crates/e2e/src/chain.rs 0.96% 11/1145 ▼ 0.03%
crates/e2e/src/client.rs 0.00% 0/363 ● 0.00%
crates/e2e/src/node.rs 26.30% 126/479 ▲ +8.07%
History
Commit Total Δ vs base
996db8f 81.16% ▼ 0.08%
effca5e 81.16% ▼ 0.08%
6c15770 (HEAD) 81.18% ▼ 0.06%

thiras and others added 2 commits July 23, 2026 18:02
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]>
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]>
@thiras
thiras merged commit 6d00951 into main Jul 23, 2026
25 checks passed
@thiras
thiras deleted the e2e-review-followups-1366-1367 branch July 23, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants