libp2p / go-libp2p-pubsub

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

Implement lazyHello (fix #460) #477

Closed d-roak closed 1 year ago

d-roak commented 2 years ago

Does not emit the eager hello when a node has the lazy flag. When a non-lazy node receives a graft message, it adds the TopicID to the subscriptions that are going to be processed.

vyzo commented 2 years ago

there are also some security considerations, as this could become a DoS vector.

d-roak commented 2 years ago

this is not going to work, it will never receive a graft if it hasnt send a hello.

The non-lazy node receives a graft message even without the hello (i tested it).

Also, i would prefer to not conflate with gs semantics, it is incompatible with floodsub. So we should not process any control events for this.

Yes, I agree!

I think the right way foreard is to send back a hello packet if it receives one, and only include topics of interest. These topics should be decided by a user defined function, passed through the lazy option.

I am guessing we would also want to Relay those topics (not subscribe), so the application should also be given the chance to do so, maybe indicated as the respone from the user supplied function (maybe object?). Or it could emit an event to let the application decide whether to subscribe or relay to relevant topics.

We'll have to think about this a bit more.

What if when a lazy node receives a "subscriptions" rpc call, it calls the handleNewPeer subroutine with the subscription packet he received (if it's in the mySubs or myRelays)? I am trying to avoid a replyHelloPacket approach, but if you think is the best approach, we can go with that.

there are also some security considerations, as this could become a DoS vector.

What is the attack vector you are thinking?

d-roak commented 2 years ago

Hi @vyzo,

Can you check the last comment, please?