Skip to content

Conversation

TheBlueMatt
Copy link
Contributor

This was mostly written as a way to clean things up so that the NETWORK_LIMITED PR (#10387) can be simplified a ton, but its also a nice standalone cleanup that will also require a bit of review because it tweaks a lot of stuff across net. The new functions are fine in protocol.h right now since they're straight-forward, but after NETWORK_LIMITED will really want to move elsewhere after @theuni moves the nServices-based selection to addrman from connman.

Adds HasAllRelevantServices and GetRelevantServices, which check
for NETWORK|WITNESS.

This changes the following:

  • Removes nRelevantServices from CConnman, disconnecting it a bit
    more from protocol-level logic.
  • Replaces our sometimes-connect-to-!WITNESS-nodes logic with
    simply always requiring WITNESS|NETWORK for outbound non-feeler
    connections (feelers still only require NETWORK).
  • This has the added benefit of removing nServicesExpected from
    CNode - instead letting net_processing's VERSION message
    handling simply check HasAllRelevantServices.
  • This implies we believe WITNESS nodes to continue to be a
    significant majority of nodes on the network, but also because
    we cannot sync properly from !WITNESS nodes, it is strange to
    continue using our valuable outbound slots on them.
  • In order to prevent this change from preventing connection to
    -connect= nodes which have !WITNESS, -connect nodes are now
    given the "addnode" flag. This also allows outbound connections
    to !NODE_NETWORK nodes for -connect nodes (which was already true
    of addnodes).
  • Has the (somewhat unintended) consequence of changing one of the
    eviction metrics from the same
    sometimes-connect-to-!WITNESS-nodes metric to requiring
    HasRelevantServices.

This should make NODE_NETWORK_LIMITED much simpler to implement.

@theuni
Copy link
Member

theuni commented Oct 5, 2017

In order to prevent this change from preventing connection to
-connect= nodes which have !WITNESS, -connect nodes are now
given the "addnode" flag.

I really disliked that flag anyway, as it's not obvious who should care and why. This change makes sense imo. Mind renaming this to "m_manual_connection", or "!m_from_addrman" (or hopefully something better) ?

@TheBlueMatt
Copy link
Contributor Author

@theuni done in a new commit, that is much more descriptive, indeed.

Copy link
Contributor

@jimpo jimpo 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

src/protocol.h Outdated
* If the peer is missing any of the returned service flags, they aren't
* interesting to us - we probably shouldn't conenct outbound to them.
*/
static ServiceFlags GetRelevantServiceFlags(ServiceFlags services) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you document what the parameter represents? Hard to tell since it's unused. I assume it's for future compatibility.

Copy link
Contributor Author

@TheBlueMatt TheBlueMatt Oct 5, 2017

Choose a reason for hiding this comment

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

Indeed, its for use in #10387. Will it be clearer when the function reads

GetRelevantServiceFlags(services) {
    if (services & NODE_NETWORK_LIMITED && !in_ibd) return NODE_NETWORK_LIMITED | NODE_WITNESS;
    return NODE_NETWORK | NODE_WITNESS;

or should I document it further?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, parameter documentation would be nice because I still find its purpose confusing. Especially since as a parameter of HasAllRelevantServiceFlags it represents both the service flags you want to test and a modifier on what you want to test against. Like, why is the future code not just:

GetRelevantServiceFlags() {
    if (!in_ibd) return NODE_NETWORK_LIMITED | NODE_WITNESS;
    else return NODE_NETWORK | NODE_WITNESS;

Copy link
Contributor

Choose a reason for hiding this comment

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

I like jimpo's suggestion above for getting rid of the service argument, since this code seems more vague and confusing than it needs to be. Other suggestions for making it clearer could be:

  • Rename "Relevant" to "Required" or "RequiredForOutbound." "Relevant" doesn't suggest what the return value will be used for, while "Required" does.
  • Rename "services" argument to "peer_service_flags" if it can't be eliminated so it is clearer where the argument value is coming from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You need the NODE_NETWORK_LIMITED check as a proxy for whether the node is new - eg if the node announces NODE_NETWORK_LIMITED (and you're out of IBD) then you're fine with NODE_NETWORK_LIMITED, but if the node only announces NODE_NETWORK they may be an 0.15.X node and you're perfectly OK with them having only NODE_NETWORK and not NODE_NETWORK_LIMITED.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, ok, I figured that would work because NODE_NETWORK would be a superset of NODE_NETWORK_LIMITED. But if NODE_NETWORK without NODE_NETWORK_LIMITED is a meaningful flag combination then it makes sense that you need the services argument.

In any case, I mostly wanted to suggest the renames here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NODE_NETWORK without NODE_NETWORK_LIMITED is not meaningful generally, but old nodes will (obviously) be using that, so it is important that we still treat it correctly.

@gmaxwell
Copy link
Contributor

gmaxwell commented Oct 5, 2017

I was thinking of opening a PR soon to require WITNESS for outbounds in any case, so ACK on that.

@fanquake fanquake added the P2P label Oct 5, 2017
@TheBlueMatt TheBlueMatt force-pushed the 2017-09-service-flags-cleanups branch from 8f50b87 to 12524dd Compare October 5, 2017 22:05
@TheBlueMatt
Copy link
Contributor Author

Rewrote the function description. Sufficiently descriptive, @jimpo?

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK 12524dd366306ea59ec8019e076b9a843d55bcf0, though for some reason I really dislike use of word "relevant" here.

It would be good if the -connect help string mentioned the fact that it loosens requirements for peers, since the current -connect help seems to imply that it only restricts connections. Release notes could also mention the change in behavior if you don't think it's too much of an internal detail.

src/protocol.h Outdated
* If the peer is missing any of the returned service flags, they aren't
* interesting to us - we probably shouldn't conenct outbound to them.
*/
static ServiceFlags GetRelevantServiceFlags(ServiceFlags services) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like jimpo's suggestion above for getting rid of the service argument, since this code seems more vague and confusing than it needs to be. Other suggestions for making it clearer could be:

  • Rename "Relevant" to "Required" or "RequiredForOutbound." "Relevant" doesn't suggest what the return value will be used for, while "Required" does.
  • Rename "services" argument to "peer_service_flags" if it can't be eliminated so it is clearer where the argument value is coming from.

src/protocol.h Outdated
* Checks if a peer with the given service flags may be capable of having a
* robust address-storage DB. Currently an alias for checking NODE_NETWORK.
*/
static inline bool MayHaveRelevantAddressDB(ServiceFlags services) {
Copy link
Contributor

Choose a reason for hiding this comment

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

"Relevant" doesn't seem like the right word here either, because it doesn't imply anything about the addressdb. Maybe "Robust"? "Good"? "Usable"?

src/protocol.h Outdated
* == GetRelevantServiceFlags(services), ie determines whether the given
* set of service flags are sufficient for a peer to be "relevant".
*/
static inline bool HasAllRelevantServiceFlags(ServiceFlags services) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Again could consider "Required" / "peer_service_flags" renames suggested above.

@JeremyRubin
Copy link
Contributor

Concept Ack and a light CR-Ack.

I agree with @ryanofsky about naming -- I didn't find the new function names you introduced to be particularly elucidating, so maybe you can pick something better.

Also, I don't think we want to introduce new hungarian notation member variables (unless the m_ stands for 'matt_' ;) ).

@TheBlueMatt
Copy link
Contributor Author

@ryanofsky I'm not sure what your comment about -connect is about. The help text still reads correct to me (it still limits you to only that one connection), the only thing it changes is that previously we would disconnect-on-VERSION-message for -connect peers which do not set NODE_NETWORK, now we will keep it connected just the same as -addnode peers. If you think thats a critical change to document I'm happy to do so, but I think thats a rather esoteric case for -connect.

src/protocol.h Outdated
* Relevant service flags may be peer- and state-specific in that the
* version of the peer may determine which flags are required (eg in the
* case of NODE_NETWORK_LIMITED where we seek out NODE_NETWORK peers
* unless they set NODE_NETWORK_LIMITED and we our out of IBD, in which
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we are*

@ryanofsky
Copy link
Contributor

Yeah, I wasn't saying the help text is incorrect, I was saying it was incomplete. Help text says -connect does one thing (limit which peers will be connected to) but actually -connect does two things (limit peers, and also loosen requirements for those peers). Feel free to leave it alone if you don't think it's worth mentioning, but it seemed like an omission.

@@ -1602,7 +1601,7 @@ void CConnman::ThreadDNSAddressSeed()
LOCK(cs_vNodes);
int nRelevant = 0;
for (auto pnode : vNodes) {
nRelevant += pnode->fSuccessfullyConnected && ((pnode->nServices & nRelevantServices) == nRelevantServices);
Copy link
Member

Choose a reason for hiding this comment

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

I think services are just acting as a proxy here. Since we enforce service checking for (non-manual) outgoing connections already, and should probably consider incoming nodes as insignificant for the sake of this check, don't we really just want to tally fSuccessfullyConnected && !fInbound && !m_manual_connection ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, though I went ahead and added OneShot and Feeler into the mix.

@TheBlueMatt TheBlueMatt force-pushed the 2017-09-service-flags-cleanups branch from 12524dd to 4189656 Compare October 6, 2017 21:29
@TheBlueMatt
Copy link
Contributor Author

OK, addressed all the feedback except the desire to rename Relevant to something else. I'm not a fan of Required or RequiredForOutbound, as neither really caputures its full user (its also used in eviction logic). I admit Relevant isnt so descriptive either, but it also doesn't give a false impression (and is documented), so I'm open to other suggestions but not a fan of the current options.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK 41896568e9ba776a61406a86ec565570eaa399e7. Thanks for the updates! Possible alternatives to relevant: Valid, Expected, Usable, Syncable

src/rpc/net.cpp Outdated
@@ -201,6 +201,8 @@ UniValue addnode(const JSONRPCRequest& request)
"addnode \"node\" \"add|remove|onetry\"\n"
"\nAttempts to add or remove a node from the addnode list.\n"
"Or try a connection to a node once.\n"
"Nodes added using addnode (or -connect) are protected from DoS disconnection andare not required to be\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

and are

@TheBlueMatt TheBlueMatt force-pushed the 2017-09-service-flags-cleanups branch from 4189656 to 989d2fe Compare October 6, 2017 21:54
@TheBlueMatt
Copy link
Contributor Author

Changed to "Desirable" instead of "Relevant" at @JeremyRubin's suggestion.

*
* Thus, generally, avoid calling with peerServices == NODE_NONE.
*/
static ServiceFlags GetDesirableServiceFlags(ServiceFlags services) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, unused services, comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

inline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See #11456 (comment), this function should get much more complicated soon, and hopefully move out of protocol.h at the same time.

@theuni
Copy link
Member

theuni commented Oct 10, 2017

Concept ACK. Though, I believe that these lines demonstrate why "Desirable" is so awkward:

if (!fFeeler && !HasAllDesirableServiceFlags(addr.nServices)) {
    continue;
    } else if (fFeeler && !MayHaveUsefulAddressDB(addr.nServices)) {
    continue;
}

MayHaveUsefulAddressDB() is explicit in what it's checking, but HasAllDesirableServiceFlags() is not.

I'd be much more comfortable with this (and I think it'd be much more straightforward) if HasAllDesirableServiceFlags() was replaced with two or three different functions, each representing an explicit functionality check. e.g.: MayServeSomeWitnessBlocks(), MayServeAllWitnessBlocks(), etc.

After all, that's what we're really trying to figure out, right?

Then the flag checks aren't dependent on app state, because those checks are done in a straightforward way by the caller instead:

if ((in_ibd && MayServeAllWitnessBlocks(services))
  || (!in_ibd && MayServeSomeWitnessBlocks(services))) {
    request()
    ...
}

That also means that "Desirable" doesn't have to share the same meaning everywhere. The obvious example where that's useful is the eviction logic.

So... basically just a glorified version of the previous binary logic, except that the functions understand cases where multiple flags may be suitable.

@TheBlueMatt
Copy link
Contributor Author

The goal with the naming was to allow the place that owns network logic to have a function which captures whether a peer is interesting to us. Point being you want some function which captures everything net wants to avoid knowing about, even if that's some crazy wrapper for MayServe*WitnessBlocks, that wrapper should still exist outside of CConnman/net. Ideally, eventually, this will be in net_processing.h (ie the place where we know about what stuff we want out of our peers), but the circular deps right now make that a mess. Lacking net_processing being able to take it, protocol.h or some new header seems most reasonable to me.

@sipa
Copy link
Member

sipa commented Oct 10, 2017

The reason for CNode::nExpected wasn't so much enforcing services, but checking whether we're connecting out to the right node.

Many of our assumptions on partition resistance and privacy are based on the fact that outgoing connections are more under our control. If we're making an outgoing connection, and the node we end up connecting to has different service flags than what we expect - even if they're 'better' - we're likely not connected to who we thought we were. If that's the case, I believe it's better to disconnect and pick another node we want to connect to, rather than accepting wasting an outbound connection slot on an unknown peer.

@theuni
Copy link
Member

theuni commented Oct 10, 2017

@sipa I think this logic would roughly mimic that of nExpected, as we only attempt connections with preferred flags anyway.

Though disconnecting upon receiving preferred but not expected flags would mean that if a node goes from full -> pruned (or the reverse), it would see a bunch of disconnects for a while. Post bip159, that is.

I think it would also open us up to issues if someone was handing out phony addr's?

@sipa
Copy link
Member

sipa commented Oct 11, 2017

@theuni My view is that at connection time, we're making a certain determination of what to connect to, with biases based on (among other things) the service flags of all things in addrman. Disconnecting if you see that what you connected to was based on wrong information just gives everything a new chance (including the peer you just connected to). In the end, what node you end up connecting to has the same probability distribution to the one you'd have if you had perfect information (about the nodes you tried) from the start. Using nExpected means all the biasing logic can be encapsulated inside the outgoing-connection-logic, without needing to reason about corrections afterwards.

Talking to @TheBlueMatt about this, I agree that this pretty abstract, as we don't actually want to bias based on service flags anymore (at least for the time being), and even after BIP159, it will likely be a boolean acceptable or not, instead of a complicated bias.

So, I withdraw my objection.

src/protocol.h Outdated
* set of service flags are sufficient for a peer to be "relevant".
*/
static inline bool HasAllDesirableServiceFlags(ServiceFlags services) {
return (GetDesirableServiceFlags(services) & services) == GetDesirableServiceFlags(services);
Copy link
Member

Choose a reason for hiding this comment

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

Slightly easier expression !(GetDesirableServiceFlags(services) & ~services).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@TheBlueMatt TheBlueMatt force-pushed the 2017-09-service-flags-cleanups branch from 989d2fe to b4809fc Compare October 12, 2017 00:59
src/net.cpp Outdated
@@ -1601,7 +1601,7 @@ void CConnman::ThreadDNSAddressSeed()
LOCK(cs_vNodes);
int nRelevant = 0;
for (auto pnode : vNodes) {
nRelevant += pnode->fSuccessfullyConnected && HasAllDesirableServiceFlags(pnode->nServices);
nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->fOneShot && !pnode->m_manual_connection && !pnode->fInbound;
Copy link
Member

@sipa sipa Oct 12, 2017

Choose a reason for hiding this comment

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

Are you sure you wouldn't want MayHaveUsefulAddressDB at least here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fSuccessfullyConnected && !special_peer_flag implies the peer is useful (and really want to have as few service-bit-aware pieces of logic in net as possible).

Copy link
Member

Choose a reason for hiding this comment

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

Got it.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK b4809fc30be4d27cabf1a81bc954014070fa3117 if HasAllDesirableServiceFlags logic is fixed. Changes since last review were the "desirable" rename, "andare" typo fix, and HasAllDesirableServiceFlags bitwise logic simplification.

src/protocol.h Outdated
* set of service flags are sufficient for a peer to be "relevant".
*/
static inline bool HasAllDesirableServiceFlags(ServiceFlags services) {
return GetDesirableServiceFlags(services) & (~services);
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing !

@sipa
Copy link
Member

sipa commented Oct 12, 2017

Commit 'Rename fAddnode to a more-descriptive "manual_connection"': convert to scripted diff?

@sipa
Copy link
Member

sipa commented Oct 12, 2017

utACK after fixing the incorrect HasAllDesirableServiceFlags logic. One nit.

Adds HasAllRelevantServices and GetRelevantServices, which check
for NETWORK|WITNESS.

This changes the following:
 * Removes nRelevantServices from CConnman, disconnecting it a bit
   more from protocol-level logic.
 * Replaces our sometimes-connect-to-!WITNESS-nodes logic with
   simply always requiring WITNESS|NETWORK for outbound non-feeler
   connections (feelers still only require NETWORK).
 * This has the added benefit of removing nServicesExpected from
   CNode - instead letting net_processing's VERSION message
   handling simply check HasAllRelevantServices.
 * This implies we believe WITNESS nodes to continue to be a
   significant majority of nodes on the network, but also because
   we cannot sync properly from !WITNESS nodes, it is strange to
   continue using our valuable outbound slots on them.
 * In order to prevent this change from preventing connection to
   -connect= nodes which have !WITNESS, -connect nodes are now
   given the "addnode" flag. This also allows outbound connections
   to !NODE_NETWORK nodes for -connect nodes (which was already true
   of addnodes).
 * Has the (somewhat unintended) consequence of changing one of the
   eviction metrics from the same
   sometimes-connect-to-!WITNESS-nodes metric to requiring
   HasRelevantServices.

This should make NODE_NETWORK_LIMITED much simpler to implement.
@TheBlueMatt TheBlueMatt force-pushed the 2017-09-service-flags-cleanups branch from b4809fc to 15f5d3b Compare October 13, 2017 17:29
@TheBlueMatt
Copy link
Contributor Author

Fixed missing !, making the fAnnode -> manul_connection commit scripted isnt trivial given some of them are m_manual_connection but some are manul_connection in function parameters. Its a pretty simple commit anyway so I'll just leave it unless you have strong objections.

@theuni
Copy link
Member

theuni commented Oct 13, 2017

@ryanofsky nice spot.

I'm still not a big fan of keeping the relevant concept around, but this is an improvement regardless.

utACK 15f5d3b.

@sipa
Copy link
Member

sipa commented Oct 13, 2017

making the fAnnode -> manul_connection commit scripted isnt trivial given some of them are m_manual_connection but some are manul_connection in function parameters

I missed that. The change looks fine without.

@sipa
Copy link
Member

sipa commented Oct 13, 2017

utACK 15f5d3b

@sipa sipa merged commit 15f5d3b into bitcoin:master Oct 13, 2017
sipa added a commit that referenced this pull request Oct 13, 2017
15f5d3b Switch DNSSeed-needed metric to any-automatic-nodes, not services (Matt Corallo)
5ee88b4 Clarify docs for requirements/handling of addnode/connect nodes (Matt Corallo)
57edc0b Rename fAddnode to a more-descriptive "manual_connection" (Matt Corallo)
4440710 Replace relevant services logic with a function suite. (Matt Corallo)

Pull request description:

  This was mostly written as a way to clean things up so that the NETWORK_LIMITED PR (#10387) can be simplified a ton, but its also a nice standalone cleanup that will also require a bit of review because it tweaks a lot of stuff across net. The new functions are fine in protocol.h right now since they're straight-forward, but after NETWORK_LIMITED will really want to move elsewhere after @theuni moves the nServices-based selection to addrman from connman.

  Adds HasAllRelevantServices and GetRelevantServices, which check
  for NETWORK|WITNESS.

  This changes the following:
   * Removes nRelevantServices from CConnman, disconnecting it a bit
     more from protocol-level logic.
   * Replaces our sometimes-connect-to-!WITNESS-nodes logic with
     simply always requiring WITNESS|NETWORK for outbound non-feeler
     connections (feelers still only require NETWORK).
   * This has the added benefit of removing nServicesExpected from
     CNode - instead letting net_processing's VERSION message
     handling simply check HasAllRelevantServices.
   * This implies we believe WITNESS nodes to continue to be a
     significant majority of nodes on the network, but also because
     we cannot sync properly from !WITNESS nodes, it is strange to
     continue using our valuable outbound slots on them.
   * In order to prevent this change from preventing connection to
     -connect= nodes which have !WITNESS, -connect nodes are now
     given the "addnode" flag. This also allows outbound connections
     to !NODE_NETWORK nodes for -connect nodes (which was already true
     of addnodes).
   * Has the (somewhat unintended) consequence of changing one of the
     eviction metrics from the same
     sometimes-connect-to-!WITNESS-nodes metric to requiring
     HasRelevantServices.

  This should make NODE_NETWORK_LIMITED much simpler to implement.

Tree-SHA512: 90606896c86cc5da14c77843b16674a6a012065e7b583d76d1c47a18215358abefcbab44ff4fab3fadcd39aa9a42d4740c6dc8874a58033bdfc8ad3fb5c649fc
@morcos morcos mentioned this pull request Nov 2, 2017
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Nov 2, 2017
codablock pushed a commit to codablock/dash that referenced this pull request Sep 26, 2019
…suite.

15f5d3b Switch DNSSeed-needed metric to any-automatic-nodes, not services (Matt Corallo)
5ee88b4 Clarify docs for requirements/handling of addnode/connect nodes (Matt Corallo)
57edc0b Rename fAddnode to a more-descriptive "manual_connection" (Matt Corallo)
4440710 Replace relevant services logic with a function suite. (Matt Corallo)

Pull request description:

  This was mostly written as a way to clean things up so that the NETWORK_LIMITED PR (bitcoin#10387) can be simplified a ton, but its also a nice standalone cleanup that will also require a bit of review because it tweaks a lot of stuff across net. The new functions are fine in protocol.h right now since they're straight-forward, but after NETWORK_LIMITED will really want to move elsewhere after @theuni moves the nServices-based selection to addrman from connman.

  Adds HasAllRelevantServices and GetRelevantServices, which check
  for NETWORK|WITNESS.

  This changes the following:
   * Removes nRelevantServices from CConnman, disconnecting it a bit
     more from protocol-level logic.
   * Replaces our sometimes-connect-to-!WITNESS-nodes logic with
     simply always requiring WITNESS|NETWORK for outbound non-feeler
     connections (feelers still only require NETWORK).
   * This has the added benefit of removing nServicesExpected from
     CNode - instead letting net_processing's VERSION message
     handling simply check HasAllRelevantServices.
   * This implies we believe WITNESS nodes to continue to be a
     significant majority of nodes on the network, but also because
     we cannot sync properly from !WITNESS nodes, it is strange to
     continue using our valuable outbound slots on them.
   * In order to prevent this change from preventing connection to
     -connect= nodes which have !WITNESS, -connect nodes are now
     given the "addnode" flag. This also allows outbound connections
     to !NODE_NETWORK nodes for -connect nodes (which was already true
     of addnodes).
   * Has the (somewhat unintended) consequence of changing one of the
     eviction metrics from the same
     sometimes-connect-to-!WITNESS-nodes metric to requiring
     HasRelevantServices.

  This should make NODE_NETWORK_LIMITED much simpler to implement.

Tree-SHA512: 90606896c86cc5da14c77843b16674a6a012065e7b583d76d1c47a18215358abefcbab44ff4fab3fadcd39aa9a42d4740c6dc8874a58033bdfc8ad3fb5c649fc
codablock pushed a commit to codablock/dash that referenced this pull request Sep 29, 2019
…suite.

15f5d3b Switch DNSSeed-needed metric to any-automatic-nodes, not services (Matt Corallo)
5ee88b4 Clarify docs for requirements/handling of addnode/connect nodes (Matt Corallo)
57edc0b Rename fAddnode to a more-descriptive "manual_connection" (Matt Corallo)
4440710 Replace relevant services logic with a function suite. (Matt Corallo)

Pull request description:

  This was mostly written as a way to clean things up so that the NETWORK_LIMITED PR (bitcoin#10387) can be simplified a ton, but its also a nice standalone cleanup that will also require a bit of review because it tweaks a lot of stuff across net. The new functions are fine in protocol.h right now since they're straight-forward, but after NETWORK_LIMITED will really want to move elsewhere after @theuni moves the nServices-based selection to addrman from connman.

  Adds HasAllRelevantServices and GetRelevantServices, which check
  for NETWORK|WITNESS.

  This changes the following:
   * Removes nRelevantServices from CConnman, disconnecting it a bit
     more from protocol-level logic.
   * Replaces our sometimes-connect-to-!WITNESS-nodes logic with
     simply always requiring WITNESS|NETWORK for outbound non-feeler
     connections (feelers still only require NETWORK).
   * This has the added benefit of removing nServicesExpected from
     CNode - instead letting net_processing's VERSION message
     handling simply check HasAllRelevantServices.
   * This implies we believe WITNESS nodes to continue to be a
     significant majority of nodes on the network, but also because
     we cannot sync properly from !WITNESS nodes, it is strange to
     continue using our valuable outbound slots on them.
   * In order to prevent this change from preventing connection to
     -connect= nodes which have !WITNESS, -connect nodes are now
     given the "addnode" flag. This also allows outbound connections
     to !NODE_NETWORK nodes for -connect nodes (which was already true
     of addnodes).
   * Has the (somewhat unintended) consequence of changing one of the
     eviction metrics from the same
     sometimes-connect-to-!WITNESS-nodes metric to requiring
     HasRelevantServices.

  This should make NODE_NETWORK_LIMITED much simpler to implement.

Tree-SHA512: 90606896c86cc5da14c77843b16674a6a012065e7b583d76d1c47a18215358abefcbab44ff4fab3fadcd39aa9a42d4740c6dc8874a58033bdfc8ad3fb5c649fc
barrystyle pushed a commit to PACGlobalOfficial/PAC that referenced this pull request Jan 22, 2020
…suite.

15f5d3b Switch DNSSeed-needed metric to any-automatic-nodes, not services (Matt Corallo)
5ee88b4 Clarify docs for requirements/handling of addnode/connect nodes (Matt Corallo)
57edc0b Rename fAddnode to a more-descriptive "manual_connection" (Matt Corallo)
4440710 Replace relevant services logic with a function suite. (Matt Corallo)

Pull request description:

  This was mostly written as a way to clean things up so that the NETWORK_LIMITED PR (bitcoin#10387) can be simplified a ton, but its also a nice standalone cleanup that will also require a bit of review because it tweaks a lot of stuff across net. The new functions are fine in protocol.h right now since they're straight-forward, but after NETWORK_LIMITED will really want to move elsewhere after @theuni moves the nServices-based selection to addrman from connman.

  Adds HasAllRelevantServices and GetRelevantServices, which check
  for NETWORK|WITNESS.

  This changes the following:
   * Removes nRelevantServices from CConnman, disconnecting it a bit
     more from protocol-level logic.
   * Replaces our sometimes-connect-to-!WITNESS-nodes logic with
     simply always requiring WITNESS|NETWORK for outbound non-feeler
     connections (feelers still only require NETWORK).
   * This has the added benefit of removing nServicesExpected from
     CNode - instead letting net_processing's VERSION message
     handling simply check HasAllRelevantServices.
   * This implies we believe WITNESS nodes to continue to be a
     significant majority of nodes on the network, but also because
     we cannot sync properly from !WITNESS nodes, it is strange to
     continue using our valuable outbound slots on them.
   * In order to prevent this change from preventing connection to
     -connect= nodes which have !WITNESS, -connect nodes are now
     given the "addnode" flag. This also allows outbound connections
     to !NODE_NETWORK nodes for -connect nodes (which was already true
     of addnodes).
   * Has the (somewhat unintended) consequence of changing one of the
     eviction metrics from the same
     sometimes-connect-to-!WITNESS-nodes metric to requiring
     HasRelevantServices.

  This should make NODE_NETWORK_LIMITED much simpler to implement.

Tree-SHA512: 90606896c86cc5da14c77843b16674a6a012065e7b583d76d1c47a18215358abefcbab44ff4fab3fadcd39aa9a42d4740c6dc8874a58033bdfc8ad3fb5c649fc
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants