Skip to content

Conversation

jan-ferdinand
Copy link
Member

In order to help newcomers to connect to peers on the network, certain nodes act as bootstrap nodes. Those nodes tend to be well known, and users tend to specify them as potential peers via command line arguments.

Previously, connections to potential peers specified as command line arguments were always re-initiated when dropped. This can cause an involuntary denial-of-service of those well-known bootstrap nodes.

With this PR, a well-connected node does not initiate connections with bootstrap nodes.

Second attempt of #488 after its reversal in 10e327b and ee37959.

In order to give bootstrap nodes an easier time at fulfilling their
service, they should only be contacted if necessary. In order to stop
connecting to them, nodes need to communicate their bootstrap status and
track their peer's bootstrap status.

BREAKING CHANGE: Add additional variants to the public enumeration
`NegativePeerSanction`.
In order to help newcomers to connect to peers on the network, certain
nodes act as bootstrap nodes. Those nodes tend to be well known, and
users tend to specify them as potential peers via command line
arguments.

Previously, connections to potential peers specified as command line
arguments were always re-initiated when dropped. This can cause an
involuntary denial-of-service of those well-known bootstrap nodes.

Now, a well-connected node does not initiate connections with bootstrap
nodes.
@Sword-Smith
Copy link
Member

You probably already found the problematic part of the code that causes the old node to hang up when receiving an unknown message type. It's here in run in peer_loop.rs:

                peer_message = peer.try_next() => {
                    let peer_address = self.peer_address;
                    let peer_message = match peer_message {
                        Ok(message) => message,
                        Err(err) => {
                            let msg = format!("Error when receiving from peer: {peer_address}");
                            error!("{msg}. Error: {err}");
                            bail!("{msg}. Closing connection.");
                        }

Currently this error causes the node to hang up. That behavior could be changed to e.g. log a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Only connect to bootstrap nodes from nodes that are insufficiently well connected
2 participants