Skip to content

Bound Gossipsub control-plane work - #213

Open
flcl42 wants to merge 5 commits into
gossipsub-message-cachefrom
gossipsub-control-limits
Open

flcl42 wants to merge 5 commits into
gossipsub-message-cachefrom
gossipsub-control-limits

Conversation

@flcl42

@flcl42 flcl42 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • cap IHAVE intake and IWANT responses, including retransmission and byte limits
  • honor bounded, expiring IDONTWANT state for v1.2 peers
  • track a bounded random sample of IHAVE promises for behavioral penalties

Validation

  • Pubsub protocol unit tests

@flcl42
flcl42 requested a review from rubo as a code owner August 24, 2026 09:30
@flcl42
flcl42 requested a lite review from Copilot August 24, 2026 09:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces bounded, per-peer control-plane limits for Gossipsub to reduce abuse potential and to align behavior with protocol expectations around IHAVE/IWANT/IDONTWANT handling, including tracking and penalizing unmet IWANT “promises”.

Changes:

  • Adds configurable caps for IHAVE intake, IWANT retransmission, and IWANT response byte size, plus bounded IWANT promise sampling and IDONTWANT TTL behavior.
  • Introduces per-peer control state (PeerControlState) and an IwantPromiseTracker to support bounded suppression/retransmission and behavioral penalties.
  • Adds unit tests covering the new control-plane limits and validations.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/libp2p/Libp2p.Protocols.Pubsub/PubSubSettings.cs Adds new Gossipsub control-plane limit settings (IHAVE/IWANT/IDONTWANT/promise tracking).
src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Rpc.cs Enforces new per-peer limits when handling IHAVE/IWANT/IDONTWANT; fulfills IWANT promises on message arrival.
src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.cs Wires in control settings validation, IWANT promise penalty application, and per-heartbeat reset of peer control counters.
src/libp2p/Libp2p.Protocols.Pubsub/PeerControlState.cs New bounded per-peer state for counting envelopes/IDs, suppressing unwanted IDs, and limiting IWANT retransmissions.
src/libp2p/Libp2p.Protocols.Pubsub/IwantPromiseTracker.cs New bounded sampler for IHAVE→IWANT promise tracking and expiry-based penalty accounting.
src/libp2p/Libp2p.Protocols.Pubsub.Tests/GossipsubControlLimitsTests.cs Adds unit tests validating the new control limits and promise tracking behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Rpc.cs
Comment thread src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Rpc.cs
@flcl42
flcl42 force-pushed the gossipsub-control-limits branch from 252e858 to 7cd7bf5 Compare August 24, 2026 09:38
@flcl42
flcl42 requested a lite review from Copilot August 24, 2026 09:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Suppressed comments (1)

src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Rpc.cs:130

  • IWANT promises are fulfilled for Accepted/Rejected/Ignored outcomes, but the signature-verification failure path still doesn't fulfill the promise. This can cause broken-promise penalties even though the message arrived (it just failed signature validation).
            _seenMessages.Add(messageId);
            _messageCache.Put(messageId, message);
            _iwantPromises.Fulfill(messageId);

Comment thread src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Rpc.cs
Comment thread src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Rpc.cs Outdated
Comment thread src/libp2p/Libp2p.Protocols.Pubsub/IwantPromiseTracker.cs Outdated
@flcl42
flcl42 force-pushed the gossipsub-control-limits branch from 680e43e to 95e5e5d Compare August 24, 2026 10:34
@flcl42
flcl42 requested a lite review from Copilot August 24, 2026 10:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@flcl42
flcl42 force-pushed the gossipsub-control-limits branch from 95e5e5d to 3013d10 Compare August 24, 2026 10:47
@flcl42
flcl42 force-pushed the gossipsub-control-limits branch from 83cd299 to 4427464 Compare August 24, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants