From 87bebfc2468bdf069532d5178cf50dcc5fa06752 Mon Sep 17 00:00:00 2001 From: pasta Date: Sun, 18 Aug 2024 09:10:33 +0700 Subject: [PATCH] Merge #6219: fix: correct is_snapshot_cs in VerifyDB bf377d47e59d9adaca42d5b6df3505e5d3b24fc7 fix: correct is_snapshot_cs in VerifyDB (James O'Beirne) Pull request description: ## Issue being fixed or feature implemented Flag `is_snapshot_cs` has been inverted in bitcoin#21584 Discovered during investigation of issue: ``` Verifying last 6 blocks at level 3 2024-08-14T14:51:55Z [0%]...*** Found EvoDB inconsistency, you must reindex to continue ``` So far as code below does: ``` if ((fPruneMode || is_snapshot_cs) && !(pindex->nStatus & BLOCK_HAVE_DATA)) { // If pruning or running under an assumeutxo snapshot, only go // back as far as we have data. LogPrintf("VerifyDB(): block verification stopping at height %d (pruning, no data)\n", pindex->nHeight); break; } ``` In case of missing data in evo db we will get instead of "block verification stopping at height" we may get data inconsistency issue. ## What was done? Inverted condition back (same fix in bitcoin/bitcoin#27596) ## How Has This Been Tested? Unit/functional tests doesn't cover it, but they do no fail after fix. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: UdjinM6: utACK bf377d47e59d9adaca42d5b6df3505e5d3b24fc7 PastaPastaPasta: utACK bf377d47e59d9adaca42d5b6df3505e5d3b24fc7 Tree-SHA512: ac21e6db6e23c4c7dc150fb16171aef47c9f42c29466b403bca7d56ed6faa2fccc41df92e1fabec4d6e9fd56991e152dea168593a4550fc3583631a63009c27f --- src/validation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index 15be0df400..1509b8499f 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4678,7 +4678,7 @@ bool CVerifyDB::VerifyDB( int reportDone = 0; LogPrintf("[0%%]..."); /* Continued */ - const bool is_snapshot_cs{!chainstate.m_from_snapshot_blockhash}; + const bool is_snapshot_cs{chainstate.m_from_snapshot_blockhash}; for (pindex = chainstate.m_chain.Tip(); pindex && pindex->pprev; pindex = pindex->pprev) { const int percentageDone = std::max(1, std::min(99, (int)(((double)(chainstate.m_chain.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))));