Filtering nodes that we gossip to

This partly does the job, but not completely.

Not sure if this is a bug, but even if we use subscription filters, it doesn’t prevent graft requests from other peers.

In other words, say peer A uses a subscription filter that blocks peer B from subscribing to topic X.

This will prevent peer B from getting added to p.topics[X], but the problem is that the gossipsub implementation also picks gossipsub peers to publish the message to: go-libp2p-pubsub/gossipsub.go at master · libp2p/go-libp2p-pubsub · GitHub

And the subscription filter does not prevent peer B from getting added to gs.mesh[X], which may happen during a graft.

Is this the intended behavior? Or would this be a bug?

This is a bug I would say, but it is known and there are reasons for this; basically the announce message might get dropped and is thus lenient in accepting grafts. But yeah, all things considered, it is a bug that we should probably fix.

Created an issue and will work on a fix for this.

Based on what you said, should this fix be implemented at the level which would prevent the graft entirely? Or would it be simpler to add another step to the Publish method to run the subscription filters again?

I’m thinking actually we could just add the logic here, where the subscription filter is currently checked, to also filter out any graft control messages as well?

Do you think we need to filter out IWANT control messages too?