About Discv5
Understand how Discv5 uses a distributed hash table to find peers across the network.
Discv5 is a decentralised and efficient peer discovery mechanism for the Logos Delivery Network. It uses a Distributed Hash Table (DHT) 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 randomised sets of nodes for mesh expansion. Have a look at the Discv5 specification to learn more.
How Discv5 works
sequenceDiagram
Alice->>DNS Server: (1) Execute DNS Discovery
DNS Server-->>Alice: (2) Bob's connection details (UDP + TCP)
activate Alice
Alice->>Bob: (3) Execute Discv5 over UDP
Bob-->>Alice: (4) ENRs (UDP + TCP): Carol, David, Erin
Alice->>Alice: (5) Decode ENRs
Alice->>Carol: (6) Execute Discv5 over UDP
Carol-->>Alice: (7) ENRs (UDP + TCP): Frank, Gwen, Harry
Alice->>Alice: (8) Decode ENRs
deactivate Alice
Alice->>Alice: (9) Select peers to dial
Alice->>David: (10) Libp2p dial (TCP)
Alice->>Frank: (10) Libp2p dial (TCP)
Alice->>Gwen: (10) Libp2p dial (TCP)
- DNS Discovery protocol is executed.
- Alice retrieves Bob's ENR (Ethereum Node Record) from DNS Server.
- Alice executes the Discv5 protocol with Bob using UDP connection details from ENR.
- Bob returns Carol's, David's and Erin's ENRs to Alice.
- Alice decodes ENRs and extracts the details of Carol, David, and Erin's TCP and UDP connections.
- Alice executes the Discv5 protocol with Carol using UDP connection details from ENR.
- Carol returns Frank's, Gwen's and Harry's ENRs to Alice.
- Alice decodes ENRs and extracts Frank's, Gwen's and Harry's TCP and UDP connection details.
- Alice selects to dial David, Frank and Gwen.
- Alice dials David, Frank and Gwen over libp2p using TCP connection details from ENRs.
Pros and cons
Pros:
- Decentralised 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.