waku-org / js-waku

JavaScript implementation of Waku v2
https://js.waku.org
Apache License 2.0
162 stars 41 forks source link

feat: cycle peers in local storage #2018

Open danisharora099 opened 1 month ago

danisharora099 commented 1 month ago

This is a feature request

Problem

When a js-waku node is started and starts to discover nodes, using different discovery mechanisms, it starts to store successfully connected nodes in the local storage for faster bootstrapping when a js-waku node starts the next time.

This can lead to an aspect of potential centralisation where the node is attempting to connect to the same pool of nodes, stored in the localstorage.

Proposed Solutions

Cycle the list of nodes stored in localstorage when new nodes are found upon a restart.

Notes

weboko commented 1 month ago

Adding quote from https://github.com/waku-org/js-waku/issues/1463#issuecomment-1679337931:

It's probably a good idea to cache some peers, but I would try to flush out that cache as soon as possible after a startup and replace each of these subscriptions with a new one to a random node. This is to prevent a node from always using the same peers and so being vulnerable to bias.