libp2p / libp2p/rust-libp2p

feat(gossipsub): Add Message Batch Publishing in Gossipsub

Open
#6,006 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

decision-pending
Dominant language
Rust
Stars
5.6k
Forks
1.3k
Avg merge
8h 47m
Merged PRs (30d)
19

Description

Description

Adding a MessageBatch API to the libp2p::gossipsub to support batch publishing. This feature allows publishing a batch of related messages by prioritizing the transmission of one copy of each message to different peers before sending redundant copies.

Motivation

The Gossipsub protocol in rust-libp2p (implemented in the libp2p-gossipsub crate) currently allows publishing messages to topics individually, with each message being sent to connected peers as soon as it is published.

However, in scenarios with bandwidth-constrained peers or high message volumes, sending messages individually can lead to inefficiencies, such as redundant message propagation, dropped messages due to outbound queue limits, ..

One solution could be adding a MessageBatch mechanism to allow users to group related messages into a batch and publish them together (the implementation on go pubsub -> https://github.com/libp2p/go-libp2p-pubsub/pull/607).

This would optimize bandwidth usage by ensuring that a single copy of each unique message is sent to each peer before additional copies.

Requirements
  • MessageBatch Struct: A new struct to collect messages for batch publishing, with methods to add messages and trigger publication.

  • Batch Publishing Logic: A mechanism to prioritize sending one copy of each message to peers before sending duplicates, similar to the Go implementation’s rarest-first strategy.

  • Integration with Gossipsub: Extend the Gossipsub behaviour to handle batched messages, ensuring compatibility with existing message ID generation and peer outbound queues.

  • Configurable Queue Size: Recommend setting the peer outbound queue size to accommodate the expected number of batched messages, plus additional slack for gossip overhead.

Open questions

No response

Are you planning to do it yourself in a pull request?

Maybe

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing publishing API and message flow in the libp2p-gossipsub crate, then compare the proposed behavior with the referenced Go pubsub pull request. Done means agreeing on a MessageBatch API, implementing rarest-first batch propagation, and covering queue sizing and compatibility with existing message IDs and outbound queues.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
distributed-systems, networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.