Skip to content

gossipsub: Topic Streams Extension#729

Open
MarcoPolo wants to merge 2 commits into
masterfrom
marco/topic-message-streams
Open

gossipsub: Topic Streams Extension#729
MarcoPolo wants to merge 2 commits into
masterfrom
marco/topic-message-streams

Conversation

@MarcoPolo

Copy link
Copy Markdown
Contributor

Gossipsub v1.3 uses a single stream per direction for all RPCs. This introduces some problems: unnecessary head of line blocking between messages (especially problematic when a large message in one topic delays small messages in another topic) and topic name overhead on each message.

The Topic Streams Extension addresses these problems. It moves topic scoped application messages to separate long-lived streams.

@MarcoPolo
MarcoPolo requested a review from sukunrt July 8, 2026 16:45
@github-project-automation github-project-automation Bot moved this to Triage in libp2p Specs Jul 8, 2026
@MarcoPolo
MarcoPolo requested a review from jxs July 8, 2026 16:55
Comment thread pubsub/gossipsub/topic-streams.md Outdated
Comment on lines +63 to +66
When this extension is negotiated, the original gossipsub stream becomes the
control stream. Application messages (such as the `Message` or
`PartialMessagesExtension` messages) MUST NOT be published on the control
stream.

@sukunrt sukunrt Jul 14, 2026

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.

What do you think about a design where we have per topic control streams too?

So the control stream would share the topic relevant: IHave, IWant, IDontWant, and maybe Graft and Prune

This allows:
Easier implementation. Need to read a control scoped RPC.
Heartbeat can now be per topic and be staggered by having different topics at different times, and also more frequent for some topics.
Less HOL Blocking when sharing IHave, IWant, IDontWant

And mostly the fact that there really isn't any reason that control messages for a topic should interleave with control messages of another topic.

Similarly What do you think about?
1 topic control stream as defined above
1 topic data stream per message.
With this design we get nice cancellation properties. So we can cancel in progress sends easily. And if we add message preambles / ids before sending messages we can also reset on the receive side.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Discussed synchronously. Resolved that theoretically 1 topic control stream would be better, the actual utility doesn't justify its implementation complexity. Decided to leave as is.

Comment on lines +81 to +86
If there are multiple streams for a single topic, the receiver SHOULD process
them in the order the streams were opened by the initiator. The receiver
SHOULD limit the number of concurrent topic streams for the same topic to 3 and
downscore peers that open more. Initiators SHOULD limit the number of
concurrent topic streams to 1 per topic. The initiator MUST close the old
stream before writing on a new stream for a given topic.

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.

it's a bit confusing, why would there be 3 streams?

Is this because of subscribe, unsubscribe, subscribe, unsubscribe kind of pattern?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right, or if the implementation opens a new stream per message. Because there is a potential for packets to be reordered or delayed, the sender should avoid concurrent streams that could appear to the receiver as multiple concurrent streams open at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants