libp2p / go-libp2p-pubsub

The PubSub implementation for go-libp2p
https://github.com/libp2p/specs/tree/master/pubsub
Other
327 stars 186 forks source link

Gossipsub direct peers get added into fanout and from there into mesh on subscription #371

Closed blacktemplar closed 4 years ago

blacktemplar commented 4 years ago

Consider the following scenario:

  1. P1 and P2 get initiated as direct peers of each other
  2. P1 subscribes to a topic "topic"
  3. P2 publishes a message in topic "topic", this will create a fanout, but it gets not checked if the peers are direct peers (see https://github.com/libp2p/go-libp2p-pubsub/blob/2b5243c72f0d1a13a49d346e0f8391bbb0076f8d/gossipsub.go#L905), therefore P1 will be part of the fanout of P2.
  4. P2 subscribes to the topic "topic" and and the peers from the fanout will be added to the mesh which will result in a GRAFT to peer P1.

The spec states:

It is an error to GRAFT on an explicit peer, [...]

Therefore I assume this is a bug and either direct peers shouldn't get added to the fanout (a direct peer in a fanout doesn't make sense) or they should get filtered out before the fanout gets added to the mesh on subscription.

vyzo commented 4 years ago

Yes, that's a bug, albeit a benign one.

vyzo commented 4 years ago

fix in #375.