Skip to content

Conversation

@ppopth
Copy link
Contributor

@ppopth ppopth commented Nov 3, 2025

Implementing libp2p/specs#689 and libp2p/specs#699

Currently I decided not to implement the protocol violation part yet. When I receive an unsubstituted topic reference, currently I just treat it as it is and I don't close the stream or anything because I think it's possible that I will receive the unsubstituted topic reference by accident.

One corner case is because the hello packet handshake is not synchronized. It means that I can send a few more packets after my hello packet is sent but before I receive a hello packet from the other peer, so I cannot substitute the topic ref for those few packets.

We can make the hello packet handshake synchronous, but I think it requires a refactor.

@ppopth ppopth force-pushed the pop/topictable-extension branch from 26d7f30 to 93048e8 Compare November 3, 2025 08:22
@ppopth ppopth force-pushed the pop/topictable-extension branch from 93048e8 to 8ebd84c Compare November 3, 2025 09:14
@ppopth ppopth force-pushed the pop/topictable-extension branch from 8ebd84c to b9ec702 Compare November 3, 2025 14:16
@ppopth ppopth force-pushed the pop/topictable-extension branch from b9ec702 to 6c5e9e3 Compare November 3, 2025 14:20
@ppopth ppopth marked this pull request as ready for review November 4, 2025 11:25
@raulk
Copy link
Member

raulk commented Nov 4, 2025

Thanks for describing the edge case. A priori, it makes sense to not deem unsubstituted strings as a protocol violation.

The dual monodirectional streams approach has been a painpoint for a long time. AFAIR, the original rationale is that baseline libp2p has no way of knowing if the peer supports gossipsub, nor an easy to synchronize peers around a particular condition.

In practice, all libp2p users use identify and identify push, which advertises gossipsub. But we don't even need that. A simple rule would work:

The peer with the lowest peer ID is responsible for opening the duplex gossipsub stream (peer A). The receiving party (peer B) applies a timeout of 5 x RTT from libp2p connection establishment OR the first identify message listing A's protocols (whichever comes latest) to await the opening of the duplex stream. If no stream is opened, it assumes the peer does not want to interface over gossipsub.

@raulk raulk requested a review from sukunrt November 4, 2025 19:26
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