mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-31 10:56:03 +02:00
Merge bitcoin/bitcoin#28170: p2p: adaptive connections services flags
27f260aa6enet: remove now unused global 'g_initial_block_download_completed' (furszy)aff7d92b15test: add coverage for peerman adaptive connections service flags (furszy)6ed53602acnet: peer manager, dynamically adjust desirable services flag (furszy)9f36e591c5net: move state dependent peer services flags (furszy)f9ac96b8d6net: decouple state independent service flags from desirable ones (furszy)97df4e3887net: store best block tip time inside PeerManager (furszy) Pull request description: Derived from #28120 discussion. By relocating the peer desirable services flags into the peer manager, we allow the connections acceptance process to handle post-IBD potential stalling scenarios. The peer manager will be able to dynamically adjust the services flags based on the node's proximity to the tip (back and forth). Allowing the node to recover from the following post-IBD scenario: Suppose the node has successfully synced the chain, but later experienced dropped connections and remained inactive for a duration longer than the limited peers threshold (the timeframe within which limited peers can provide blocks). In such cases, upon reconnecting to the network, the node might only establish connections with limited peers, filling up all available outbound slots. Resulting in an inability to synchronize the chain (because limited peers will not provide blocks older than the `NODE_NETWORK_LIMITED_MIN_BLOCKS` threshold). ACKs for top commit: achow101: ACK27f260aa6evasild: ACK27f260aa6enaumenkogs: ACK27f260aa6emzumsande: Light Code Review ACK27f260aa6eandrewtoth: ACK27f260aa6eTree-SHA512: 07befb9bcd0b60a4e7c45e4429c02e7b6c66244f0910f4b2ad97c9b98258b6f46c914660a717b5ed4ef4814d0dbfae6e18e6559fe9bec7d0fbc2034109200953
This commit is contained in:
@@ -203,7 +203,7 @@ static std::vector<CAddress> ConvertSeeds(const std::vector<uint8_t> &vSeedsIn)
|
||||
while (!s.eof()) {
|
||||
CService endpoint;
|
||||
s >> endpoint;
|
||||
CAddress addr{endpoint, GetDesirableServiceFlags(NODE_NONE)};
|
||||
CAddress addr{endpoint, SeedsServiceFlags()};
|
||||
addr.nTime = rng.rand_uniform_delay(Now<NodeSeconds>() - one_week, -one_week);
|
||||
LogPrint(BCLog::NET, "Added hardcoded seed: %s\n", addr.ToStringAddrPort());
|
||||
vSeedsOut.push_back(addr);
|
||||
@@ -2267,7 +2267,7 @@ void CConnman::ThreadDNSAddressSeed()
|
||||
AddAddrFetch(seed);
|
||||
} else {
|
||||
std::vector<CAddress> vAdd;
|
||||
ServiceFlags requiredServiceBits = GetDesirableServiceFlags(NODE_NONE);
|
||||
constexpr ServiceFlags requiredServiceBits{SeedsServiceFlags()};
|
||||
std::string host = strprintf("x%x.%s", requiredServiceBits, seed);
|
||||
CNetAddr resolveSource;
|
||||
if (!resolveSource.SetInternal(host)) {
|
||||
@@ -2638,7 +2638,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
||||
const CAddress addr = m_anchors.back();
|
||||
m_anchors.pop_back();
|
||||
if (!addr.IsValid() || IsLocal(addr) || !g_reachable_nets.Contains(addr) ||
|
||||
!HasAllDesirableServiceFlags(addr.nServices) ||
|
||||
!m_msgproc->HasAllDesirableServiceFlags(addr.nServices) ||
|
||||
outbound_ipv46_peer_netgroups.count(m_netgroupman.GetGroup(addr))) continue;
|
||||
addrConnect = addr;
|
||||
LogPrint(BCLog::NET, "Trying to make an anchor connection to %s\n", addrConnect.ToStringAddrPort());
|
||||
@@ -2704,7 +2704,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
||||
// for non-feelers, require all the services we'll want,
|
||||
// for feelers, only require they be a full node (only because most
|
||||
// SPV clients don't have a good address DB available)
|
||||
if (!fFeeler && !HasAllDesirableServiceFlags(addr.nServices)) {
|
||||
if (!fFeeler && !m_msgproc->HasAllDesirableServiceFlags(addr.nServices)) {
|
||||
continue;
|
||||
} else if (fFeeler && !MayHaveUsefulAddressDB(addr.nServices)) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user