waku-org / waku-rust-bindings

Rust wrapper over go-waku ffi
14 stars 6 forks source link

Filter protocol receives and parse signal from unrelated content topics #54

Closed hopeyen closed 1 year ago

hopeyen commented 1 year ago

When a node subscribe to a list of content topics within a pubsub topic on the filter protocol, it should not receive messages with an unrelated content topic, even if the message was with the same pubsub topic.

To reproduce,

The nodes will receive the messages and only realize those are not of interest after reading the content topics. We expect that no message should be received under this case, please suggest if the set up was incorrect.

danielSanchezQ commented 1 year ago

Filtering just means that you will not be relying those messages not that you do not receive them. Because otherwise what would be the first node to not rely them? Pinging @richard-ramos @LNSD

richard-ramos commented 1 year ago

initialize 2 nodes with relay and filter protocol enabled with the same pubsub topic

Since both nodes are using relay with the same pubsub topic, they will receive all messages regardless of the criteria set in the filter protocol. Filter and Relay are independent protocols. A filter client should probably not use relay protocol.

Here's an example on the behavior as implemented in go-waku:

Node 1:

Scenario 1: Node 2: publishes a message with content topic "xxxx" and pubsub topic "ABC" Node 1: will receive the message only once, via relay protocol. Messages are not filtered by content topic in this protocol. Filter subscription will ignore the message as the content topic does not match

Scenario 2: Node 2: publishes a message with content topic "test" and pubsubtopic "ABC" Node 1: will receive message twice, via relay protocol (because the pubsub topic matches), and also via the filter subscription (pubsub topic and content topic match)

hopeyen commented 1 year ago

That makes sense, understood, thanks! The reason we have relay protocol enabled is because the node cannot be initialized with pubsub topic if relay is disabled, but I've noted that they are independent protocol, and the pubsub field there is solely for the relay protocol. Learning that that the pubsub topic can be filter_subscribed without being a relay topic upon initialization, will then disable relay protocol and only run on filter