Peer Discovery in Blockchain


#1

Peer discovery is the process in which new nodes discover other nodes in the network and join the network. In Bitcoin, new nodes contact a DNS feed that uses DNS record to get IPs of a few well-known nodes. The new node contacts the peer nodes and the peers send up to 2500 random IP addresses to the new node. Each node may have up to 8 outgoing links and 125 links in total. All messages are broadcast to 8 peers, and each peer broadcasts to 8 more peers. In Ethereum, the well-known nodes are hardcoded into the Ethereum client software. Peers use a distributed hash table (DHT) to return a list of nodes, based on XOR-metrics distance as the method for discovering other nodes. The DHT is based on the Kademlia paper.

For Harmony, new nodes contact the beacon chain to submit a proof of stake. Once the proof of stake is validated, the new node will receive a list of IPs.The new node waits to join at the next epoch and we use a bounded cuckoo rule to phase in/out new and old nodes. A new node can contact any node in the list supplied by beacon chain. The new node will need to figure out which shard it is in and the peers in the same shard may return a list of peers based on Kademlia DHT.

Further readings:

Peer discovery in the Harmony network: https://medium.com/harmony-one/peer-discovery-in-harmony-network-6a07f9401c61


#2

I’m curious to know who controls the DNS feed for Bitcoin? This sounds as a potential point of centralization/failure.


#3

Great question, Nicolas!

My understanding was that “seed addresses” are hard-coded in by the software developers, but my readings suggest that this method is secondary to a primary method: “several host names (such as dnsseed.bluematt.me) are maintained that resolve to a list of IP addresses known to be running nodes.”

An operator of one of the DNS seeds answered this question on Stackoverflow–read more here.


#4

Thanks Gavin. The combination of static IPs in the client and DNS seed is interesting. Also that make sense to have several DNS to reduce the attack vector on this side.


#5

try the following command and you will see a list of IPs returned by DNS.

$ dig seed.bitcoinstats.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.58.amzn1 <<>> seed.bitcoinstats.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57365
;; flags: qr rd ra; QUERY: 1, ANSWER: 25, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;seed.bitcoinstats.com. IN A

;; ANSWER SECTION:
seed.bitcoinstats.com. 60 IN A 35.197.220.209
seed.bitcoinstats.com. 60 IN A 36.35.143.221
seed.bitcoinstats.com. 60 IN A 46.229.165.138
seed.bitcoinstats.com. 60 IN A 52.57.212.185
seed.bitcoinstats.com. 60 IN A 54.39.69.2
seed.bitcoinstats.com. 60 IN A 62.251.102.242
seed.bitcoinstats.com. 60 IN A 68.183.114.120
seed.bitcoinstats.com. 60 IN A 81.7.16.182
seed.bitcoinstats.com. 60 IN A 82.43.171.91
seed.bitcoinstats.com. 60 IN A 85.10.211.100
seed.bitcoinstats.com. 60 IN A 91.218.214.90
seed.bitcoinstats.com. 60 IN A 95.216.0.79
seed.bitcoinstats.com. 60 IN A 134.255.226.227
seed.bitcoinstats.com. 60 IN A 136.27.10.6