Skip to content

fix(gossipsub): cap prune backoff and process all prune entries - #3682

Merged
tabcat merged 1 commit into
libp2p:mainfrom
lodekeeper:fix/gossipsub-prune-backoff-cap
Oct 25, 2026
Merged

tabcat merged 1 commit into
libp2p:mainfrom
lodekeeper:fix/gossipsub-prune-backoff-cap

Conversation

@lodekeeper

Copy link
Copy Markdown
Contributor

Title

fix(gossipsub): cap prune backoff and process all prune entries

Description

Two small fixes in handlePrune:

  • The backoff a peer sends in a PRUNE is used as is, so an arbitrarily large value creates a backoff entry that never expires in clearBackoff. It is now clamped to one hour (GossipsubMaxPruneBackoff), matching rust-libp2p (MAX_REMOTE_PRUNE_BACKOFF_SECONDS = 3600).
  • A PRUNE entry for a topic we are not meshed in hit return, which dropped every remaining entry in the control message. It now uses continue, matching go-libp2p and rust-libp2p.

Notes & open questions

  • Behaviour change: a peer-requested backoff is now honoured for at most one hour.
  • Locally, the build currently needs @types/sinon pinned to 22.0.0. 22.0.1 (published 2026-10-21) breaks type-checking of existing @libp2p/utils tests, which also shows up on current CI runs. That failure is unrelated to this change.
  • Local results: npm run test:node in packages/gossipsub passes (171 passing). The new prune.spec.ts fails on main and passes with this change. lint, dep-check and spell-check are clean.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

🤖 Generated with AI assistance

Clamp the backoff accepted from a peer in a PRUNE message to one hour,
matching rust-libp2p, and skip PRUNE entries for topics we are not
meshed in instead of dropping the rest of the control message, matching
go-libp2p and rust-libp2p.

🤖 Generated with AI assistance
@lodekeeper
lodekeeper requested a review from a team as a code owner October 23, 2026 11:50

@tabcat tabcat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@lodekeeper Thanks!

@tabcat
tabcat merged commit 0d3ca9f into libp2p:main Oct 25, 2026
59 of 62 checks passed
@tabcat tabcat mentioned this pull request Oct 25, 2026
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