mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #6133: backport: Merge bitcoin#22622, 22780, 22797, 22755, 22501, 21331
a35f0c6a99
Merge bitcoin/bitcoin#22501: netinfo: display addr_{processed, rate_limited, relay_enabled} and relaytxes data (W. J. van der Laan)f263bea244
Merge bitcoin/bitcoin#22755: fuzz: Avoid timeout in blockfilter fuzz target (MarcoFalke)dd26a7a806
Merge bitcoin/bitcoin#22797: test, doc: refer to the correct variable names in p2p_invalid_tx.py (fanquake)c3ea99e492
Merge bitcoin/bitcoin#22780: doc: Remove incorrect INIT_PROTO_VERSION from nTime comment (MarcoFalke)56c3f844dc
Merge bitcoin/bitcoin#22622: util: Check if specified config file cannot be opened (MarcoFalke) Pull request description: bitcoin backports Top commit has no ACKs. Tree-SHA512: 4db8131cb97e4345f598fbef4f73fa601ee837a395ce00acb37e721078b0a13dba8f0a1a8047f2096482fc0c87388b01a2ea7ab2b2b2caacce4ecd55e0377b24
This commit is contained in:
commit
d0be2ce653
@ -401,7 +401,9 @@ private:
|
||||
bool IsVersionSelected() const { return m_details_level == 3 || m_details_level == 4; }
|
||||
bool m_is_asmap_on{false};
|
||||
size_t m_max_addr_length{0};
|
||||
size_t m_max_age_length{3};
|
||||
size_t m_max_addr_processed_length{5};
|
||||
size_t m_max_addr_rate_limited_length{6};
|
||||
size_t m_max_age_length{5};
|
||||
size_t m_max_id_length{2};
|
||||
struct Peer {
|
||||
std::string addr;
|
||||
@ -411,6 +413,8 @@ private:
|
||||
std::string age;
|
||||
double min_ping;
|
||||
double ping;
|
||||
int64_t addr_processed;
|
||||
int64_t addr_rate_limited;
|
||||
int64_t last_blck;
|
||||
int64_t last_recv;
|
||||
int64_t last_send;
|
||||
@ -418,6 +422,7 @@ private:
|
||||
int id;
|
||||
int mapped_as;
|
||||
int version;
|
||||
bool is_addr_relay_enabled;
|
||||
bool is_bip152_hb_from;
|
||||
bool is_bip152_hb_to;
|
||||
bool is_block_relay;
|
||||
@ -498,6 +503,8 @@ public:
|
||||
const int peer_id{peer["id"].get_int()};
|
||||
const int mapped_as{peer["mapped_as"].isNull() ? 0 : peer["mapped_as"].get_int()};
|
||||
const int version{peer["version"].get_int()};
|
||||
const int64_t addr_processed{peer["addr_processed"].isNull() ? 0 : peer["addr_processed"].get_int64()};
|
||||
const int64_t addr_rate_limited{peer["addr_rate_limited"].isNull() ? 0 : peer["addr_rate_limited"].get_int64()};
|
||||
const int64_t conn_time{peer["conntime"].get_int64()};
|
||||
const int64_t last_blck{peer["last_block"].get_int64()};
|
||||
const int64_t last_recv{peer["lastrecv"].get_int64()};
|
||||
@ -508,10 +515,13 @@ public:
|
||||
const std::string addr{peer["addr"].get_str()};
|
||||
const std::string age{conn_time == 0 ? "" : ToString((m_time_now - conn_time) / 60)};
|
||||
const std::string sub_version{peer["subver"].get_str()};
|
||||
const bool is_addr_relay_enabled{peer["addr_relay_enabled"].isNull() ? false : peer["addr_relay_enabled"].get_bool()};
|
||||
const bool is_bip152_hb_from{peer["bip152_hb_from"].get_bool()};
|
||||
const bool is_bip152_hb_to{peer["bip152_hb_to"].get_bool()};
|
||||
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});
|
||||
m_peers.push_back({addr, sub_version, conn_type, network, 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});
|
||||
m_max_addr_length = std::max(addr.length() + 1, m_max_addr_length);
|
||||
m_max_addr_processed_length = std::max(ToString(addr_processed).length(), m_max_addr_processed_length);
|
||||
m_max_addr_rate_limited_length = std::max(ToString(addr_rate_limited).length(), m_max_addr_rate_limited_length);
|
||||
m_max_age_length = std::max(age.length(), m_max_age_length);
|
||||
m_max_id_length = std::max(ToString(peer_id).length(), m_max_id_length);
|
||||
m_is_asmap_on |= (mapped_as != 0);
|
||||
@ -524,34 +534,41 @@ public:
|
||||
// Report detailed peer connections list sorted by direction and minimum ping time.
|
||||
if (DetailsRequested() && !m_peers.empty()) {
|
||||
std::sort(m_peers.begin(), m_peers.end());
|
||||
result += strprintf("<-> type net mping ping send recv txn blk hb %*s ", m_max_age_length, "age");
|
||||
result += strprintf("<-> type net mping ping send recv txn blk hb %*s%*s%*s ",
|
||||
m_max_addr_processed_length, "addrp",
|
||||
m_max_addr_rate_limited_length, "addrl",
|
||||
m_max_age_length, "age");
|
||||
if (m_is_asmap_on) result += " asmap ";
|
||||
result += strprintf("%*s %-*s%s\n", m_max_id_length, "id", IsAddressSelected() ? m_max_addr_length : 0, IsAddressSelected() ? "address" : "", IsVersionSelected() ? "version" : "");
|
||||
for (const Peer& peer : m_peers) {
|
||||
std::string version{ToString(peer.version) + peer.sub_version};
|
||||
result += strprintf(
|
||||
"%3s %6s %5s%7s%7s%5s%5s%5s%5s %2s %*s%*i %*s %-*s%s\n",
|
||||
"%3s %6s %5s%7s%7s%5s%5s%5s%5s %2s %*s%*s%*s%*i %*s %-*s%s\n",
|
||||
peer.is_outbound ? "out" : "in",
|
||||
ConnectionTypeForNetinfo(peer.conn_type),
|
||||
peer.network,
|
||||
PingTimeToString(peer.min_ping),
|
||||
PingTimeToString(peer.ping),
|
||||
peer.last_send == 0 ? "" : ToString(m_time_now - peer.last_send),
|
||||
peer.last_recv == 0 ? "" : ToString(m_time_now - peer.last_recv),
|
||||
peer.last_trxn == 0 ? "" : ToString((m_time_now - peer.last_trxn) / 60),
|
||||
peer.last_blck == 0 ? "" : ToString((m_time_now - peer.last_blck) / 60),
|
||||
peer.last_send ? ToString(m_time_now - peer.last_send) : "",
|
||||
peer.last_recv ? ToString(m_time_now - peer.last_recv) : "",
|
||||
peer.last_trxn ? ToString((m_time_now - peer.last_trxn) / 60) : peer.is_block_relay ? "*" : "",
|
||||
peer.last_blck ? ToString((m_time_now - peer.last_blck) / 60) : "",
|
||||
strprintf("%s%s", peer.is_bip152_hb_to ? "." : " ", peer.is_bip152_hb_from ? "*" : " "),
|
||||
m_max_addr_processed_length, // variable spacing
|
||||
peer.addr_processed ? ToString(peer.addr_processed) : peer.is_addr_relay_enabled ? "" : ".",
|
||||
m_max_addr_rate_limited_length, // variable spacing
|
||||
peer.addr_rate_limited ? ToString(peer.addr_rate_limited) : "",
|
||||
m_max_age_length, // variable spacing
|
||||
peer.age,
|
||||
m_is_asmap_on ? 7 : 0, // variable spacing
|
||||
m_is_asmap_on && peer.mapped_as != 0 ? ToString(peer.mapped_as) : "",
|
||||
m_is_asmap_on && peer.mapped_as ? ToString(peer.mapped_as) : "",
|
||||
m_max_id_length, // variable spacing
|
||||
peer.id,
|
||||
IsAddressSelected() ? m_max_addr_length : 0, // variable spacing
|
||||
IsAddressSelected() ? peer.addr : "",
|
||||
IsVersionSelected() && version != "0" ? version : "");
|
||||
}
|
||||
result += strprintf(" ms ms sec sec min min %*s\n\n", m_max_age_length, "min");
|
||||
result += strprintf(" ms ms sec sec min min %*s\n\n", m_max_age_length, "min");
|
||||
}
|
||||
|
||||
// Report peer connection totals by type.
|
||||
@ -636,10 +653,14 @@ public:
|
||||
" send Time since last message sent to the peer, in seconds\n"
|
||||
" recv Time since last message received from the peer, in seconds\n"
|
||||
" txn Time since last novel transaction received from the peer and accepted into our mempool, in minutes\n"
|
||||
" \"*\" - the peer requested we not relay transactions to it (relaytxes is false)\n"
|
||||
" blk Time since last novel block passing initial validity checks received from the peer, in minutes\n"
|
||||
" hb High-bandwidth BIP152 compact block relay\n"
|
||||
" \".\" (to) - we selected the peer as a high-bandwidth peer\n"
|
||||
" \"*\" (from) - the peer selected us as a high-bandwidth peer\n"
|
||||
" addrp Total number of addresses processed, excluding those dropped due to rate limiting\n"
|
||||
" \".\" - we do not relay addresses to this peer (addr_relay_enabled is false)\n"
|
||||
" addrl Total number of addresses dropped due to rate limiting\n"
|
||||
" age Duration of connection to the peer, in minutes\n"
|
||||
" asmap Mapped AS (Autonomous System) number in the BGP route to the peer, used for diversifying\n"
|
||||
" peer selection (only displayed if the -asmap config option is set)\n"
|
||||
|
@ -471,7 +471,7 @@ public:
|
||||
SerReadWriteMany(os, ser_action, ReadWriteAsHelper<CService>(obj));
|
||||
}
|
||||
|
||||
//! Always included in serialization, except in the network format on INIT_PROTO_VERSION.
|
||||
//! Always included in serialization.
|
||||
uint32_t nTime{TIME_INIT};
|
||||
//! Serialized as uint64_t in V1, and as CompactSize in V2.
|
||||
ServiceFlags nServices{NODE_NONE};
|
||||
|
@ -36,9 +36,10 @@ FUZZ_TARGET(blockfilter)
|
||||
(void)gcs_filter.GetEncoded();
|
||||
(void)gcs_filter.Match(ConsumeRandomLengthByteVector(fuzzed_data_provider));
|
||||
GCSFilter::ElementSet element_set;
|
||||
while (fuzzed_data_provider.ConsumeBool()) {
|
||||
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 30000)
|
||||
{
|
||||
element_set.insert(ConsumeRandomLengthByteVector(fuzzed_data_provider));
|
||||
gcs_filter.MatchAny(element_set);
|
||||
}
|
||||
gcs_filter.MatchAny(element_set);
|
||||
}
|
||||
}
|
||||
|
@ -960,6 +960,12 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||
const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME);
|
||||
fsbridge::ifstream stream(GetConfigFile(confPath));
|
||||
|
||||
// not ok to have a config file specified that cannot be opened
|
||||
if (IsArgSet("-conf") && !stream.good()) {
|
||||
error = strprintf("specified config file \"%s\" could not be opened.", confPath);
|
||||
return false;
|
||||
}
|
||||
// ok to not have a config file
|
||||
if (stream.good()) {
|
||||
if (!ReadConfigStream(stream, confPath, error, ignore_invalid_keys)) {
|
||||
return false;
|
||||
|
@ -247,6 +247,10 @@ class ConfArgsTest(BitcoinTestFramework):
|
||||
|
||||
self.nodes[0].assert_start_raises_init_error(['-conf=' + conf_file], 'Error: Error reading configuration file: specified data directory "' + new_data_dir + '" does not exist.')
|
||||
|
||||
# Check that an explicitly specified config file that cannot be opened fails
|
||||
none_existent_conf_file = os.path.join(default_data_dir, "none_existent_dash.conf")
|
||||
self.nodes[0].assert_start_raises_init_error(['-conf=' + none_existent_conf_file], 'Error: Error reading configuration file: specified config file "' + none_existent_conf_file + '" could not be opened.')
|
||||
|
||||
# Create the directory and ensure the config file now works
|
||||
os.mkdir(new_data_dir)
|
||||
# Temporarily disabled, because this test would access the user's home dir (~/.bitcoin)
|
||||
|
@ -174,9 +174,9 @@ class InvalidTxRequestTest(BitcoinTestFramework):
|
||||
tx_orphan_2_valid, # The valid transaction (with sufficient fee)
|
||||
]
|
||||
}
|
||||
# Transactions that do not end up in the mempool
|
||||
# tx_orphan_no_fee, because it has too low fee (p2ps[0] is not disconnected for relaying that tx)
|
||||
# tx_orphan_invaid, because it has negative fee (p2ps[1] is disconnected for relaying that tx)
|
||||
# Transactions that do not end up in the mempool:
|
||||
# tx_orphan_2_no_fee, because it has too low fee (p2ps[0] is not disconnected for relaying that tx)
|
||||
# tx_orphan_2_invalid, because it has negative fee (p2ps[1] is disconnected for relaying that tx)
|
||||
if resolve_via_block:
|
||||
# This TX has appeared in a block instead of being broadcasted via the mempool
|
||||
expected_mempool.remove(tx_withhold.hash)
|
||||
|
Loading…
Reference in New Issue
Block a user