18

There are several implementations of Ethereum clients. How do these clients find each other? What are the algorithms and peer-to-peer protocols involved in this peer discovery process?

18

The peer discovery algorithm is based on the kademlia protocol.

A standalone implementation can be found here.

Edit:

A simplified model of how the p2p algorithm works is the following:

  • you have nodes that are assumed to be always available/online (in Ethereum they are called bootstrap nodes)
  • bootstrap nodes maintain a list of all nodes that connected to them in a period of time (predefined temporal value, for example last 24 hours)
  • when peers (Ethereum client applications such as eth, geth, pyethapp, etc.) connect to the Ethreum network, they first connect to the bootstrap nodes which share the lists of peers that have connected to them in the last predefined time period
  • the connecting peers then synchronize with the peers and may prune the connections to the bootstrap nodes since they are no longer essential in peer discovery (the peers can perform discovery on their own)
  • Can you provide a brief description of how this works? – galahad Aug 5 '16 at 19:13
  • Yes, I've edited the answer. – Sebi Aug 5 '16 at 19:40
  • Is bootstrap nodes the only way? What would be the situation if the IP address of a node has changed from the last connection? Will the bootstrap nodes keep track of these changes also? – galahad Aug 5 '16 at 19:46
  • 2
    Yes, you need to connect to nodes that have a high availability. The IP addresses are configured in the source code of the clients. If the IP changes, the list of the last bootstrap node that it connected to will change (the old IP will be removed and when the node connects again the new IP will be stored in the list). Yes, they do. – Sebi Aug 5 '16 at 20:58
  • 3
    @Marian Klühspies. Yes, Ethereum is pseudo p2p. The nodes you connect to initially will update their peer lists with your address and share them subsequently with the remaining clients. The address is given a weight given network parameters such as bandwidth and availability and will be kept for an amount of time that is a function of them. It is, of course, always possible to create a private network with custom bootstrap nodes. – Sebi Jan 10 '17 at 14:12
1

The accepted answer is not correct. The bootnodes are unreliable. A node can get blacklisted from the bootnodes and the bootnodes are sometimes unavailable without any apparent reason.

The Ethereum network carries forward on its own inertia because peers maintain a history of seed candidates based on past experience. Completely new nodes must join the network by looking for node data, such as on etherscan.

For example my current instance of geth cannot connect to any main net bootnode, but joins the network easily because it has a database of previous nodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.