lodestar icon indicating copy to clipboard operation
lodestar copied to clipboard

Keep at least 10% of outbound peers

Open dapplion opened this issue 4 years ago • 2 comments

If you run current master with ports open the node will eventually be connected to 100% of inbound peers.

From https://discord.com/channels/595666850260713488/646778960830660623/811507775389696050

  • Is there any reason or issue to keep a certain ratio of inbound vs outbound peers? i.e. any issues with having ~100% of your peers inbound?
  • You'd be much more susceptible to an eclipse attack in that scenario. Having a minimum number of outbound peers ensures that you chose at least some of your peers.
  • What specific numbers are you targeting in your implmentation?
  • I don’t remember off the top of my head. I think it’s 10% are entirely randomly selected outbound connections.

dapplion avatar Mar 22 '21 08:03 dapplion

May want to wait till libp2p ESM is merged. cc: @wemeetagain

  • blocked by https://github.com/ChainSafe/lodestar/pull/4114

philknows avatar Jul 01 '22 14:07 philknows

When you dial a peer, it's possible to temporarily exceed the connection limit. When the node notices the connection limit has been exceeded, it'll close some connections to bring itself back under the limit.

Connected peers will be ranked in terms of importance in order to choose connections to close, starting with low-importance connections.

You can tag peers with a value - if we are connected to this peer, the value is used to sort the peers before closing connections.

In the future we may apply other metrics - close incoming connections first, or connections with fewer streams, etc, but at the moment it's a simple sum of all the tag values.

So, gossipsub might want to tag it's mesh peers with a high value to prevent those connections being closed, and it may also wish to untag peers that are no longer in the mesh to allow those connections to be closed.

You can also tag a peer with the special 'keep-alive' tag which will try to dial the peer when the node starts up (e.g. after a restart) and, at some point in the future, re-open a connection to that peer if it's closed for whatever reason.

Tags are new in the ESM version and will be released as part of [email protected] (installable with npm i libp2p@next right now).

achingbrain avatar Jul 05 '22 15:07 achingbrain