refactor: replace CConnman pointers by references in net_processing.cpp #19174

pull theStack wants to merge 1 commits into bitcoin:master from theStack:20200602-refactor-use-cconnman-references-within-net_processing changing 2 files +64 −64
  1. theStack commented at 11:29 AM on June 5, 2020: contributor

    This is a follow-up to the recently merged PR #19053, replacing two more types of one more type of pointer (CConnman) by references to increase the code quality -- pointers should either check for nullptr or be replaced by references, and the latter strategy seems to be more reasonable.

    Again, to keep the review burden managable, the changes are kept simple,

    • only tackling CConnman* and BanMan* pointers
    • only within the net_processing module, i.e. no changes that would need adaption in other modules
    • keeping the names of the variables as they are
  2. fanquake added the label Refactoring on Jun 5, 2020
  3. MarcoFalke commented at 11:36 AM on June 5, 2020: member

    Concept ACK, but this conflicts with some ongoing work, so let's get those in first.

  4. DrahtBot commented at 1:26 PM on June 5, 2020: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #19503 (Add parameter feature to serialization and use it for CAddress by sipa)
    • #19498 (Tidy up ProcessOrphanTx by jnewbery)
    • #19184 (Overhaul transaction request logic by sipa)
    • #18991 (Cache responses to GETADDR to prevent topology leaks by naumenkogs)

    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.

  5. DrahtBot cross-referenced this on Jun 5, 2020 from issue Cache responses to GETADDR to prevent topology leaks by naumenkogs
  6. DrahtBot cross-referenced this on Jun 5, 2020 from issue doc: noban precludes maxuploadtarget disconnects by MarcoFalke
  7. DrahtBot cross-referenced this on Jun 5, 2020 from issue net processing: Make it more obvious that we'll never upgrade a pre-segwit node to high-bandwidth by jnewbery
  8. DrahtBot cross-referenced this on Jun 5, 2020 from issue p2p: Unify Send and Receive protocol versions by hebasto
  9. promag commented at 12:24 AM on June 6, 2020: member

    Concept ACK, no rush though.

  10. DrahtBot cross-referenced this on Jun 6, 2020 from issue Overhaul transaction request logic by sipa
  11. DrahtBot added the label Needs rebase on Jun 6, 2020
  12. theStack force-pushed on Jun 10, 2020
  13. theStack commented at 1:41 PM on June 10, 2020: contributor

    Rebased.

  14. DrahtBot removed the label Needs rebase on Jun 10, 2020
  15. DrahtBot cross-referenced this on Jun 10, 2020 from issue Replace automatic bans with discouragement filter by sipa
  16. DrahtBot cross-referenced this on Jun 10, 2020 from issue p2p: Move all header verification into the network layer, extend logging by troygiorshev
  17. DrahtBot cross-referenced this on Jun 10, 2020 from issue net: Use mockable time for ping/pong, add tests by MarcoFalke
  18. DrahtBot cross-referenced this on Jun 11, 2020 from issue tests: Add fuzzing harness for BanMan by practicalswift
  19. DrahtBot cross-referenced this on Jun 16, 2020 from issue net: Avoid redundant and confusing FAILED log by MarcoFalke
  20. DrahtBot cross-referenced this on Jun 17, 2020 from issue [net] Cleanup logic around connection types by amitiuttarwar
  21. DrahtBot cross-referenced this on Jun 17, 2020 from issue [tests] Allow outbound & block-relay-only connections in functional tests. by amitiuttarwar
  22. DrahtBot cross-referenced this on Jun 17, 2020 from issue refactor: Replace RecursiveMutex with Mutex in CTxMemPool by hebasto
  23. DrahtBot added the label Needs rebase on Jun 19, 2020
  24. jnewbery commented at 2:59 PM on July 13, 2020: member

    concept ACK. Needs rebase

  25. theStack force-pushed on Jul 13, 2020
  26. theStack force-pushed on Jul 13, 2020
  27. DrahtBot removed the label Needs rebase on Jul 13, 2020
  28. theStack commented at 5:15 PM on July 13, 2020: contributor

    Rebased.

  29. DrahtBot cross-referenced this on Jul 13, 2020 from issue Tidy up ProcessOrphanTx by jnewbery
  30. jnewbery commented at 8:58 PM on July 13, 2020: member

    I'm modifying my concept ACK to a partial concept ACK. @theuni has pointed out to me that for maximum flexibility, we should potentially be able to run the software with different components disabled, eg it should be possible to run with connman or banman disabled. It's not possible to run net_processing without a connman, but it should be possible to run without a banman, and that possibility was part of banman's Original Vision. Therefore, I think this PR should be modified to:

    • change connman pointers to references within net_processing
    • wrap all banman derefernces in net_processing inside if (banman) conditionals
    • add comments inside the PeerValidationLogic definition in net_processing.h explaining that.
  31. DrahtBot cross-referenced this on Jul 14, 2020 from issue Add parameter feature to serialization and use it for CAddress by sipa
  32. theStack commented at 11:53 AM on July 14, 2020: contributor

    @jnewbery: I see your PR #19514 already covers points 2 and 3 of your list. Will remove the BanMan pointer by references replacements and rebase on master as soon as #19514 is merged.

  33. DrahtBot added the label Needs rebase on Jul 14, 2020
  34. jnewbery commented at 1:53 PM on July 14, 2020: member

    #19514 is merged. I'll review this as soon as it's rebased.

  35. refactor: replace CConnman pointers by references in net_processing.cpp 0c8461a88e
  36. theStack force-pushed on Jul 14, 2020
  37. theStack renamed this:
    refactor: replace CConnman/BanMan pointers by references in net_processing.cpp
    refactor: replace CConnman pointers by references in net_processing.cpp
    on Jul 14, 2020
  38. theStack commented at 2:11 PM on July 14, 2020: contributor

    Removed BanMan pointer by reference replacements (only leaving CConnman replacements), rebased on master, adapted PR title and PR description accordingly.

  39. DrahtBot removed the label Needs rebase on Jul 14, 2020
  40. theuni commented at 8:51 PM on July 14, 2020: member

    Concept NACK. CConnman is a pointer here because it's intended to be (eventually) optional, as a way to run bitcoind without p2p (for only local rpc, wallet, etc.)

    Making it a reference is a step backwards, imo.

  41. MarcoFalke commented at 6:59 AM on July 15, 2020: member

    This is only changing stuff inside the call path of PeerLogicValidation::ProcessMessages, a function which is impossible to call when connman is nullptr. I don't see how this makes it harder to run without p2p.

  42. jnewbery commented at 8:30 AM on July 15, 2020: member

    I tend to agree with @MarcoFalke here. I think if we ran bitcoind without p2p, then both ConnMan and PeerLogicValidation would be disabled. PeerLogicValidation can't do anything without a ConnMan. Contrast that with BanMan, which PeerLogicValidation can very easily run without.

    The fact that connman is dereferenced everywhere without being checked first shows that there's an expectation that net_processing always has a ConnMan. The alternative of adding nullptr checks to all of those dereferences seems like it'd make the code much less readable. @theuni - am I missing something important?

    utACK 0c8461a88ed66a1f70559fc96646708949b17e4b

  43. MarcoFalke commented at 6:07 AM on July 16, 2020: member

    ACK 0c8461a88ed66a1f70559fc96646708949b17e4b 🕧

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    ACK 0c8461a88ed66a1f70559fc96646708949b17e4b 🕧
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUht4Qv/SineQytgBJXUxI6I4QLHmS7miAD8FwB1cYzr9D4kXhIXNifLt5d/c1tR
    RnkkKmimrCeiy6IRXKkDSYt4wq9OKGBFdbbs+xiGNRz3CVBtMDwXEynkPKQc00V3
    2n01vRPfMKwsE3h/DK2GezxCily+u2vEMQGm07lmxThie00YtUPkWObmxFFKxTcZ
    De6GhMZmzsVmR105lU4UWik75n6YeWShmY4qnJJrSWyDQyc0FnRCUHC2JIcrLhMG
    Hkurn8+NUo9t4hVNwsdpaBjQu7yEDA4Lpg2scC6ohHmrrrK8OkQoyz3ED5GKkSh3
    ETkVZXWM58NHhLGU4saMwVe0/hcYTiVAMbtBlLcc4EmBeEuwHZQZj2X0YC2kPrhS
    ijguxYEthzTtsbFa7zQ7Q60DbEFV4xtIa6Q9GpuivpFsK1D1Wul32HIM7qcGgCLp
    N70AvShj8+EZRYFbwK8dmVObQshIrGar+X1JkhjR2sp8gRSowb+dveBt/t6J68sm
    P5ahRdA8
    =MB6Y
    -----END PGP SIGNATURE-----
    

    Timestamp of file with hash 5a8ecf4a91cf13cdd18a3b4e4f73b5e1b8bece873c6f28a95508698de9f4917e -

    </details>

  44. MarcoFalke merged this on Jul 16, 2020
  45. MarcoFalke closed this on Jul 16, 2020

  46. JeremyRubin commented at 4:21 PM on July 16, 2020: contributor

    Process wise I don't think that this should have been merged over @theuni's concept nack, especially not without a reasonable amount of time to follow up.

  47. fanquake commented at 6:27 AM on July 17, 2020: member

    I agree. I would be good to have at-least heard @theuni's thoughts here.

  48. laanwj commented at 9:50 AM on July 17, 2020: member

    I'm going to revert this. I don't think there was enough agreement to make this change. See #19542.

  49. laanwj referenced this in commit 1aff21b364 on Jul 17, 2020
  50. laanwj cross-referenced this on Jul 17, 2020 from issue Revert "refactor: replace CConnman pointers by references in net_processing.cpp" by laanwj
  51. theuni commented at 8:32 PM on July 17, 2020: member

    For posterity, concept NACK withdrawn. Agree with @MarcoFalke and @jnewbery above.

    ACK 0c8461a88ed66a1f70559fc96646708949b17e4b.

  52. sidhujag referenced this in commit 647a40216e on Jul 18, 2020
  53. hebasto cross-referenced this on Jul 21, 2020 from issue p2p: Try to preserve outbound block-relay-only connections during restart by hebasto
  54. jnewbery cross-referenced this on Aug 12, 2020 from issue Net processing: move ProcessMessage() to PeerLogicValidation by jnewbery
  55. jasonbcox referenced this in commit 7ce32e64a0 on Nov 21, 2020
  56. theStack deleted the branch on Dec 1, 2020
  57. bitcoin locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:54 UTC