Continues the work of moving net_processing logic into PeerLogicValidation. See #19704 and #19607 (review) for motivation.
This PR also renames PeerLogicValidation to PeerManager as suggested in #10756#pullrequestreview-53892618.
Continues the work of moving net_processing logic into PeerLogicValidation. See #19704 and #19607 (review) for motivation.
This PR also renames PeerLogicValidation to PeerManager as suggested in #10756#pullrequestreview-53892618.
The PR title only addresses one of the many commits (the last one), I assume you either wanted to only include this commit or change the title to be more general to also include all other changes.
The PR title only addresses one of the many commits (the last one), I assume you either wanted to only include this commit or change the title to be more general to also include all other changes.
The object of this PR is to move Misbehaving to PeerLogicValidation. The other commits are necessary to do that because they all eventually call in to Misbehaving: https://doxygen.bitcoincore.org/net__processing_8cpp.html#ad2983e754c4d90bd68adf91b208664f5
The PR title only addresses one of the many commits (the last one), I assume you either wanted to only include this commit or change the title to be more general to also include all other changes.
The object of this PR is to move Misbehaving to PeerLogicValidation. The other commits are necessary to do that because they all eventually call in to Misbehaving: https://doxygen.bitcoincore.org/net__processing_8cpp.html#ad2983e754c4d90bd68adf91b208664f5
Thanks for clarifying, that makes sense. (And it's the first time in my life that a generated caller graph by Doxygen actually is of any help and not confusing ;-)) Concept ACK
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
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.
Concept ACK
( Note to myself: commit eb170099f3ea91555b56fdaaae89a64fe04b93be with this diff #19704 (review) should pass the unit tests again )
( Note to myself: commit eb17009 with this diff #19704 (comment) should pass the unit tests again )
Thanks @MarcoFalke . I've cherrypicked that commit into this branch, which reduced further the number of parameters in some of these moved functions.
Rebased
Concept ACK
Almost ACK. Please use a scripted diff where appropriate:
7: 534b4a2d86 ! 7: fffffffffff [net processing] Rename PeerLogicValidation to PeerManager
@@ Metadata
Author: John Newbery <john@johnnewbery.com>
## Commit message ##
- [net processing] Rename PeerLogicValidation to PeerManager
+ scripted-diff: [net processing] Rename PeerLogicValidation to PeerManager
+
+ -BEGIN VERIFY SCRIPT-
+ sed -i 's/PeerLogicValidation/PeerManager/g' $(git grep -l PeerLogicValidation ./src ./test)
+ -END VERIFY SCRIPT-
PeerLogicValidation was originally net_processing's implementation to
the validation interface. It has since grown to contain much of
ACK b9486cc514 🍳
Exclusively move-only and rename-only changes. The only risk I see would be uninteded changes due to shadowing, but that shouldn't be a problem because all local symbols are aliases to the global ones anyway. (m_mempool == ::mempool, m_params == Params(), ...)
<details><summary>Show signature and timestamp</summary>
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
ACK b9486cc514 🍳
Exclusively move-only and rename-only changes. The only risk I see would be
uninteded changes due to shadowing, but that shouldn't be a problem because all
local symbols are aliases to the global ones anyway. (m_mempool == ::mempool,
m_params == Params(), ...)
* d45f2bb682 --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
* e4f6ec6aa3 --word-diff-regex=. -U0
* 534b4a2d86 I have not reviewed this. Why is this not a scripted diff ???
* 66f20e7738 --word-diff-regex=. -U0
* f9a76b620b --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
* e83b1497a7 --word-diff-regex=. -U0
* 689b2b3926 --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
* f789dd7214 --word-diff-regex=. -U0
* b9486cc514 --word-diff-regex=. -U0 (also reviewed with b9486cc514 --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space)
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUi44wv9EqnP0JBiaYaFXQOP16rPsjbXFLjfNTDcxy44OW6fdjz+y3twK6r5dSvj
QIsy5XuOL9Wb+RONSaBIfuABsKHZPxP3gPP6PrWd/ukD4ypUyvbi97UrCYGgaGkb
A0H6n4OIF2o9QXo+pu/fLFfPucuy/CWML5BrhUAmVwjjB7WLs5wFfGyX7nleL9nd
pM4R/JK9wgttCScaVBhF+hvWJazV86UqtktLU++AR675mH4YjRBx2Ng3BQRrmeD5
bScdeICbZ9uKYKDjZiyegfwmr7ni+zP7vIc1LVNbCEXBYzfMSyeB3+fKwQl0+bRt
ihgTP9FhuMcfGt6NLTAr5/J/Ar4IFlFYWceB7n/DG38Tt0cK1cs+9yiTyhRXttsK
ZL5u1oYqA9OMf6tLm1Ey0MvNgYRJ7iQMj1xM4BWZJlztUdaOseOT4tTaY9yQYuQg
lZJwmTGfUXodw65qfU07ARGigKsCQzL9qchrzHlyc+oQHSAcwrSTMmFKlPxit53W
pmMky4Ak
=kiZz
-----END PGP SIGNATURE-----
Timestamp of file with hash 5be0c45ea49e947755a8bba146134d0a71a0de60deb5f538b4a22c3d9a457df9 -
</details>
Thanks for the review @MarcoFalke ! I've taken your suggestion of making the rename a scripted diff (and added a follow-up commit that fixes the indentation).
re-ACK ab9e416812 🔋
<details><summary>Show signature and timestamp</summary>
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
re-ACK ab9e416812 🔋
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgOmAv/XiLCgaJ+N1uXLqQGle28I8T65NwC7lN8op1+AcF0HdvG4P/nr9XAKJGO
HGutxFBbwYhY0gdFiShEKPI/LdTIPF+HEARqQ3bt4HCM1XxFf01UZOKIRjDpEOIl
Zij/8/JIbYQnrl5ROhLlDc89QQKxOyfcviYkshahiXK3QUEDbLrb8axuWl4OJ7jR
eXvlwHqY54k8DbT8ofjCxaHpADgWjLWxsjW4a3QhYM0MnI+KI8g0UryLBvGs2A23
X6VTgJ0hXQX+QJTLVUjy0jwIalrBVWpMXRcDa+LF6PTsZnFKIH3i9ej2p+91MHJk
2kxiAUFYcbpYIhhAi21m4TUSwZ2OjxXPv1Fa3X122caj2eHmotlrH+ACo6/O0uWe
3QWyAB5caNLs0KAxtCC5F7A2caYKjlVw/BnR8krn8PQXP+H3kjZAjUzDQkT9xOhx
eHAVHR5w7+dDbuZQ39fdC9inTJqXSYzwtvfMPpxpCIPECleG0SxvrtRTw5UWzOnU
OUb2Ix1f
=ffIE
-----END PGP SIGNATURE-----
Timestamp of file with hash 8ca020057d8fe8423b0403eeebc5772bea83a87127a66a83c6409a6a47884972 -
</details>
Concept ACK.
104 | @@ -105,6 +105,7 @@ class PeerManager final : public CValidationInterface, public NetEventsInterface 105 | */ 106 | bool MaybeDiscourageAndDisconnect(CNode& pnode); 107 | 108 | + void ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<CTransactionRef>& removed_txn) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans);
4ca3570c4a6a1332dbfc1f97eda6b717b21df468, nit:
void ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<CTransactionRef>& removed_txn)
EXCLUSIVE_LOCKS_REQUIRED(::cs_main, g_cs_orphans);
Done!
IIUC, the goal of this PR is a better encapsulation. Therefore, functions that do not require an access to private data members should be placed into a dedicated namespace as non-member ones. I mean MaybePunishNodeForBlock(), MaybePunishNodeForTx() and Misbehaving().
In commit 30dbd283cc3c4bcc55cefe5925581dbf9da78c2d "scripted-diff: [net processing] Rename PeerLogicValidation to PeerManager" the commit message is incomplete.
Please see #19607 (review) for motivation. The idea is to move the g_peer_map to be a member of PeerLogicValidation. To do that, we need to move these functions into PeerLogicValidation since they need to access that data.
In commit 30dbd28 "scripted-diff: [net processing] Rename PeerLogicValidation to PeerManager" the commit message is incomplete.
I meant that before the latest push the commit message was
scripted-diff: [net processing] Rename PeerLogicValidation to PeerManager
-BEGIN VERIFY SCRIPT-
sed -i 's/PeerLogicValidation/PeerManager/g' $(git grep -l PeerLogicValidation ./src ./test)
-END VERIFY SCRIPT-
PeerLogicValidation was originally net_processing's implementation to
the validation interface. It has since grown to contain much of
I didn't mean to drop the scripted-diff part. Sorry.
The idea is to move the
g_peer_mapto be a member ofPeerLogicValidation. To do that, we need to move these functions intoPeerLogicValidationsince they need to access that data.
But MaybePunishNodeForBlock(), MaybePunishNodeForTx() and Misbehaving() do not access to g_peer_map, no?
But MaybePunishNodeForBlock(), MaybePunishNodeForTx() and Misbehaving() do not access to g_peer_map, no?
Misbehaving calls GetPeerRef
But MaybePunishNodeForBlock(), MaybePunishNodeForTx() and Misbehaving() do not access to g_peer_map, no?
Misbehaving calls
GetPeerRef
Correct. But it seems that MaybePunishNodeForBlock() and MaybePunishNodeForTx() have neither direct nor indirect access to g_peer_map.
They call Misbehaving, which calls GetPeerRef, which accesses g_peer_map
They call
Misbehaving, which callsGetPeerRef, which accessesg_peer_map
Indeed. Sorry for noise.
I didn't mean to drop the scripted-diff part. Sorry.
Oops. I didn't mean to do that. Restored the scripted-diff and fixed the commit log.
They call Misbehaving, which calls GetPeerRef, which accesses g_peer_map
Indeed. Sorry for noise.
No problem. Thanks for reviewing!
ACK 7ed1612715785bb48053c50167c136f1d46ac352
re-ACK 7ed1612715 only change is in commit message 💮
<details><summary>Show signature and timestamp</summary>
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
re-ACK 7ed1612715 only change is in commit message 💮
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjjSAv/eL83MPVWHHsG87sMVTjfZH87F5ioMxNs/Rj/ZwuFkj3yMLwXFPDlJMsw
cBoTZS/i1PBCZwueOjGJd5E5RFY98FsLsUG6zsxcnxZvbiUCnGvc6gnPqHnFLDzN
yJGDOLlFrT9NRMsuo+sQ9fZ0dGRB3UmXkX9g3PRIFqLAvW9++ZHgHsHFWEDaWjXo
eZ40OcEAZ0/y8OiZLNcyP5m/XUrmirxLQvLBbnBa7knP9ieE8Gz1XIgTPXrbJxno
PzPIwFrB0z6iyKB1v8HW1mO/qK+zGTKkPAjev0KucuFmlApTp+WcH98yBvhazuQQ
GMBk64LQLOhb2RiHTrjKHUXfcr05gc68or4LbB40E/8FoSHWu5H3U6h3rUgOWp5+
xklUznWZix1ajWjIJxDBDALKgxJNkDQrtRTVX0fCjjrgLkYsZo22ciMjE9VNg4z9
1x+aja5E7olxX6mLq61JvXLA+fLUrLYOa5kUs3+vcSjr1FkEGKOB8jYUcsnwx1Ot
jvSFZpV0
=Ghuq
-----END PGP SIGNATURE-----
Timestamp of file with hash 3fb7d2e970f192a638e72cead0f90dc92194e177f7fcf6b6a23b27665d46f3a5 -
</details>
We don't have a project style for ordering class members, but it always
makes sense to have no more than one of each public/protected/private
specifier.
Also move documentation for MaybeDiscourageAndDisconnect to the header.
Keep a references to chainparams, rather than calling the global
Params() function every time it's needed. This is fine, since
globalChainParams does not get updated once it's been set, and it's
available at the point of constructing the PeerLogicValidation object.
-BEGIN VERIFY SCRIPT-
sed -i 's/PeerLogicValidation/PeerManager/g' $(git grep -l PeerLogicValidation ./src ./test)
sed -i 's/peer_logic/peerman/g' $(git grep -l peer_logic ./src ./test)
-END VERIFY SCRIPT-
PeerLogicValidation was originally net_processing's implementation to
the validation interface. It has since grown to contain much of
net_processing's logic. Therefore rename it to reflect its
responsibilities.
Suggested in
https://github.com/bitcoin/bitcoin/pull/10756#pullrequestreview-53892618.
rebased on master.
Also updated NodeContext.peer_logic to NodeContext.peerman to be consistent with the new class name.
re-ACK bb6a32ce99 only change is rebase due to conflict in struct NodeContext and variable rename 🤸
<details><summary>Show signature and timestamp</summary>
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
re-ACK bb6a32ce99 only change is rebase due to conflict in struct NodeContext and variable rename 🤸
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUj5EwwAgJp5hQNNMrXFOSwWHrMZfCS1OfNXgNYhlArGTaksEIeWnJDhRQ4IsH+V
Y/9eTNx/HALYtCI6B+JcJ9BKpKFyvkCcBAReHCvpq0f47Q97bBcfn6630pH03c++
joxTTZxFv8shXm5VTvr+5GFDJFQZ6UvnoPqByZHvLvB69knjpHqX6E46m2Ki5QYE
pK5FKoD2wFMjj82+YDoELfVx98r6zw0h7uVeFQbBH4I0EL28RYsXTj5WAAF+wWCj
Nzfx+ELzNtjpPQ4Kp4PItWSpJWa96+7HD/UmZB6dWcqE38sLF+nMWFHR1r1oDRCW
s45QqvuQUYDgQW42OnxNd4O8t0vMO6yc0VM5VWd7w7jEDzh03MQSBzrhOIr9Cnd9
QolSfQmFuvSHnXCoyM8NHC4CW6FFarQU0mjmb765p1sX5Z6im01ivS15c1KCKuCA
SmsoydGdO7GtKV6ZdG8ut+ztkvBK1146HxpxZBmDjIC9P0nnHzzYIjAztq/qd4sv
iU/NLnck
=HoQu
-----END PGP SIGNATURE-----
Timestamp of file with hash 65490dd75525720cc364871d69f74f20cb23d460478111dc409134823950f8b3 -
</details>