Skip to content

Conversation

@gmaxwell
Copy link
Contributor

If a node is offline failed outbound connection attempts will crank up
the addrman counter and effectively blow away our state.

This change reduces the problem by only counting attempts made while
the node believes it has outbound connections to at least two
netgroups.

Connect and addnode connections are also not counted, as there is no
reason to unequally penalize them for their more frequent
connections -- though there should be no real effect from this
unless their addnode configureation is later removed.

Wasteful repeated connection attempts while only a few connections are
up are avoided via nLastTry.

This is still somewhat incomplete protection because our outbound
peers could be down but not timed out or might all be on 'local'
networks (although the requirement for multiple netgroups helps).

( reopen of #6030 )

@pstratem
Copy link
Contributor

This should probably be checking for connections to at least two netgroups outside of RFC1918 IP space, but this is certainly an improvement.

@gmaxwell
Copy link
Contributor Author

@pstratem checking connections is better than no check at all. This PR is from April 2015, so I'm not inclined to expand the scope any further right now. If this is accepted I'll happily open a follow on PR to make it stronger.

@arowser
Copy link
Contributor

arowser commented May 25, 2016

Can one of the admins verify this patch?

@sipa
Copy link
Member

sipa commented May 25, 2016

Needs rebase.

@sipa
Copy link
Member

sipa commented May 26, 2016

Did you accidentally include #7992?

@sipa
Copy link
Member

sipa commented May 26, 2016

utACK 66cefd47194a8aa7478dbea9a1b96640febeeda7

gmaxwell added 2 commits May 26, 2016 12:56
If a node is offline failed outbound connection attempts will crank up
 the addrman counter and effectively blow away our state.

This change reduces the problem by only counting attempts made while
 the node believes it has outbound connections to at least two
 netgroups.

Connect and addnode connections are also not counted, as there is no
 reason to unequally penalize them for their more frequent
 connections -- though there should be no real effect from this
 unless their addnode configureation is later removed.

Wasteful repeated connection attempts while only a few connections are
 up are avoided via nLastTry.

This is still somewhat incomplete protection because our outbound
 peers could be down but not timed out or might all be on 'local'
 networks (although the requirement for multiple netgroups helps).
This slows the increase of the nAttempts in addrman while partitioned,
 even if the node hasn't yet noticed the partitioning.
@sipa
Copy link
Member

sipa commented May 26, 2016

Running a public node with #7960 #8007 #8065 #8080 #8082 #8084 #8086 for testing.

@sipa
Copy link
Member

sipa commented Jun 7, 2016

This should be easy to test manually: add a debug log entry above the info.nAttempts increment in CAddrMan::Attempt_(), and see how often it triggers with network connected and disconnected.

@laanwj
Copy link
Member

laanwj commented Jun 8, 2016

utACK 6182d10

@laanwj laanwj merged commit 6182d10 into bitcoin:master Jun 8, 2016
laanwj added a commit that referenced this pull request Jun 8, 2016
6182d10 Do not increment nAttempts by more than one for every Good connection. (Gregory Maxwell)
c769c4a Avoid counting failed connect attempts when probably offline. (Gregory Maxwell)
sickpig referenced this pull request in sickpig/BitcoinUnlimited Apr 14, 2017
6182d10 Do not increment nAttempts by more than one for every Good connection. (Gregory Maxwell)
c769c4a Avoid counting failed connect attempts when probably offline. (Gregory Maxwell)
sickpig referenced this pull request in sickpig/BitcoinUnlimited Apr 14, 2017
Since we merged core PR #8065 a new bool parameter has been added
to such function. if false we avoid the book keeping of connections
failed attempt. This will happen in the followin cases:

- node is offline
- node connect to less than 2 netgroups via outound conns
- connect(s) and addnode(s)
sickpig referenced this pull request in sickpig/BitcoinUnlimited Apr 14, 2017
6182d10 Do not increment nAttempts by more than one for every Good connection. (Gregory Maxwell)
c769c4a Avoid counting failed connect attempts when probably offline. (Gregory Maxwell)
sickpig referenced this pull request in sickpig/BitcoinUnlimited Apr 14, 2017
Since we merged core PR #8065 a new bool parameter has been added
to such function. if false we avoid the book keeping of connections
failed attempt. This will happen in the following cases:

- node is offline
- node connect to less than 2 netgroups via outbound conns
- connect(s) and addnode(s)
codablock pushed a commit to codablock/dash that referenced this pull request Dec 22, 2017
6182d10 Do not increment nAttempts by more than one for every Good connection. (Gregory Maxwell)
c769c4a Avoid counting failed connect attempts when probably offline. (Gregory Maxwell)
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
6182d10 Do not increment nAttempts by more than one for every Good connection. (Gregory Maxwell)
c769c4a Avoid counting failed connect attempts when probably offline. (Gregory Maxwell)
furszy added a commit to PIVX-Project/PIVX that referenced this pull request Mar 27, 2020
40e4116 Do not increment nAttempts by more than one for every Good connection. (Gregory Maxwell)
b988ce6 Avoid counting failed connect attempts when probably offline. (Gregory Maxwell)

Pull request description:

  Backport of bitcoin#8065

  > If a node is offline failed outbound connection attempts will crank up
  > the addrman counter and effectively blow away our state.
  >
  > This change reduces the problem by only counting attempts made while
  > the node believes it has outbound connections to at least two
  > netgroups.
  >
  > Connect and addnode connections are also not counted, as there is no
  > reason to unequally penalize them for their more frequent
  > connections -- though there should be no real effect from this
  > unless their addnode configureation is later removed.
  >
  > Wasteful repeated connection attempts while only a few connections are
  > up are avoided via nLastTry.
  >
  > This is still somewhat incomplete protection because our outbound
  > peers could be down but not timed out or might all be on 'local'
  > networks (although the requirement for multiple netgroups helps).

  Note: A future PR will focus on refactoring the layer 2 (masternode) methods to stop using `ConnectNode()` directly

ACKs for top commit:
  random-zebra:
    ACK 40e4116
  furszy:
    utACK 40e4116

Tree-SHA512: 96adadea1d214a2afcf5e43c13a4409ca3de1d81ae51225bda74eabda6a3435a7678c3826e3c3930e543b084de1f28a4a5a102ccd1e3ad3c01da4937f312941b
akshaynexus pushed a commit to ZENZO-Ecosystem/ZENZO-Core that referenced this pull request Mar 30, 2020
40e4116 Do not increment nAttempts by more than one for every Good connection. (Gregory Maxwell)
b988ce6 Avoid counting failed connect attempts when probably offline. (Gregory Maxwell)

Pull request description:

  Backport of bitcoin#8065

  > If a node is offline failed outbound connection attempts will crank up
  > the addrman counter and effectively blow away our state.
  >
  > This change reduces the problem by only counting attempts made while
  > the node believes it has outbound connections to at least two
  > netgroups.
  >
  > Connect and addnode connections are also not counted, as there is no
  > reason to unequally penalize them for their more frequent
  > connections -- though there should be no real effect from this
  > unless their addnode configureation is later removed.
  >
  > Wasteful repeated connection attempts while only a few connections are
  > up are avoided via nLastTry.
  >
  > This is still somewhat incomplete protection because our outbound
  > peers could be down but not timed out or might all be on 'local'
  > networks (although the requirement for multiple netgroups helps).

  Note: A future PR will focus on refactoring the layer 2 (masternode) methods to stop using `ConnectNode()` directly

ACKs for top commit:
  random-zebra:
    ACK 40e4116
  furszy:
    utACK 40e4116

Tree-SHA512: 96adadea1d214a2afcf5e43c13a4409ca3de1d81ae51225bda74eabda6a3435a7678c3826e3c3930e543b084de1f28a4a5a102ccd1e3ad3c01da4937f312941b
wqking pushed a commit to wqking-temp/Vitae that referenced this pull request Aug 24, 2020
40e41169503533f08f4d1861c3b76a3a0c6226eb Do not increment nAttempts by more than one for every Good connection. (Gregory Maxwell)
b988ce6d9e99622fcc366a091bd64300fa251a5f Avoid counting failed connect attempts when probably offline. (Gregory Maxwell)

Pull request description:

  Backport of bitcoin/bitcoin#8065

  > If a node is offline failed outbound connection attempts will crank up
  > the addrman counter and effectively blow away our state.
  >
  > This change reduces the problem by only counting attempts made while
  > the node believes it has outbound connections to at least two
  > netgroups.
  >
  > Connect and addnode connections are also not counted, as there is no
  > reason to unequally penalize them for their more frequent
  > connections -- though there should be no real effect from this
  > unless their addnode configureation is later removed.
  >
  > Wasteful repeated connection attempts while only a few connections are
  > up are avoided via nLastTry.
  >
  > This is still somewhat incomplete protection because our outbound
  > peers could be down but not timed out or might all be on 'local'
  > networks (although the requirement for multiple netgroups helps).

  Note: A future PR will focus on refactoring the layer 2 (masternode) methods to stop using `ConnectNode()` directly

ACKs for top commit:
  random-zebra:
    ACK 40e41169503533f08f4d1861c3b76a3a0c6226eb
  furszy:
    utACK 40e4116

Tree-SHA512: 96adadea1d214a2afcf5e43c13a4409ca3de1d81ae51225bda74eabda6a3435a7678c3826e3c3930e543b084de1f28a4a5a102ccd1e3ad3c01da4937f312941b

# Conflicts:
#	src/activemasternode.cpp
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants