Search code examples
blockchainethereumgethdhtkademlia

How Ethereum protocol works with geth


I am new to Ethereum and generally to blockchain. I learned that Ethereum blockchain works on Kademlia. The distributed hash table and its working was beautiful and nicely explained by Eleuth P2P.

Now I used geth to connect to the Ethereum Mainnet and it discovered 2 to 3 maximum peers in 5 to 6 minutes.

Now I know the algorithm but my concern is how the first peer is discovered? Because internet is just a big set of routers and different type of computers (server, computer, etc ) and if you broadcast the discovery like in ARP. The internet will be flooded with these peer discovery broadcast messages and this doesn't seems right. So how initially the connections are made? Also we cannot trust a single network for first time connection because this will make the system server and client based and not decentralised so how the initial connections and peer discovery happens?

Are the broadcast message like have TTL like to prevent the circular loop like in TCP I guess? But this also seems a horrible idea to me.

Please explain.


Solution

  • In order to get going initially, geth uses a set of bootstrap nodes whose endpoints are recorded in the source code.

    Source: Geth docs

    Here's the list of the bootstrap nodes hardcoded in the Geth source code: https://github.com/ethereum/go-ethereum/blob/v1.10.11/params/bootnodes.go#L23

    The --bootnodes option allows you to overwrite this list with your own. Example from the above linked docs:

    geth --bootnodes enode://pubkey1@ip1:port1,enode://pubkey2@ip2:port2,enode://pubkey3@ip3:port3