vacp2p / nim-libp2p

libp2p implementation in Nim
https://vacp2p.github.io/nim-libp2p/docs/
MIT License
240 stars 52 forks source link

Improvements related to Gossipsub 1.2 #1131

Closed diegomrsantos closed 5 days ago

diegomrsantos commented 1 week ago
diegomrsantos commented 6 days ago

@kaiserd the spec https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#spam-protection-measures says:

In flight IWANT requests, sent as a response to an IHAVE advertisement, are probabilistically tracked. For each IHAVE advertisement which elicits an IWANT request, the router tracks a random message ID within the advertised set. If the message is not received (from any peer) within a period of time, then a behavioural penalty is applied to the advertising peer through P₇. This measure helps protect against spam IHAVE floods by quickly flagging and graylisting peers who advertise bogus message IDs and/or do not follow up to the IWANT requests.

I believe this hasn't been implemented. https://github.com/vacp2p/nim-libp2p/pull/943 tried to do something similar, but it seems to me it goes against the spec. In order to implement https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#cancelling-iwant, we need to track in-flight IWANT messages. I am going to remove the last point here and create an issue for keeping track of in-flight IWANT messages.

See https://github.com/vacp2p/nim-libp2p/issues/1136.

diegomrsantos commented 6 days ago

I won't implement the second point either. We process IWANT messages synchronously and there won't be any opportunity for an IDONTWANT to arrive before we schedule the requested msg to be sent. It's better to just check the idontwants when we pop a msg from the non-prio queue.

See https://github.com/vacp2p/nim-libp2p/issues/1137.

kaiserd commented 5 days ago

Thanks for the update :).