Skip to content

gossip: drop ReportGate's vestigial <S> generic and dead Clone/Copy derives #1342

Closed

Description

@yigitdot

Follow-up from the review of #1340 (which closed #1338).

ReportGate<S> in crates/gossip/src/reputation.rs was given the same generic shape as its sibling AnnounceGate<S>, but the two are not in the same position:

  • Copy can never apply. It derives as impl<S: Copy> Copy. The only instantiation anywhere is Arc<dyn StakedNodeSet>, which is not Copy.
  • Clone has zero call sites. The gate is moved once, destructured out of ReputationWiring in spawn_reputation_tasks.
  • No borrowed form is possible. AnnounceGate earns its generic because validate_envelope takes AnnounceGate<&dyn StakedNodeSet> and as_gate() bridges the two. The reputation path has no counterpart: validate_reputation_envelope takes a bare &dyn StakedNodeSet, and the gate is resolved once at spawn and never re-checked per message.

AnnounceGate documents its conditional Copy in a four-line caveat (validation.rs:30-33) that was not carried over — so a reader following the cross-reference from the annotated sibling to the unannotated one may reasonably assume the same rationale holds. It does not.

Proposed: make it non-generic and delete the OwnedReportGate alias, removing the export churn across lib.rs, service.rs, and node/src/reputation_wiring.rs.

pub enum ReportGate {
    Enforce(Arc<dyn StakedNodeSet>),
    Disabled,
}

Counterargument to weigh: shape-parity with AnnounceGate is the stated point of #1338, and a reader comparing them side by side benefits from identical shapes. The counter-counter is that the symmetry lives in the variant names, and a shape difference signals "these are not interchangeable" — which is the actual hazard. Minimum acceptable outcome is dropping Copy.

Activity

  1. added
    rust
    prio:low
    on Jul 21, 2026
  2. self-assigned this
    on Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

prio:lowrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions