This is a non-gui part of adding Tor icon to the GUI.
Split from https://github.com/bitcoin-core/gui/pull/86 as requested:
Also, the RPC and net changes are not gui related, so should go into the main repo
The first approach was in #19926.
This is a non-gui part of adding Tor icon to the GUI.
Split from https://github.com/bitcoin-core/gui/pull/86 as requested:
Also, the RPC and net changes are not gui related, so should go into the main repo
The first approach was in #19926.
The commits moved from https://github.com/bitcoin-core/gui/pull/86 already have two ACKs:
Code review ACK https://github.com/bitcoin-core/gui/commit/6549abcb072d73e0ac91c7992cc5d86eb4064b70 (node changes only. Did not fully review qt changes)
tACK https://github.com/bitcoin-core/gui/commit/6549abcb072d73e0ac91c7992cc5d86eb4064b70 with notes for followup
532@@ -533,10 +533,11 @@ static RPCHelpMan getnetworkinfo()
533 }},
534 {RPCResult::Type::BOOL, "localrelay", "true if transaction relay is requested from peers"},
535 {RPCResult::Type::NUM, "timeoffset", "the time offset"},
536+ {RPCResult::Type::BOOL, "networkactive", "whether p2p networking is enabled"},
537 {RPCResult::Type::NUM, "connections", "the total number of connections"},
538 {RPCResult::Type::NUM, "connections_in", "the number of inbound connections"},
539 {RPCResult::Type::NUM, "connections_out", "the number of outbound connections"},
540- {RPCResult::Type::BOOL, "networkactive", "whether p2p networking is enabled"},
541+ {RPCResult::Type::BOOL, "connections_onion_only", "whether all connection are through the onion network"},
195+ }
196+
197+ ConnCounts(int num_in, int num_out, bool is_onion_only)
198+ : all(num_in + num_out), in(num_in), out(num_out), onion_only(is_onion_only)
199+ {
200+ }
{}
. It looks like this is clang-format output, but ISTM this particular formatting is ugly, wastes space, and isn’t followed in the new code additions we see while reviewing. Maybe others disagree :man_shrugging:
Approach ACK, only skimmed the code so far but the changes look good. Needs test coverage for the new getnetworkinfo
“connections_onion_only” field. Debug build is clean and I did some quick manual testing. The counts fields contain the correct values. With mixed peers:
0 "connections_onion_only": false,
With only onion peers:
0 "connections_onion_only": true,
RPC help:
0 "connections_onion_only" : true|false, (boolean) whether all connection are through the onion network
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
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.
Concept ACK.
Agree that a functional test for connections_onion_only
would be good, but not sure how easy it is. You could spin up two test nodes, 0 with default settings, 1 with -onlynet=onion
and -bind=...=onion
, and then connect node 0 to node 1 via it’s “onion” port. In that case node 1 should have connections_onion_only=true
.
Updated 174848ffb88767fe9190dd7fa160e7187dfcdc07 -> 9371757d9031ad40ca99543bb4d24fc48e00b32e (pr20172.01 -> pr20172.02, diff):
Hmm, the current pr20172.03 branch does not pass macOS 10.14 build on Travis.
The alternative pr20172.04 branch pass locally on macOS 10.15 and Linux Mint 20 (Focal codebase), but it does not pass on Travis at all.
What is the correct portable way to -bind=localhost
and -bind=localhost:port=onion
simultaneously?
UPDATE: it was such a silly error, and I’ve caught it after sleep :smiley:
Updated 9371757d9031ad40ca99543bb4d24fc48e00b32e -> d301cc5c564f8c130949567602e182917efef18e (pr20172.02 -> pr20172.06, diff):
Travis is green now!
349@@ -346,7 +350,8 @@ class CConnman
350 bool RemoveAddedNode(const std::string& node);
351 std::vector<AddedNodeInfo> GetAddedNodeInfo();
352
353- size_t GetNodeCount(NumConnections num);
354+ size_t PeerCount() { return WITH_LOCK(cs_vNodes, return vNodes.size()); }
355+ ConnCounts ConnectionCounts();
GetConnectionCounts()
?
56+ assert_equal(network_info["connections_in"], 1)
57+ assert_equal(network_info["connections_out"], 0)
58+ assert_equal(network_info["connections_onion_only"], True)
59+
60+ self.log.info("Creating an outbound onion connection, and checking...")
61+ self.nodes[0].addnode("bitcoinostk4e4re.onion:8333", "onetry")
One question and one small naming suggestion.
This PR contains qt-only changes. It shouldn’t be too difficult to separate the changes so that PRs to the main repo only contain changes to the node code, and PRs to the GUI repo only contain changes to qt code.
This PR contains qt-only changes. It shouldn’t be too difficult to separate the changes so that PRs to the main repo only contain changes to the node code, and PRs to the GUI repo only contain changes to qt code.
Clear qt-only changes are already leaved in the GUI repo. This pull contains two commits that modify signal signatures. As these signals propagate through the qt code, I do not want to break those commits in “non-qt” and “qt” parts.
45+ self.log.info("Checking a node without any peers...")
46+ network_info = self.nodes[0].getnetworkinfo()
47+ assert_equal(network_info["connections"], 0)
48+ assert_equal(network_info["connections_in"], 0)
49+ assert_equal(network_info["connections_out"], 0)
50+ assert_equal(network_info["connections_onion_only"], False)
get_connection_info()
.
60+ self.log.info("Creating an outbound onion connection, and checking...")
61+ self.nodes[0].addnode("bitcoinostk4e4re.onion:8333", "onetry")
62+ network_info = self.nodes[0].getnetworkinfo()
63+ assert_equal(network_info["connections"], 2)
64+ assert_equal(network_info["connections_in"], 1)
65+ assert_equal(network_info["connections_out"], 1)
getnetworkinfo()
again?
It creates an outbound connection to where?
To created self.proxy
.
Why does that outbound connection show up here, but is gone by the time you call
getnetworkinfo()
again?
IDK why add_p2p_connection(P2PInterface())
causes drop of the connection to the proxy.
Why does that outbound connection show up here, but is gone by the time you call
getnetworkinfo()
again?
Connections to a dummy Socks5 server are short-lived:https://github.com/bitcoin/bitcoin/blob/45385018e13e167521e655c36128d8ee4f2a3e0b/test/functional/test_framework/socks5.py#L113-L124
This change prevents repetitive traversing vNodes.
Updated d301cc5c564f8c130949567602e182917efef18e -> caebabfc4b239bfb854228f041a6b4220e87e3af (pr20172.06 -> pr20172.09, diff):
This repetitious code could potentially be refactored into a small helper function
get_connection_info()
.
28+ self.add_nodes(self.num_nodes)
29+ self.start_nodes()
30+
31+ def test_connections(self, in_clearnet=0, in_onion=0, out_onion=0):
32+ self.restart_node(0, ['-bind={}=onion'.format(self.bind_onion), self.arg_onion])
33+ self.restart_node(1)
Updated 85ff09ef5d4da9991ee1e9761662d003ff464679 -> da8b1092fc2d5fa5ee9da3310dae16d4c919bc1b (pr20172.10 -> pr20172.11, diff):
Stop-starting the nodes 11 times just to test new connections seems very inefficient. Is there a reason you need to do this stop-start?
🐙 This pull request conflicts with the target branch and needs rebase.
Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a “draft”.