Skip to content

Conversation

@ajtowns
Copy link
Contributor

@ajtowns ajtowns commented Jan 15, 2021

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.

@ajtowns
Copy link
Contributor Author

ajtowns commented Jan 15, 2021

Next set of patches from #20758 -- should be straightforward to review hopefully.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 15, 2021

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

@jnewbery jnewbery left a 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 PeerManagerImpl declaration 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.
@ajtowns ajtowns force-pushed the 202101-netproc-anti-globalisation-pt1 branch from a3ef949 to 6452190 Compare January 29, 2021 16:52
@ajtowns
Copy link
Contributor Author

ajtowns commented Jan 29, 2021

Rebased, addressed some of @jnewbery's comments. There's still more stuff coming from #20758 so will leave reorganising PeerManagerImpl declaration until later.

Copy link
Contributor

@jnewbery jnewbery left a 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.
Copy link
Contributor

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)

Copy link
Contributor Author

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

Copy link

@ariard ariard left a 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, changes are pretty straightforward.

See this stylistic comment, overall we can order better PeerManagerImpl members instead of intertwining methods and vars ? Up to you.

*/
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);
Copy link

Choose a reason for hiding this comment

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

a490f0a

"Check if our chain is stalling by measuring if a delta of pow targets has been reached since last time of tip update" ?

Copy link
Contributor Author

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

@vasild
Copy link
Contributor

vasild commented Feb 9, 2021

It would be really nice to get these right before merge:

  • Order of member variables and methods, private and public. I think the Google C++ Style Guide makes perfect sense.
  • Member variables naming.
  • Proper doxygen comments.

Otherwise 6452190 looks good.

@jnewbery
Copy link
Contributor

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.

Copy link
Member

@maflcko maflcko 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 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)
Copy link
Member

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.

Copy link
Member

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.

@maflcko maflcko merged commit 45ea103 into bitcoin:master Feb 15, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 15, 2021
@amitiuttarwar
Copy link
Contributor

fwiw, I had reviewed until a490f0a, so post-merge-ACK the first few commits =P

@Sjors
Copy link
Member

Sjors commented Apr 1, 2021

Thanks, d440848 allows me to simplify #20295 a bit.

Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 10, 2022
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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 10, 2022
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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 10, 2022
…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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 10, 2022
…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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 10, 2022
…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
@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.

8 participants