Skip to content

Commit 5903fb7

Browse files
5dd60c4 merge bitcoin#29239: Make v2transport default for addnode RPC when enabled (Kittywhiskers Van Gogh) b2ac426 merge bitcoin#29058: use v2transport for manual/addrfetch connections, add to -netinfo (Kittywhiskers Van Gogh) 92e862a merge bitcoin#28951: damage ciphertext/aad in full byte range (Kittywhiskers Van Gogh) 4e96e26 merge bitcoin#28805: Make existing functional tests compatible with --v2transport (Kittywhiskers Van Gogh) 9371e2e merge bitcoin#28849: fix node index bug when comparing peerinfo (Kittywhiskers Van Gogh) 400c9dd merge bitcoin#28634: add check for missing garbage terminator detection (Kittywhiskers Van Gogh) 65eb194 merge bitcoin#28588: add checks for v1 prefix matching / wrong network magic detection (Kittywhiskers Van Gogh) 6074974 merge bitcoin#28577: raise V1_PREFIX_LEN from 12 to 16 (Kittywhiskers Van Gogh) ff92d1a partial bitcoin#28331: BIP324 integration (Kittywhiskers Van Gogh) f9f8805 fix: drop `CConnman::mapNodesWithDataToSend`, use transport data (UdjinM6) d39d8a4 partial bitcoin#28452: Do not use std::vector = {} to release memory (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Dependent on #6280 * Dependent on #6276 * Dependency for #6329 * [bitcoin#28452](bitcoin#28452) was backported as the behavior it introduces is required for backports like [bitcoin#28331](bitcoin#28331). As it pre-dates earlier BIP324 backports, the `ClearShrink` usage from those backports have also been incorporated into this backport. * When backporting [bitcoin#28331](bitcoin#28331), in TestFramework's `add_nodes()`, `extra_args[i]` is not converted to a `list` like it is done upstream and avoiding duplication of `-v2transport=1` is instead done by an additional check. This is done to prevent test failures in `feature_mnehf.py`. * The local variable `args` is removed in [bitcoin#28805](bitcoin#28805) as it does nothing (the argument appending logic is removed as part of the backport) and upstream removes it anyways. Special thanks to UdjinM6 for significant contributions to this and dependent PRs! 🎉 ## Breaking Changes None expected. ## 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: light ACK 5dd60c4 PastaPastaPasta: utACK 5dd60c4 Tree-SHA512: 7f3d0e54e1c96fc99b2d6b1e64485110aa73aeec0e4e4245ed4e6dc0529a7608e9c39103af636d5945d289775c40d3d15d7d4a75bea82462194dbf355fca48dc
2 parents 1fd0160 + 5dd60c4 commit 5903fb7

28 files changed

Lines changed: 745 additions & 207 deletions

doc/bips.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ Versions and PRs are relevant to Bitcoin's core if not mentioned other.
4141
* [`BIP 158`](https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki): Compact Block Filters for Light Clients can be indexed as of **Dash Core v18.0** ([PR dash#4314](https://github.com/dashpay/dash/pull/4314), [PR #14121](https://github.com/bitcoin/bitcoin/pull/14121)).
4242
* [`BIP 159`](https://github.com/bitcoin/bips/blob/master/bip-0159.mediawiki): The `NODE_NETWORK_LIMITED` service bit is signalled as of **v0.16.0** ([PR 11740](https://github.com/bitcoin/bitcoin/pull/11740)), and such nodes are connected to as of **v0.17.0** ([PR 10387](https://github.com/bitcoin/bitcoin/pull/10387)).
4343
* [`BIP 174`](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki): RPCs to operate on Partially Signed Bitcoin Transactions (PSBT) are present as of **v18.0** ([PR 13557](https://github.com/bitcoin/bitcoin/pull/13557)).
44+
* [`BIP 324`](https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki): The v2 transport protocol specified by BIP324 and the associated `NODE_P2P_V2` service bit are supported as of **v22.0**, but off by default ([PR 28331](https://github.com/bitcoin/bitcoin/pull/28331)).
4445
* [`BIP 339`](https://github.com/bitcoin/bips/blob/master/bip-0339.mediawiki): Relay of transactions by wtxid is supported as of **v0.21.0** ([PR 18044](https://github.com/bitcoin/bitcoin/pull/18044)).

src/bitcoin-cli.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
413413
std::string conn_type;
414414
std::string network;
415415
std::string age;
416+
std::string transport_protocol_type;
416417
double min_ping;
417418
double ping;
418419
int64_t addr_processed;
@@ -517,10 +518,11 @@ class NetinfoRequestHandler : public BaseRequestHandler
517518
const std::string addr{peer["addr"].get_str()};
518519
const std::string age{conn_time == 0 ? "" : ToString((m_time_now - conn_time) / 60)};
519520
const std::string sub_version{peer["subver"].get_str()};
521+
const std::string transport{peer["transport_protocol_type"].get_str()};
520522
const bool is_addr_relay_enabled{peer["addr_relay_enabled"].isNull() ? false : peer["addr_relay_enabled"].get_bool()};
521523
const bool is_bip152_hb_from{peer["bip152_hb_from"].get_bool()};
522524
const bool is_bip152_hb_to{peer["bip152_hb_to"].get_bool()};
523-
m_peers.push_back({addr, sub_version, conn_type, NETWORK_SHORT_NAMES[network_id], age, min_ping, ping, addr_processed, addr_rate_limited, last_blck, last_recv, last_send, last_trxn, peer_id, mapped_as, version, is_addr_relay_enabled, is_bip152_hb_from, is_bip152_hb_to, is_block_relay, is_outbound});
525+
m_peers.push_back({addr, sub_version, conn_type, NETWORK_SHORT_NAMES[network_id], age, transport, min_ping, ping, addr_processed, addr_rate_limited, last_blck, last_recv, last_send, last_trxn, peer_id, mapped_as, version, is_addr_relay_enabled, is_bip152_hb_from, is_bip152_hb_to, is_block_relay, is_outbound});
524526
m_max_addr_length = std::max(addr.length() + 1, m_max_addr_length);
525527
m_max_addr_processed_length = std::max(ToString(addr_processed).length(), m_max_addr_processed_length);
526528
m_max_addr_rate_limited_length = std::max(ToString(addr_rate_limited).length(), m_max_addr_rate_limited_length);
@@ -536,7 +538,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
536538
// Report detailed peer connections list sorted by direction and minimum ping time.
537539
if (DetailsRequested() && !m_peers.empty()) {
538540
std::sort(m_peers.begin(), m_peers.end());
539-
result += strprintf("<-> type net mping ping send recv txn blk hb %*s%*s%*s ",
541+
result += strprintf("<-> type net tp mping ping send recv txn blk hb %*s%*s%*s ",
540542
m_max_addr_processed_length, "addrp",
541543
m_max_addr_rate_limited_length, "addrl",
542544
m_max_age_length, "age");
@@ -545,10 +547,11 @@ class NetinfoRequestHandler : public BaseRequestHandler
545547
for (const Peer& peer : m_peers) {
546548
std::string version{ToString(peer.version) + peer.sub_version};
547549
result += strprintf(
548-
"%3s %6s %5s%7s%7s%5s%5s%5s%5s %2s %*s%*s%*s%*i %*s %-*s%s\n",
550+
"%3s %6s %5s %2s%7s%7s%5s%5s%5s%5s %2s %*s%*s%*s%*i %*s %-*s%s\n",
549551
peer.is_outbound ? "out" : "in",
550552
ConnectionTypeForNetinfo(peer.conn_type),
551553
peer.network,
554+
peer.transport_protocol_type == "detecting" ? "*" : peer.transport_protocol_type,
552555
PingTimeToString(peer.min_ping),
553556
PingTimeToString(peer.ping),
554557
peer.last_send ? ToString(m_time_now - peer.last_send) : "",
@@ -570,7 +573,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
570573
IsAddressSelected() ? peer.addr : "",
571574
IsVersionSelected() && version != "0" ? version : "");
572575
}
573-
result += strprintf(" ms ms sec sec min min %*s\n\n", m_max_age_length, "min");
576+
result += strprintf(" ms ms sec sec min min %*s\n\n", m_max_age_length, "min");
574577
}
575578

576579
// Report peer connection totals by type.
@@ -657,6 +660,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
657660
" \"feeler\" - short-lived connection for testing addresses\n"
658661
" \"addr\" - address fetch; short-lived connection for requesting addresses\n"
659662
" net Network the peer connected through (\"ipv4\", \"ipv6\", \"onion\", \"i2p\", \"cjdns\", or \"npr\" (not publicly routable))\n"
663+
" tp Transport protocol used for the connection (\"v1\", \"v2\" or \"*\" if detecting)\n"
660664
" mping Minimum observed ping time, in milliseconds (ms)\n"
661665
" ping Last observed ping time, in milliseconds (ms)\n"
662666
" send Time since last message sent to the peer, in seconds\n"

src/init.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ void SetupServerArgs(ArgsManager& argsman)
588588
argsman.AddArg("-i2psam=<ip:port>", "I2P SAM proxy to reach I2P peers and accept I2P connections (default: none)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
589589
argsman.AddArg("-i2pacceptincoming", strprintf("Whether to accept inbound I2P connections (default: %i). Ignored if -i2psam is not set. Listening for inbound I2P connections is done through the SAM proxy, not by binding to a local address and port.", DEFAULT_I2P_ACCEPT_INCOMING), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
590590
argsman.AddArg("-onlynet=<net>", "Make automatic outbound connections only to network <net> (" + Join(GetNetworkNames(), ", ") + "). Inbound and manual connections are not affected by this option. It can be specified multiple times to allow multiple networks.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
591+
argsman.AddArg("-v2transport", strprintf("Support v2 transport (default: %u)", DEFAULT_V2_TRANSPORT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
591592
argsman.AddArg("-peerblockfilters", strprintf("Serve compact block filters to peers per BIP 157 (default: %u)", DEFAULT_PEERBLOCKFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
592593
argsman.AddArg("-peerbloomfilters", strprintf("Support filtering of blocks and transaction with bloom filters (default: %u)", DEFAULT_PEERBLOOMFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
593594
argsman.AddArg("-peertimeout=<n>", strprintf("Specify a p2p connection timeout delay in seconds. After connecting to a peer, wait this amount of time before considering disconnection based on inactivity (minimum: 1, default: %d)", DEFAULT_PEER_CONNECT_TIMEOUT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
@@ -1147,6 +1148,11 @@ bool AppInitParameterInteraction(const ArgsManager& args)
11471148
}
11481149
}
11491150

1151+
// Signal NODE_P2P_V2 if BIP324 v2 transport is enabled.
1152+
if (args.GetBoolArg("-v2transport", DEFAULT_V2_TRANSPORT)) {
1153+
nLocalServices = ServiceFlags(nLocalServices | NODE_P2P_V2);
1154+
}
1155+
11501156
// Signal NODE_COMPACT_FILTERS if peerblockfilters and basic filters index are both enabled.
11511157
if (args.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS)) {
11521158
if (g_enabled_filter_types.count(BlockFilterType::BASIC_FILTER) != 1) {

0 commit comments

Comments
 (0)