You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
0af16e7 doc: add release note for #25574 (Martin Zumsande)
57ef2a4 validation: report if pruning prevents completion of verification (Martin Zumsande)
0c7785b init, validation: Improve handling if VerifyDB() fails due to insufficient dbcache (Martin Zumsande)
d6f781f validation: return VerifyDBResult::INTERRUPTED if verification was interrupted (Martin Zumsande)
6360b53 validation: Change return value of VerifyDB to enum type (Martin Zumsande)
Pull request description:
`VerifyDB()` can fail to complete due to insufficient dbcache at the level 3 checks. This PR improves the error handling in this case in the following ways:
- The rpc `-verifychain` now returns false if the check can't be completed due to insufficient cache
- During init, we only log a warning if the default values for `-checkblocks` and `-checklevel` are taken and the check doesn't complete. However, if the user actively specifies one of these args, we return with an InitError if we can't complete the check.
This PR also changes `-verifychain` RPC to return `false` if the verification didn't finish due to missing block data (pruning) or due to being interrupted by the node being shutdown.
Previously, this PR also included a fix for a possible assert during verification - this was done in #27009 (now merged).
ACKs for top commit:
achow101:
ACK 0af16e7
ryanofsky:
Code review ACK 0af16e7. Only small suggested changes since the last review, like renaming some of the enum values. I did leave more suggestions, but they are not very important and could be followups
john-moffett:
ACK 0af16e7
MarcoFalke:
lgtm re-ACK 0af16e7 🎚
Tree-SHA512: 84b4f767cf9bfbafef362312757c9bf765b41ae3977f4ece840e40c52a2266b1457832df0cdf70440be0aac2168d9b58fc817238630b0b6812f3836ca950bc0e
Copy file name to clipboardExpand all lines: src/validation.cpp
+32-15Lines changed: 32 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -4060,7 +4060,7 @@ CVerifyDB::~CVerifyDB()
4060
4060
uiInterface.ShowProgress("", 100, false);
4061
4061
}
4062
4062
4063
-
boolCVerifyDB::VerifyDB(
4063
+
VerifyDBResultCVerifyDB::VerifyDB(
4064
4064
Chainstate& chainstate,
4065
4065
const Consensus::Params& consensus_params,
4066
4066
CCoinsView& coinsview,
@@ -4069,7 +4069,7 @@ bool CVerifyDB::VerifyDB(
4069
4069
AssertLockHeld(cs_main);
4070
4070
4071
4071
if (chainstate.m_chain.Tip() == nullptr || chainstate.m_chain.Tip()->pprev == nullptr) {
4072
-
returntrue;
4072
+
returnVerifyDBResult::SUCCESS;
4073
4073
}
4074
4074
4075
4075
// Verify blocks in the best chain
@@ -4084,6 +4084,7 @@ bool CVerifyDB::VerifyDB(
4084
4084
int nGoodTransactions = 0;
4085
4085
BlockValidationState state;
4086
4086
int reportDone = 0;
4087
+
bool skipped_no_block_data{false};
4087
4088
bool skipped_l3_checks{false};
4088
4089
LogPrintf("Verification progress: 0%%\n");
4089
4090
@@ -4103,25 +4104,29 @@ bool CVerifyDB::VerifyDB(
4103
4104
if ((chainstate.m_blockman.IsPruneMode() || is_snapshot_cs) && !(pindex->nStatus & BLOCK_HAVE_DATA)) {
4104
4105
// If pruning or running under an assumeutxo snapshot, only go
4105
4106
// back as far as we have data.
4106
-
LogPrintf("VerifyDB(): block verification stopping at height %d (pruning, no data)\n", pindex->nHeight);
4107
+
LogPrintf("VerifyDB(): block verification stopping at height %d (no data). This could be due to pruning or use of an assumeutxo snapshot.\n", pindex->nHeight);
4108
+
skipped_no_block_data = true;
4107
4109
break;
4108
4110
}
4109
4111
CBlock block;
4110
4112
// check level 0: read from disk
4111
4113
if (!ReadBlockFromDisk(block, pindex, consensus_params)) {
4112
-
returnerror("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
4114
+
LogPrintf("Verification error: ReadBlockFromDisk failed at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
4115
+
return VerifyDBResult::CORRUPTED_BLOCK_DB;
4113
4116
}
4114
4117
// check level 1: verify block validity
4115
4118
if (nCheckLevel >= 1 && !CheckBlock(block, state, consensus_params)) {
4116
-
returnerror("%s: *** found bad block at %d, hash=%s (%s)\n", __func__,
0 commit comments