Skip to content

gossipsub: retain peer scores across disconnects and expire stale backoff state #254

Description

@adust09

Spec

specs/pubsub/gossipsub/gossipsub-v1.1.md, Peer Scoring:

the score is retained for some period of time when a peer disconnects, so that malicious peers cannot easily reset their score when it drops to negative.

The configured duration is RetainScore.

Current state

PeerScoreParams defines pspRetainScore (default one hour), but the value has no consumer. Router.removePeer immediately deletes the complete PeerState, including all P1-P7 counters. Reconnecting therefore resets a negative score to zero.

Separately, expired entries in gsBackoff are checked as inactive but never removed, so the (peer, topic) map grows monotonically over long-running/high-churn workloads.

Scope

  • Separate connected-peer state from retained scoring state, or mark a peer disconnected with an expiry time.
  • Preserve relevant P1-P7 counters for pspRetainScore after disconnect.
  • Continue applying configured decay while the score is retained.
  • Restore the retained score when the peer reconnects before expiry.
  • Remove retained state after expiry.
  • Remove expired gsBackoff entries during heartbeat maintenance.
  • Keep mesh/fanout membership, IP-colocation membership, promises, and connection-only state cleaned up immediately on disconnect.

Acceptance tests

  • A negatively scored peer disconnects/reconnects and keeps its penalty.
  • Retained counters continue decaying while disconnected.
  • A peer reconnecting after RetainScore starts with fresh score state.
  • Disconnect immediately removes mesh/fanout and IP membership.
  • Expired backoff entries are physically removed from the map.
  • Repeated unique peer/topic churn does not grow retained maps past their expiry windows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions