Skip to content

Commit

Permalink
validation: move header validation error logging to VALIDATION debug …
Browse files Browse the repository at this point in the history
…category

Summary:
This is a backport of [[bitcoin/bitcoin#23235 | core#23235]] [2/4]
bitcoin/bitcoin@da94ebc

Depends on D12038

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D12039
  • Loading branch information
ajtowns authored and PiRK committed Sep 23, 2022
1 parent baa8f6f commit 5e24b19
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3837,8 +3837,8 @@ bool BlockManager::AcceptBlockHeader(const Config &config,
}

if (pindex->nStatus.isInvalid()) {
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");
}
Expand All @@ -3857,25 +3857,27 @@ bool BlockManager::AcceptBlockHeader(const Config &config,
// Get prev block index
BlockMap::iterator mi = m_block_index.find(block.hashPrevBlock);
if (mi == m_block_index.end()) {
LogPrintf("ERROR: %s: %s prev block not found\n", __func__,
hash.ToString());
LogPrint(BCLog::VALIDATION, "%s: %s prev block not found\n",
__func__, hash.ToString());
return state.Invalid(BlockValidationResult::BLOCK_MISSING_PREV,
"prev-blk-not-found");
}

CBlockIndex *pindexPrev = (*mi).second;
assert(pindexPrev);
if (pindexPrev->nStatus.isInvalid()) {
LogPrintf("ERROR: %s: %s prev block invalid\n", __func__,
hash.ToString());
LogPrint(BCLog::VALIDATION, "%s: %s prev block invalid\n", __func__,
hash.ToString());
return state.Invalid(BlockValidationResult::BLOCK_INVALID_PREV,
"bad-prevblk");
}

if (!ContextualCheckBlockHeader(chainparams, block, state, *this,
pindexPrev, GetAdjustedTime())) {
return error("%s: Consensus::ContextualCheckBlockHeader: %s, %s",
__func__, hash.ToString(), state.ToString());
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
Expand Down Expand Up @@ -3913,8 +3915,8 @@ bool BlockManager::AcceptBlockHeader(const Config &config,
setDirtyBlockIndex.insert(invalid_walk);
invalid_walk = invalid_walk->pprev;
}
LogPrintf("ERROR: %s: %s prev block invalid\n", __func__,
hash.ToString());
LogPrint(BCLog::VALIDATION, "%s: %s prev block invalid\n",
__func__, hash.ToString());
return state.Invalid(
BlockValidationResult::BLOCK_INVALID_PREV,
"bad-prevblk");
Expand Down

0 comments on commit 5e24b19

Please sign in to comment.