mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-25 06:55:32 +01:00
validation: Don't load a snapshot if it's not in the best header chain.
If the snapshot is not an ancestor of the most-work header (m_best_header), syncing from that alternative chain should be prioritised. Therefore don't accept loading a snapshot in this situation. If that other chain turns out to be invalid, m_best_header would be reset and loading the snapshot should be possible again. Because of the work required to generate a conflicting headers chain, this should only be possible under extreme circumstances, such as major forks.
This commit is contained in:
@@ -5683,6 +5683,10 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
|
||||
return util::Error{strprintf(Untranslated("The base block header (%s) is part of an invalid chain"), base_blockhash.ToString())};
|
||||
}
|
||||
|
||||
if (!m_best_header || m_best_header->GetAncestor(base_blockheight) != snapshot_start_block) {
|
||||
return util::Error{_("A forked headers-chain with more work than the chain with the snapshot base block header exists. Please proceed to sync without AssumeUtxo.")};
|
||||
}
|
||||
|
||||
auto mempool{m_active_chainstate->GetMempool()};
|
||||
if (mempool && mempool->size() > 0) {
|
||||
return util::Error{Untranslated("Can't activate a snapshot when mempool not empty")};
|
||||
|
||||
Reference in New Issue
Block a user