-
Notifications
You must be signed in to change notification settings - Fork 38.6k
[refactor] Move some net_processing globals into PeerManagerImpl #20942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[refactor] Move some net_processing globals into PeerManagerImpl #20942
Conversation
|
Next set of patches from #20758 -- should be straightforward to review hopefully. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
jnewbery
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK a3ef94957be28d1b94ee0a34e015b39e60895e0d
This seems fine, but since this is mostly a code cleanup PR, it'd be nice to tidy this up a bit further while you're touching all these lines:
- you rename some of the variables you're moving to the standard
m_convention, but leave others unchanged. Perhaps move all of them without changing the naming, and then finish this branch with a single scripted diff which changes everything to use standard naming? - The
PeerManagerImpldeclaration mixes up the data members and member functions. I think it's much easier to read if the data members are grouped first and then the member functions. Perhaps add a final move-only commit that groups data members and member functions? - Some of the member function comments have been left attached to the definitions rather than moved to the declaration.
nSyncStarted, mapBlockSource, g_wtxid_relay_peers, g_outbound_peers_with_protect_from_disconnect were all only used by PeerManagerImpl methods already.
Allows making recentRejects and g_recent_confirmed_transactions members rather than globals.
No need to pass mempool to PeerManagerImpl methods.
…to PeerManagerImpl Allows converting mapBlocksInFlight and g_last_tip_update from globals to member variables.
No need to pass mempool to MarkBlockAsInFlight, or consensusParams to TipMayBeStale or FindNextBlocksToDownload.
…erImpl Allows making mapRelay and vRelayExpiration members rather than globals.
No need to pass mempool or connman to PeerManagerImpl methods.
…anagerImpl Allows making lNodesAnnouncingHeaderAndIDs and nPeersWithValidatedDownloads member vars instead of globals.
No need to pass connman to PeerManagerImpl methods.
a3ef949 to
6452190
Compare
jnewbery
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 6452190
One minor suggestion inline
|
|
||
| /** Stack of nodes which we have set to announce using compact blocks */ | ||
| std::list<NodeId> lNodesAnnouncingHeaderAndIDs GUARDED_BY(cs_main); | ||
| /* Returns a bool indicating whether we requested this block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and the comment for MarkBlockAsInFlight()) won't get picked up by doxygen without the /** comment marker (https://www.doxygen.nl/manual/docblocks.html)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a todo commit in #20758 to track this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/net_processing.cpp
Outdated
| */ | ||
| bool MarkBlockAsInFlight(CTxMemPool& mempool, NodeId nodeid, const uint256& hash, const CBlockIndex* pindex = nullptr, std::list<QueuedBlock>::iterator** pit = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||
|
|
||
| bool TipMayBeStale(const Consensus::Params &consensusParams) EXCLUSIVE_LOCKS_REQUIRED(cs_main); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Check if our chain is stalling by measuring if a delta of pow targets has been reached since last time of tip update" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some text to 4f9931d
|
It would be really nice to get these right before merge:
Otherwise 6452190 looks good. |
|
I think this is probably ready for merge. It's a simple refactor and has three ACKs. @ajtowns - All three reviewers have asked for sorting members, doxygen comments and renaming data members. I have a small branch that does those things here: https://github.com/jnewbery/bitcoin/tree/pr20942.1. Feel free to take those commits in a follow-up PR. |
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK 6452190 I have not reviewed this, but I left a comment 🐡
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Concept ACK 6452190841 I have not reviewed this, but I left a comment 🐡
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiXRwv+Ot8x+JJaOzZ1kM34x9ikAMnoPkV6rbc1xn4csg3qX+vlwOoAsQU9S1VX
UmBGAg9aiY5q5IiNlmBL+17Oay0iQOUYnqkhnPqtoIFHLbTW5QnoC31bi7csjuGj
XASAOnwk8IcXHi19lUdq0LuHld3vdT4bYD+vViO8ANLU8NT7xKgn4/hfXiyL01Qw
rqGGda/3oIzJXZC9/BIBOCfS5xIPfbilQtT3XllyxJBhI8+kblGhbqPQ+GfYZ+to
PoG4mpFzQVrUEL7aYnUapwQ3x0+Rh4+y7UMcz2KC76PjYfDOk1pH8Nnswr8fUBNs
KV7ofcN6cdg6QAdse8GpOQozZdMc706bBLtp1XyZT3MyaRibm/Kw8KYCoQcrqeF2
ZPlzqI55FKybz9YFfAZ0g9xE2G2E/m0k/S2ulbepKboelqvRAQ0j0PMUIV4VQPOW
5QZ0C1ka/jobPQt7XYYxBMhlUpofXzHPe+A0iN6cURPJ9b2SQ+br7BFKAt3aq1HZ
0UwAzlpn
=PF32
-----END PGP SIGNATURE-----
Timestamp of file with hash 39fd4a1774698d6853a62e53b467bd6ee8d7c78c218cf8d662c407770c5d971b -
|
|
||
|
|
||
| bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid, const CTxMemPool& mempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main) | ||
| bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_main) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to not shadow the lock annotation from the "header". Otherwise it won't result in a compile failure if a new lock requirement is added to the "header", but not here, and the new lock isn't taken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for all other commits.
|
fwiw, I had reviewed until a490f0a, so post-merge-ACK the first few commits =P |
Summary: nSyncStarted, mapBlockSource, g_outbound_peers_with_protect_from_disconnect were all only used by PeerManagerImpl methods already. Changes related to `g_wtxid_relay_peers` are not present because these are for segwit. This is a backport of [[bitcoin/bitcoin#20942 | core#20942]] [1/9] bitcoin/bitcoin@9781c08 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, sdulfari Reviewed By: #bitcoin_abc, sdulfari Subscribers: sdulfari Differential Revision: https://reviews.bitcoinabc.org/D11433
Summary: Allows making recentRejects and g_recent_confirmed_transactions members rather than globals, and remove need to pass mempool as argument. This is a backport of [[bitcoin/bitcoin#20942 | core#20942]] [2&3/9] bitcoin/bitcoin@eeac506 bitcoin/bitcoin@052d9bc Depends on D11433 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D11434
…to PeerManagerImpl Summary: Allows converting mapBlocksInFlight and g_last_tip_update from globals to member variables, and remove need to pass mempool or consensus params to methods. This is a backport of [[bitcoin/bitcoin#20942 | core#20942]] [4&5/9] bitcoin/bitcoin@a490f0a bitcoin/bitcoin@d440848 Note: `consensusParams` is not needed in our version of `FindNextBlocksToDownload`. Core uses it to test `IsWitnessEneabled`. Depends on D11434 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D11435
…erImpl Summary: Allows making mapRelay and vRelayExpiration members rather than globals. Remove need to pass mempool of conman to methods? This is a backport of [[bitcoin/bitcoin#20942 | core#20942]] [6&7/9] bitcoin/bitcoin@34207b9 bitcoin/bitcoin@7b7117e Depends on D11435 Notes : - also convert a uint256 to TxId in `mapRelay` type - rename `g_relay_expiration` to vRelayExpiration now that it is no longer a global (undoes a change in D10914). The `m_` prefix is not very commonly used in this class, so I feel like it is best to stick with the source material. Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D11436
…anagerImpl Summary: Allows making lNodesAnnouncingHeaderAndIDs and nPeersWithValidatedDownloads member vars instead of globals. Removes the need to pass conman as a parameter to the method. This concludes a backport of [[bitcoin/bitcoin#20942 | core#20942]] [8&9/9] bitcoin/bitcoin@39c2a69 bitcoin/bitcoin@6452190 Depends on D11436 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D11437
Turns some globals into member variables, and simplifies the parameter list for some of net_processing's internal functions. Mostly just serves as a code cleanup at this point.