Bitcoin Forum
November 11, 2024, 12:30:08 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How do blockchain nodes find each other?  (Read 435 times)
kooler1 (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 1


View Profile
November 30, 2017, 08:20:30 PM
Merited by ABCbits (1)
 #1

It is well known that blockchain is decentralised and each node stores whole history of transactions (all blocks).

But when you start the node, how does it know how to connect to others to synchronise? Is there central registry of nodes (or IP addresses of nodes) that it checks?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6886


Just writing some code


View Profile WWW
November 30, 2017, 08:31:27 PM
Merited by ABCbits (3)
 #2

Bitcoin Core (the most common type of node) has 3 methods of discovering peers. First it consults an internal database of peers it knows about. For a new node, this will be empty. Then it will consult a set of servers called DNS seeders. The DNS seeders give out the IP addresses of nodes that a node can connect to. The node will connect to these nodes only temporarily to gather the IP addresses of other nodes it can also connect to. It will then connect to those nodes. Lastly, if the previous two were unavailable, the node will consult a built in list of seed nodes. It does the same thing with these seed nodes that it did with nodes returned by the DNS seeders.

kooler1 (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 1


View Profile
November 30, 2017, 08:39:33 PM
 #3

Bitcoin Core (the most common type of node) has 3 methods of discovering peers. First it consults an internal database of peers it knows about. For a new node, this will be empty. Then it will consult a set of servers called DNS seeders. The DNS seeders give out the IP addresses of nodes that a node can connect to. The node will connect to these nodes only temporarily to gather the IP addresses of other nodes it can also connect to. It will then connect to those nodes. Lastly, if the previous two were unavailable, the node will consult a built in list of seed nodes. It does the same thing with these seed nodes that it did with nodes returned by the DNS seeders.

Thanks for explanation achow101. Does it mean that DNS seeders (primary and built in) are set of "hardcoded" servers which are basically critical point of bitcoin core and if those servers won't be available whole blockchain will stop functioning (as eventually nodes won't be able to discover each other)?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6886


Just writing some code


View Profile WWW
November 30, 2017, 08:45:26 PM
 #4

Thanks for explanation achow101. Does it mean that DNS seeders (primary and built in) are set of "hardcoded" servers which are basically critical point of bitcoin core and if those servers won't be available whole blockchain will stop functioning (as eventually nodes won't be able to discover each other)?
No. Nodes can still discover each other without the DNS seeders. The DNS seeders can be swapped out with some other initial discovery process too.

Furthermore, as I said, nodes maintain their own internal database that persists across restarts of nodes that it can connect to. So it will use those nodes instead of the DNS seeders on all starts after the first start. For new nodes, new nodes will fall back to the hundreds of hard coded seed nodes.

Lastly, nodes can be added manually too.

kooler1 (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 1


View Profile
November 30, 2017, 08:48:19 PM
 #5

Thanks for explanation achow101. Does it mean that DNS seeders (primary and built in) are set of "hardcoded" servers which are basically critical point of bitcoin core and if those servers won't be available whole blockchain will stop functioning (as eventually nodes won't be able to discover each other)?
No. Nodes can still discover each other without the DNS seeders. The DNS seeders can be swapped out with some other initial discovery process too.

Furthermore, as I said, nodes maintain their own internal database that persists across restarts of nodes that it can connect to. So it will use those nodes instead of the DNS seeders on all starts after the first start. For new nodes, new nodes will fall back to the hundreds of hard coded seed nodes.

Lastly, nodes can be added manually too.

Ah, ok. Thanks for clarification!
hopeAo
Jr. Member
*
Offline Offline

Activity: 42
Merit: 2


View Profile
December 02, 2017, 03:17:48 PM
 #6

It is well known that blockchain is decentralised and each node stores whole history of transactions (all blocks).

But when you start the node, how does it know how to connect to others to synchronise? Is there central registry of nodes (or IP addresses of nodes) that it checks?

For blockchain nodes to find each other it query the DNS using a number of "DNS seeds," which are DNS servers that provide a list of IP addresses of bitcoin nodes. Some of those DNS seeds provide a static list of IP addresses of stable bitcoin listening nodes. Some of the DNS seeds are custom implementations of BIND (Berkeley Internet Name Daemon) that return a random subset from a list of bitcoin node addresses collected by a crawler or a long-running bitcoin node. The Bitcoin Core client contains the names of five different DNS seeds. The diversity of ownership and diversity of implementation of the different DNS seeds offers a high level or reliability for the initial bootstrapping process. In the Bitcoin Core client, the option to use the DNS seeds is controlled by the option switch -dnsseed.





achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6886


Just writing some code


View Profile WWW
December 02, 2017, 06:20:35 PM
 #7

Some of those DNS seeds provide a static list of IP addresses of stable bitcoin listening nodes.
None of the DNS seeders provide a static list of IP addresses. They all provide a random subset of IPs that are gathered by a crawler. It is against Bitcoin Core's DNS Seeder policy to have a seeder that returns static addresses.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!