nanocurrency / nano-node

Nano is digital currency. Its ticker is: XNO and its currency symbol is: Ӿ
https://nano.org
BSD 3-Clause "New" or "Revised" License
3.48k stars 787 forks source link

Limit peer diversity #419

Open androm3da opened 6 years ago

androm3da commented 6 years ago

Diversity is great for decentralization but can cause problems:

Let's enable a configuration option that will allow people to limit the scope of the peer diversity.

clemahieu commented 6 years ago

Agreed this needs to be worked on and it should probably be default.

My first thought was some sort of distance metric between IPs with a bucketing system like kademlia. One issue is it's hard to determine the local IP especially behind nat.

Another option would be to rotate outbound traffic on an interval. Right now it picks a new set of peers for every broadcast, we could rotate it on an interval to decrease the number of connections at a given time. Maybe on a 15 second rotation.

slact commented 6 years ago

There is another issue with the current protocol regarding peer connectivity, apart from saturating router state tables:

There is no way to walk the network to find the fastest peers without incurring a keepalive storm. Meaning, every node you send a keepalive to is going to forward you its traffic for the next 5 minutes. This makes it impossible to reliably measure the distance to any given peer once a relatively low-bandwidth node becomes saturated in the inbound direction.

One way to solve this would be to add an explocit forgetme or imdead command, which would remove the sender from the peer list of the receiver. Trouble is, UDP packets could be spoofed and this would become an easy DoS attack to keep a targeted node offline indefinitely. So to get around this, imdead messages would need to be signed, and keepalives would need to include a peer's pubkey.

This way, a peer could send keepalives with their pubkeys as they walk through the network, disconnecting from the slower peers as they see fit with signed imdead messages. This would make it possible for nodes to eventually find the fastest/nearest peer subset on the network without interference from slower / more distant nodes.

rkeene commented 6 years ago

We have a plan for this that involves node_id, but it will need further investigation. This ticket will probably be replaced by something more specific once more details have been thought out.