From 0067abe153298ce9f14262a15533033e6e907f2b Mon Sep 17 00:00:00 2001 From: stringintech Date: Thu, 18 Dec 2025 02:04:45 +0330 Subject: [PATCH] p2p: Allow block downloads from peers without snapshot block after assumeutxo validation After assumeutxo background validation completes, allow block downloads from peers that don't have the snapshot block in their best chain. Previously, these peers were skipped until restart because `m_chainman.CurrentChainstate().SnapshotBase()` continued returning non-null even after validation finished. Add `m_chainman.CurrentChainstate().m_assumeutxo == Assumeutxo::UNVALIDATED` check to only apply the restriction while background validation is ongoing. --- src/net_processing.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 51dcadad6f8..a3707d3b5f4 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1385,11 +1385,13 @@ void PeerManagerImpl::FindNextBlocksToDownload(const Peer& peer, unsigned int co return; } - // When we sync with AssumeUtxo and discover the snapshot is not in the peer's best chain, abort: - // We can't reorg to this chain due to missing undo data until the background sync has finished, + // When syncing with AssumeUtxo and the snapshot has not yet been validated, + // abort downloading blocks from peers that don't have the snapshot block in their best chain. + // We can't reorg to this chain due to missing undo data until validation completes, // so downloading blocks from it would be futile. const CBlockIndex* snap_base{m_chainman.CurrentChainstate().SnapshotBase()}; - if (snap_base && state->pindexBestKnownBlock->GetAncestor(snap_base->nHeight) != snap_base) { + if (snap_base && m_chainman.CurrentChainstate().m_assumeutxo == Assumeutxo::UNVALIDATED && + state->pindexBestKnownBlock->GetAncestor(snap_base->nHeight) != snap_base) { LogDebug(BCLog::NET, "Not downloading blocks from peer=%d, which doesn't have the snapshot block in its best chain.\n", peer.m_id); return; }