Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: FlatPepsi on July 16, 2018, 04:01:41 PM



Title: How does a node ensure it sees all other nodes?
Post by: FlatPepsi on July 16, 2018, 04:01:41 PM
If I start up a BTC full node, it connects to a small number of other nodes. (is it 8?)  How do I really know that I'm connected to all other bitcoin nodes? It seems that it would be possible that somehow I connected to a small subset of nodes that only know about the subset - like a high school clique that only talks to people at the cool kids table.

For example, with bit torrent, it's not unusual to have lots of little groups that don't know about each other.  Digging up a long list of seeds gets better results than just one seed & what it knows about.

With Bitcoin, that could be a very bad thing.  Are there mechanisms in place to prevent or detect this?


Title: Re: How does a node ensure it sees all other nodes?
Post by: pebwindkraft on July 17, 2018, 06:12:35 AM
The bitcoin node has a set of pre-defined names in its initial installation. It would try to connect to one of these systems, and get further systems to connect to from there.
During initial sync you might not see many connections. When initial sync is done, you can see the system getting connected to 15-20 other systems, or even more. So a node does not "ensure", it is connected to all other nodes. Thats not how the system works.

And one more hint: several ports have to be opened on your router, so that incoming connections are allowed. If you haven't configured the router correctly, the system will not connect to more than 8 other systems.


Title: Re: How does a node ensure it sees all other nodes?
Post by: FlatPepsi on July 17, 2018, 01:05:39 PM
A related question: what happens when a node gets saturated with connections?  
I can imagine that the first few servers in the known servers list at startup get a ton of requests.


Title: Re: How does a node ensure it sees all other nodes?
Post by: Evil-Knievel on July 17, 2018, 01:10:08 PM
If I start up a BTC full node, it connects to a small number of other nodes. (is it 8?)  How do I really know that I'm connected to all other bitcoin nodes? It seems that it would be possible that somehow I connected to a small subset of nodes that only know about the subset - like a high school clique that only talks to people at the cool kids table.

For example, with bit torrent, it's not unusual to have lots of little groups that don't know about each other.  Digging up a long list of seeds gets better results than just one seed & what it knows about.

With Bitcoin, that could be a very bad thing.  Are there mechanisms in place to prevent or detect this?

Well, what you typically have is a small world graph - so you can reach anyone in the world by approximately 7 hops (if I recall correctly)? To prevent certain types of attacks that would "isolate" you from the network, the client should prevent you to connect to multiple nodes from the same subnet, which reduces the chance of you getting isolated to an absolute minimum.

Regarding Bittorrent: That is definitely not true. How can such small groups occur when there is a global tracker maintaining a chunks-list of all connected peers?


Title: Re: How does a node ensure it sees all other nodes?
Post by: Evil-Knievel on July 17, 2018, 01:12:13 PM
A related question: what happens when a node gets saturated with connections?  
I can imagine that the first few servers in the known servers list at startup get a ton of requests.

I would assume that the peers are chosen randomly, and not starting with the first entry in the peersDB. The list is also constantly changing (DNS seeds, getaddr messages, pruning of offline peers).

Any excess inbound connections beyond the limit of a (user configurable) "max inbound connections limit" are of course dropped.