Skip to content

Commit 2f93ee4

Browse files
1cbf3b9 merge bitcoin-core/gui#206: Display fRelayTxes and bip152_highbandwidth_{to, from} in peer details (Kittywhiskers Van Gogh) 2390621 merge bitcoin#20764: cli -netinfo peer connections dashboard updates (Kittywhiskers Van Gogh) 06a6f84 merge bitcoin#25147: follow ups to bitcoin#20799 (removing support for v1 compact blocks) (Kittywhiskers Van Gogh) 6274a57 merge bitcoin#20799: Only support version 2 compact blocks (Kittywhiskers Van Gogh) f4ce573 merge bitcoin#22340: Use legacy relaying to download blocks in blocks-only mode (Kittywhiskers Van Gogh) 73b8f84 merge bitcoin#22147: p2p: Protect last outbound HB compact block peer (Kittywhiskers Van Gogh) 2ce4818 merge bitcoin#20599: Tolerate sendheaders and sendcmpct messages before verack (Kittywhiskers Van Gogh) 799214b merge bitcoin#19776: expose high bandwidth mode state via getpeerinfo (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Version 2 of BIP152 high-bandwidth mode/compact blocks implements SegWit support. As Dash does not implement SegWit, there has never been a need to implement v2 (and therefore, have all the code necessary to support both v1 and v2, that gets removed as part of making support v2 only). * Despite that, the changes surrounding removing support for both versions (that in our case, do not apply as we never have supported v2) refactor the code in other ways and influence their behaviour. In the interest of upstream alignment, those changes have been backported. * [bitcoin#19776](bitcoin#19776) doesn't seem to work on its own without successive backports, specifically [bitcoin#20799](bitcoin#20799), despite the latter being a later backport. <details> <summary>19776-only p2p_compactblocks.py run (9f2c868)</summary> ``` dash@825a14c32b73:/src/dash$ ./test/functional/p2p_compactblocks.py 2024-06-09T12:29:09.777000Z TestFramework (INFO): Initializing test directory /tmp/dash_func_test_kb2nr5oe 2024-06-09T12:29:16.341000Z TestFramework (INFO): Testing SENDCMPCT p2p message... 2024-06-09T12:29:31.432000Z TestFramework (INFO): Testing compactblock construction... 2024-06-09T12:29:40.068000Z TestFramework (INFO): Testing compactblock requests... 2024-06-09T12:29:44.597000Z TestFramework (INFO): Testing getblocktxn handler... 2024-06-09T12:29:59.808000Z TestFramework (INFO): Testing compactblock requests/announcements not at chain tip... 2024-06-09T12:30:03.855000Z TestFramework (INFO): Testing handling of incorrect blocktxn responses... 2024-06-09T12:30:05.868000Z TestFramework (INFO): Testing reconstructing compact blocks from all peers... 2024-06-09T12:30:09.389000Z TestFramework (INFO): Testing end-to-end block relay... 2024-06-09T12:30:10.404000Z TestFramework (INFO): Testing handling of invalid compact blocks... 2024-06-09T12:30:12.418000Z TestFramework (INFO): Testing invalid index in cmpctblock message... 2024-06-09T12:30:14.384000Z TestFramework (INFO): Testing high-bandwidth mode states via getpeerinfo... 2024-06-09T12:30:16.893000Z TestFramework (ERROR): Assertion failed Traceback (most recent call last): File "/src/dash/test/functional/test_framework/test_framework.py", line 158, in main self.run_test() File "./test/functional/p2p_compactblocks.py", line 849, in run_test self.test_highbandwidth_mode_states_via_getpeerinfo() File "./test/functional/p2p_compactblocks.py", line 791, in test_highbandwidth_mode_states_via_getpeerinfo hb_test_node.send_and_ping(msg_block(block)) File "/src/dash/test/functional/test_framework/p2p.py", line 579, in send_and_ping self.sync_with_ping(timeout=timeout) File "/src/dash/test/functional/test_framework/p2p.py", line 596, in sync_with_ping self.wait_until(test_function, timeout=timeout) File "/src/dash/test/functional/test_framework/p2p.py", line 487, in wait_until wait_until_helper(test_function, timeout=timeout, lock=p2p_lock, timeout_factor=self.timeout_factor) File "/src/dash/test/functional/test_framework/util.py", line 249, in wait_until_helper if predicate(): File "/src/dash/test/functional/test_framework/p2p.py", line 484, in test_function assert self.is_connected AssertionError 2024-06-09T12:30:17.396000Z TestFramework (INFO): Stopping nodes 2024-06-09T12:30:18.400000Z TestFramework (WARNING): Not cleaning up dir /tmp/dash_func_test_kb2nr5oe 2024-06-09T12:30:18.401000Z TestFramework (ERROR): Test failed. Test logging available at /tmp/dash_func_test_kb2nr5oe/test_framework.log 2024-06-09T12:30:18.401000Z TestFramework (ERROR): 2024-06-09T12:30:18.401000Z TestFramework (ERROR): Hint: Call /src/dash/test/functional/combine_logs.py '/tmp/dash_func_test_kb2nr5oe' to consolidate all logs 2024-06-09T12:30:18.401000Z TestFramework (ERROR): 2024-06-09T12:30:18.401000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log. 2024-06-09T12:30:18.402000Z TestFramework (ERROR): https://github.com/dashpay/dash/issues 2024-06-09T12:30:18.402000Z TestFramework (ERROR): ``` </details> <details> <summary>20799-incl p2p_compactblocks.py run (aa116c4)</summary> ``` dash@825a14c32b73:/src/dash$ ./test/functional/p2p_compactblocks.py 2024-06-09T12:34:27.169000Z TestFramework (INFO): Initializing test directory /tmp/dash_func_test_7d65lmhz 2024-06-09T12:34:32.695000Z TestFramework (INFO): Testing SENDCMPCT p2p message... 2024-06-09T12:34:51.288000Z TestFramework (INFO): Testing compactblock construction... 2024-06-09T12:34:55.325000Z TestFramework (INFO): Testing compactblock requests... 2024-06-09T12:34:59.861000Z TestFramework (INFO): Testing getblocktxn handler... 2024-06-09T12:35:07.460000Z TestFramework (INFO): Testing compactblock requests/announcements not at chain tip... 2024-06-09T12:35:09.503000Z TestFramework (INFO): Testing handling of incorrect blocktxn responses... 2024-06-09T12:35:11.519000Z TestFramework (INFO): Testing reconstructing compact blocks from all peers... 2024-06-09T12:35:15.039000Z TestFramework (INFO): Testing end-to-end block relay... 2024-06-09T12:35:16.055000Z TestFramework (INFO): Testing handling of invalid compact blocks... 2024-06-09T12:35:17.062000Z TestFramework (INFO): Testing invalid index in cmpctblock message... 2024-06-09T12:35:19.139000Z TestFramework (INFO): Testing high-bandwidth mode states via getpeerinfo... 2024-06-09T12:35:22.159000Z TestFramework (INFO): Stopping nodes 2024-06-09T12:35:23.163000Z TestFramework (INFO): Cleaning up /tmp/dash_func_test_7d65lmhz on exit 2024-06-09T12:35:23.163000Z TestFramework (INFO): Tests successful ``` </details> * The backport of [bitcoin-core/gui#206](bitcoin-core/gui#206) is a continuation of 3e8ba24 from [dash#5964](dashpay#5964) * The backport of [bitcoin#20764](bitcoin#20764) is a continuation of bd934c7 from [dash#6034](dashpay#6034) ## Breaking changes * The `getpeerinfo` RPC returns two new boolean fields, `bip152_hb_to` and `bip152_hb_from`, that respectively indicate whether we selected a peer to be in compact blocks high-bandwidth mode or whether a peer selected us as a compact blocks high-bandwidth peer. High-bandwidth peers send new block announcements via a `cmpctblock` message rather than the usual inv/headers announcements. See BIP 152 for more details. * Blocks-only mode will use legacy relaying instead of BIP152 high-bandwidth mode ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 1cbf3b9 PastaPastaPasta: utACK 1cbf3b9 knst: utACK 1cbf3b9 Tree-SHA512: 5947b622d8d57a1dc9445cd6e07d4ad690379416d0fcf04ed574269975d1beb704691a79ff081341f3c800cf11869d401f1ed90baa5449f371f9ce658f2d2e95
2 parents 74fcd02 + 1cbf3b9 commit 2f93ee4

13 files changed

+493
-161
lines changed

doc/release-notes-19776.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Updated RPCs
2+
------------
3+
4+
- The `getpeerinfo` RPC returns two new boolean fields, `bip152_hb_to` and
5+
`bip152_hb_from`, that respectively indicate whether we selected a peer to be
6+
in compact blocks high-bandwidth mode or whether a peer selected us as a
7+
compact blocks high-bandwidth peer. High-bandwidth peers send new block
8+
announcements via a `cmpctblock` message rather than the usual inv/headers
9+
announcements. See BIP 152 for more details.

src/bitcoin-cli.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
401401
bool IsVersionSelected() const { return m_details_level == 3 || m_details_level == 4; }
402402
bool m_is_asmap_on{false};
403403
size_t m_max_addr_length{0};
404-
size_t m_max_age_length{4};
404+
size_t m_max_age_length{3};
405405
size_t m_max_id_length{2};
406406
struct Peer {
407407
std::string addr;
@@ -418,6 +418,8 @@ class NetinfoRequestHandler : public BaseRequestHandler
418418
int id;
419419
int mapped_as;
420420
int version;
421+
bool is_bip152_hb_from;
422+
bool is_bip152_hb_to;
421423
bool is_block_relay;
422424
bool is_outbound;
423425
bool operator<(const Peer& rhs) const { return std::tie(is_outbound, min_ping) < std::tie(rhs.is_outbound, rhs.min_ping); }
@@ -506,7 +508,9 @@ class NetinfoRequestHandler : public BaseRequestHandler
506508
const std::string addr{peer["addr"].get_str()};
507509
const std::string age{conn_time == 0 ? "" : ToString((m_time_now - conn_time) / 60)};
508510
const std::string sub_version{peer["subver"].get_str()};
509-
m_peers.push_back({addr, sub_version, conn_type, network, age, min_ping, ping, last_blck, last_recv, last_send, last_trxn, peer_id, mapped_as, version, is_block_relay, is_outbound});
511+
const bool is_bip152_hb_from{peer["bip152_hb_from"].get_bool()};
512+
const bool is_bip152_hb_to{peer["bip152_hb_to"].get_bool()};
513+
m_peers.push_back({addr, sub_version, conn_type, network, age, min_ping, ping, last_blck, last_recv, last_send, last_trxn, peer_id, mapped_as, version, is_bip152_hb_from, is_bip152_hb_to, is_block_relay, is_outbound});
510514
m_max_addr_length = std::max(addr.length() + 1, m_max_addr_length);
511515
m_max_age_length = std::max(age.length(), m_max_age_length);
512516
m_max_id_length = std::max(ToString(peer_id).length(), m_max_id_length);
@@ -520,13 +524,13 @@ class NetinfoRequestHandler : public BaseRequestHandler
520524
// Report detailed peer connections list sorted by direction and minimum ping time.
521525
if (DetailsRequested() && !m_peers.empty()) {
522526
std::sort(m_peers.begin(), m_peers.end());
523-
result += strprintf("<-> type net mping ping send recv txn blk %*s ", m_max_age_length, "age");
527+
result += strprintf("<-> type net mping ping send recv txn blk hb %*s ", m_max_age_length, "age");
524528
if (m_is_asmap_on) result += " asmap ";
525529
result += strprintf("%*s %-*s%s\n", m_max_id_length, "id", IsAddressSelected() ? m_max_addr_length : 0, IsAddressSelected() ? "address" : "", IsVersionSelected() ? "version" : "");
526530
for (const Peer& peer : m_peers) {
527531
std::string version{ToString(peer.version) + peer.sub_version};
528532
result += strprintf(
529-
"%3s %6s %5s%7s%7s%5s%5s%5s%5s %*s%*i %*s %-*s%s\n",
533+
"%3s %6s %5s%7s%7s%5s%5s%5s%5s %2s %*s%*i %*s %-*s%s\n",
530534
peer.is_outbound ? "out" : "in",
531535
ConnectionTypeForNetinfo(peer.conn_type),
532536
peer.network,
@@ -536,6 +540,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
536540
peer.last_recv == 0 ? "" : ToString(m_time_now - peer.last_recv),
537541
peer.last_trxn == 0 ? "" : ToString((m_time_now - peer.last_trxn) / 60),
538542
peer.last_blck == 0 ? "" : ToString((m_time_now - peer.last_blck) / 60),
543+
strprintf("%s%s", peer.is_bip152_hb_to ? "." : " ", peer.is_bip152_hb_from ? "*" : " "),
539544
m_max_age_length, // variable spacing
540545
peer.age,
541546
m_is_asmap_on ? 7 : 0, // variable spacing
@@ -546,7 +551,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
546551
IsAddressSelected() ? peer.addr : "",
547552
IsVersionSelected() && version != "0" ? version : "");
548553
}
549-
result += strprintf(" ms ms sec sec min min %*s\n\n", m_max_age_length, "min");
554+
result += strprintf(" ms ms sec sec min min %*s\n\n", m_max_age_length, "min");
550555
}
551556

552557
// Report peer connection totals by type.
@@ -632,6 +637,9 @@ class NetinfoRequestHandler : public BaseRequestHandler
632637
" recv Time since last message received from the peer, in seconds\n"
633638
" txn Time since last novel transaction received from the peer and accepted into our mempool, in minutes\n"
634639
" blk Time since last novel block passing initial validity checks received from the peer, in minutes\n"
640+
" hb High-bandwidth BIP152 compact block relay\n"
641+
" \".\" (to) - we selected the peer as a high-bandwidth peer\n"
642+
" \"*\" (from) - the peer selected us as a high-bandwidth peer\n"
635643
" age Duration of connection to the peer, in minutes\n"
636644
" asmap Mapped AS (Autonomous System) number in the BGP route to the peer, used for diversifying\n"
637645
" peer selection (only displayed if the -asmap config option is set)\n"

src/net.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ void CNode::CopyStats(CNodeStats& stats)
706706
}
707707
stats.fInbound = IsInboundConn();
708708
stats.m_manual_connection = IsManualConn();
709+
X(m_bip152_highbandwidth_to);
710+
X(m_bip152_highbandwidth_from);
709711
{
710712
LOCK(cs_vSend);
711713
X(mapSendBytesPerMsgCmd);

src/net.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ class CNodeStats
284284
std::string cleanSubVer;
285285
bool fInbound;
286286
bool m_manual_connection;
287+
bool m_bip152_highbandwidth_to;
288+
bool m_bip152_highbandwidth_from;
287289
int m_starting_height;
288290
uint64_t nSendBytes;
289291
mapMsgCmdSize mapSendBytesPerMsgCmd;
@@ -582,6 +584,11 @@ class CNode
582584
}
583585

584586
public:
587+
// We selected peer as (compact blocks) high-bandwidth peer (BIP152)
588+
std::atomic<bool> m_bip152_highbandwidth_to{false};
589+
// Peer selected us as (compact blocks) high-bandwidth peer (BIP152)
590+
std::atomic<bool> m_bip152_highbandwidth_from{false};
591+
585592
/** Whether we should relay transactions to this peer (their version
586593
* message did not include fRelay=false and this is not a block-relay-only
587594
* connection). This only changes from false to true. It will never change

0 commit comments

Comments
 (0)