Skip to content

Conversation

@jonatack
Copy link
Member

@jonatack jonatack commented Jul 19, 2021

Update CLI -netinfo to display the getpeerinfo addr_processed, addr_rate_limited, addr_relay_enabled and relaytxes data with auto-adjusting column widths.

$ ./src/bitcoin-cli -netinfo help

  txn      Time since last novel transaction received from the peer and accepted into our mempool, in minutes
           "*" - the peer requested we not relay transactions to it (relaytxes is false)

  addrp    Total number of addresses processed, excluding those dropped due to rate limiting
           "." - we do not relay addresses to this peer (addr_relay_enabled is false)

  addrl    Total number of addresses dropped due to rate limiting

Screenshot from 2021-08-22 14-31-40

Copy link
Contributor

@lsilva01 lsilva01 left a comment

Choose a reason for hiding this comment

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

Tested ACK a5cc9e2 on mainnet on Ubuntu 20.04.

@fanquake
Copy link
Member

It looks like a5cc9e28f9e125a62168dcbe0b3484d098e56c1f should be part of 1893c907eac1e52294add6e059f192eb13702829 & ad5ea77d5dde3fb40dd4701ea0b92e445e060ef0 rather than a separate commit.

How is it determined when to add new information and/or verbosity levels? Given they are additive, it seems unsustainable to just keep adding new levels and more info.

@jonatack
Copy link
Member Author

jonatack commented Jul 20, 2021

It looks like a5cc9e2 should be part of 1893c90 & ad5ea77 rather than a separate commit.

Done!

How is it determined when to add new information and/or verbosity levels? Given they are additive, it seems unsustainable to just keep adding new levels and more info.

Right, the data provided by getpeerinfo seems to be the upper bound, and apart from the bytes sent/received objects, there are only a handful of remaining fields. My current thinking is to orient levels 1-4 to node operators, and to use level 5 for data more suited to dev/testing. Open to feedback, of course.

@jonatack
Copy link
Member Author

Combined the help into the first two commits as suggested by @fanquake and changed the help as follows: git diff a5cc9e2 a52c94c

diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 4c3cc22dfc..5a0371e3de 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -592,7 +592,7 @@ public:
         "                                  2 - Like 1 but with an address column\n"
         "                                  3 - Like 1 but with a version column\n"
         "                                  4 - Like 1 but with both address and version columns\n"
-        "                                  5 - Like 4 but with additional statistics in the peers listing (addrl, addrp)\n"
+        "                                  5 - Like 4 but with additional data for development and testing purposes\n"

Copy link
Contributor

@klementtan klementtan left a comment

Choose a reason for hiding this comment

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

Code Review and tested ACK a52c94c

image

Copy link
Contributor

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

ACK a52c94c

Tested on macOS 11.3. Tested functionality and also tested each commit one by one rebased on current master.

Notes on commits:

@RandyMcMillan
Copy link
Contributor

tACK a52c94c

macOS 11.4

Screen Shot 2021-07-21 at 10 53 52 PM


One nit:

The data repaints if it detects a window resize - but if the user uses <Command> + R to "reload" the window - the data doesn't automatically repaint. Not a huge issue. Note the macOS 11 Terminal has repurposed <Command> + R for "Allow mouse reporting" but apps like iTerm still use <Command> + R for "Reset"

Screen Shot 2021-07-21 at 11 26 56 PM

One request:

If the terminal listened for up arrows and down arrows to change data info resolution - that would be awesome.

@sipa
Copy link
Member

sipa commented Jul 22, 2021

I'm really not convinced these numbers are sufficiently important to turn into a new field, unless the expectation is that many more things will be added to it.

@jonatack jonatack force-pushed the netinfo-addr-statistics branch from a52c94c to 936d8ff Compare July 24, 2021 15:26
@jonatack
Copy link
Member Author

Thanks for the feedback everyone. Droppied the middle two commits; punting on adding a new level until or if there's a clearer need.

Diff: git range-diff 2b5563b a52c94c 936d8ff

@jonatack jonatack changed the title cli: add new address statistics to -netinfo cli: add getpeerinfo addr_{processed, rate_limited} data to -netinfo Jul 24, 2021
@klementtan
Copy link
Contributor

code review and tested reACK 936d8ff49beeac5e0c77a87618e021b09d55c7a1

image

@bitcoin bitcoin deleted a comment from achirawi Jul 25, 2021
@practicalswift
Copy link
Contributor

Concept ACK

Thanks for improving this feature: -netinfo is great addition to the toolbox! :)

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

ACK 936d8ff49beeac5e0c77a87618e021b09d55c7a1

Copy link
Contributor

@Zero-1729 Zero-1729 left a comment

Choose a reason for hiding this comment

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

tACK 936d8ff49beeac5e0c77a87618e021b09d55c7a1

Tested on macOS v11.4

Screenshot 2021-07-27 at 19 03 50

Minor code review nit: agree with @vasild regarding printing 0 instead of an empty string for addr_rate_limited. Below is the output with his code change suggestion:

Screenshot 2021-07-27 at 18 55 59

@jonatack
Copy link
Member Author

Thanks @Zero-1729! A propos displaying zeroes, see #22501 (comment).

@jarolrod
Copy link
Contributor

tACK 936d8ff49beeac5e0c77a87618e021b09d55c7a1

@jonatack jonatack force-pushed the netinfo-addr-statistics branch from 936d8ff to 1df9552 Compare August 10, 2021 10:29
@jonatack
Copy link
Member Author

jonatack commented Aug 10, 2021

Thanks @klementtan, @vasild, @Zero-1729 and @jarolrod for the ACKs!

I've pushed an update for these reasons:

  • to indicate peers that requested we not relay transactions, i.e. relaytxes is false
  • to indicate peers we don't relay addresses to, i.e. addr_relay_enabled is false (this is a new getpeerinfo field and required rebasing here)
  • added null checking on these new nodestatestats addr fields to avoid UniValue JSON parsing errors
  • inversed the order of the addrp and addrl columns and moved them to the left of the age column, so that age is next to id
  • updated the PR title and description

@jonatack jonatack changed the title cli: add getpeerinfo addr_{processed, rate_limited} data to -netinfo netinfo: display addr_{processed, rate_limited, relay_enabled} and relaytxes data Aug 10, 2021
Copy link
Contributor

@Zero-1729 Zero-1729 left a comment

Choose a reason for hiding this comment

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

re-tACK 1df9552

Tested on macOS v11.4

936d8ff -> 1df9552, clean update (still works as expected) 🧉

Updated docs look good:

Note: left a minor nit regarding txn.

$ src/bitcoin-cli -netinfo help
...
  txn      Time since last novel transaction received from the peer and accepted into our mempool, in minutes
           "." - the peer requested we not relay transactions to it (relaytxes is false)
  blk      Time since last novel block passing initial validity checks received from the peer, in minutes
  hb       High-bandwidth BIP152 compact block relay
           "." (to)   - we selected the peer as a high-bandwidth peer
           "*" (from) - the peer selected us as a high-bandwidth peer
  addrp    Total number of addresses processed, excluding those dropped due to rate limiting
           "." - we do not relay addresses to this peer (addr_relay_enabled is false)
  addrl    Total number of addresses dropped due to rate limiting
...

Personally love the new column arrangement; processed addresses (addrp) before rate-limit-dropped ones (addrl), followed by age before id:

Screenshot 2021-08-13 at 04 01 34

i.e. peers where getpeerinfo#relaytxes is false
i.e. peers where getpeerinfo#addr_relay_enabled is false
@jonatack jonatack force-pushed the netinfo-addr-statistics branch from 1df9552 to 218862a Compare August 13, 2021 10:28
@jonatack
Copy link
Member Author

Updated per #22501 (comment) review feedback by @Zero-1729 (thanks!)

git diff 1df9552 218862a

diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index f960737bfd..718ad5dcef 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -536,7 +536,7 @@ public:
                     PingTimeToString(peer.ping),
                     peer.last_send ? ToString(m_time_now - peer.last_send) : "",
                     peer.last_recv ? ToString(m_time_now - peer.last_recv) : "",
-                    peer.last_trxn ? ToString((m_time_now - peer.last_trxn) / 60) : peer.is_block_relay ? "." : "",
+                    peer.last_trxn ? ToString((m_time_now - peer.last_trxn) / 60) : peer.is_block_relay ? "*" : "",
                     peer.last_blck ? ToString((m_time_now - peer.last_blck) / 60) : "",
                     strprintf("%s%s", peer.is_bip152_hb_to ? "." : " ", peer.is_bip152_hb_from ? "*" : " "),
                     m_max_addr_processed_length, // variable spacing
@@ -627,7 +627,7 @@ public:
         "  send     Time since last message sent to the peer, in seconds\n"
         "  recv     Time since last message received from the peer, in seconds\n"
         "  txn      Time since last novel transaction received from the peer and accepted into our mempool, in minutes\n"
-        "           \".\" - the peer requested we not relay transactions to it (relaytxes is false)\n"
+        "           \"*\" - the peer requested we not relay transactions to it (relaytxes is false)\n"
         "  blk      Time since last novel block passing initial validity checks received from the peer, in minutes\n"
         "  hb       High-bandwidth BIP152 compact block relay\n"
         "           \".\" (to)   - we selected the peer as a high-bandwidth peer\n"

Copy link
Contributor

@Zero-1729 Zero-1729 left a comment

Choose a reason for hiding this comment

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

re-tACK 218862a

Tested on macOS v11.4

1df9552 -> 218862a, clean update 🧼 (LGTM)

Screenshot 2021-08-13 at 12 05 26

@klementtan
Copy link
Contributor

re crAck and tAck 218862a
image

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

ACK 218862a

@jonatack
Copy link
Member Author

Thanks for all the reviews! I updated the PR description with a current screenshot. One peer seems to be spamming addresses a bit:

<->   type   net  mping   ping send recv  txn  blk  hb addrp addrl  age  asmap   id address                                                             version
out   full  ipv4    204    214    0    0    0          14958 31870 2334   6830  296 178.200.242.132:8333                                                70016/Satoshi:0.21.1/

Copy link
Contributor

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

tACK 218862a

tested on Ubuntu 20.04 and macOS 12. PR works nicely.

A note on 0a9ee3a: While not necessary for the goals of this PR; the usage of the conditional operator and reordering of the logic is a welcome simplification, it's certainly neater.

@jonatack
Copy link
Member Author

This has many ACKs, seems ready for merge?

@0xB10C
Copy link
Contributor

0xB10C commented Aug 30, 2021

Code review and tested ACK 218862a

@jonatack jonatack mentioned this pull request Aug 31, 2021
@sipa
Copy link
Member

sipa commented Sep 2, 2021

Concept ACK

@laanwj laanwj merged commit a70768d into bitcoin:master Sep 2, 2021
@jonatack jonatack deleted the netinfo-addr-statistics branch September 2, 2021 15:21
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 4, 2021
…relay_enabled} and relaytxes data

218862a Display peers in -netinfo that we don't relay addresses to (Jon Atack)
3834e23 Display peers in -netinfo that request we not relay transactions (Jon Atack)
0a9ee3a Simplify a few conditionals in -netinfo (Jon Atack)
5eeea8e Add addr_processed and addr_rate_limited stats to -netinfo (Jon Atack)

Pull request description:

  Update CLI -netinfo to display the getpeerinfo `addr_processed`, `addr_rate_limited`, `addr_relay_enabled` and `relaytxes` data with auto-adjusting column widths.

  ```
  $ ./src/bitcoin-cli -netinfo help

    txn      Time since last novel transaction received from the peer and accepted into our mempool, in minutes
             "*" - the peer requested we not relay transactions to it (relaytxes is false)

    addrp    Total number of addresses processed, excluding those dropped due to rate limiting
             "." - we do not relay addresses to this peer (addr_relay_enabled is false)

    addrl    Total number of addresses dropped due to rate limiting
  ```

  ![Screenshot from 2021-08-22 14-31-40](https://user-images.githubusercontent.com/2415484/130355514-f6fd4f21-79d6-463b-9791-de01ebef20b1.png)

ACKs for top commit:
  0xB10C:
    Code review and tested ACK 218862a
  Zero-1729:
    re-tACK 218862a
  vasild:
    ACK 218862a
  jarolrod:
    tACK 218862a

Tree-SHA512: bb9da4bdd71859b234f6e4c2c46257a57ef0d0e0b363d2b8fded128bcaa28132f64a0a4651c622e1de1e3b7c05c7587a4369e9e79799895884fda9745c63409d
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.