validation: Remove stale BlockManager param in ContextualCheckBlockHeader
What changed, and why it matters
This is a small code cleanup that removes an unused parameter from an internal function. The function previously received a 'BlockManager' object but did not actually use it. The change only adjusts the function signature and the two places that call it. There is no security fix here.
No security action needed. Treat as normal code-maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes the BlockManager& blockman parameter from the static helper ContextualCheckBlockHeader() in src/validation.cpp and updates its two call sites in AcceptBlockHeader() and TestBlockValidity(). The parameter was stale (unused within the function body). The change is purely refactoring; no logic, validation rules, or locking behavior were modified.
Changed components
src/validation.cppContextualCheckBlockHeaderAcceptBlockHeaderTestBlockValidityInspect captured patch +3 / −3
diff --git a/src/validation.cpp b/src/validation.cpp
index fc15c26d..2b0de23d 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -4077,7 +4077,7 @@ arith_uint256 CalculateClaimedHeadersWork(std::span<const CBlockHeader> headers)
* v0.12 and v0.15 (when no additional protection was in place) whereby an attacker could unboundedly
* grow our in-memory block index. See https://bitcoincore.org/en/2024/07/03/disclose-header-spam.
*/
-static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, BlockManager& blockman, const ChainstateManager& chainman, const CBlockIndex* pindexPrev) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
+static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, const ChainstateManager& chainman, const CBlockIndex* pindexPrev) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
{
AssertLockHeld(::cs_main);
assert(pindexPrev != nullptr);
@@ -4221,7 +4221,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
LogDebug(BCLog::VALIDATION, "header %s has prev block invalid: %s\n", hash.ToString(), block.hashPrevBlock.ToString());
return state.Invalid(BlockValidationResult::BLOCK_INVALID_PREV, "bad-prevblk");
}
- if (!ContextualCheckBlockHeader(block, state, m_blockman, *this, pindexPrev)) {
+ if (!ContextualCheckBlockHeader(block, state, *this, pindexPrev)) {
LogDebug(BCLog::VALIDATION, "%s: Consensus::ContextualCheckBlockHeader: %s, %s\n", __func__, hash.ToString(), state.ToString());
return false;
}
@@ -4502,7 +4502,7 @@ BlockValidationState TestBlockValidity(
* - do run ContextualCheckBlock()
*/
- if (!ContextualCheckBlockHeader(block, state, chainstate.m_blockman, chainstate.m_chainman, tip)) {
+ if (!ContextualCheckBlockHeader(block, state, chainstate.m_chainman, tip)) {
if (state.IsValid()) NONFATAL_UNREACHABLE();
return state;
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.