Repository navigation
test(e2e): harden authorized-origin & slash-evidence journeys (#1366/#1367 follow-ups) - #1404
Conversation
…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]>
|
Warning Review limit reached
Next review available in: 32 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 (1)
WalkthroughThe 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. ChangesRefusal and authorized-origin validation
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
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 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
NotFoundrefusals in journeys. - Extend origin seeding to also write
{H}.obao4outboards 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-pullmid-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.
Coverage reportTotal: 81.18% (was 81.24%, ▼ 0.06%) — 54179/66742 lines
History
|
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]>
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 inclient-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
NotFoundthatServeRejectReason::wire_errorcollapses seven reasons onto.Issues
RenderConfig's single bool intonode_to_node_pull_through+require_authorized_origin; the round-trip test sets them to distinct values so the pre-#1376 re-tie regresses loudly.NodeFixture::scrape_metric(the fixture allocatedmetrics_portthen discarded it); G-NODE-08 asserts..._unauthorized_origin_totalsteps 0→1, pinning the refusal to the gate.seed_origin_blob_with_outboardwrites 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.revokeAssignmentbinding +ChainFixture::revoke_assignment; newg_node_08_revocationjourney pins gate re-closes on revoke (distinct fresh hashes per poll attempt to avoid cache-masking) and already-held content survives.EvidenceAlreadyUsed(salted replay) +InvalidStreamSignature(forged stream) negatives;client-pullmid_stream_refusalconstructor + unit tests pinningresponse: Noneandpreserved.error == refused.error;set_rate_per_mbround-trip test.extract_slash_id(filters by address+topic0, propagates decode errors instead of swallowing them, asserts offenseType/evidenceHash);UpstreamVoucherRejectedarm inrefused_stream; node-B refusal pinned to the cache-miss counter; fixed the backwardsrefusal()message.smoke_compose_fixturesserved-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 canonicaldecdn_bao_range::align_range(..).wire_len().Production change
crates/client-pull/src/lib.rs: a privateconst fn mid_stream_refusalthat the four mid-stream refusal sites now route through (they previously built the identicalUpstreamRefused { error, response: None }inline), plus a corrected message inrefusal()'s unreachableNonearm. Public API unchanged.Not in scope (tracked follow-ups)
active_node_fordropping belowminBondwith noOriginAssignmentevent, routing throughChainStakerSet+ the fulldecdn node unbondwindow (g_node_06_unbond.rs). Documented ing_node_08_revocation.rs.Testing
cargo nextest run -p decdn-client-pull -p decdn-e2e— 101/101cargo 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_appealall pass locally (anvil + forge); fullanvil e2eCI job greencargo fmt --check+cargo clippy --workspace --all-targetscleanCloses #1371
Closes #1372
Closes #1373
Closes #1376
Closes #1378
Closes #1379
Closes #1381