Repository navigation
feat(e2e,client-pull): real daemon responses as on-chain slash evidence (G-GOV-03) - #1367
Conversation
…lash evidence Preserve the upstream operator's signed StreamResponse on UpstreamRefused instead of discarding it, then build the G-GOV-03 journey on it: every byte of evidence submitted to SlashJudge comes off the wire from a running decdn-node, slash_sig included and forwarded verbatim. client-pull: UpstreamRefused gains `response: Option<StreamResponse>` — Some for an open-stage `ok == false` refusal (already verified against `expected_signer` by verify_response), None for the unsigned mid-stream StreamError frames. `refusal()` now takes the whole response rather than just its error code. Unit-tested through the real private constructor with a real StreamSlashData signature. e2e: new g_gov_03_real_evidence journey — two nodes, a phantom announcement (admin evict between probe and stream) and a rate bait-and-switch (payment.rate_per_mb hot-reload between probe and stream), each submitted to SlashJudge with a challenge bond. Asserts the slash lands, escrow-on-slash books the TOKEN, slashedAtEpoch stamps the ADR-036 vote-weight zero-out, and finalizeUnappealedSlash splits the escrow 50/50 challenger/burn. Negatives re-use the same real evidence: a 40s-apart pair (TimestampWindowViolated), a probe re-signed by a non-operator key (InvalidProbeSignature), and neither failed challenge moves any TOKEN (ADR 014 § Bond Handling). ChainFixture gains `challenge_with_real_evidence` as an additive sibling of `slash_operator_via_judge`; the existing signature is untouched. 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: 55 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 (12)
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 |
`cargo doc --document-private-items` with `-D warnings` rejects a public doc link to a private const (rustdoc::private_intra_doc_links). Demote the reference to plain code formatting. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Coverage reportTotal: 81.20% (was 81.55%, ▼ 0.36%) — 53830/66297 lines
History
|
…t matching Review follow-ups on #1367. No change to the journey coverage; all 20 anvil-e2e tests still pass. Two doc comments stated things that are not true: - NodeFixture::set_rate_per_mb claimed its return value reflects the on-chain clamp. It does not - ReloadSnapshot is a bare load of the raw pre-clamp atomic (runtime/reload.rs), and clamping happens later and per-response at sign time (handlers/client/wire.rs, handlers/probe.rs). A caller who trusted the doc and picked an out-of-band rate would see the assertion pass and ship a silently clamped, non-slashable StreamResponse. - ClientFixture::refused_stream justified reusing a channel via an UnknownChannel -> NotFound race that cannot fire: serve_stream resolves the channel *after* the blob-availability gate, so both captured refusals return before the lookup. The real confound is pull_authorized returning false for an unrecognized channel, which suppresses the fill tiers. Reuse instead of reinvention: - Promote expect_revert from g_origin_01_publish into e2e::assert and add an anyhow-taking sibling. The negatives now match on E::SELECTOR from sol!-declared errors instead of hand-copied selector hex substring-matched against the rendered error chain - compiler-checked against the ABI, and able to report which error actually came back. - Route Offense::discriminant through the generated SlashJudge::OffenseType, collapsing two of four hand-kept mirrors of the contract enum ordering. - Fold CapacityBondEscrow/Erc20Supply into the CapacityBond/Erc20 blocks already declared in the same file, and point slash_operator_via_judge at the extracted arm_challenger instead of its duplicated arming block. Also fixes the stale anvil-e2e CI budget: the comment still described 6 tests after the cli_* and g_origin_* journeys landed, leaving timeout-minutes: 75 below the ~92m worst 2-thread schedule of the real 14-test inventory - inverting the ordering the bound exists to guarantee. Remaining review findings filed as #1375, #1377, #1378, #1379. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 89.58% (2657/2966 lines) |
Code reviewReviewed the full diff (12 files, +1198/−76) and traced the load-bearing correctness claim against the base code. Summary: this is a high-quality, well-scoped change — I'd merge it after a look at the nits below, none of which are blocking. What it doesCloses #1042 in two parts:
VerifiedThe whole design rests on the preserved Strengths
Minor / non-blocking
Coverage noteThe coverage bot shows Nice work — the "real daemon output, forwarded verbatim, one field perturbed for each negative" structure is exactly the right shape for closing this gap. Generated by Claude Code |
Review follow-ups from @altanoruc on #1367. - Assert the node-B refusal answers for the probed hash, matching the node-A capture. Was transitively enforced by the judge same-hash check on the positive, but asserting at the capture localizes a failure to the capture. - Spell out why assert_fifty_fifty_split rounds the way it does. SlashEscrowLib._distribute floors the *challenger* leg (amount * CHALLENGER_BPS / BPS_DENOMINATOR) and gives the remainder to burn; since 5000/10_000 is exactly 1/2 that equals amount / 2 for every amount, odd ones included. Also records why the shares are not read off the SlashUpheld event: that would prove only internal consistency, where hard-coding 50/50 pins the ADR 026 policy. - Record the timeout-minutes 75 -> 130 tradeoff as deliberate: the bound is now a generous backstop, so a wedged compile or a forge deploy that hangs before a test arms its own timer burns the full 130m. Accepted because a tighter bound kills legitimate runs, and one below the per-test ceilings reintroduces the opaque job-level kill (#785) the ordering exists to avoid. Not changed, with reasoning: the reviewer flagged a possible off-by-one if a slash amount were odd and the contract floored the burn leg instead. It does not - SlashEscrowLib.sol:203-204 floors the challenger leg and takes the remainder for burn, which is what the test already computes. Noted inline instead. The toml round-trip dropping comments is real but harmless for a render_config-generated fixture; tracked with a round-trip test in #1378. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Went through all five. Fixed 1, 3, 5; pushed back on 2; declined 4 with a pointer. Pushed as 1 — stale PR description. Correct, and my fault: follow-up 2 — rounding: the off-by-one can't happen. The premise is that the contract might floor the burn leg. It floors the challenger leg: uint256 challengerShare = (amount * CHALLENGER_BPS) / BPS_DENOMINATOR; // SlashEscrowLib.sol:203
uint256 burnShare = amount - challengerShare; // :204
On reading the split off the event instead: deliberately not doing that. 3 — capture asymmetry. Valid, fixed. Node B now asserts 4 — toml comments. Real, and I'll leave it. The fixture config is machine-generated by 5 — timeout backstop. Agreed it should be a conscious choice rather than a number, and you named the exact gap: a wedged compile or a Coverage. Same read as yours — the |
fix(e2e): drop duplicate expect_revert from a semantic merge conflict #1387 and #1367 each landed their own `expect_revert` in `crates/e2e/src/assert.rs` — textually disjoint, so git merged both and main stopped compiling (E0428, `decdn-e2e` lib), taking clippy, test, doctest, cargo doc, and anvil e2e down with it. Keep #1367's version: same signature and behaviour, but it shares the selector check with `expect_revert_anyhow` via `assert_revert_data` instead of inlining it. Callers of either copy are unaffected. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…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]>
What
Every existing "signed evidence" path in the harness cheats: it builds
ProbeSlashData/StreamSlashDatain the test and signs withnode.operator()(crates/e2e/src/chain.rsslash_operator_via_judge,g_node_04_blacklist_compliance.rs). That proves the contract accepts a well-formed signature — whichSlashJudge.t.solalready proves — and nothing about the daemon. This closes that gap.Production change (
crates/client-pull)The node signs its refusals and the client threw the signature away one stack frame later.
fn refusaltook onlyresp.error; the signedStreamResponsebody andslash_sigwere dropped.UpstreamRefusedgainspub response: Option<StreamResponse>—Somefor an open-stageok == falserefusal (already run throughverify_response, so theslash_sigprovably recovers toexpected_signer),Nonefor the four mid-streamClientMessage::StreamErrorsites, which carry no signature at all.fn refusalnow takes the wholeStreamResponseinstead ofOption<StreamError>. Both open stages (fetch_inner,open_progressive_pull) passrespthrough.client-pull, the rest incli/nodetest modules) gainresponse: None. No other shape change;Display, thedowncast_refcontract, andnode_origin::classify_refusalare untouched, sonode(which re-exports the crate asclient_requester) andclineeded no logic changes.~50 lines of non-test production diff.
Fail-before / pass-after:
tests::an_open_stage_refusal_preserves_the_signed_stream_responsedrives the real privaterefusal()with aStreamResponsesigned by a realStreamSlashDatasigner, and asserts the surviving signature still recovers to that signer. It cannot compile onmain(the field does not exist); to show the assertion is load-bearing rather than tautological I kept the field and reverted onlyrefusal()'s body toresponse: None— the test fails; restoring it passes.New journey (
crates/e2e/tests/g_gov_03_real_evidence.rs)Two nodes, one offense each, both induced through real operator surfaces, all evidence captured off the wire and forwarded byte-for-byte:
UnknownChannelin disguise), answers a probe with signedhas_blob: true, the operator evictsHover admin RPC, and the next paid stream on that same channel returns signedok: false/EvictedSinceProbe. →submitPhantomChallenge.payment.rate_per_mbto 40 and hot-reloads viaadmin_v1_reload(no restart — the field is in the reloadable set), and B's next signedStreamResponsequotes 40 inside the 30s window. →submitRateChallenge.Both refusals assert their cause (
EvictedSinceProbe/NotFound), so the journey can't pass on a slash it never induced.Positive assertions: slash lands and is attributed to the operator; active bond falls by exactly the slashed amount; the TOKEN is escrowed (
escrowedTotalup by the amount) rather than distributed;slashedAtEpochstamps the ADR-036 vote-weight zero-out; and after warping past the 30-day filing window,finalizeUnappealedSlashpays the challenger exactly 50% and burns the rest (read offtotalSupply, since the burn leg is invisible as a transfer).Negatives, all built from the same real daemon output:
has_blob: trueprobe stamped 40s before the stream → revertsTimestampWindowViolated(asserted by 4-byte selector, so an unrelated fixture failure can't satisfy it);InvalidProbeSignature;slashedAtEpoch.One deliberate deviation from the issue text
The issue says a failed/bad challenge "forfeits the challenger bond". The as-built contract does not, by design — ADR 014 § Bond Handling: "a
submit*Challengethat fails on-chain verification reverts and the challenger pays only gas; the bond is not transferred for failed verifications".SlashJudge._resolvepulls the bond only after every check has passed, and there is no second-stage dispute that could claw it back. So the assertion is the behaviour of record — nothing is pulled, no slash is minted — and the reasoning is documented in the test's module header.Fixture additions (all additive)
chain.rs:challenge_with_real_evidence(a sibling ofslash_operator_via_judge— that function's signature is untouched; review follow-up29b568adid refactor its body to call the extractedarm_challengerinstead of its own duplicated arming block, so the two now share a helper),Offense,EvidencePair,challenge_bond,escrowed_total,slash_record,finalize_unappealed_slash,token_total_supply, privatearm_challenger.client.rs:probe_at(caller-chosentimestamp_us— the fixedTIMESTAMP_USsentinel reads as 1970 to the judge's staleness bound) andrefused_stream(one paid open on an existing channel, returning the daemon's signed refusal).node.rs:set_rate_per_mb(rewrite +admin_v1_reload).bindings.rs: a separatesol!block forsubmitRateChallenge, theCapacityBondescrow surface, andtotalSupply.Review follow-ups (
29b568a)Applied after review: corrected two doc comments that stated false things (
set_rate_per_mbreturns the raw pre-clamp atomic, not a clamped quote;refused_stream'sUnknownChannelrace cannot fire because the channel resolves after the blob gate). Replaced the journey's hand-copied selector hex with the typedexpect_reverthelper promoted fromg_origin_01_publishintoe2e::assert. PinnedOffense::discriminantto the generatedSlashJudge::OffenseType. Dedupedarm_challengerand folded two redundantsol!contracts into theCapacityBond/Erc20blocks already in the same file. Fixed the staleanvil e2eCI budget (the comment still described 6 tests; the real inventory is 14, whose ceilings sum past the old 75m bound).Out-of-scope findings filed as #1375, #1377, #1378, #1379. #1375 is the substantive one:
SlashJudge's rate predicate does not require!ok, so a bait-and-switch that delivers is equally slashable — but the success path drops the signed response, so the profitable variant is the one we cannot evidence.Verification
cargo clippy --workspace --all-targets -- -D warnings— cleancargo fmt -- --check— cleancargo nextest run --workspace --no-fail-fast— 2625 passed, 0 failedcargo nextest run -p decdn-e2e --features anvil-e2e --no-fail-fast— 20 passed, 0 failed (new journey ~9-65s depending on forge cache)Closes #1042