log: split assumevalid ancestry-failure-reason message
What changed, and why it matters
This commit only changes the wording of a debug log message. It splits one log reason into two more specific reasons so developers can tell whether a block is above the assumevalid block height or on a completely different chain. The commit message explicitly says 'No behavior change.'
No security action needed. This is a non-functional logging/test-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In Chainstate::ConnectBlock, the script_check_reason string for the assumevalid ancestry failure is refined. Previously both cases (block height above assumevalid height and block not on the assumevalid chain) logged ‘block not in assumevalid chain’. Now the message distinguishes them. The functional test’s expected debug log message is updated accordingly. There is no change to validation logic, script verification behavior, or consensus rules.
Changed components
src/validation.cpp loggingtest/functional/feature_assumevalid.pyInspect captured patch +2 / −2
diff --git a/src/validation.cpp b/src/validation.cpp
index e881742b..2136a63f 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2437,7 +2437,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
if (it == m_blockman.m_block_index.end()) {
script_check_reason = "assumevalid hash not in headers";
} else if (it->second.GetAncestor(pindex->nHeight) != pindex) {
- script_check_reason = "block not in assumevalid chain";
+ script_check_reason = (pindex->nHeight > it->second.nHeight) ? "block height above assumevalid height" : "block not in assumevalid chain";
} else if (m_chainman.m_best_header->GetAncestor(pindex->nHeight) != pindex) {
script_check_reason = "block not in best header chain";
} else if (m_chainman.m_best_header->nChainWork < m_chainman.MinimumChainWork()) {
diff --git a/test/functional/feature_assumevalid.py b/test/functional/feature_assumevalid.py
index 756f2d35..ed2bff63 100755
--- a/test/functional/feature_assumevalid.py
+++ b/test/functional/feature_assumevalid.py
@@ -169,7 +169,7 @@ class AssumeValidTest(BitcoinTestFramework):
# nodes[1]
with self.nodes[1].assert_debug_log(expected_msgs=[
f"Disabling script verification at block #1 ({self.blocks[0].hash_hex}).",
- f"Enabling script verification at block #103 ({self.blocks[102].hash_hex}): block not in assumevalid chain.",
+ f"Enabling script verification at block #103 ({self.blocks[102].hash_hex}): block height above assumevalid height.",
]):
p2p1 = self.nodes[1].add_p2p_connection(BaseNode())
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.