Skip to content

Conversation

jnewbery
Copy link
Contributor

@jnewbery jnewbery commented Oct 23, 2020

Addrman is currently a member variable of connman. Make it a top-level component with lifetime owned by node.context, and add a reference to addrman in peerman. This allows us to eliminate some functions in connman that are simply forwarding requests to addrman, and simplifies the connman-peerman interface.

By constructing the addrman in init, we can also add parameters to the ctor, which allows us to test it better. See #20233, where we enable consistency checking for addrman in our functional tests.

@maflcko
Copy link
Member

maflcko commented Oct 23, 2020

does it conceptually make sense to have an addrman without connman or connman without addrman? I'd say no.

This allows us to eliminate some functions in connman that are simply forwarding

An alternative to achieve that would be to let PeerMan steal a reference to addrman from connman (and assign it to m_addrman)

@Saibato
Copy link
Contributor

Saibato commented Oct 23, 2020

This allows us to eliminate some functions in connman that are simply forwarding

In general to have things double or more if ( ,,,) or detrimental decision processes in the same code is a good design in industry where u can kill ppl easy, if there is no double check and just one bit ( that could be just by chance or external forces have flipped ) decides over mayhem.

In financials we used to do that the same and wrote "bad ugly code". bcs u get no bonus at the years end, if the code "looks" good but your customers got screwed. Unless that was ur biz.

@jnewbery
Copy link
Contributor Author

does it conceptually make sense to have an addrman without connman or connman without addrman? I'd say no.

Why not? If -connect is set, then we don't use addrman for choosing outbound connections (see m_use_addrman_outgoing inside connman). In general, I think being able to run with different components disabled enforces strict separation between components and means there can't be unintentional coupling between them.

@jnewbery jnewbery changed the title [addrman] Make addrman a top-level component addrman: Make addrman a top-level component Oct 23, 2020
@jnewbery
Copy link
Contributor Author

Fixed whitespace linter issue

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 23, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@maflcko
Copy link
Member

maflcko commented Oct 24, 2020

This doesn't compile on gcc4.8, but we'll drop support for that soon anyway, so the failure can be ignored/rebased out when 22.0 is branched off.

@jnewbery
Copy link
Contributor Author

This doesn't compile on gcc4.8

Hopefully fixed

@jnewbery
Copy link
Contributor Author

jnewbery commented Nov 3, 2020

rebased

@amitiuttarwar
Copy link
Contributor

concept ACK

@jnewbery
Copy link
Contributor Author

rebased

@jnewbery jnewbery force-pushed the 2020-10-addrman branch 3 times, most recently from a765e9b to 8715f8d Compare March 20, 2021 10:20
node.context owns the CAddrMan. CConnman holds a reference to
the CAddrMan.
It just forwards calls to CAddrMan::SetServices.
It just forwards calls to CAddrMan::Good.
It just forwards calls to CAddrMan::Add.
@jnewbery
Copy link
Contributor Author

Thanks for the review @MarcoFalke. I've addressed all of your comments.

@jnewbery
Copy link
Contributor Author

@MarcoFalke - I've taken your suggested diff.

@maflcko
Copy link
Member

maflcko commented Mar 22, 2021

re-ACK 06653e4 🕸

Only changes:

  • Add missing m_node.addrman.reset() in tests
  • Remove unused symbols random_service and random_address in tests
  • Add commit 06653e4
Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

re-ACK 06653e4aaccc84dc7773d3888f687cf44e20abcd 🕸

Only changes:
* Add missing m_node.addrman.reset() in tests
* Remove unused symbols random_service and random_address in tests
* Add commit 06653e4aac
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUh2TQwAuta5eICUDWp5ZOK6mqTbXME6W4oZ2tq4JrradpQgatb0gd7Cvl9voHBS
95imHMkW8gS8qyTS5lCJfmaGZs6GsANQ4WY/SSMDAYPZHR7UUnicrlP5hBE1zUP0
olJXiIu/cNeTibA2gImd1bwxW11h3UII6R8fZ91lLHBTlsakqgX84n1fsRmOHdn7
UG4S6VDK9qceJ/dNTbww56vEn7hnrE9t0FUmFNqb6Yb5LgkG11Bw9XA71urWcFjc
2nvl4CBmZI73SzCyPtcyQ8iYuL6INtg6Rt6BtV6ff8Xm9cYB28cvkP6PFwjp4SHw
Zns+ZiBshcMWgODAvaetrCQNVHo597lW94zfCrSRrhsIVWw9TK6sTJRpkJRLMNxv
6ASeEetu7cME/nFHzabA+PV6nhQIcHoaczCZfdkiY+n1u83KJGvyEl3c12LW/rLT
yjNU8VV/34GM7Fr+HmjK1TJx3aBdcurK+4sNorAr+7JiAovtqTTjEavKYnoeftmm
N1OnbouT
=MOU8
-----END PGP SIGNATURE-----

Timestamp of file with hash 04be068a42318cb4f710b8b8d5521a5bda7090c95bd0fa710e8d6dbc7a70894e -

@maflcko
Copy link
Member

maflcko commented Mar 22, 2021

Could squash the last two commits and mention that --color-moved=dimmed-zebra can be used on them for review?

PeerManager can just call directly into CAddrMan::Connected() now.
@jnewbery
Copy link
Contributor Author

Could squash the last two commits

Done

and mention that --color-moved=dimmed-zebra can be used on them for review?

I tried this and it wasn't very useful - there are only a couple of lines that are moved without changing.

@maflcko
Copy link
Member

maflcko commented Mar 22, 2021

re-ACK 3fc06d3 only change is squash 🏀

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

re-ACK 3fc06d3d7b43dc1143fe0850db23c4e7ffbfe682 only change is squash 🏀
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhYRgv+NLihAeug6hwKodKc6lvG+BPtQdQqV3afHzM2iCE9UzX8UPEWDomfRpNr
/TCwhhMSaT1yKoWh3S9ePwDiVqEx0g9UPfJIfB0bZ20N94tDZY/L/9NXk4jxNlV7
0uqA5jtS93p3QggaVRhGOuOYUBXlgFC+kROYSLgAK9wuQmDI1X9NGlgx1h1tC3yt
qrGvDAuL+x1ALFYH6fOkAZHEwntte+lHPwymA9wktdPCntsmQaM7WimftLMK+z/H
47EYxadADEKJ84aLzeLzU2NJjb+Ow5OwEvsH6DdwcAazCrN5TnSWvpEso+EXP+qY
/CN7Iyy/beRbZsA0inj81zKs2P9k5sKvJuKvzdZLY+HjHcOBZnvB4TqgrSrlQ/sf
9smWO+ndxPc1vjakxxkB7ZFTVL+ju/sc9S14eD6zx9WAldtTeafz6/3YePo7IQlB
gq6AIW8HVsTDV0BHgjG3P2H+TclKtdT5pykhN781QhMuHVvfvkKs7p+dfCv7Lwxi
ugjJlKIA
=o4vy
-----END PGP SIGNATURE-----

Timestamp of file with hash a02bd2eb33e158baac0fe590960dabd93a73914fa44637c90c6b2566e605a7f5 -

@jnewbery
Copy link
Contributor Author

@vasild @sipa: Do you mind reACKing? There have only been minor changes since your last reviews.

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Mar 23, 2021
5555446 fuzz: Use ConsumeWeakEnum in addrman for service flags (MarcoFalke)

Pull request description:

  This has minimally better performance. Reported by me in bitcoin/bitcoin#20228 (comment)

ACKs for top commit:
  practicalswift:
    Tested ACK 5555446
  vasild:
    ACK 5555446

Tree-SHA512: 4e5f51fe4f2bd7b2f37d0690e41203341ba45c0c9bc9247449cd26cfb5f77dc2ec61df3e4963276f68694e4b3ca3d0a76367a51c4d775501edeb3224d305a261
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 23, 2021
… flags

5555446 fuzz: Use ConsumeWeakEnum in addrman for service flags (MarcoFalke)

Pull request description:

  This has minimally better performance. Reported by me in bitcoin#20228 (comment)

ACKs for top commit:
  practicalswift:
    Tested ACK 5555446
  vasild:
    ACK 5555446

Tree-SHA512: 4e5f51fe4f2bd7b2f37d0690e41203341ba45c0c9bc9247449cd26cfb5f77dc2ec61df3e4963276f68694e4b3ca3d0a76367a51c4d775501edeb3224d305a261
Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 3fc06d3

@jnewbery
Copy link
Contributor Author

@sipa do you mind rereviewing this? It has two ACKs on the current branch.

@maflcko maflcko merged commit 1999baa into bitcoin:master Mar 30, 2021
@jnewbery jnewbery deleted the 2020-10-addrman branch March 30, 2021 10:38
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 30, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants