log: [refactor] Use info level for init logs

This refactor does not change behavior.
This commit is contained in:
MarcoFalke
2025-07-25 09:52:43 +02:00
parent fa183761cb
commit face8123fd
27 changed files with 106 additions and 102 deletions

View File

@@ -2035,7 +2035,7 @@ bool ChainstateManager::IsInitialBlockDownload() const
if (chain.Tip()->Time() < Now<NodeSeconds>() - m_options.max_tip_age) {
return true;
}
LogPrintf("Leaving InitialBlockDownload (latching to false)\n");
LogInfo("Leaving InitialBlockDownload (latching to false)");
m_cached_finished_ibd.store(true, std::memory_order_relaxed);
return false;
}
@@ -2136,7 +2136,7 @@ ValidationCache::ValidationCache(const size_t script_execution_cache_bytes, cons
m_script_execution_cache_hasher.Write(nonce.begin(), 32);
const auto [num_elems, approx_size_bytes] = m_script_execution_cache.setup_bytes(script_execution_cache_bytes);
LogPrintf("Using %zu MiB out of %zu MiB requested for script execution cache, able to store %zu elements\n",
LogInfo("Using %zu MiB out of %zu MiB requested for script execution cache, able to store %zu elements",
approx_size_bytes >> 20, script_execution_cache_bytes >> 20, num_elems);
}
@@ -4695,7 +4695,7 @@ bool Chainstate::LoadChainTip()
PruneBlockIndexCandidates();
tip = m_chain.Tip();
LogPrintf("Loaded best chain: hashBestChain=%s height=%d date=%s progress=%f\n",
LogInfo("Loaded best chain: hashBestChain=%s height=%d date=%s progress=%f",
tip->GetBlockHash().ToString(),
m_chain.Height(),
FormatISO8601DateTime(tip->GetBlockTime()),
@@ -4741,7 +4741,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
nCheckDepth = chainstate.m_chain.Height();
}
nCheckLevel = std::max(0, std::min(4, nCheckLevel));
LogPrintf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel);
LogInfo("Verifying last %i blocks at level %i", nCheckDepth, nCheckLevel);
CCoinsViewCache coins(&coinsview);
CBlockIndex* pindex;
CBlockIndex* pindexFailure = nullptr;
@@ -4750,7 +4750,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
int reportDone = 0;
bool skipped_no_block_data{false};
bool skipped_l3_checks{false};
LogPrintf("Verification progress: 0%%\n");
LogInfo("Verification progress: 0%%");
const bool is_snapshot_cs{chainstate.m_from_snapshot_blockhash};
@@ -4758,7 +4758,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
const int percentageDone = std::max(1, std::min(99, (int)(((double)(chainstate.m_chain.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))));
if (reportDone < percentageDone / 10) {
// report every 10% step
LogPrintf("Verification progress: %d%%\n", percentageDone);
LogInfo("Verification progress: %d%%", percentageDone);
reportDone = percentageDone / 10;
}
m_notifications.progress(_("Verifying blocks…"), percentageDone, false);
@@ -4834,7 +4834,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
const int percentageDone = std::max(1, std::min(99, 100 - (int)(((double)(chainstate.m_chain.Height() - pindex->nHeight)) / (double)nCheckDepth * 50)));
if (reportDone < percentageDone / 10) {
// report every 10% step
LogPrintf("Verification progress: %d%%\n", percentageDone);
LogInfo("Verification progress: %d%%", percentageDone);
reportDone = percentageDone / 10;
}
m_notifications.progress(_("Verifying blocks…"), percentageDone, false);
@@ -4852,7 +4852,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
}
}
LogPrintf("Verification: No coin database inconsistencies in last %i blocks (%i transactions)\n", block_count, nGoodTransactions);
LogInfo("Verification: No coin database inconsistencies in last %i blocks (%i transactions)", block_count, nGoodTransactions);
if (skipped_l3_checks) {
return VerifyDBResult::SKIPPED_L3_CHECKS;
@@ -4901,7 +4901,7 @@ bool Chainstate::ReplayBlocks()
}
m_chainman.GetNotifications().progress(_("Replaying blocks…"), 0, false);
LogPrintf("Replaying blocks\n");
LogInfo("Replaying blocks");
const CBlockIndex* pindexOld = nullptr; // Old tip during the interrupted flush.
const CBlockIndex* pindexNew; // New tip during the interrupted flush.
@@ -4931,7 +4931,7 @@ bool Chainstate::ReplayBlocks()
LogError("RollbackBlock(): ReadBlock() failed at %d, hash=%s\n", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
return false;
}
LogPrintf("Rolling back %s (%i)\n", pindexOld->GetBlockHash().ToString(), pindexOld->nHeight);
LogInfo("Rolling back %s (%i)", pindexOld->GetBlockHash().ToString(), pindexOld->nHeight);
DisconnectResult res = DisconnectBlock(block, pindexOld, cache);
if (res == DISCONNECT_FAILED) {
LogError("RollbackBlock(): DisconnectBlock failed at %d, hash=%s\n", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
@@ -4950,7 +4950,7 @@ bool Chainstate::ReplayBlocks()
for (int nHeight = nForkHeight + 1; nHeight <= pindexNew->nHeight; ++nHeight) {
const CBlockIndex& pindex{*Assert(pindexNew->GetAncestor(nHeight))};
LogPrintf("Rolling forward %s (%i)\n", pindex.GetBlockHash().ToString(), nHeight);
LogInfo("Rolling forward %s (%i)", pindex.GetBlockHash().ToString(), nHeight);
m_chainman.GetNotifications().progress(_("Replaying blocks…"), (int)((nHeight - nForkHeight) * 100.0 / (pindexNew->nHeight - nForkHeight)), false);
if (!RollforwardBlock(&pindex, cache)) return false;
}
@@ -5228,7 +5228,7 @@ void ChainstateManager::LoadExternalBlockFile(
} catch (const std::runtime_error& e) {
GetNotifications().fatalError(strprintf(_("System error while loading external block file: %s"), e.what()));
}
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
LogInfo("Loaded %i blocks from external file in %dms", nLoaded, Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
}
bool ChainstateManager::ShouldCheckBlockIndex() const
@@ -5578,9 +5578,9 @@ bool Chainstate::ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size)
m_coinsdb_cache_size_bytes = coinsdb_size;
CoinsDB().ResizeCache(coinsdb_size);
LogPrintf("[%s] resized coinsdb cache to %.1f MiB\n",
LogInfo("[%s] resized coinsdb cache to %.1f MiB",
this->ToString(), coinsdb_size * (1.0 / 1024 / 1024));
LogPrintf("[%s] resized coinstip cache to %.1f MiB\n",
LogInfo("[%s] resized coinstip cache to %.1f MiB",
this->ToString(), coinstip_size * (1.0 / 1024 / 1024));
BlockValidationState state;
@@ -5687,7 +5687,7 @@ Chainstate& ChainstateManager::InitializeChainstate(CTxMemPool* mempool)
}
std::string path_str = fs::PathToString(db_path);
LogPrintf("Removing leveldb dir at %s\n", path_str);
LogInfo("Removing leveldb dir at %s\n", path_str);
// We have to destruct before this call leveldb::DB in order to release the db
// lock, otherwise `DestroyDB` will fail. See `leveldb::~DBImpl()`.
@@ -5850,8 +5850,8 @@ util::Result<CBlockIndex*> ChainstateManager::ActivateSnapshot(
m_active_chainstate = m_snapshot_chainstate.get();
m_blockman.m_snapshot_height = this->GetSnapshotBaseHeight();
LogPrintf("[snapshot] successfully activated snapshot %s\n", base_blockhash.ToString());
LogPrintf("[snapshot] (%.2f MB)\n",
LogInfo("[snapshot] successfully activated snapshot %s", base_blockhash.ToString());
LogInfo("[snapshot] (%.2f MB)",
m_snapshot_chainstate->CoinsTip().DynamicMemoryUsage() / (1000 * 1000));
this->MaybeRebalanceCaches();
@@ -5922,7 +5922,7 @@ util::Result<void> ChainstateManager::PopulateAndValidateSnapshot(
const uint64_t coins_count = metadata.m_coins_count;
uint64_t coins_left = metadata.m_coins_count;
LogPrintf("[snapshot] loading %d coins from snapshot %s\n", coins_left, base_blockhash.ToString());
LogInfo("[snapshot] loading %d coins from snapshot %s", coins_left, base_blockhash.ToString());
int64_t coins_processed{0};
while (coins_left > 0) {
@@ -5958,7 +5958,7 @@ util::Result<void> ChainstateManager::PopulateAndValidateSnapshot(
++coins_processed;
if (coins_processed % 1000000 == 0) {
LogPrintf("[snapshot] %d coins loaded (%.2f%%, %.2f MB)\n",
LogInfo("[snapshot] %d coins loaded (%.2f%%, %.2f MB)",
coins_processed,
static_cast<float>(coins_processed) * 100 / static_cast<float>(coins_count),
coins_cache.DynamicMemoryUsage() / (1000 * 1000));
@@ -6013,7 +6013,7 @@ util::Result<void> ChainstateManager::PopulateAndValidateSnapshot(
coins_count))};
}
LogPrintf("[snapshot] loaded %d (%.2f MB) coins from snapshot %s\n",
LogInfo("[snapshot] loaded %d (%.2f MB) coins from snapshot %s",
coins_count,
coins_cache.DynamicMemoryUsage() / (1000 * 1000),
base_blockhash.ToString());
@@ -6080,7 +6080,7 @@ util::Result<void> ChainstateManager::PopulateAndValidateSnapshot(
index->m_chain_tx_count = au_data.m_chain_tx_count;
snapshot_chainstate.setBlockIndexCandidates.insert(snapshot_start_block);
LogPrintf("[snapshot] validated snapshot (%.2f MB)\n",
LogInfo("[snapshot] validated snapshot (%.2f MB)",
coins_cache.DynamicMemoryUsage() / (1000 * 1000));
return {};
}
@@ -6184,8 +6184,8 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation()
const AssumeutxoData& au_data = *maybe_au_data;
std::optional<CCoinsStats> maybe_ibd_stats;
LogPrintf("[snapshot] computing UTXO stats for background chainstate to validate "
"snapshot - this could take a few minutes\n");
LogInfo("[snapshot] computing UTXO stats for background chainstate to validate "
"snapshot - this could take a few minutes");
try {
maybe_ibd_stats = ComputeUTXOStats(
CoinStatsHashType::HASH_SERIALIZED,
@@ -6221,7 +6221,7 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation()
return SnapshotCompletionResult::HASH_MISMATCH;
}
LogPrintf("[snapshot] snapshot beginning at %s has been fully validated\n",
LogInfo("[snapshot] snapshot beginning at %s has been fully validated",
snapshot_blockhash.ToString());
m_ibd_chainstate->m_disabled = true;
@@ -6257,7 +6257,7 @@ void ChainstateManager::MaybeRebalanceCaches()
}
else if (snapshot_usable && !ibd_usable) {
// If background validation has completed and snapshot is our active chain...
LogPrintf("[snapshot] allocating all cache to the snapshot chainstate\n");
LogInfo("[snapshot] allocating all cache to the snapshot chainstate");
// Allocate everything to the snapshot chainstate.
m_snapshot_chainstate->ResizeCoinsCaches(m_total_coinstip_cache, m_total_coinsdb_cache);
}
@@ -6326,7 +6326,7 @@ bool ChainstateManager::DetectSnapshotChainstate()
if (!base_blockhash) {
return false;
}
LogPrintf("[snapshot] detected active snapshot chainstate (%s) - loading\n",
LogInfo("[snapshot] detected active snapshot chainstate (%s) - loading",
fs::PathToString(*path));
this->ActivateExistingSnapshot(*base_blockhash);
@@ -6338,7 +6338,7 @@ Chainstate& ChainstateManager::ActivateExistingSnapshot(uint256 base_blockhash)
assert(!m_snapshot_chainstate);
m_snapshot_chainstate =
std::make_unique<Chainstate>(nullptr, m_blockman, *this, base_blockhash);
LogPrintf("[snapshot] switching active chainstate to %s\n", m_snapshot_chainstate->ToString());
LogInfo("[snapshot] switching active chainstate to %s", m_snapshot_chainstate->ToString());
// Mempool is empty at this point because we're still in IBD.
Assert(m_active_chainstate->m_mempool->size() == 0);
@@ -6382,7 +6382,7 @@ util::Result<void> Chainstate::InvalidateCoinsDBOnDisk()
auto invalid_path = snapshot_datadir + "_INVALID";
std::string dbpath = fs::PathToString(snapshot_datadir);
std::string target = fs::PathToString(invalid_path);
LogPrintf("[snapshot] renaming snapshot datadir %s to %s\n", dbpath, target);
LogInfo("[snapshot] renaming snapshot datadir %s to %s", dbpath, target);
// The invalid snapshot datadir is simply moved and not deleted because we may
// want to do forensics later during issue investigation. The user is instructed
@@ -6494,7 +6494,7 @@ bool ChainstateManager::ValidatedSnapshotCleanup()
// No chainstates should be considered usable.
assert(this->GetAll().size() == 0);
LogPrintf("[snapshot] deleting background chainstate directory (now unnecessary) (%s)\n",
LogInfo("[snapshot] deleting background chainstate directory (now unnecessary) (%s)",
fs::PathToString(ibd_chainstate_path));
fs::path tmp_old{ibd_chainstate_path + "_todelete"};
@@ -6518,8 +6518,8 @@ bool ChainstateManager::ValidatedSnapshotCleanup()
throw;
}
LogPrintf("[snapshot] moving snapshot chainstate (%s) to "
"default chainstate directory (%s)\n",
LogInfo("[snapshot] moving snapshot chainstate (%s) to "
"default chainstate directory (%s)",
fs::PathToString(snapshot_chainstate_path), fs::PathToString(ibd_chainstate_path));
try {
@@ -6536,7 +6536,7 @@ bool ChainstateManager::ValidatedSnapshotCleanup()
"directory is now unnecessary.\n",
fs::PathToString(tmp_old));
} else {
LogPrintf("[snapshot] deleted background chainstate directory (%s)\n",
LogInfo("[snapshot] deleted background chainstate directory (%s)",
fs::PathToString(ibd_chainstate_path));
}
return true;