Skip to content

Conversation

theStack
Copy link
Contributor

@theStack theStack commented Jun 5, 2020

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

@maflcko
Copy link
Member

maflcko commented Jun 5, 2020

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

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 5, 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.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept ACK, no rush though.

@theStack theStack force-pushed the 20200602-refactor-use-cconnman-references-within-net_processing branch from 022ad4e to bb725d8 Compare June 10, 2020 13:40
@theStack
Copy link
Contributor Author

Rebased.

@jnewbery
Copy link
Contributor

concept ACK. Needs rebase

@theStack theStack force-pushed the 20200602-refactor-use-cconnman-references-within-net_processing branch 2 times, most recently from 033a6e3 to 11e8464 Compare July 13, 2020 16:33
@theStack
Copy link
Contributor Author

Rebased.

@jnewbery
Copy link
Contributor

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.

@theStack
Copy link
Contributor Author

@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.

@jnewbery
Copy link
Contributor

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

@theStack theStack force-pushed the 20200602-refactor-use-cconnman-references-within-net_processing branch from 11e8464 to 0c8461a Compare July 14, 2020 14:08
@theStack theStack changed the title refactor: replace CConnman/BanMan pointers by references in net_processing.cpp refactor: replace CConnman pointers by references in net_processing.cpp Jul 14, 2020
@theStack
Copy link
Contributor Author

theStack commented Jul 14, 2020

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

@theuni
Copy link
Member

theuni commented Jul 14, 2020

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.

@maflcko
Copy link
Member

maflcko commented Jul 15, 2020

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.

@jnewbery
Copy link
Contributor

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 0c8461a

@maflcko
Copy link
Member

maflcko commented Jul 16, 2020

ACK 0c8461a 🕧

Show signature and timestamp

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 -

@maflcko maflcko merged commit affed84 into bitcoin:master Jul 16, 2020
@JeremyRubin
Copy link
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.

@fanquake
Copy link
Member

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

@laanwj
Copy link
Member

laanwj commented Jul 17, 2020

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

laanwj added a commit to laanwj/bitcoin that referenced this pull request Jul 17, 2020
…essing.cpp"

This reverts commit 0c8461a.

In discussion in bitcoin#19174 there was a concept NACK by the original
author of the code. It was merged after this without any further
discussion.
@theuni
Copy link
Member

theuni commented Jul 17, 2020

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

ACK 0c8461a.

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 18, 2020
…s in net_processing.cpp

0c8461a refactor: replace CConnman pointers by references in net_processing.cpp (Sebastian Falbesoner)

Pull request description:

  This is a follow-up to the recently merged PR bitcoin#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

ACKs for top commit:
  jnewbery:
    utACK 0c8461a
  MarcoFalke:
    ACK 0c8461a 🕧

Tree-SHA512: 79dc05144bcfb5e0bbc62180285aadcc6199f044fa3016c0f54f7b7f45037415260970037bd63b18fafefb8aef448549dae14b780bafb540fa2373f493a17f71
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 21, 2020
Summary:
```
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
```

Backport of core [[bitcoin/bitcoin#19174 | PR19174]].

Depends on D8479.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8480
@theStack theStack deleted the 20200602-refactor-use-cconnman-references-within-net_processing branch December 1, 2020 09:58
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 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