log: Use LogWarning for non-critical logs

As per doc/developer-notes#logging, LogWarning should be used for severe
problems that do not warrant shutting down the node
This commit is contained in:
MarcoFalke
2025-11-26 17:13:09 +01:00
parent fa0018d011
commit fa45a1503e
23 changed files with 116 additions and 115 deletions

View File

@@ -1966,7 +1966,7 @@ void Chainstate::CheckForkWarningConditions()
}
if (m_chainman.m_best_invalid && m_chainman.m_best_invalid->nChainWork > m_chain.Tip()->nChainWork + (GetBlockProof(*m_chain.Tip()) * 6)) {
LogPrintf("%s: Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.\n", __func__);
LogWarning("Found invalid chain at least ~6 blocks longer than our best chain. Chain state database corruption likely.");
m_chainman.GetNotifications().warningSet(
kernel::Warning::LARGE_WORK_INVALID_CHAIN,
_("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade."));
@@ -2862,7 +2862,7 @@ void Chainstate::ForceFlushStateToDisk()
{
BlockValidationState state;
if (!this->FlushStateToDisk(state, FlushStateMode::ALWAYS)) {
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
LogWarning("Failed to force flush state (%s)", state.ToString());
}
}
@@ -2871,7 +2871,7 @@ void Chainstate::PruneAndFlush()
BlockValidationState state;
m_blockman.m_check_for_pruning = true;
if (!this->FlushStateToDisk(state, FlushStateMode::NONE)) {
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
LogWarning("Failed to flush state (%s)", state.ToString());
}
}
@@ -4584,7 +4584,7 @@ void PruneBlockFilesManual(Chainstate& active_chainstate, int nManualPruneHeight
BlockValidationState state;
if (!active_chainstate.FlushStateToDisk(
state, FlushStateMode::NONE, nManualPruneHeight)) {
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
LogWarning("Failed to flush state after manual prune (%s)", state.ToString());
}
}
@@ -4749,7 +4749,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
return VerifyDBResult::CORRUPTED_BLOCK_DB;
}
if (skipped_l3_checks) {
LogPrintf("Skipped verification of level >=3 (insufficient database cache size). Consider increasing -dbcache.\n");
LogWarning("Skipped verification of level >=3 (insufficient database cache size). Consider increasing -dbcache.");
}
// store block count as we move pindex at check level >= 4
@@ -5618,7 +5618,7 @@ Chainstate& ChainstateManager::InitializeChainstate(CTxMemPool* mempool)
try {
bool existed = fs::remove(base_blockhash_path);
if (!existed) {
LogPrintf("[snapshot] snapshot chainstate dir being removed lacks %s file\n",
LogWarning("[snapshot] snapshot chainstate dir being removed lacks %s file",
fs::PathToString(node::SNAPSHOT_BLOCKHASH_FILENAME));
}
} catch (const fs::filesystem_error& e) {
@@ -6096,8 +6096,8 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation()
};
if (index_new.GetBlockHash() != snapshot_blockhash) {
LogPrintf("[snapshot] supposed base block %s does not match the "
"snapshot base block %s (height %d). Snapshot is not valid.\n",
LogWarning("[snapshot] supposed base block %s does not match the "
"snapshot base block %s (height %d). Snapshot is not valid.",
index_new.ToString(), snapshot_blockhash.ToString(), snapshot_base_height);
handle_invalid_snapshot();
return SnapshotCompletionResult::BASE_BLOCKHASH_MISMATCH;
@@ -6117,8 +6117,8 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation()
const auto& maybe_au_data = m_options.chainparams.AssumeutxoForHeight(curr_height);
if (!maybe_au_data) {
LogPrintf("[snapshot] assumeutxo data not found for height "
"(%d) - refusing to validate snapshot\n", curr_height);
LogWarning("[snapshot] assumeutxo data not found for height "
"(%d) - refusing to validate snapshot", curr_height);
handle_invalid_snapshot();
return SnapshotCompletionResult::MISSING_CHAINPARAMS;
}
@@ -6139,7 +6139,7 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation()
// XXX note that this function is slow and will hold cs_main for potentially minutes.
if (!maybe_ibd_stats) {
LogPrintf("[snapshot] failed to generate stats for validation coins db\n");
LogWarning("[snapshot] failed to generate stats for validation coins db");
// While this isn't a problem with the snapshot per se, this condition
// prevents us from validating the snapshot, so we should shut down and let the
// user handle the issue manually.
@@ -6155,7 +6155,7 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation()
// hash for the snapshot when it's loaded in its chainstate's leveldb. We could then
// reference that here for an additional check.
if (AssumeutxoHash{ibd_stats.hashSerialized} != au_data.hash_serialized) {
LogPrintf("[snapshot] hash mismatch: actual=%s, expected=%s\n",
LogWarning("[snapshot] hash mismatch: actual=%s, expected=%s",
ibd_stats.hashSerialized.ToString(),
au_data.hash_serialized.ToString());
handle_invalid_snapshot();
@@ -6473,8 +6473,8 @@ bool ChainstateManager::ValidatedSnapshotCleanup()
if (!DeleteCoinsDBFromDisk(tmp_old, /*is_snapshot=*/false)) {
// No need to FatalError because once the unneeded bg chainstate data is
// moved, it will not interfere with subsequent initialization.
LogPrintf("Deletion of %s failed. Please remove it manually, as the "
"directory is now unnecessary.\n",
LogWarning("Deletion of %s failed. Please remove it manually, as the "
"directory is now unnecessary.",
fs::PathToString(tmp_old));
} else {
LogInfo("[snapshot] deleted background chainstate directory (%s)",