Spec
https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md §"Peer Scoring"
Current zig-libp2p only exposes setPeerBehaviourScore and applies discrete deltas (validator reject, GRAFT-during-backoff). No per-topic counters, no decay, no thresholds, no opportunistic graft, no inbound/outbound peer preference — degraded eclipse-attack resistance and mesh-health.
peer_scores: HashMap(PeerId, i32) (line 275) — manually set only.
- No
P1 (time in mesh), P2 (first-message deliveries), P3 (mesh-message deliveries), P3b (mesh-message failure), P4 (invalid messages), P5 (app-specific), P6 (IP colocation), P7 (behaviour penalty).
- No thresholds:
gossip_threshold, publish_threshold, graylist_threshold, accept_px_threshold, opportunistic_graft_threshold.
- No decay heartbeat — set scores are static.
D_out (outbound peer preference) — no inbound/outbound flag tracked on connected peers (runtime.zig:1122).
- Opportunistic graft (§4.2) never runs — heartbeat only GRAFTs when
mesh_size < D_low (runtime.zig:1401).
Acceptance (suggest sub-PRs)
Cross-impl ref: rust-libp2p protocols/gossipsub/src/peer_score.rs.
Severity: S1 — interoperable for delivery, degraded for resilience.
Spec
https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md §"Peer Scoring"
Current zig-libp2p only exposes
setPeerBehaviourScoreand applies discrete deltas (validator reject, GRAFT-during-backoff). No per-topic counters, no decay, no thresholds, no opportunistic graft, no inbound/outbound peer preference — degraded eclipse-attack resistance and mesh-health.Current state (src/gossipsub/runtime.zig)
peer_scores: HashMap(PeerId, i32)(line 275) — manually set only.P1(time in mesh),P2(first-message deliveries),P3(mesh-message deliveries),P3b(mesh-message failure),P4(invalid messages),P5(app-specific),P6(IP colocation),P7(behaviour penalty).gossip_threshold,publish_threshold,graylist_threshold,accept_px_threshold,opportunistic_graft_threshold.D_out(outbound peer preference) — no inbound/outbound flag tracked onconnectedpeers (runtime.zig:1122).mesh_size < D_low(runtime.zig:1401).Acceptance (suggest sub-PRs)
score_decay_interval_ms.gossip_threshold, suppress publish forward belowpublish_threshold, drop all RPC belowgraylist_threshold, refuse PX belowaccept_px_threshold.opportunistic_graft_peersoveropportunistic_graft_thresholdand grafts them in. Tag eachconnectedpeer as inbound/outbound (transport tells us); maintain at leastD_outoutbound mesh peers.Cross-impl ref: rust-libp2p
protocols/gossipsub/src/peer_score.rs.Severity: S1 — interoperable for delivery, degraded for resilience.