-
Notifications
You must be signed in to change notification settings - Fork 37.7k
net processing: Move CNode::nServices and CNode::nLocalServices to Peer #25514
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
37b03bb
to
dd46511
Compare
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. |
dd46511
to
10a4eba
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.
Concept ACK.
f7965ef
to
fae6a00
Compare
fae6a00
to
d5b6ba7
Compare
utACK d5b6ba7 |
d5b6ba7
to
c38a00d
Compare
utACK c38a00d |
991ea8e
to
8f6ed20
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.
Looking a lot better with the Handshake test helper. Thanks.
review ACK 8f6ed20 though I have not yet reviewed the last two commits 🏼
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK 8f6ed20acae2a4f93f5b52c3937ab704980db44b though I have not yet reviewed the last two commits 🏼
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjqHwwAlNYcnHxFpa3FBWcBsYy2DSbbm3Ww6p+dqZLivANiuNWpc7qKrFYoVQKY
OlCbOyMJNHuGbC0ACwjSfVxh1VhyLpdW7qtrMr203XD3j3MRComWe1Q5h6jG4jfn
rEB0ybHIAowvoWQBfvtY5Ti20WEsiPvWL4qEgA+b+wYClG+42BCHUyRePkN+1k+u
0fD/BOhTiRszyXgfWNV5q1iI/UhR6caf213mV/5X+udIXWMgi1PRV+4HQG4GmZdq
s25Ua9Quzmgtjz3sUDb4op2ztlS8BOMpzulKqSiXmIyAQz72zODaYrCieHOItZs8
vRR/JbGs4IMF/whQFtzJgPIMQ+O6iO8V/VHBoYbrmhjcbxpX9ioXhpX4mXelepeN
NFkdOR9WQWpaMAfcOl948axSgfVaN7MFU+9+0rzpHLEamQj5wbzdP4xdtyXqFGA4
jf11QGqoAh3a0IvYhEoUgK0MPbeR6ASSvhzAtglIw6vFtCPkCXBRnM+8vqBmaLBr
iVM6GTFy
=YLIt
-----END PGP SIGNATURE-----
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.
I tried to do some testing, but the second commit doesn't compile:
test/denialofservice_tests.cpp:75:23: error: too many arguments to function call, expected 6, have 7
54c7f95
to
e7aea6a
Compare
Thanks @MarcoFalke and @jnewbery for the reviews! I addressed all comments and rebased. All commits should now build without issues. |
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.
lgtm
review ACK e7aea6a 🏞
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK e7aea6ae6d0cd668dc7228cc24d0a58419c6ebcd 🏞
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjuqQv/aHcMUNox1MQBi+1Mj3WJorgEHy85MaRS3JiylOIrpUpGgtjvmh91HpoG
6ThPApvoEKGf3sYRKgU8COOVoEgzBj3AqXeG/RTu6wJaZNq3AFRmCjBtzzsxJjDJ
6w9SLoBexTQyTLLFEf/EvwxlE3ttldDgPQOQ0Ui6zZgxs1eCjpgBb119V41BTBmy
esOxtkE8ZHoPo+4nPYhB0d9f2i60wYX1jbeZAv0b3BDB+4XL67UUXhq8IhEJFvRY
LTDbgtSxhNQJAx3NOcOeHtmDdy8xfQe3Nnc7q8WAIfcitCa+DGXSIt5pKTzuwvut
bbPZroBqWarME+zSsVxvR6JMfAVoTrLO2zaFoAYrCvFQq6yrbq3OJZ6Rqq9GOJjj
kuwMGpW6yKJvTRb0qxgcds3Bgh6UJ/U3ZUVtfxNJ5LR7+JCpOkSBN1Ro+vH+amml
GZC7tDdeC7f8IaexX51tUXbweRzE49zK3NH5pYazHubyZDncMRM4dlLs8AtIzL8C
6XsRJRHp
=ZDto
-----END PGP SIGNATURE-----
@dergoegge just checking that you saw my comment about member naming: #25514 (comment). |
Track services offered by us and the peer in the Peer object.
…essages Prior to this commit, the peer was connected, and then the services and connectivity fields in the CNode object were manually set. Instead, send p2p `version` and `verack` messages, and have net_processing's internal logic set the state of the node. This ensures that the node's internal state is consistent with how it would be set in the live code. Prior to this commit, `dummyNode1.nServices` was set to `NODE_NONE` which was not a problem since `CNode::fClient` and `CNode::m_limited_node` are default initialised to false. Now that we are doing the actual version handshake, the values of `fClient` and `m_limited_node` are set during the handshake and cause the test to fail if we do not set `dummyNode1.nServices` to a reasonable value (NODE_NETWORK | NODE_WITNESS).
fClient is replaced by CanServeBlocks(), and m_limited_node is replaced by IsLimitedPeer().
Use Peer::m_their_services instead
e7aea6a
to
8d8eeb4
Compare
ACK 8d8eeb4 🔑 Show signatureSignature:
|
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.
utACK 8d8eeb4
One missed our_services
-> m_our_services
in a comment, but that shouldn't hold up merge.
* | ||
* \sa CNode::nLocalServices | ||
* \sa Peer::our_services |
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.
* \sa Peer::our_services | |
* \sa Peer::m_our_services |
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 8d8eeb4
This looks good to me, only found nits/doc comments during review.
@@ -2650,7 +2649,7 @@ bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer, | |||
return true; | |||
} | |||
|
|||
void PeerManagerImpl::ProcessGetCFilters(CNode& peer, CDataStream& vRecv) | |||
void PeerManagerImpl::ProcessGetCFilters(CNode& node,Peer& peer, CDataStream& vRecv) |
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.
nit:space after node
* This data is replicated in each CNode instance we create during peer | ||
* connection (in ConnectNode()) under a member also called | ||
* nLocalServices. | ||
* This data is replicated in each Peer instance we create. |
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 confused me during review, "replicated" makes it sound like the data is just copied to each peer (which was technically true before, when the comment specifically addressed ConnectNode()
and ignored the CreateNodeFromAcceptedSocket()
call site ).
It might be good to mention here and/or in the Peer::m_our_services
doc that different peers can be offered different local services based on permissions - otherwise m_our_services
wouldn't need to be a member of Peer
but could exist on the level of PeerManagerImpl
.
@dergoegge @jnewbery I am still digging deeper here, but I have a question (and might be terribly wrong). Moving However, I think service bits (also propagated with addr relay) are useful at the transport layer. For instance in BIP324, the proposed signaling method uses |
@dhruv Currently all service bits signal readiness to serve application layer data (blocks, bloom/compact filters, witness data). The BIP324 service bit differs from that as it signals support for a new transport protocol, which would make it the only bit that is needed within our net layer. I would therefore argue that passing around a bool to/within the net layer for the v2 bit seems more appropriate than passing around all service bits. |
Another step in #19398. Which services we offer to a peer and which services they offer to us is application layer data and should not be stored on
CNode
.This is also a prerequisite for adding
PeerManager
unit tests (See #25515).