Repository navigation
refactor(gossip): name the reputation-report gate's staked-membership states (#1338) - #1340
Conversation
… states (#1338) `ReputationWiring.staked` was an `Option<Arc<dyn StakedNodeSet>>` whose `None` means fail-CLOSED, sitting one field away from the `AnnounceGate<S>` introduced by #1335 whose `Disabled` means fail-OPEN. Two identically-shaped gates with opposite polarity is the exact hazard #1222 set out to remove. Give the reputation path its own `ReportGate<S> { Enforce(S), Disabled }` (plus `OwnedReportGate`), mirroring `AnnounceGate`'s shape: hand-written `Debug` naming the variant, and a hand-written `Default` (the trait-object handle has none) that keeps the unwired state `Disabled`. Both enums carry a doc cross-reference to the other's inverse polarity. Node-side, the runtime now builds the gate via a named `report_staked_gate` constructor alongside `announce_staked_gate`. No behavior change: `sink` and the gate remain one combined check with the same warning, and `ReputationWiring::default()` still runs no reputation gossip. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 19 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 (4)
WalkthroughReputation gossip now uses an explicit ChangesReputation report admission
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant NodeRuntime
participant report_staked_gate
participant ReputationWiring
participant spawn_reputation_tasks
participant ReputationTasks
NodeRuntime->>report_staked_gate: provide staker set
report_staked_gate-->>ReputationWiring: return Enforce gate
ReputationWiring->>spawn_reputation_tasks: provide sink and gate
spawn_reputation_tasks->>ReputationTasks: spawn only for Enforce gate
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.
Code Review
This pull request introduces a dedicated ReportGate enum to manage the admission of inbound reputation reports, replacing the previous Option<Arc<dyn StakedNodeSet>> representation. This ensures a fail-closed behavior by default (ReportGate::Disabled) and prevents potential copy-paste errors with the sibling AnnounceGate (which is fail-open). The changes include updating the ReputationWiring struct, modifying task spawning logic, and adding corresponding unit tests to verify the fail-closed behavior. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Coverage reportTotal: 81.77% (was 81.74%, ▲ +0.03%) — 51510/62994 lines
History
|
…n the warning Post-review fixes on #1340 (no wire or behavior change). - Derive `Default` on `ReportGate` with `#[default]` on `Disabled` and drop the hand-written impl. Its doc justified itself with "a derive would demand `S: Default`", which is false: `#[derive(Default)]` on an enum with a `#[default]` unit variant emits an unbounded impl. Verified against the exact shape on rustc 1.94 / edition 2024 — the enum compiles for `ReportGate<Arc<dyn StakedNodeSet>>` while the struct control case does not. - `ReputationWiring`'s doc claimed "the publisher needs `report_drain`". The publisher spawns on the same enforcing branch as the subscriber, so it also needs `sink` and `Enforce` — as this PR's own `disabled_report_gate_spawns_no_reputation_tasks` asserts. - The unwired warning said "no reputation sink/staker wired", which reads as "neither", but a wired sink with a `Disabled` gate trips it too. Report `sink_wired` and `gate_enforcing` as separate fields, via a new `ReportGate::is_enforcing`. - Drop the "a sink with no gate would admit unvetted reports" comment: there is no such state, and `reputation_subscriber_task` takes the set by value, so an ungated subscriber is unrepresentable. - Stop defining the gate by the `Option` it replaced (`reputation.rs`, `reputation_wiring.rs`) and stop re-describing the fail-closed mechanism in `validation.rs` — bc83b16 reworded `AnnounceGate` away from exactly this so the docs would not become dangling references. Also soften "every signature-valid announce is admitted": `AnnounceGate::Disabled` skips only the membership check. - New `report_gate_debug_reports_variant_only`, mirroring `AnnounceGate`'s test, pins both `Debug` arms. Confirmed fails-before: mislabelling the `Enforce` arm as `"ReportGate::Disabled"` was caught by this test alone, with the other 69 gossip tests green. cargo clippy --workspace --all-targets -D warnings, cargo fmt --check, RUSTDOCFLAGS=-D warnings cargo doc, cargo deny check, and 2520/2520 workspace tests all pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Multi-agent review pass (code / tests / comments / type-design) plus independent verification. The refactor itself is behavior-preserving and CI-clean; findings were concentrated in the prose. Fixed in 78fc60b: Corrected a false claim. The Fixed a doc this PR's own test contradicts. Covered the Stopped defining the gate by the Warning now names which half is missing. "no reputation sink/staker wired" reads as "neither", but a wired sink with a Verification: Deferred to follow-ups rather than growing scope: #1342 ( |
…#1350, #1355) (#1358) Follow-ups filed off the reviews of #1340, #1341 and #1353. Closes #1342, #1343, #1344, #1345, #1350 and #1355; #1356 was closed as a duplicate of #1347, which stays open for the deferred swap-revert tests. BREAKING: `ReportGate` and `ReputationWiring`'s struct literal are gone — `ReputationWiring` is now a sum type (`Disabled` / `Enabled { sink, staked, publish }`), so an admission set without a sink is unrepresentable rather than warned about at runtime. That deletes the test #1344 asked for instead of adding it. `GossipRuntimeConfig::subscribe_reputation` is also gone; the operator-facing `[gossip] subscribe_reputation` key is unchanged, but `decdn-node` now resolves it into the wiring variant at the one site that builds it, so there is a single off-switch instead of two. `AnnounceGate::Disabled` is `#[cfg(test)]`. It fails OPEN on ADR 001 rule 2 and was guarded only by a doc comment plus a test on `announce_staked_gate`, which would have stayed green if a future edit passed `Disabled` to `spawn` — the hole #1170 closed. It no longer exists in production builds. Transaction submission is unified in `decdn_incentive::tx::send`, including both swap venues (they spend USDC and read the hash after `get_receipt()`, so a receipt timeout named no transaction at all). `send` takes a caller-owned `landed` slot: `Some` means "may have taken effect" — including the unreadable- receipt case — and is cleared on a confirmed revert. `bond`, `setup`, `register` and `appeal` use it. `channel` deliberately does not: it classifies a revert as an expected outcome rather than an error. That slot is what makes the re-run guidance safe. The earlier wording asserted "no TOKEN was transferred" / "on-chain state is unchanged" and told the operator to re-run immediately; alloy's nonce filler resolves against the pending block, so re-running while a bond tx is in flight submits a second one and doubles the bond. `setup`'s live phases are one fallible section with a single reporting site, so a failure at any phase emits the aggregated `--json` summary with whatever landed — previously a register-phase failure printed nothing and a landed swap's hash had no machine-readable carrier at all. `build_summary` emits one shape on both paths with a `partial` flag. Note for the record: commit `edb3e80`'s message asserts a symbol (`bundle_pull::discover_candidates`) that does not exist — copied from #1350's text without verifying, in a commit about fixing inaccurate comments. The code is correct; the message could not be amended. Tests: new `cli_setup_partial` e2e journey drives the production binary against anvil (with a new `ChainFixture::pause_capacity_bond` lever, since starving the operator of TOKEN trips the pre-flight instead of entering the live phase); the gossip integration test's drain now varies its payload per round, because plumtree dedups byte-identical messages for 90s and a constant payload collapsed a 50-round budget to ~6. Every new test was mutation-verified.
Problem
#1335 (part of #1222) replaced the
NodeAnnounceadmission gate'sOption<Arc<dyn StakedNodeSet>>with a purpose-namedAnnounceGate<S> { Enforce(S), Disabled }, because nullability was overloaded to encode two safety-opposite states. That left the reputation-report gate one field over in the same file still shaped asOption<Arc<dyn StakedNodeSet>>— and with the opposite polarity:Disabled/NonemeansAnnounceGateSame type, opposite meaning: not a bug today, but a copy-paste between them would be silently wrong-way-round.
Change (issue Option 2, symmetric treatment)
ReportGate<S> { Enforce(S), Disabled }+OwnedReportGatealias incrates/gossip/src/reputation.rs, mirroringAnnounceGate's shape: hand-writtenDebugthat names the variant (theStakedNodeSethandle isn'tDebug) and a hand-writtenDefaultreturningDisabled— derivedDefaultwould demandS: Default, which a trait-object handle has not. Noas_gate()borrow projection: the reputation path resolves the gate once at spawn and never re-checks it per message, so it doesn't need one.ReputationWiring.stakedis nowOwnedReportGate;spawn_reputation_tasksdestructures it in the same single let-else assink(let (Some(sink), ReportGate::Enforce(staked)) = ...), so the combined check and its existing warning are unchanged.ReportGate's doc spells out that itsDisabledis fail-CLOSED, the inverse ofAnnounceGate::Disabled, andAnnounceGate's doc points atReportGatefor the same reason.report_staked_gate()constructor next to the existingannounce_staked_gate(), so the runtime's always-enforce choice is explicit and unit-tested on both gates rather than implied by aSome(..).No functional or wire behavior change.
Tests
reputation_wiring_default_gate_is_disabled— pins the newly-expressed invariant: the default gate isDisabled(pattern match) andDebugnames the variant. Verified fails-before: against pre-change code it renderedReputationWiring { sink: false, staked: false, report_drain: false }and failed the assertion.disabled_report_gate_spawns_no_reputation_tasks— behavior pin for the fail-CLOSED half: a wired sink + drain with aDisabledgate andsubscribe_reputation = truejoins no reputation topic (4 tasks, no publish trigger). This combination had no coverage before.report_staked_gate_enforces_over_the_live_set— the node-side mirror ofannounce_staked_gate_enforces_never_fails_open:Enforceover the real staker set, not an admit-everyone stub.Verification
cargo build— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo nextest run -p decdn-gossip— 69/69 passcargo nextest run --no-fail-fast— 2519/2519 pass. (A first run flaked ondecdn-node::node_origin_pull a_reserved_open_slot_does_not_starve_the_candidate_loop, a timing test unrelated to this diff; it passes in isolation and on the clean re-run.)cargo fmt -- --check— clean🤖 Generated with Claude Code
Closes #1338
Summary by CodeRabbit
New Features
Bug Fixes
Documentation