Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does bootnode peering work in geth? #30122

Closed
SyedMuhamadYasir opened this issue Jul 5, 2024 · 2 comments
Closed

How does bootnode peering work in geth? #30122

SyedMuhamadYasir opened this issue Jul 5, 2024 · 2 comments

Comments

@SyedMuhamadYasir
Copy link

I am quite unsure about the peering tendency of the geth peers

My question is about geth bootnodes not peering properly - however, instead of leaving the question as it is here, i would like to provide some elaboration.

i have set up a private ethereum PoS network with geth + lighthouse,

and i am now struggling with setting up a bootnode

I started a geth node (lets call it Node A), assigned to it its OWN enode address (using the --bootnode parameter)

I then added a static peer (lets call it SPeer ) to Node A

this worked, so Node A who is supposed to be a bootnode, is now synced with the PoS private testnet

NOW, i start another geth node (Node B), it is fresh and has no peers

Node B is given the enode of Node A, so basically Node B, in its --bootnode parameter, has the enode address of
Node A

here is what happens

Node B only discovers Node A as a peer

but Node B does NOT discover SPeer (the static peer of Node A), as an additional peer for itself

why is that?

am i missing something in how geth peering works?

or what the bootnode is supposed to do?

Aren't geth nodes supposed to also discover OTHER nodes connected to their peers, so that they can have a healthy collection of peers? ( the analogy of 'knowing a friend of a friend' applies here)

This is exactly the problem i am facing with my PoS test network, i cannot set up auto peering through bootnodes and every time, i have to add peers through the geth js console

at best, if the node, whose enode address is provided to others, is healthy, then those other nodes will peer with it and start working normal

but thats about it,

how can i make my geth nodes find other peer nodes in the private testnetwork seamlessly and thorugh a bootnode (or a collection of bootnodes atleast)

I am looking forward to some help, as i have asked this in geth discord among other places but i did not get any helpful answers (S1na was willing to help me on discord, but he's busy i believe, as he hasn't replied in a while)

Best,
Yasir

@chanderprakash20
Copy link

Hi Yasir,

It sounds like you're encountering some common challenges with bootnode configuration and peer discovery in a private Ethereum network. Here are suggestions that might help you resolve the issue:

Understanding Bootnodes and Peer Discovery

  1. Bootnodes Role:
    Bootnodes act as entry points for nodes to join the network by providing an initial list of peers. However, they do not automatically propagate all known peers to connecting nodes. This means that while Node B can discover Node A via the bootnode mechanism, it won't necessarily discover SPeer, which is a static peer of Node A.

  2. Peer Discovery Protocol:
    Geth uses a distributed hash table (DHT) for peer discovery, following the Kademlia protocol. Nodes will query known peers to discover additional peers, but this process can take time and is not guaranteed to find all peers immediately, especially in a private network setup.

Suggestions for Improving Peer Discovery

  1. Multiple Bootnodes:
    Consider setting up multiple bootnodes to improve redundancy and provide more initial connection options for new nodes.

  2. Static Peers:
    Define static peers for each node to ensure key nodes in your network can always connect with each other. This is especially useful for initial network bootstrapping.

  3. Enable Discovery:
    Make sure that the discovery protocol (--discovery) is enabled on all nodes, allowing them to advertise themselves and find others automatically.

  4. Adjust Network Settings:
    Increase the --maxpeers setting to allow nodes to connect with more peers, which can help nodes discover more peers over time.

  5. Node Restarts:
    Periodically restart nodes to refresh their peer lists, as this can sometimes help them find new peers.

  6. Monitor and Log:
    Use logging to monitor peer discovery and connection processes, helping you identify where the process might be stalling or failing.

Addressing the Issue

You should ensure that all nodes have the --bootnodes parameter configured correctly and that static peers are added where necessary. By following these practices, you should see improved connectivity and peer discovery across your network.

If problems persist, consider reaching out to the Geth community or consulting additional documentation for more detailed troubleshooting steps.

Best regards,

chan


This response provides a clear explanation of the bootnode and peer discovery process in Geth, along with actionable steps to address the issues Yasir is facing. It also encourages ongoing monitoring and adjustment to optimize network connectivity.

@lightclient
Copy link
Member

Aren't geth nodes supposed to also discover OTHER nodes connected to their peers, so that they can have a healthy collection of peers?

The eth wire protocol doesn't share any info about peers it's connected to. The discovery protocol can share info about peers it has included in it's table. Geth is not optimized for discovery on small networks. You can see further discussion here: #30243

@lightclient lightclient closed this as not planned Won't fix, can't repro, duplicate, stale Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@lightclient @SyedMuhamadYasir @chanderprakash20 and others