28

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?

1

2 Answers 2

29

The peer discovery algorithm is based on the kademlia protocol.

More details: https://github.com/ethereum/devp2p

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)
4
  • 1
    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
    Commented Aug 5, 2016 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
    Commented Aug 5, 2016 at 20:58
  • Does that mean, that Ethereum Clients have a list integrated with fixed IP addresses of the bootstrap nodes? What happens if you decide to host a bootstrap node (which is possible), does that mean someone has to integrate your IP manually into the source code? Commented Jan 10, 2017 at 10:27
  • 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
    Commented Jan 10, 2017 at 14:12
7

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.

1
  • Thanks for this answer. Could you elaborate on the details? E.g. What is the first step the Eth client does technically if it does not use the boot nodes list? what are the next steps?
    – aholbreich
    Commented Jun 18, 2023 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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