Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Sep 22, 2020

This PR:

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 23, 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.

@practicalswift
Copy link
Contributor

Concept ACK

Nice! :)

@laanwj
Copy link
Member

laanwj commented Sep 23, 2020

Concept ACK

What about a multiple-choice option that more generally specifies the network that the connection (comes in/goes out) through, instead of specializing it for Tor? Might want to have the same for I2P later, for example.

Also this should be 'onion' to be consistent with our other uses.

@hebasto
Copy link
Member Author

hebasto commented Sep 23, 2020

@laanwj

What about a multiple-choice option that more generally specifies the network that the connection (comes in/goes out) through, instead of specializing it for Tor? Might want to have the same for I2P later, for example.

Do I understand you correctly that smth following is expected:

$ src/bitcoin-cli help getpeerinfo | grep network_type
    "network_type" : clearnet|onion|I2P,        Type of the network the peer has connected via

?

@naumenkogs
Copy link
Member

Concept ACK.
I agree with wladimir's suggestions.
@hebasto I think your understanding is correct.

@jonatack
Copy link
Member

Concept ACK

What about a multiple-choice option that more generally specifies the network that the connection (comes in/goes out) through, instead of specializing it for Tor? Might want to have the same for I2P later, for example.

Also this should be 'onion' to be consistent with our other uses.

This was the goal in #20002, which exposes the GetNetClass() index (allowing for a significant code simplification in -netinfo). Feedback welcome if it should also expose the network class name.

@hebasto
Copy link
Member Author

hebasto commented Sep 23, 2020

@jonatack

This was the goal in #20002, which exposes the GetNetClass() index (allowing for a significant code simplification in -netinfo). Feedback welcome if it should also expose the network class name.

What about limiting this PR to introducing CNode::GetNetClass() in addition to CNetAddr::GetNetClass() as the latter does not work for inbound connections via Tor?

Or just drop the last commit in favor of #20002 (if CNode::ConnectedViaTor() logic is sufficient)?

@jonatack
Copy link
Member

jonatack commented Sep 23, 2020

@hebasto after chatting offline, that makes sense, will look at building on your commit "net: Add CNode::ConnectedViaTor() member function".

Concept ACK in any case, will test your inbound onions detection.

@hebasto
Copy link
Member Author

hebasto commented Sep 23, 2020

Updated fcd938e -> 911a3f9 (pr19998.02 -> pr19998.03, diff):

@laanwj @naumenkogs RPC part has been moved to #20002 now.

@hebasto hebasto changed the title rpc: Add via_tor to getpeerinfo output Net: Add CNode::ConnectedViaTor() Sep 23, 2020
@Sjors
Copy link
Member

Sjors commented Oct 1, 2020

utACK c972792

This will be easier to test after #20002 is refreshed (don't forget to mention it in the description)

The asmap test failure on macOS Travis seems spurious (it passes on my machine)

@hebasto
Copy link
Member Author

hebasto commented Oct 2, 2020

Updated c972792 -> ac0f497 (pr19998.07 -> pr19998.08) due to the conflict with #19991.

@jonatack
Copy link
Member

jonatack commented Oct 2, 2020

Do you plan to add test coverage for the changes here (and in #19991?)

@hebasto
Copy link
Member Author

hebasto commented Oct 2, 2020

@jonatack

Do you plan to add test coverage for the changes here (and in #19991?)

I thought your tests could cover all aspects, right?

@jonatack
Copy link
Member

jonatack commented Oct 2, 2020

@hebasto I don't plan to open a PR just for follow-up tests. I think it's easiest when the coverage accompanies the changes.

@jonatack
Copy link
Member

jonatack commented Oct 2, 2020

Starting to see inbound onions while testing this on #20002 (Edit: WIP update now pushed if anyone wants to use it for testing).

<-> relay   net mping   ping send recv  txn  blk uptime  asmap  id address
 in  full onion   358    469    0   90               49         35 127.0.0.1:43064
 in block onion   450    722   29  104               35         66 127.0.0.1:45118

The updated function here is easy to use, too.

stats.m_network = GetNetworkName(ConnectedThroughNetwork());

@hebasto
Copy link
Member Author

hebasto commented Oct 3, 2020

Added test coverage.

Copy link
Member

@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, I've been testing this with #20002 and also rebased on #19954 (it's thankfully a clean merge) and it seems to be working. A few optional comments below. It may be good to update fuzz/netaddress.cpp (or other fuzzers, I didn't look further) with ConnectedThroughNetwork() and add unit or functional tests for the new -bind functionality. I did add some testing in #20002 for the values returned by ConnectedThroughNetwork(). Edit: reviewing the new push!

Copy link
Member

@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. The new unit tests are green for me locally. Not sure what's up with the travis linter.

@hebasto
Copy link
Member Author

hebasto commented Oct 3, 2020

Updated 5fc8f15 -> 3989fcf (pr19998.10 -> pr19998.11):

Copy link
Member

@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 3989fcf

@hebasto
Copy link
Member Author

hebasto commented Oct 3, 2020

Updated 3989fcf -> 3984b78 (pr19998.11 -> pr19998.12, diff):

@jonatack
Copy link
Member

jonatack commented Oct 3, 2020

Thanks for your patience with the suggestions.

re-ACK 3984b78 per git diff 3989fcf 3984b78c

Edit: testing with #20002 (inbound onions detected server-side) vs on master (inbound onions detected client-side), I'm seeing the same ones detected.

@laanwj
Copy link
Member

laanwj commented Oct 12, 2020

Code review ACK 3984b78
Thanks for addressing my suggestion. And making CNode::ConnectedThroughNetwork() return a Network enum directly is a nice touch.

@laanwj laanwj merged commit f79a4a8 into bitcoin:master Oct 12, 2020
@hebasto hebasto deleted the 200922-istor branch October 12, 2020 16:45
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 13, 2020
…unction

3984b78 test: Add tests for CNode::ConnectedThroughNetwork (Hennadii Stepanov)
49fba9c net: Add CNode::ConnectedThroughNetwork member function (Hennadii Stepanov)
d4dde24 net: Add CNode::m_inbound_onion data member (Hennadii Stepanov)

Pull request description:

  This PR:
  - adds `CNode::ConnectedThroughNetwork` member function
  - is based on bitcoin#19991, and only last two commits belong to it
  - is required for bitcoin-core/gui#86 and bitcoin#20002

ACKs for top commit:
  jonatack:
    re-ACK 3984b78 per `git diff 3989fcf 3984b78`
  laanwj:
    Code review ACK 3984b78

Tree-SHA512: 23a9c8bca8dca75113b5505fe443b294f2d42d03c98c7e34919da12d8396beb8d0ada3a58ae16e3da04b7044395f72cf9c216625afc078256cd6c897ac42bf3d
laanwj added a commit that referenced this pull request Oct 15, 2020
…lify/improve -netinfo

6272604 refactor: enable -netinfo to add future networks (i2p, cjdns) (Jon Atack)
82fd402 refactor: promote some -netinfo localvars to class members (Jon Atack)
5133fab cli: simplify -netinfo using getpeerinfo network field (Jon Atack)
4938a10 rpc, test: expose CNodeStats network in RPC getpeerinfo (Jon Atack)
6df7882 net: add peer network to CNodeStats (Jon Atack)

Pull request description:

  This PR:

  - builds on #19991 and #19998
  - exposes peer networks via a new getpeerinfo `network` field ("ipv4", "ipv6", or "onion"), and adds functional tests
  - updates -netinfo to use getpeerinfo `network` rather than detecting the peer networks client-side
  - refactors -netinfo to easily add future networks

ACKs for top commit:
  laanwj:
    ACK 6272604

Tree-SHA512: 28883487585135ceaaf84ce09131f2336e3193407f2e3df0960e3f4ac340f500ab94ffecb9d06a4c49bc05e3cca4f914ea4379860bea0bd5df2f834f74616015
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 16, 2020
…o; simplify/improve -netinfo

6272604 refactor: enable -netinfo to add future networks (i2p, cjdns) (Jon Atack)
82fd402 refactor: promote some -netinfo localvars to class members (Jon Atack)
5133fab cli: simplify -netinfo using getpeerinfo network field (Jon Atack)
4938a10 rpc, test: expose CNodeStats network in RPC getpeerinfo (Jon Atack)
6df7882 net: add peer network to CNodeStats (Jon Atack)

Pull request description:

  This PR:

  - builds on bitcoin#19991 and bitcoin#19998
  - exposes peer networks via a new getpeerinfo `network` field ("ipv4", "ipv6", or "onion"), and adds functional tests
  - updates -netinfo to use getpeerinfo `network` rather than detecting the peer networks client-side
  - refactors -netinfo to easily add future networks

ACKs for top commit:
  laanwj:
    ACK 6272604

Tree-SHA512: 28883487585135ceaaf84ce09131f2336e3193407f2e3df0960e3f4ac340f500ab94ffecb9d06a4c49bc05e3cca4f914ea4379860bea0bd5df2f834f74616015
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 12, 2021
Summary:
This is a backport of [[bitcoin/bitcoin#19998 | core#19998]] [1/3]
bitcoin/bitcoin@d4dde24

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D10456
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 12, 2021
Summary:
This is a backport of [[bitcoin/bitcoin#19998 | core#19998]] [2/3]
bitcoin/bitcoin@49fba9c

Depends on D10456

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D10457
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 12, 2021
Summary:
Note: I didn't backport the inline comments for argument names, because I don't think it is an improvement (my IDE already show the parameter names for literal parameters) and it will not help avoiding future merge conflicts (coding style incompatible with our linter and different signature for the `CNode`  constructor)

This is a backport of [[bitcoin/bitcoin#19998 | core#19998]] [3/3]
bitcoin/bitcoin@3984b78

Depends on D10457

Test Plan: `ninja check`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D10458
@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.

7 participants