mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-11 05:42:06 +02:00
Merge #23235: Reduce unnecessary default logging
b5950dd59ca3e144721a5f15568a65be43bd2f20 validation: put coins cache write log into bench debug log (Anthony Towns)
31b2b802b5b8f214e91ec47fbc953c6ca95c7cf9 blockstorage: use debug log category (Anthony Towns)
da94ebc2facd75c6105a7bd31765c6d2b37fc73b validation: move header validation error logging to VALIDATION debug category (Anthony Towns)
1d7d835ec3a7cc17924f80222784fe3afb567b67 validation: include block hash when reporting prev block not found errors (Anthony Towns)
Pull request description:
Moves the following log messages into debug log categories:
* "AcceptBlockHeader: ..." to validation
* "Prune: deleted blk/rev" to new blockstorage log category
* "Leaving block file" moves from validation to blockstorage
* "write coins cache to disk" to bench
Also adds the hash of the block to the log message when AcceptBlockHeader is rejecting because of problems with the prev block.
ACKs for top commit:
practicalswift:
cr ACK b5950dd59ca3e144721a5f15568a65be43bd2f20
Empact:
Code review ACK b5950dd59c
laanwj:
Code review ACK b5950dd59ca3e144721a5f15568a65be43bd2f20
promag:
Code review ACK b5950dd59ca3e144721a5f15568a65be43bd2f20.
meshcollider:
Code review ACK b5950dd59ca3e144721a5f15568a65be43bd2f20
Tree-SHA512: a73fdbfe8d36da48a3e89c2d5e0b6a3c5045d280c1a57f61c38d0d21f4f198aece4bd85155be3439e179d5dabdb523bf15fa0395e0e3ceff19c878ba3112c840
This commit is contained in:
commit
ec4e43c21c
@ -161,6 +161,7 @@ const CLogCategoryDesc LogCategories[] =
|
||||
{BCLog::IPC, "ipc"},
|
||||
{BCLog::LOCK, "lock"},
|
||||
{BCLog::UTIL, "util"},
|
||||
{BCLog::BLOCKSTORE, "blockstorage"},
|
||||
{BCLog::ALL, "1"},
|
||||
{BCLog::ALL, "all"},
|
||||
};
|
||||
|
@ -61,6 +61,7 @@ namespace BCLog {
|
||||
IPC = (1 << 23),
|
||||
LOCK = (1 << 24),
|
||||
UTIL = (1 << 25),
|
||||
BLOCKSTORE = (1 << 26),
|
||||
ALL = ~(uint32_t)0,
|
||||
};
|
||||
|
||||
|
@ -204,7 +204,7 @@ void UnlinkPrunedFiles(const std::set<int>& setFilesToPrune)
|
||||
FlatFilePos pos(*it, 0);
|
||||
fs::remove(BlockFileSeq().FileName(pos));
|
||||
fs::remove(UndoFileSeq().FileName(pos));
|
||||
LogPrintf("Prune: %s deleted blk/rev (%05u)\n", __func__, *it);
|
||||
LogPrint(BCLog::BLOCKSTORE, "Prune: %s deleted blk/rev (%05u)\n", __func__, *it);
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ bool FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigned int nHeight,
|
||||
|
||||
if ((int)nFile != nLastBlockFile) {
|
||||
if (!fKnown) {
|
||||
LogPrint(BCLog::VALIDATION, "Leaving block file %i: %s\n", nLastBlockFile, vinfoBlockFile[nLastBlockFile].ToString());
|
||||
LogPrint(BCLog::BLOCKSTORE, "Leaving block file %i: %s\n", nLastBlockFile, vinfoBlockFile[nLastBlockFile].ToString());
|
||||
}
|
||||
FlushBlockFile(!fKnown, finalize_undo);
|
||||
nLastBlockFile = nFile;
|
||||
|
@ -2029,8 +2029,8 @@ bool CChainState::FlushStateToDisk(
|
||||
}
|
||||
// Flush best chain related state. This can only be done if the blocks / block index write was also done.
|
||||
if (fDoFullFlush && !CoinsTip().GetBestBlock().IsNull()) {
|
||||
LOG_TIME_SECONDS(strprintf("write coins cache to disk (%d coins, %.2fkB)",
|
||||
coins_count, coins_mem_usage / 1000));
|
||||
LOG_TIME_MILLIS_WITH_CATEGORY(strprintf("write coins cache to disk (%d coins, %.2fkB)",
|
||||
coins_count, coins_mem_usage / 1000), BCLog::BENCH);
|
||||
|
||||
// Typical Coin structures on disk are around 48 bytes in size.
|
||||
// Pushing a new one to the database can cause it to be written
|
||||
@ -3205,7 +3205,7 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
|
||||
if (ppindex)
|
||||
*ppindex = pindex;
|
||||
if (pindex->nStatus & BLOCK_FAILED_MASK) {
|
||||
LogPrintf("ERROR: %s: block %s is marked invalid\n", __func__, hash.ToString());
|
||||
LogPrint(BCLog::VALIDATION, "%s: block %s is marked invalid\n", __func__, hash.ToString());
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CACHED_INVALID, "duplicate");
|
||||
}
|
||||
return true;
|
||||
@ -3220,16 +3220,18 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
|
||||
CBlockIndex* pindexPrev = nullptr;
|
||||
BlockMap::iterator mi = m_block_index.find(block.hashPrevBlock);
|
||||
if (mi == m_block_index.end()) {
|
||||
LogPrintf("ERROR: %s: prev block not found\n", __func__);
|
||||
LogPrint(BCLog::VALIDATION, "%s: %s prev block not found\n", __func__, hash.ToString());
|
||||
return state.Invalid(BlockValidationResult::BLOCK_MISSING_PREV, "prev-blk-not-found");
|
||||
}
|
||||
pindexPrev = (*mi).second;
|
||||
if (pindexPrev->nStatus & BLOCK_FAILED_MASK) {
|
||||
LogPrintf("ERROR: %s: prev block invalid\n", __func__);
|
||||
LogPrint(BCLog::VALIDATION, "%s: %s prev block invalid\n", __func__, hash.ToString());
|
||||
return state.Invalid(BlockValidationResult::BLOCK_INVALID_PREV, "bad-prevblk");
|
||||
}
|
||||
if (!ContextualCheckBlockHeader(block, state, *this, chainparams, pindexPrev, GetAdjustedTime()))
|
||||
return error("%s: Consensus::ContextualCheckBlockHeader: %s, %s", __func__, hash.ToString(), state.ToString());
|
||||
if (!ContextualCheckBlockHeader(block, state, *this, chainparams, pindexPrev, GetAdjustedTime())) {
|
||||
LogPrint(BCLog::VALIDATION, "%s: Consensus::ContextualCheckBlockHeader: %s, %s\n", __func__, hash.ToString(), state.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Determine if this block descends from any block which has been found
|
||||
* invalid (m_failed_blocks), then mark pindexPrev and any blocks between
|
||||
@ -3264,7 +3266,7 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
|
||||
setDirtyBlockIndex.insert(invalid_walk);
|
||||
invalid_walk = invalid_walk->pprev;
|
||||
}
|
||||
LogPrintf("ERROR: %s: prev block invalid\n", __func__);
|
||||
LogPrint(BCLog::VALIDATION, "%s: %s prev block invalid\n", __func__, hash.ToString());
|
||||
return state.Invalid(BlockValidationResult::BLOCK_INVALID_PREV, "bad-prevblk");
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class RpcMiscTest(BitcoinTestFramework):
|
||||
self.log.info("test logging rpc and help")
|
||||
|
||||
# Test logging RPC returns the expected number of logging categories.
|
||||
assert_equal(len(node.logging()), 26)
|
||||
assert_equal(len(node.logging()), 27)
|
||||
|
||||
# Test toggling a logging category on/off/on with the logging RPC.
|
||||
assert_equal(node.logging()['qt'], True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user