-
Notifications
You must be signed in to change notification settings - Fork 37.7k
net processing: Move cleanSubVer, fPreferredDownload and nLocalHostNonce to Peer #24970
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
Conversation
Concept ACK |
Concept ACK. |
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. |
Concept ACK |
529415a
to
f9763a1
Compare
Fixed a bug ( I'm going to mark this as a draft since it conflicts with and overlaps with #24543, which has been open for longer. |
f9763a1
to
a099b6b
Compare
Rebased on master now that #24543 is merged. Leaving this as draft for now. I think there may be a better way of handling the version nonces. |
a099b6b
to
53d581f
Compare
Rebased on master and tidied up the nonce handling code. This is now ready for review. |
53d581f
to
db4eeb2
Compare
db4eeb2
to
7ef17fe
Compare
Most of the stats in CNodeStateStats are now taken from the Peer object. Rename the struct to PeerStats. -BEGIN VERIFY SCRIPT- ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); } ren CNodeStateStats PeerStats ren GetNodeStateStats GetPeerStats ren nodeStateStats m_peer_stats ren statestats peer_stats ren fNodeStateStatsAvailable m_peer_stats_available ren fStateStats peer_stats_available -END VERIFY SCRIPT-
Also rename to m_clean_subversion. Since the subversion is now contained in the Peer object, it may not be available in `getpeerinfo` while the peer connection is being torn down. Update the rpc help text to mark the field optional and update the tests to tolerate the field being absent.
Also rename to m_preferred_download
7ef17fe
to
f6bf0d1
Compare
Rebased |
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 f6bf0d1
Nice idea to use a std::map for the sent nonce values and only store them as long as necessary (that is, until the connection is fully established). Left two refactoring nits where one-liners could be used instead, feel free to ignore.
Handle version nonces entirely within net_processing.
Thanks for the review @theStack. I've taken your suggestions. |
f6bf0d1
to
7df3d82
Compare
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.
re-ACK 7df3d82
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 4680a64 🚡
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
concept ACK 4680a64075758f3a08a69dc2bf9243631628900d 🚡
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhd+gv+IJsGtuUaa3dRjoJRyLWYPP5KF8uARYx7CkD9oxwEaVycVUCrTvQevQFE
pT6AV7iljFwqfboaliFxveFaoJlZY314jNUtjlpADZS20FQrKvQN74ZEt8/WYWOy
aZ2KOaTd7+kxJOIAcIIPFuFPCZM/PYjuuEwO1POYtvUGCIQySCV15uoHALhklxmE
x8BcZ6PBycjLyCtZ9J6se6yB+PNoIoWZlELVEe5sX8cpWrloQVSfx89k9tRf7oMF
LrentpcIo3Iu/k2LTUw8yjeQGuq9c5OrSw0GxLo2J1vrB5LyKVSpca2VP29GOdnv
QgBBNIT2UQLCsWuHm/wQVdSqkDCxPAfXzLRFmXSbFCLQWuKpG4MxXSUXpKbzGD6i
W5E9Kbm24KR/TnkayAVOIIcJTMBuTvw2f3Mu0durb4dBaOo9ZMEAPOI4vvyE/Ohq
x1Zx+0Ecn5+CFuVQfFeXrBKTsREFn9YHomksVCdoBkaPPdzlEVOyQOWk2tHi1zhd
RSZPVvfl
=uVaU
-----END PGP SIGNATURE-----
@@ -210,6 +210,9 @@ struct Peer { | |||
* This cleaned string can safely be logged or displayed. */ | |||
std::string m_clean_subversion GUARDED_BY(m_subver_mutex){}; | |||
|
|||
/** Whether we consider this a preferred download peer. */ | |||
bool m_preferred_download{false}; |
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.
fPreferredDownload
used to be protected by cs_main
. Can you explain why the lock is not needed anymore, considering that the socket thread and the p2p thread will both read this value?
@@ -656,7 +657,7 @@ class PeerManagerImpl final : public PeerManager | |||
int m_outbound_peers_with_protect_from_disconnect GUARDED_BY(cs_main) = 0; | |||
|
|||
/** Number of preferable block download peers. */ | |||
int m_num_preferred_download_peers GUARDED_BY(cs_main){0}; | |||
std::atomic<int> m_num_preferred_download_peers{0}; |
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.
can you explain why atomic is sufficient, given that the value is assumed to be changed atomically with fPreferredDownload
, and is used in calculations with that assumption:
m_num_preferred_download_peers - state.fPreferredDownload >= 1
Closing this since it needs a bit of work and I don't have time to maintain it. In terms of priority, I think there's more immediate benefit in moving the services fields from CNode to Peer (the last 6 commits in master...jnewbery:2020-06-cs-main-split), since that allows |
Next step in #19398. Moves additional members from CNode and CNodeState into Peer.
Also renames CNodeStateStats to PeerStats, since most of the stats are now taken from the Peer object.