Skip to content

fix(gossipsub): prune empty topic entries from topics map#3405

Open
lodekeeper wants to merge 3 commits intolibp2p:mainfrom
lodekeeper:fix/gossipsub-empty-topic-prune
Open

fix(gossipsub): prune empty topic entries from topics map#3405
lodekeeper wants to merge 3 commits intolibp2p:mainfrom
lodekeeper:fix/gossipsub-empty-topic-prune

Conversation

@lodekeeper
Copy link
Contributor

Summary

Monorepo port of ChainSafe/js-libp2p-gossipsub#543.

This carries over the empty-topic pruning fix for the internal topics: Map<TopicStr, Set<PeerIdStr>> bookkeeping:

  • prune empty topics entries on remote unsubscribe
  • prune empty topics entries on peer disconnect
  • avoid creating empty topics entries from unsubscribe-only updates
  • add regression coverage for the above cases

Original standalone PR / discussion: ChainSafe/js-libp2p-gossipsub#543
Original issue context: ChainSafe/js-libp2p-gossipsub#542

Why reopen here?

wemeetagain asked for this to be reopened against the js-libp2p monorepo because js-libp2p-gossipsub will soon be archived.

Notes

This is intentionally scoped to topics only. I did not fold in any mesh cleanup changes here because mesh tracks local joined-topic state and deleting empty mesh topics on disconnect would interfere with heartbeat maintenance/regrafting.

Testing

  • npm exec --workspace packages/gossipsub -- aegir lint
  • focused gossip.spec.ts run currently trips pre-existing monorepo package type/build issues in unrelated test/utils/* files; this patch itself is limited to packages/gossipsub/src/gossipsub.ts and packages/gossipsub/test/gossip.spec.ts

AI disclosure

Initial heap analysis and patch drafting were assisted by AI tooling, then validated with local source inspection and review.

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.

3 participants