Add -netinfo peer connections dashboard - #19643
Conversation
|
@sumBTC you might find this useful--I've been using it to observe your issue #19500. |
|
@jonatack Ah was wondering what you were using. Nice to know this kind of information will soon be part of bitcoin-cli. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
|
Concept ACK. Especially on the detailed peers listing as |
|
Wow, this is really neat! As a pure terminal user I love the Concept ACK |
0xB10C
left a comment
There was a problem hiding this comment.
Ran unit tests and the extend functional tests.
Mainly played around with the verbose mode on testnet without inbound peers. Works great with watch!
Did not see anything in the asmap column. Guess that's due to me not using the asmap feature.
Tested the bitcoin-cli build from this PR with -netinfo 1 on a v0.20.0 Bitcoin Core node and they seem to be compatible. That's super awesome!
jnewbery
left a comment
There was a problem hiding this comment.
Concept ACK. This is very cool. I'd normally be against adding this kind of functionality to bitcoin-cli for reasons of scope creep and bloat, but this seems really useful, and it's very neatly encapsulated in the NetinfoRequestHandler class. I'm looking forward to playing around with it.
hebasto
left a comment
There was a problem hiding this comment.
Concept ACK, but not sure about min ping data usefulness though.
Thanks for having a look. |
Great! |
|
Concept and functionality ACK |
|
Concept ACK 👍 |
d64d4fc to
c456ffe
Compare
|
Took most all of the feedback and also added |
Updated to not display the |
e64170b to
f0ff7cb
Compare
|
Further updates, per
|
|
Tested ACK 8587e78221492ee26aafbbc332453f7639912a41 -- patch looks correct and is limited to |
|
Awesome stuff @jonatack - I was wondering if it would be possible to add some flags to make it automatically report after each new block (or some other arbitrary time interval) - the idea would be to generate a report that could be easily read into another service such as statsd. Thanks! |
I've been using
I wouldn't use the |
|
@0xB10C thanks, I couldn't have said it better. Edit: added your If we want this in the next release (and feature freeze isn't far away now), it's probably best to stabilize this PR on what we have now. It has gone through several rounds of review with lots of good feedback and updates. I'd propose to try to have this merged in its current state and consider further changes (e.g. possible future |
|
ACK bf1f913 -- patch looks correct and is limited to |
| const UniValue& getpeerinfo{batch[ID_PEERINFO]["result"]}; | ||
|
|
||
| for (const UniValue& peer : getpeerinfo.getValues()) { | ||
| const std::string addr{peer["addr"].get_str()}; |
There was a problem hiding this comment.
peer["addr"] can also contain hostnames (bitcoin-cli addnode "foo.bar" onetry) or IPv6 addresses without square brackets (bitcoin-cli addnode "2001:db8::1337" onetry). In theses cases the IsAddrIPv6 will not recognize them properly and they will be always marked as IPv4 🤔.
There was a problem hiding this comment.
Maybe, if there are no square brackets, ask inet_pton if it´s a valid IPv6 address? But what if there´s a hostname?
There was a problem hiding this comment.
Dug a little bit deeper: Adding a new field to getpeerinfo seems to be a better solution IMO. The actual remote address (that is IPv6 with square brackets or resolved hostname) is already stored here, but only addrName is passed back as addr instead.
I would suggest to return both addrName & addr so that the former contains the hostname (or ordinary IP address) and the latter the actual resolved remote address. This would at least solve the hostname/IPv6 problems, not sure how that effects onion addresses. Let me know what you think and if I should prepare a PR :)
There was a problem hiding this comment.
@n-thumann Thanks for having a look. I don't plan to make further changes for edge cases unless they can be addressed within the scope of this PR (but am willing to update if they can be!)
The net address code is currently being deeply changed for BIP155 addrv2. This PR has seen a lot of review and updates, and if we begin gating it on changes in code outside this PR, we'll risk missing the next feature freeze (October 15 deadline for merge). I think this is very useable in its current state--if you start using it, good luck doing without it afterward 😃--and if merged, I'll be happy to make further improvements based on the state of the codebase at that time.
|
ACK bf1f913 I tested with a testnet node having connections both via clearnet and tor. nit: I think |
|
@0xB10C thanks! |
|
I think this Thanks @jonatack for coming up with this nifty utility. I'm using it daily! Looking forward to being able to use it directly from |
|
Concept ACK, haven't reviewed/tested at all, but this might come in handy when testing pull requests on the live network. bitcoin-cli isn't a stable interface, so we can change or remove this at will if issues come up in the future. |
|
fwiw: ce57bf6 (leaving out the last three commits) can be used with edit: |
Next steps checklistEasy, do in next commit (done in #20115):
Medium term:
|
@practicalswift I'm still seeing these (both mping and ping), so added it to the checklist above. |
|
I've been using this to test another PR and it's very helpful. Thanks @jonatack ! One thing I've noticed is that connections are inaccurately classified as blocks-only on first connection, I think because all connections start out as |
|
Here's a branch with some of the updates, including using the connection type: |
398045b cli -netinfo: print oversized/extreme ping times as "-" (Jon Atack) 773f4c9 cli -netinfo: handle longer tor v3 local addresses (Jon Atack) 33e9874 cli -netinfo: make age column variable-width (Jon Atack) f8a1c4d cli -netinfo: various quick updates and fixes (Jon Atack) Pull request description: Quick fixups and updates for v0.21.0: - [x] handle larger BIP155 `addrv2` addresses - [x] add Signet chain - [x] add an additional space between the `net` and `mping` columns; add missing `tinyformat` and `algorithm` headers - [x] s/uptime/age/ per 0xB10C suggestion, and make the column auto-adjusting variable width - [x] display `-` for oversized mping/ping times like `1.17348e+06`, as reported by practicalswift Edit: removed the release note commit, as this PR was not merged before the notes were moved to the wiki. It's here: ``` - A new `bitcoin-cli -netinfo` command returns a network peer connections dashboard that displays data from the `getpeerinfo` and `getnetworkinfo` RPCs in a human-readable format. An optional integer argument from `0` to `4` may be passed to see various levels of detail. (#19643) ``` ACKs for top commit: michaelfolkson: ACK 398045b Emzy: Tested ACK 398045b Tree-SHA512: 0625ee840141bafbfcaf8f1fce53f8f850ae91721b2bdad4279372da87c18a1fe3a214d90bfdbbabdf6da38d58290d7dd0f1109b4e2ca5d20cacf417d6ced0f9
Summary:
```
This PR is inspired by laanwj's python script mentioned in #19405, which
it turns out I ended up using every day and extending because I got
hooked on using it to monitor Bitcoin peer connections.
For the full experience, run ./src/bitcoin-cli -netinfo 4
On Linux, try it with watch watch ./src/bitcoin-cli -netinfo 4
Help doc
$ ./src/bitcoin-cli -help | grep -A3 netinfo
-netinfo
Get network peer connection information from the remote server.
An
optional integer argument from 0 to 4 can be passed for different
peers listings (default: 0).
```
Backport of [[bitcoin/bitcoin#19643 | core#19643]].
Depends on D9331 and D9333.
Test Plan:
watch ./src/bitcoin-cli -netinfo 4
Reviewers: #bitcoin_abc, majcosta
Reviewed By: #bitcoin_abc, majcosta
Differential Revision: https://reviews.bitcoinabc.org/D9334
This PR is inspired by laanwj's python script mentioned in #19405, which it turns out I ended up using every day and extending because I got hooked on using it to monitor Bitcoin peer connections.
For the full experience, run
./src/bitcoin-cli -netinfo 4On Linux, try it with watch
watch ./src/bitcoin-cli -netinfo 4Help doc