waku-org / go-waku

Go implementation of Waku v2 protocol
https://waku.org/
Other
116 stars 42 forks source link

feat: skip strict checking for discovering peerExchange peers #1136

Open chaitanyaprem opened 3 months ago

chaitanyaprem commented 3 months ago

Problem

On-Demand discovery is not able to select peers for peerExchange, since that is not registered as a waku protocol and also the ENR for peers don't have this information. So, this check can be laxed and we can assume that any serviceNode in the network will support peerExchange and use them for peerExchange. Worst case there would be failure identified during stream negotiation which is still fine.

More details here: https://discord.com/channels/1110799176264056863/1242773830016176129

Alternatives considered

Update Waku ENR to include peerExchange bit capability. This is more complex and require further research hence not taking this path for now.

Additional context

Update status-go so that light clients discovery can stop once some limit in peer store is reached. Some housekeeping could be run from time to time, but this could be much less often than every 5 seconds.

chaitanyaprem commented 3 months ago

Looks like it may not be an ENR related issue, but noticing these logs in status-desktop. This should not happen as the peer-exchange peers are added with pubsubTopics in peerstore. Need to dig deeper to understand what is going on. It is not affecting as of now any functionality, as peerExchange is able to fetch peers from some of the nodes.

  4359 INFO [06-25|11:11:41.020|github.com/status-im/status-go/wakuv2/waku.go:539]                                          Running peer exchange loop 
  4360 DEBUG[06-25|11:11:41.020|github.com/waku-org/go-waku/waku/v2/peermanager/peer_selection.go:193]                      Select Peers                             select       ionCriteria="{\"selectionType\":0,\"protocolId\":\"/vac/waku/peer-exchange/2.0.0-alpha1\",\"pubsubTopics\":[\"/waku/2/rs/16/32\"],\"specificPeers\":[\"16Uiu2HAmAR24       Mbb6VuzoyUiGx42UenDkshENVDj4qnmmbabLvo31\",\"16Uiu2HAm8mUZ18tBWPXDQsaF7PbCKYA35z7WB2xNZH2EVq1qS8LJ\",\"16Uiu2HAmGwcE8v7gmJNEWFtZtojYpPMTHy2jBLL6xRk33qgDxFWX\"],\"ma       xPeerCount\":1,\"excludePeers\":null}" excludedPeers=
  4361 DEBUG[06-25|11:11:41.021|github.com/waku-org/go-waku/waku/v2/peermanager/peer_selection.go:147]                      discovering peers by pubsubTopic         pubsub       Topics=[/waku/2/rs/16/32]
  4362 INFO [06-25|11:11:41.021|github.com/waku-org/go-waku/waku/v2/peermanager/peer_discovery.go:58]                       cannot do on demand discovery for non-waku prot       ocol protocol=/vac/waku/peer-exchange/2.0.0-alpha1
  4363 ERROR[06-25|11:11:41.021|github.com/waku-org/go-waku/waku/v2/peermanager/peer_discovery.go:115]                      failed to discover and connect to peers  error=       "cannot do on demand discovery for non-waku protocol"
  4364 DEBUG[06-25|11:11:41.021|github.com/waku-org/go-waku/waku/v2/peermanager/peer_selection.go:158]                      could not retrieve random peer from slot
chaitanyaprem commented 3 months ago

Looks like it may not be an ENR related issue, but noticing these logs in status-desktop. This should not happen as the peer-exchange peers are added with pubsubTopics in peerstore. Need to dig deeper to understand what is going on. It is not affecting as of now any functionality, as peerExchange is able to fetch peers from some of the nodes.

  4359 INFO [06-25|11:11:41.020|github.com/status-im/status-go/wakuv2/waku.go:539]                                          Running peer exchange loop 
  4360 DEBUG[06-25|11:11:41.020|github.com/waku-org/go-waku/waku/v2/peermanager/peer_selection.go:193]                      Select Peers                             select       ionCriteria="{\"selectionType\":0,\"protocolId\":\"/vac/waku/peer-exchange/2.0.0-alpha1\",\"pubsubTopics\":[\"/waku/2/rs/16/32\"],\"specificPeers\":[\"16Uiu2HAmAR24       Mbb6VuzoyUiGx42UenDkshENVDj4qnmmbabLvo31\",\"16Uiu2HAm8mUZ18tBWPXDQsaF7PbCKYA35z7WB2xNZH2EVq1qS8LJ\",\"16Uiu2HAmGwcE8v7gmJNEWFtZtojYpPMTHy2jBLL6xRk33qgDxFWX\"],\"ma       xPeerCount\":1,\"excludePeers\":null}" excludedPeers=
  4361 DEBUG[06-25|11:11:41.021|github.com/waku-org/go-waku/waku/v2/peermanager/peer_selection.go:147]                      discovering peers by pubsubTopic         pubsub       Topics=[/waku/2/rs/16/32]
  4362 INFO [06-25|11:11:41.021|github.com/waku-org/go-waku/waku/v2/peermanager/peer_discovery.go:58]                       cannot do on demand discovery for non-waku prot       ocol protocol=/vac/waku/peer-exchange/2.0.0-alpha1
  4363 ERROR[06-25|11:11:41.021|github.com/waku-org/go-waku/waku/v2/peermanager/peer_discovery.go:115]                      failed to discover and connect to peers  error=       "cannot do on demand discovery for non-waku protocol"
  4364 DEBUG[06-25|11:11:41.021|github.com/waku-org/go-waku/waku/v2/peermanager/peer_selection.go:158]                      could not retrieve random peer from slot

As peerExchange is not defined in ENR and it is not registered as waku protocol hence it is not included in serviceSlots which is causing these logs to happen during on-demand discovery. Hence, these logs can be ignored for now as they don't mean anything going wrong.