-
Notifications
You must be signed in to change notification settings - Fork 38.7k
cli: rework -addrinfo cli to use addresses which aren’t filtered for quality/recency #26988
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
base: master
Are you sure you want to change the base?
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/26988. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. LLM Linter (✨ experimental)Possible places where named args for integral literals may be used (e.g.
2025-12-13 |
cac08f2 to
caab213
Compare
mzumsande
left a comment
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, will review soon.
caab213 to
c645fb6
Compare
|
obvious concept ack considering I proposed #26907 |
mzumsande
left a comment
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.
Looks good to me, only minor nits.
ping @jonatack, could you have a look, especially at the changes to bitcoin-cli?
c645fb6 to
35bd55c
Compare
35bd55c to
a04bfa3
Compare
brunoerg
left a comment
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
"network" : "str", (string) The network (ipv4, ipv6, onion, i2p, cjdns)Instead of being a string, wouldn't make sense it to be an array? E.g. I want to get new/tried table address count for ipv4 and ipv6 together. |
a04bfa3 to
7c34c35
Compare
i'm confused about this since making it into and there are only few network types. would be interested in what others think. |
|
to minimize the complexity that we need to maintain over time, we try to reduce the amount of client-side niftiness that we offer. it seems to me that the string would offer all the information needed for a client to write a simple query if they wanted the sum of multiple. agreed that the syntax is another challenge of the array type so I am +1 to leaving as is |
|
that was just a question, thinking about complexity I agree on leaving it as is. going to review in depth soon. |
|
light code review ACK 7c34c35b47. tested that the RPC and cli endpoints make sense & handle errors reasonably. these changes will require release notes, which can be done here or in a separate PR. |
|
thank you for the reviews! I've pushed an update changing the long key names. regarding #26988 (comment):
Good point. Thinking of changing it in the next push. According to bitnodes.io - among bitcoin core nodes, 95% are already on v26+ and therefore support getaddrmaninfo (introduced 2 years ago). Maybe the concern regarding older node <-> newer CLI compatibility isn't there anymore considering how much the network/software has changed! (cc @jonatack, curious to hear your thoughts and anyone else's of course)
|
|
CLI calls can be made to a node running a different, older version. If a researcher, data gatherer, developer, or node operator is calling this on a pre-getaddrmaninfo node, then the call should still work. As commented above, colleagues here requested that -netinfo continue to work in such cases, and we patched it. There doesn't seem to be any reason not to do the same here, rather than choosing to break it. |
src/bitcoin-cli.cpp
Outdated
| uint64_t total{0}; // Total address count | ||
| for (size_t i = 1; i < NETWORKS.size() - 1; ++i) { | ||
| addresses.pushKV(NETWORKS[i], counts.at(i)); | ||
| total += counts.at(i); | ||
| } | ||
| addresses.pushKV("total", total); | ||
| result.pushKV("addresses_known", std::move(addresses)); | ||
| result.pushKV("addresses_filtered", std::move(addresses)); |
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 agree with preferably keeping the field names short, but the data corresponding to "addresses_known" should not change.
Perhaps use "addresses_unfiltered" or "addresses_not_filtered_for_quality_and_recency" for the new field.
As this is a CLI output, as opposed to an RPC one, its output presentation can be more optimized for human use (see -getinfo, for instance) while providing consistent historical data.
Could you elaborate on why these people, particularly the developers, or node operators, are running EOL versions of Core (with known CVEs); and why they can't upgrade their nodes, but at the same time, they are downloading and using the latest version of bitcoin-cli?
The reason to not do it, is that it then implies we are still supporting versions of our software, which we have marked as EOL. |
mzumsande
left a comment
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.
CLI calls can be made to a node running a different, older version. If a researcher, data gatherer, developer, or node operator is calling this on a pre-getaddrmaninfo node, then the call should still work. As commented above, colleagues here requested that -netinfo continue to work in such cases, and we patched it. There doesn't seem to be any reason not to do the same here, rather than choosing to break it.
I don't agree with that. I don't see bitcoin-cli and bitcoind as completely separate programs that should be supported in arbitrary combinations for eternity.
If that was the case, it would have been a bad mistake to ever have added non-trivial functionality like -addrinfo or -netinfo to bitcoin-cli instead of bitcoind in the first place because that would have created an infinite obligation to maintain compatibility of current bitcoind versions with ancient versions of bitcoin-cli long out of support.
While it makes some limited sense to try to keep up compatibility over version ranges supported at the same time (although even that is debatable in my opinion), I don't think that it is reasonable to make any efforts supporting compatibility beyond this.
currently -addrinfo returns addresses known to the node after filtering for quality and recency. However, the node considers all known addresses (even the filtered out addresses) when selecting peers to connect to. So update -addrinfo to also display the full set of known addresses for more useful node information.
858f49b to
5b05a99
Compare
|
I pushed an update. I also don't think we should implement a fallback to support a rare usecase for few individuals. I've run into a few occasions where I used older bitcoind and newer cli but it's when I misconfigure something accidentally and wasn't the behaviour I intended. I guess this is what most normal users would run into. This is why I think we shouldn't implement a fallback:
So my preferred solution is to give human node operators a clear + helpful message explaining the issue and asking them to use an older CLI or newer bitcoind to which they can choose. A clear message is more helpful than silently falling back. @jonatack, thank you for your feedback and I'm sorry there's a difference in opinion + this is dragging out so long. |
|
Concept/Approach ACK. I think it's fine to break compatibility with unmaintained node versions, given that there is a good error message for this case. |
vasild
left a comment
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.
ACK 5b05a9959f1633bfee78d9edb180c672b0640ab5
pablomartin4btc
left a comment
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.
tACK 5b05a9959f1633bfee78d9edb180c672b0640ab5
with bitcoind < v26:
/build/bin/bitcoin-cli -signet -datadir=/tmp/btc -addrinfo
error: -addrinfo requires bitcoind v26.0 or later which supports getaddrmaninfo RPC. Please upgrade your node or use bitcoin-cli from the same version.
5b05a99 to
325f98b
Compare
vasild
left a comment
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.
ACK 325f98bca07c3a0c48a46dc18f67376d44c5341d
pablomartin4btc
left a comment
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.
ACK 325f98bca07c3a0c48a46dc18f67376d44c5341d
(Left a small suggestion since the older node may be operated by someone other than the CLI user, and upgrading it might not be possible or appropriate when this change is the only reason. I think this would also align with @jonatack’s earlier note.)
325f98b to
b3046cc
Compare
pablomartin4btc
left a comment
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 b3046cc
Rework of
-addrinfoCLI is done usinggetaddrmaninfoRPC proposed in #27511. This would be useful for users who want to know the total number of addresses the node knows about and can make connections to.Currently,
-addrinforeturns total number of addresses the node knows about after filtering them for quality + recency usingisTerrible. HoweverisTerribleaddresses don't matter when selecting outbound peers to connect to. Total number of addresses the node knows about could be higher than what-addrinfocurrently displays. See #24370.