From 45bd8914658a675d00aa9c83373d6903a8a9ece8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Thu, 18 Sep 2025 14:46:45 -0700 Subject: [PATCH] log: split assumevalid ancestry-failure-reason message When the assumevalid ancestry check fails, log a precise reason: - "block height above assumevalid height" if the block is above the assumevalid block (the default reason) - "block not in of assumevalid chain" otherwise The new split was added under the existing condition to simplify conceptually that the two cases are related. It could still be useful to know when the block is just above the assumevalid block or when it's not even on the same chain. Update the functional test to assert the new reason strings. No behavior change. Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com> --- src/validation.cpp | 2 +- test/functional/feature_assumevalid.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index e881742bda2..2136a63fc46 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 756f2d35c73..ed2bff63daa 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())