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
rpc: Add test-only RPC getaddrmaninfo for new/tried table address count #27511
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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. |
This PR is based on master from two months age. You may need to rebase it to current master for the (tidy) CI to be green. |
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
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 c505611
just tested it with my "clearnet only" node, results:
➜ bitcoin-core-dev git:(27511-stratospher) ✗ ./src/bitcoin-cli getaddrmaninfo
{
"ipv4": {
"new": 28765,
"tried": 277,
"total": 29042
},
"ipv6": {
"new": 7245,
"tried": 67,
"total": 7312
},
"onion": {
"new": 0,
"tried": 0,
"total": 0
},
"i2p": {
"new": 0,
"tried": 0,
"total": 0
},
"cjdns": {
"new": 0,
"tried": 0,
"total": 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.
Code Review ACK c505611, I would use this rpc a lot in my work.
I also think that a totals
field would be useful.
I don't think that a split-up with respect to "terrible" would be necessary, because in my opinion "terrible" is an internal property used only in address relay / addrman collisions that is not so critical to expose because it isn't used for the main purpose of addrman: selecting peers for outbound connections
It's used in RPC getnodeaddresses and CLI -addrinfo to return only non-IsTerrible peers to users. (I meant pre and post that filtering in the suggestion above). |
in my opinion unfortunately. I think this was mostly coincidental, because #13152 chose to reuse an addrman function used only for GETADDR answers before. Then #21595 used that output without any mentioning of that restriction, and the doc was only adjusted a year later in #24370. I think that ideally we never should have exposed the terrible filter in the first place. |
@mzumsande do you want to propose some changes to remove its exposure? |
The author and the numerous reviewers of #13152 were aware of the relationship to getaddr (see the PR description and review discussion), as well as mention of IsTerrible in #13152 (review). I don't see it as unfortunate; as a frequent user of getnodeaddresses and -addrinfo it seems useful that the data doesn't include terrible/non-recent (and banned/discouraged) peers. But guessing whether it was coincidental is beside the point. What is relevant is that changing those calls to return different data would break user space, including any tracking over time using that data. Adding data is fine, but let's not needlessly break user space. |
@stratospher do you plan to repush after rebase to current master for the CI and perhaps with the totals? |
c505611
to
7d7ee5e
Compare
no, I don't want to spend time on discussions on whether some change breaks user space or not. I'd be happy to have an alternative way to query the actual, unfiltered numbers per network, which are much more relevant to my use cases as a developer.
For me, it makes no sense that these commands might withhold our very next outbound peer - which would be picked with no disadvantage over non-terrible peers if it, for example, just has an older timestamp. |
I think that would be useful, too, perhaps by passing an argument to getnodeaddresses and -addrinfo, and/or returning both pre and post filter in -addrinfo. |
so sorry for the delay and thank you for the suggestions! the CI is all green now. i've updated the PR to include:
I'd want this RPC to be the alternative way to access the actual count of all addresses in the addrman. |
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.
Tested ACK 7d7ee5e
@mzumsande fair enough. I don't quite understand what "user space" means, when it has been used in comments here (and in other PRs), as we are not the Linux Kernel, but I assume it's a somewhat less direct way of saying backwards compatibility/continuity? In any case, as far as I'm aware, we offer no special "backwards compatiblity", or other, guarantees for our CLI tools, and I don't really think we should. Doing so would put us in an awkward position, of having our RPCs backwards compatibility requirements, extended to those tools (consumers, which just happen to exist in this codebase). We don't want to be in position where we can't change an RPC, to stop it doing something possibly incorrect/illogical, just because a CLI tool happens to call that RPC. These tools shouldn't get any special treatment, and, as far as I'm concerned, should just adapt to any RPC changes we might make, like every other consumer (internal or external) of that RPC. |
The code change here seems very simple, but since this PR does add a new RPC it would be useful to have more concept ACKs to know whether this is appropriate to merge. I noticed a number of contributors added github reactions to some comments here, so perhaps more of the people following the discussion could add concept acks or mention any reservations |
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 7d7ee5e
7d7ee5e
to
69abfd3
Compare
updated the PR to include better docs inspired from #27511 (comment). left "RPC is for testing only" as it is since all hidden RPCs have that line in the help.
|
0bff92a
to
28bac81
Compare
ACK 28bac81 |
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.
reACK 28bac81
CI failure seems unrelated.
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 28bac81
reACK 28bac81 |
ACK 28bac81 |
…ied table address count 28bac81 test: add functional test for getaddrmaninfo (stratospher) c8eb8da rpc: Introduce getaddrmaninfo for count of addresses stored in new/tried table (stratospher) Pull request description: implements bitcoin#26907. split off from bitcoin#26988 to keep RPC, CLI discussions separate. This PR introduces a new RPC `getaddrmaninfo`which returns the count of addresses in the new/tried table of a node's addrman broken down by network type. This would be useful for users who want to see the distribution of addresses from different networks across new/tried table in the addrman. ```jsx $ getaddrmaninfo Result: { (json object) json object with network type as keys "network" : { (json object) The network (ipv4, ipv6, onion, i2p, cjdns) "new" : n, (numeric) number of addresses in new table "tried" : n, (numeric) number of addresses in tried table "total" : n (numeric) total number of addresses in both new/tried tables from a network }, ... } ``` ### additional context from [original PR](bitcoin#26988) 1. network coverage tests were skipped because there’s a small chance that addresses from different networks could hash to the same bucket and cause count of different network addresses in the tests to fail. see bitcoin#26988 (comment). 2. bitcoin#26988 uses this RPC in -addrinfo CLI. Slight preference for keeping the RPC hidden since this info will mostly be useful to only super users. see bitcoin#26988 (comment). ACKs for top commit: 0xB10C: ACK 28bac81 willcl-ark: reACK 28bac81 achow101: ACK 28bac81 brunoerg: reACK 28bac81 theStack: Code-review ACK 28bac81 Tree-SHA512: 346390167e1ebed7ca5c79328ea452633736aff8b7feefea77460e04d4489059334ae78a3f757f32f5fb7827b309d7186bebab3c3760b3dfb016d564a647371a
…ied table address count 28bac81 test: add functional test for getaddrmaninfo (stratospher) c8eb8da rpc: Introduce getaddrmaninfo for count of addresses stored in new/tried table (stratospher) Pull request description: implements bitcoin#26907. split off from bitcoin#26988 to keep RPC, CLI discussions separate. This PR introduces a new RPC `getaddrmaninfo`which returns the count of addresses in the new/tried table of a node's addrman broken down by network type. This would be useful for users who want to see the distribution of addresses from different networks across new/tried table in the addrman. ```jsx $ getaddrmaninfo Result: { (json object) json object with network type as keys "network" : { (json object) The network (ipv4, ipv6, onion, i2p, cjdns) "new" : n, (numeric) number of addresses in new table "tried" : n, (numeric) number of addresses in tried table "total" : n (numeric) total number of addresses in both new/tried tables from a network }, ... } ``` ### additional context from [original PR](bitcoin#26988) 1. network coverage tests were skipped because there’s a small chance that addresses from different networks could hash to the same bucket and cause count of different network addresses in the tests to fail. see bitcoin#26988 (comment). 2. bitcoin#26988 uses this RPC in -addrinfo CLI. Slight preference for keeping the RPC hidden since this info will mostly be useful to only super users. see bitcoin#26988 (comment). ACKs for top commit: 0xB10C: ACK 28bac81 willcl-ark: reACK 28bac81 achow101: ACK 28bac81 brunoerg: reACK 28bac81 theStack: Code-review ACK 28bac81 Tree-SHA512: 346390167e1ebed7ca5c79328ea452633736aff8b7feefea77460e04d4489059334ae78a3f757f32f5fb7827b309d7186bebab3c3760b3dfb016d564a647371a
Exposing address manager table entries in a hidden RPC allows to introspect addrman tables in tests and during development. Also ran clang-format-diff.py on my diff to reduce the extra indentation from the getaddrmaninfo RPC implementation. Can be reviewed with --ignore-all-space Includes a small follow-up from bitcoin#27511 too which adds `all_networks` to the list of possible "network" key's in the JSON response. See bitcoin#27511 (comment)
Exposing address manager table entries in a hidden RPC allows to introspect addrman tables in tests and during development. Also ran clang-format-diff.py on my diff to reduce the extra indentation from the getaddrmaninfo RPC implementation. Can be reviewed with --ignore-all-space Includes a small follow-up from bitcoin#27511 too which adds `all_networks` to the list of possible "network" key's in the JSON response. See bitcoin#27511 (comment)
… entries 352d5eb test: getrawaddrman RPC (0xb10c) da384a2 rpc: getrawaddrman for addrman entries (0xb10c) Pull request description: Inspired by `getaddrmaninfo` (#27511), this adds a hidden/test-only `getrawaddrman` RPC. The RPC returns information on all addresses in the address manager new and tried tables. Addrman table contents can be used in tests and during development. The RPC result encodes the `bucket` and `position`, the internal location of addresses in the tables, in the address object's string key. This allows users to choose to consume or to ignore the location information. If the internals of the address manager implementation change, the location encoding might change too. ``` getrawaddrman EXPERIMENTAL warning: this call may be changed in future releases. Returns information on all address manager entries for the new and tried tables. Result: { (json object) "table" : { (json object) buckets with addresses in the address manager table ( new, tried ) "bucket/position" : { (json object) the location in the address manager table (<bucket>/<position>) "address" : "str", (string) The address of the node "port" : n, (numeric) The port number of the node "network" : "str", (string) The network (ipv4, ipv6, onion, i2p, cjdns) of the address "services" : n, (numeric) The services offered by the node "time" : xxx, (numeric) The UNIX epoch time when the node was last seen "source" : "str", (string) The address that relayed the address to us "source_network" : "str" (string) The network (ipv4, ipv6, onion, i2p, cjdns) of the source address }, ... }, ... } Examples: > bitcoin-cli getrawaddrman > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getrawaddrman", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/ ``` ACKs for top commit: willcl-ark: reACK 352d5eb amitiuttarwar: reACK 352d5eb stratospher: reACK 352d5eb. achow101: ACK 352d5eb Tree-SHA512: cc462666b5c709617c66b0e3e9a17c4c81e9e295f91bdd9572492d1cb6466fc9b6d48ee805ebe82f9f16010798370effe5c8f4db15065b8c7c0d8637675d615e
…n table entries 352d5eb test: getrawaddrman RPC (0xb10c) da384a2 rpc: getrawaddrman for addrman entries (0xb10c) Pull request description: Inspired by `getaddrmaninfo` (bitcoin#27511), this adds a hidden/test-only `getrawaddrman` RPC. The RPC returns information on all addresses in the address manager new and tried tables. Addrman table contents can be used in tests and during development. The RPC result encodes the `bucket` and `position`, the internal location of addresses in the tables, in the address object's string key. This allows users to choose to consume or to ignore the location information. If the internals of the address manager implementation change, the location encoding might change too. ``` getrawaddrman EXPERIMENTAL warning: this call may be changed in future releases. Returns information on all address manager entries for the new and tried tables. Result: { (json object) "table" : { (json object) buckets with addresses in the address manager table ( new, tried ) "bucket/position" : { (json object) the location in the address manager table (<bucket>/<position>) "address" : "str", (string) The address of the node "port" : n, (numeric) The port number of the node "network" : "str", (string) The network (ipv4, ipv6, onion, i2p, cjdns) of the address "services" : n, (numeric) The services offered by the node "time" : xxx, (numeric) The UNIX epoch time when the node was last seen "source" : "str", (string) The address that relayed the address to us "source_network" : "str" (string) The network (ipv4, ipv6, onion, i2p, cjdns) of the source address }, ... }, ... } Examples: > bitcoin-cli getrawaddrman > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getrawaddrman", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/ ``` ACKs for top commit: willcl-ark: reACK 352d5eb amitiuttarwar: reACK 352d5eb stratospher: reACK 352d5eb. achow101: ACK 352d5eb Tree-SHA512: cc462666b5c709617c66b0e3e9a17c4c81e9e295f91bdd9572492d1cb6466fc9b6d48ee805ebe82f9f16010798370effe5c8f4db15065b8c7c0d8637675d615e
e6e444c refactor: add and use EnsureAnyAddrman in rpc (stratospher) bf589a5 doc: add release notes for #27511 (stratospher) 3931e6a rpc: `getaddrmaninfo` followups (stratospher) Pull request description: - make `getaddrmaninfo` RPC public since it's not for development purposes only and regular users might find it useful. [#26988 (comment)](#26988 (comment)) - add missing `all_networks` key to RPC help. [#27511 (comment)](#27511 (comment)) - fix clang format spacing - add and use `EnsureAddrman` in RPC code. [#27511 (comment)](#27511 (comment)) ACKs for top commit: 0xB10C: Code Review re-ACK e6e444c theStack: Code-review ACK e6e444c pablomartin4btc: tested ACK e6e444c Tree-SHA512: c14090d5c64ff15e92d252578de2437bb2ce2e1e431d6698580241a29190f0a3528ae5b013c0ddb76a9ae538507191295c37cab7fd93469941cadbde44587072
…ied table Github-Pull: bitcoin#27511 Rebased-From: c8eb8da
Github-Pull: bitcoin#27511 Rebased-From: 28bac81
implements #26907. split off from #26988 to keep RPC, CLI discussions separate.
This PR introduces a new RPC
getaddrmaninfo
which returns the count of addresses in the new/tried table of a node's addrman broken down by network type. This would be useful for users who want to see the distribution of addresses from different networks across new/tried table in the addrman.additional context from original PR