Skip to content

feat: enforce idontwant - #3595

Draft
matthewkeil wants to merge 6 commits into
libp2p:mainfrom
matthewkeil:mkeil/enforce-idontwant
Draft

feat: enforce idontwant#3595
matthewkeil wants to merge 6 commits into
libp2p:mainfrom
matthewkeil:mkeil/enforce-idontwant

Conversation

@matthewkeil

Copy link
Copy Markdown

Implements the gossipsub v1.2 MUST (gossipsub-v1.2.md line 62): peers found in the per-peer dont_send_message_ids set are now skipped when relaying.

Previously received IDONTWANTs were tracked, pruned, and metered but never consulted on any send path, so duplicates were still sent to peers that refused them. Enforcement covers both forwardMessage and publish (content-derived message ids make pre-publish IDONTWANT possible), with a new gossipsub_idontwant_skipped_sends_total metric.

Also fixes a latent version gate: sendIDontWants matched /meshsub/1.2.0 by exact equality, which would silently stop IDONTWANT to peers on any future protocol version. Version-dependent behavior is now gated by a feature-test predicate over an ordered version ladder (the go-libp2p-pubsub pattern), so future versions inherit lower-version features automatically.

Adds an ordered ladder of gossipsub protocol IDs and a
protocolSupportsFeature() predicate so version-dependent behavior can be
gated on "supports feature X" instead of comparing protocol IDs for
equality. Future protocol versions appended to the ladder automatically
inherit all lower-version features.
sendIDontWants compared the negotiated protocol to /meshsub/1.2.0 with
exact equality, so peers negotiating any future gossipsub version would
silently stop receiving IDONTWANT. Gate on the IDontWant feature instead,
which any version at or above v1.2 on the version ladder supports.
makePrune returned a bare prune only for peers negotiated at exactly
/meshsub/1.0.0. Gate on the Backoff feature (v1.1+) instead so the check
stays correct as versions are added. Peers with no live outbound stream
now also get the conservative bare prune - moot in practice, as a prune
cannot be delivered without a stream.
The v1.2 spec requires that peers found in the per-peer
dont_send_message_ids set MUST be skipped when relaying a message
(gossipsub-v1.2.md line 62). Received IDONTWANTs were tracked in the
idontwants map but never consulted on the send path, so duplicates were
still forwarded to peers that explicitly refused them.

Skip those peers in forwardMessage and count skipped sends in a new
gossipsub_idontwant_skipped_sends_total metric.
With content-derived message ids a peer may send IDONTWANT for a message
id before we publish a message with that same id. Skip those peers in
publish, after the zero-peers check so error semantics are unchanged,
and report only peers actually sent to in the publish result.
Verifies the idontwantMaxMessages cap bounds attacker-controlled
suppression (ids beyond the cap are still forwarded) and that tracked
idontwants are dropped when the peer disconnects.
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.

1 participant