-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
@@ -548,7 +551,8 @@ impl NetworkState { | |||
let node_is_reserved = self.reserved_peers.read().contains(&infos.id); | |||
if !node_is_reserved { | |||
if self.reserved_only.load(atomic::Ordering::Relaxed) || | |||
num_open_connections >= self.max_peers | |||
num_open_connections.total >= self.max_peers || | |||
num_open_connections.incoming >= self.max_incoming_peers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is also reached when we dial. You should use endpoint
to determine whether we are dialing or listening.
We already limit the number of outgoing connections to |
Tried a fix for the "never reaching
|
/// Returns the number of new outgoing custom connections to peers to | ||
/// open. This takes into account the number of active peers. | ||
pub fn should_open_outgoing_custom_connections(&self) -> u32 { | ||
use std::cmp::max; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be at top of the file.
@@ -190,7 +190,7 @@ impl NetworkConfiguration { | |||
use_secret: None, | |||
min_peers: 25, | |||
max_peers: 50, | |||
max_incoming_peers_factor: 3, | |||
incoming_peers_factor: 3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like 3
is too high, especially for bootstrap nodes which probably want 90% of incoming connections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So 2
, probably?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And just for information, was choosing 3
because it comes from the eclipse attack paper.
@tomaka better? |
…sp-eclipse-flooding
…tions should be dropped
And just wonder, what are the reasons that we use |
Ah I see, from my understanding, looks like we need it for some cases in wasm. |
* master: (86 commits) Make contract a separate runtime module (#345) Version bump (#450) DB-based blockchain data cache for light nodes (#251) Update libp2p again (#445) Update version on git head change (#444) Fix the public key of bootnode 3 (#441) Update libp2p (#442) Switch to the master branch of libp2p (#427) Export ws port 9944 and add doc (#440) Iterate over overlay to decide which keys to purge (#436) Exit signal gets its own trait (#433) Add docker image (#375) Reset peers.json if the content is not loadable (#405) Limit number of incoming connections (#391) Fix memory leaks in libp2p (#432) Do not queue empty blocks set for import (#431) 5 random fixes (#1) (#435) Chore: fix typo (#434) Prevent building invalid blocks (#430) Better logging for public key mismatch (#429) ...
* Refactored Spot and Test
Fix #331
Add
max_incoming_peers
, which is calculated from configmax_peers / max_incoming_peers_factor
. Limit the number of incoming peers to be below this number.