validation: log initial script verification state
What changed, and why it matters
This change only affects logging: it records whether Bitcoin Core is performing full script verification the first time that state is observed, and it moves the log line to appear before the first 'UpdateTip' message. There is no security vulnerability here.
No security action required; this is a benign logging/test-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit replaces an std::atomic_bool with std::optional
Changed components
src/validation.htest/functional/feature_assumevalid.pyInspect captured patch +8 / −1
diff --git a/src/validation.h b/src/validation.h
index 644d4f73..fea11c55 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -560,7 +560,7 @@ protected:
//! Cached result of LookupBlockIndex(*m_from_snapshot_blockhash)
mutable const CBlockIndex* m_cached_snapshot_base GUARDED_BY(::cs_main){nullptr};
- std::atomic_bool m_prev_script_checks_logged{true};
+ std::optional<bool> m_prev_script_checks_logged GUARDED_BY(::cs_main){};
public:
//! Reference to a BlockManager instance which itself is shared across all
diff --git a/test/functional/feature_assumevalid.py b/test/functional/feature_assumevalid.py
index 54c62e87..478955c2 100755
--- a/test/functional/feature_assumevalid.py
+++ b/test/functional/feature_assumevalid.py
@@ -141,6 +141,7 @@ class AssumeValidTest(BitcoinTestFramework):
self.tip = block.hash_int
self.block_time += 1
height += 1
+ block_1_hash = self.blocks[0].hash_hex
self.start_node(1, extra_args=[f"-assumevalid={block102.hash_hex}"])
self.start_node(2, extra_args=[f"-assumevalid={block102.hash_hex}"])
@@ -152,6 +153,7 @@ class AssumeValidTest(BitcoinTestFramework):
# nodes[0]
# Send blocks to node0. Block 102 will be rejected.
with self.nodes[0].assert_debug_log(expected_msgs=[
+ f"Enabling script verification at block #1 ({block_1_hash})",
"Block validation error: block-script-verify-flag-failed",
]):
p2p0 = self.nodes[0].add_p2p_connection(BaseNode())
@@ -184,6 +186,7 @@ class AssumeValidTest(BitcoinTestFramework):
# nodes[2]
# Send blocks to node2. Block 102 will be rejected.
with self.nodes[2].assert_debug_log(expected_msgs=[
+ f"Enabling script verification at block #1 ({block_1_hash})",
"Block validation error: block-script-verify-flag-failed",
]):
p2p2 = self.nodes[2].add_p2p_connection(BaseNode())
@@ -197,6 +200,7 @@ class AssumeValidTest(BitcoinTestFramework):
# nodes[3]
with self.nodes[3].assert_debug_log(expected_msgs=[
+ f"Enabling script verification at block #1 ({block_1_hash})",
]):
best_hash = self.nodes[3].getbestblockhash()
tip_block = self.nodes[3].getblock(best_hash)
@@ -223,6 +227,7 @@ class AssumeValidTest(BitcoinTestFramework):
alt1 = create_block(int(genesis_hash, 16), create_coinbase(1), genesis_time + 2)
alt1.solve()
with self.nodes[4].assert_debug_log(expected_msgs=[
+ f"Enabling script verification at block #1 ({alt1.hash_hex})",
]):
p2p4 = self.nodes[4].add_p2p_connection(BaseNode())
p2p4.send_header_for_blocks(self.blocks[0:103])
@@ -238,10 +243,12 @@ class AssumeValidTest(BitcoinTestFramework):
p2p5.send_without_ping(msg_block(self.blocks[0]))
self.wait_until(lambda: self.nodes[5].getblockcount() == 1)
with self.nodes[5].assert_debug_log(expected_msgs=[
+ f"Enabling script verification at block #1 ({block_1_hash})",
]):
self.restart_node(5, extra_args=["-reindex-chainstate", "-assumevalid=1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"])
assert_equal(self.nodes[5].getblockcount(), 1)
with self.nodes[5].assert_debug_log(expected_msgs=[
+ f"Enabling script verification at block #1 ({block_1_hash})",
]):
self.restart_node(5, extra_args=["-reindex-chainstate", f"-assumevalid={block102.hash_hex}", "-minimumchainwork=0xffff"])
assert_equal(self.nodes[5].getblockcount(), 1)
Why this scored 13/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.