Skip to content
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

net, rpc: expose high bandwidth mode state via getpeerinfo #19776

Conversation

theStack
Copy link
Contributor

@theStack theStack commented Aug 21, 2020

Fixes #19676, "For every peer expose through getpeerinfo RPC whether or not we selected them as HB peers, and whether or not they selected us as HB peers." See BIP152, in particular the protocol flow diagram. The newly introduced states are changed on the following places in the code:

  • on reception of a SENDCMPCT message with valid version, the field m_highbandwidth_from is changed depending on the first integer parameter in the message (1=high bandwidth, 0=low bandwidth), i.e. it just mirrors the field CNodeState.fPreferHeaderAndIDs.
  • after adding a SENDCMPCT message to the send queue, the field m_highbandwidth_to is changed depending on how the first integer parameter is set (same as above)

Note that after receiving VERACK, the node also sends SENDCMPCT, but that is only to announce the preferred version and never selects high-bandwidth mode, hence there is no need to change the state variables there, which are initialized to false anyways.

@jonatack
Copy link
Contributor

jonatack commented Aug 21, 2020

Concept/approach ACK, could add test coverage and release note (see #19731 for an example).

@theStack
Copy link
Contributor Author

Thanks for reviewing @jonatack! Added a release note, will add a functional test for this within the next days.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 21, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, 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.

@theStack
Copy link
Contributor Author

Added a functional test to p2p_compactblocks.py that covers all 4 possible combinations of bandwidth_{from,to}.

@practicalswift
Copy link
Contributor

Concept ACK

Would be nice to have bitcoin-cli -netinfo t expose this info in the future :)

@jonatack
Copy link
Contributor

Would be nice to have bitcoin-cli -netinfo t expose this info in the future :)

Yes. Along with other new ones like last_transaction, last_block, conn_type.

Copy link
Contributor

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Tested and globally looks good. A few suggestions follow.

doc/release-notes-19776.md Outdated Show resolved Hide resolved
src/rpc/net.cpp Outdated Show resolved Hide resolved
test/functional/p2p_compactblocks.py Outdated Show resolved Hide resolved
src/net_processing.cpp Outdated Show resolved Hide resolved
test/functional/p2p_compactblocks.py Outdated Show resolved Hide resolved
@sipa
Copy link
Member

sipa commented Aug 24, 2020

Concept ACK.

I'd suggest putting "bip152" somewhere in the name of the field, as the concept of high bandwidth mode is very specific to that BIP (and really doesn't dramatically increase actual bandwidth, as an unqualified name may make seem).

@theStack
Copy link
Contributor Author

@sipa: Agreed that referring to the BIP in the name would make sense here.
@jonatack: Thanks for the detailled review! I plan to address all of your suggestions.

Before I take any further changes, I'd like to discuss the naming. Some suggestions:

  • bip152_highbandwidth_{from,to}
  • bip152_hb_{from,to} (shorter, but not obvious)
  • bip152_cmpctblk_announce_{from,to} (avoids the "high-bandwidth" terminology)
  • ...

Does anyone have preferrences here or any other idea? My favourite would simply be bip152_highbandwidth_{from,to} (though being quite long).

@jonatack
Copy link
Contributor

My favourite would simply be bip152_highbandwidth_{from,to}

I agree with you. Might be good to have input from @TheBlueMatt or @gmaxwell.

@instagibbs
Copy link
Member

instagibbs commented Aug 25, 2020

bip152_highbandwidth_{from,to}
bip152_hb_{from,to} (shorter, but not obvious)

These seems fine, hb is shorter so I prefer. Anyone who is using this stuff should be familiar with the BIP and if not read it anyways.

@naumenkogs
Copy link
Member

Concept ACK.

@theStack
Copy link
Contributor Author

theStack commented Aug 26, 2020

// EDIT: Before there was a "rebased" comment there that was not accurate, I confused with another PR 🤦‍♂️
Will still wait a bit for more naming opinions before tackling review suggestions.

Currently bip152_bandwidth_{from,to} (preferred by 2, jonatack and my humble self) is favoured over bip152_bh_{from,to} (preferred by 1, instagibbs).

@theStack theStack force-pushed the 20200821-rpc-expose-high-handwidth-mode-state-via-getpeerinfo branch from edb4ad4 to a286f89 Compare August 27, 2020 22:35
@theStack
Copy link
Contributor Author

Decided for the name bip152_highbandwidth_{to,from} for now (both for the exposed RPC result fields and the internal variable names) and force-pushed with most of the suggestions from jonatack.

@gmaxwell
Copy link
Contributor

The patch I carry locally for this calls it

  •        obj.pushKV("bip152_hb", 
    

but I don't think it matter other than it should mention BIP152.

Copy link
Contributor

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK a286f89

Happy to re-review if you opt for the shorter naming.

src/rpc/net.cpp Outdated Show resolved Hide resolved
doc/release-notes-19776.md Outdated Show resolved Hide resolved
@theStack theStack force-pushed the 20200821-rpc-expose-high-handwidth-mode-state-via-getpeerinfo branch from a286f89 to bff461c Compare September 3, 2020 08:32
@theStack
Copy link
Contributor Author

theStack commented Sep 3, 2020

Now that three people voted for the short version (instagibbs, jonatack, and indirectly also gmaxwell), I changed the RPC result fields to bip152_hb_{to,from}. The internal state variable names in CNode{Stats} are still kept in the long version though.

Copy link
Contributor

@jonatack jonatack 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 ACK bff461c per git diff a286f89 bff461c

maflcko pushed a commit that referenced this pull request Sep 20, 2020
6384419 test: add parameterized constructor for msg_sendcmpct() (Sebastian Falbesoner)

Pull request description:

  While working on the test for #19776 I noticed that creating a `sendcmpct` message is quite cumbersome -- due to the lack of a parameterized constructor, one needs to create an empty (that is, initialized with default values) object and then set the two fields one by one. This PR replaces the default constructor with a parameterized constructor and uses it in the test `p2p_compactblocks.py`, reducing LOC. No need to pollute the namespace with temporary throw-away message objects anymore.

ACKs for top commit:
  guggero:
    Code review ACK 6384419.
  epson121:
    Code review ACK 6384419

Tree-SHA512: 3b58d276d714b73abc6cc98d1d52dec5f6026b33f03faaeb7dcbc5d83ac377555179f98b159b2b9ecc8957999c35a1dc082e3c69299c5fde4e35f1bd0587ce9d
@theStack theStack force-pushed the 20200821-rpc-expose-high-handwidth-mode-state-via-getpeerinfo branch from bff461c to bc8cc02 Compare September 20, 2020 09:51
@theStack
Copy link
Contributor Author

Rebased on master and shortened the test by using the parameterized ctor for msg_sendcmpct, now that #19781 has been merged.

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 21, 2020
…cmpct()

6384419 test: add parameterized constructor for msg_sendcmpct() (Sebastian Falbesoner)

Pull request description:

  While working on the test for bitcoin#19776 I noticed that creating a `sendcmpct` message is quite cumbersome -- due to the lack of a parameterized constructor, one needs to create an empty (that is, initialized with default values) object and then set the two fields one by one. This PR replaces the default constructor with a parameterized constructor and uses it in the test `p2p_compactblocks.py`, reducing LOC. No need to pollute the namespace with temporary throw-away message objects anymore.

ACKs for top commit:
  guggero:
    Code review ACK 6384419.
  epson121:
    Code review ACK 6384419

Tree-SHA512: 3b58d276d714b73abc6cc98d1d52dec5f6026b33f03faaeb7dcbc5d83ac377555179f98b159b2b9ecc8957999c35a1dc082e3c69299c5fde4e35f1bd0587ce9d
@naumenkogs
Copy link
Member

Code review ACK bc8cc02

@theStack theStack force-pushed the 20200821-rpc-expose-high-handwidth-mode-state-via-getpeerinfo branch from bc8cc02 to 4df1d12 Compare September 21, 2020 23:28
@theStack
Copy link
Contributor Author

Rebased on master (was needed after the recent merge of #17785). Thanks a lot for reviewing, jonatack and naumenkogs!

@naumenkogs
Copy link
Member

reACK 4df1d12

@jonatack
Copy link
Contributor

Code review re-ACK 4df1d12 per git range-diff 7737603 bc8cc02 4df1d12

src/net.h Outdated Show resolved Hide resolved
@theStack theStack force-pushed the 20200821-rpc-expose-high-handwidth-mode-state-via-getpeerinfo branch from 4df1d12 to 343dc47 Compare September 28, 2020 22:55
@theStack
Copy link
Contributor Author

Rebased on master, changed the data type of the introduced high-bandwidth flags CNode::m_bip152_highbandwidth_{to,from} to atomic bools (see discussion #19776 (comment)) and fixed typos in the comments (s/sendcmpt/sendcmpct/).

@naumenkogs
Copy link
Member

reACK 343dc47

@jonatack
Copy link
Contributor

re-ACK 343dc47 per git range-diff 7ea6499 4df1d12 343dc47

@theStack
Copy link
Contributor Author

Since there hasn't been any activity for more than three weeks: is there anything else I can do for this PR? It has two ACKs (jonatack, naumenkogs) and two Concept ACKs (sipa, practicalswift), I think it should be ready for merge.

@jonatack
Copy link
Contributor

jonatack commented Oct 21, 2020

I reckon it's not a reflection on this PR (which seems good AFAICS), just that attention has been focused on reviewing key features before the feature freeze October 15 and now on fixing bugs before branch-off. After branch-off, I'm guessing that features in waiting like this one will see renewed attention (if not before).

@maflcko maflcko added this to the 0.22.0 milestone Oct 21, 2020
@maflcko
Copy link
Member

maflcko commented Oct 21, 2020

Looks like this has missed the feature freeze. Can be merged after Nov 1st

@maflcko maflcko merged commit 22f13c1 into bitcoin:master Dec 10, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 10, 2020
…etpeerinfo

343dc47 test: add test for high-bandwidth mode states in getpeerinfo (Sebastian Falbesoner)
dab6583 doc: release note for new getpeerinfo fields "bip152_hb_{from,to}" (Sebastian Falbesoner)
a7ed00f rpc: expose high-bandwidth mode states via getpeerinfo (Sebastian Falbesoner)
30bc8fa net: save high-bandwidth mode states in CNodeStats (Sebastian Falbesoner)

Pull request description:

  Fixes bitcoin#19676, "_For every peer expose through getpeerinfo RPC whether or not we selected them as HB peers, and whether or not they selected us as HB peers._" See [BIP152](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki), in particular the [protocol flow diagram](https://github.com/bitcoin/bips/raw/master/bip-0152/protocol-flow.png).  The newly introduced states are changed on the following places in the code:
  * on reception of a `SENDCMPCT` message with valid version, the field `m_highbandwidth_from` is changed depending on the first integer parameter in the message (1=high bandwidth, 0=low bandwidth), i.e. it just mirrors the field `CNodeState.fPreferHeaderAndIDs`.
  * after adding a `SENDCMPCT` message to the send queue, the field `m_highbandwidth_to` is changed depending on how the first integer parameter is set (same as above)

  Note that after receiving `VERACK`, the node also sends `SENDCMPCT`, but that is only to announce the preferred version and never selects high-bandwidth mode, hence there is no need to change the state variables there, which are initialized to `false` anyways.

ACKs for top commit:
  naumenkogs:
    reACK 343dc47
  jonatack:
    re-ACK 343dc47 per `git range-diff 7ea6499 4df1d12 343dc47`

Tree-SHA512: f4999e6a935266812c2259a9b5dc459710037d3c9e938006d282557cc225e56128f72965faffb207fc60c6531fab1206db976dd8729a69e8ca29d4835317b99f
@jonatack jonatack mentioned this pull request Jan 2, 2021
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Feb 3, 2022
Summary:
> net: save high-bandwidth mode states in CNodeStats

> rpc: expose high-bandwidth mode states via getpeerinfo

> doc: release note for new getpeerinfo fields "bip152_hb_{from,to}"

> test: add test for high-bandwidth mode states in getpeerinfo

This is a backport of [[bitcoin/bitcoin#19776 | core#19776]]
Depends on D10961

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10962
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 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.

Expose compact blocks high-bandwidth mode state through getpeerinfo
9 participants