Skip to content

fix(gossipsub): graft known subscribers when their outbound stream opens - #3598

Draft
tabcat wants to merge 1 commit into
mainfrom
fix/gossipsub-graft-on-stream-open
Draft

fix(gossipsub): graft known subscribers when their outbound stream opens#3598
tabcat wants to merge 1 commit into
mainfrom
fix/gossipsub-graft-on-stream-open

Conversation

@tabcat

@tabcat tabcat commented Aug 13, 2026

Copy link
Copy Markdown
Member

Grafts a peer we already know is subscribed as soon as our outbound stream to them is established, mirroring the existing graft-on-subscribe path (#3583).

graftOnSubscribe can only add a peer to the mesh once we have an outbound stream to them (the same guard the heartbeat applies). If a peer's SUBSCRIBE is handled before that stream exists, the graft is refused and the peer waits for the next heartbeat before joining the mesh. This adds the mirror trigger: when the outbound stream opens, graft any peer we already know is subscribed. Mesh formation no longer depends on the subscription and the stream arriving in a particular order, nor on the peer grafting us back.

rust-libp2p handles this earlier and more simply, by queuing the GRAFT into a per-peer send queue that the connection handler drains once a substream exists rather than requiring the outbound stream up front; there is a note to that effect next to the code.

graftOnSubscribe can only add a peer to the mesh once we have an outbound stream to them (the same guard the heartbeat applies). If a peer's SUBSCRIBE is handled before that stream exists, the graft is refused and the peer waits for the next heartbeat before joining the mesh. This adds the mirror trigger: when the outbound stream opens, graft any peer we already know is subscribed, so mesh formation no longer depends on the subscription and the stream arriving in a particular order, nor on the peer grafting us back.
@tabcat

tabcat commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

still trying to fix the pubsub example in ci.

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