docs.waku.org/docs/overview/concepts/peer-discovery.md

72 lines
4.2 KiB
Markdown
Raw Normal View History

2023-05-14 05:08:18 +00:00
---
2023-05-22 05:19:27 +00:00
title: Peer Discovery
2023-05-14 05:08:18 +00:00
---
2023-06-02 18:07:08 +00:00
When initializing a Waku node, it must connect with other peers to enable message sending, receiving, and retrieval. To achieve this, a discovery mechanism is employed to locate other peers in the network. This process is known as bootstrapping.
2023-05-14 05:08:18 +00:00
2023-05-22 05:19:27 +00:00
Once a connection is established, the node must actively seek out additional peers to have:
2023-05-14 05:08:18 +00:00
2023-06-02 17:25:07 +00:00
- Sufficient peers in the [Relay](/overview/concepts/protocols#relay) mesh: The goal is to have at least 6 peers in the mesh. This ensures a robust network where messages can be efficiently relayed.
2023-05-14 05:08:18 +00:00
- Reserve peers for backup: It is essential to have a surplus of peers available as reserves. These reserves are backups when the current peers become overloaded or experience unexpected disconnections.
2023-06-02 17:25:07 +00:00
- Peers with specific capabilities: The node seeks out peers with specific capabilities, such as [Store](/overview/concepts/protocols#store), [Light Push](/overview/concepts/protocols#light-push), or [Filter](/overview/concepts/protocols#filter). This allows for targeted interactions and enhanced functionality based on the desired capabilities.
2023-05-14 05:08:18 +00:00
2023-05-21 00:32:38 +00:00
## Predefined Nodes
2023-05-14 05:08:18 +00:00
2023-05-31 00:43:49 +00:00
Waku applications have the flexibility to embed bootstrap node addresses directly into their codebase. Developers can opt to use either the [predefined nodes by Status](https://github.com/waku-org/js-waku/blob/master/packages/core/src/lib/predefined_bootstrap_nodes.ts#L45) or [operate a node](/guides/sdks-and-nodes#operate-a-waku-node) per their preference.
2023-05-14 05:08:18 +00:00
#### Pros
- Low latency.
- Low resource requirements.
#### Cons
- Vulnerable to censorship: Node IPs can be blocked or restricted.
- Limited scalability: The number of nodes is fixed and cannot easily be expanded.
- Maintenance challenges: Updating the node list requires modifying the code, which can be cumbersome and involves releasing and deploying.
2023-05-14 05:08:18 +00:00
## [DNS Discovery](https://rfc.vac.dev/spec/31/)
2023-05-31 15:49:34 +00:00
Built upon the foundation of [EIP-1459: Node Discovery via DNS](https://eips.ethereum.org/EIPS/eip-1459), DNS Discovery allows the retrieval of an `ENR` tree from the `TXT` field of a domain name. This innovative approach enables the storage of essential node connection details, including IP, port, and multiaddr, using the standardized [ENR format](https://rfc.vac.dev/spec/31/).
2023-05-14 05:08:18 +00:00
This bootstrapping method allows anyone to register and publish a domain name for the network, fostering increased decentralization.
#### Pros
- Low latency, low resource requirements.
- Easy bootstrap list updates by modifying the domain name, eliminating the need for code changes.
- Ability to reference a larger list of nodes by including other domain names in the code or ENR tree.
#### Cons
- Vulnerable to censorship: Domain names can be blocked or restricted.
- Limited scalability: The listed nodes are at risk of being overwhelmed by receiving all queries. Also, operators must provide their `ENR` to the domain owner for listing.
2023-05-14 05:08:18 +00:00
## [Discv5](https://rfc.vac.dev/spec/33/)
2023-06-02 18:07:08 +00:00
`Discv5` is a decentralized and efficient peer discovery method for the Waku Network. It uses a [Distributed Hash Table (DHT)](https://en.wikipedia.org/wiki/Distributed_hash_table) for storing `ENR` records, providing resistance to censorship. `Discv5` offers a global view of participating nodes, enabling random sampling for load distribution. It uses bootstrap nodes as an entry point to the network, providing randomized sets of nodes for mesh expansion. This enhances resilience, load balancing, and security in the Waku Network.
2023-05-14 05:08:18 +00:00
#### Pros
- Decentralized with random sampling from a global view.
- Continuously researched and improved.
#### Cons
- Requires lots of connections and involves frequent churn.
- Relies on User Datagram Protocol (UDP), which is not supported in web browsers.
2023-05-14 05:08:18 +00:00
## [Peer Exchange](https://rfc.vac.dev/spec/34/)
2023-05-25 16:48:57 +00:00
The primary objective of this protocol is to facilitate peer connectivity for resource-limited devices. The peer exchange protocol enables lightweight nodes to request peers from other nodes within the network. Light nodes can bootstrap and expand their mesh independently without relying on `Discv5`.
2023-05-14 05:08:18 +00:00
#### Pros
- Low resource requirements.
- Decentralized with random sampling of nodes from a global view using `Discv5`.
#### Cons
- Decreased anonymity.
- Imposes additional load on responder nodes.