[doc] Update comments on dummy extraNonces in tests
What changed, and why it matters
This commit only updates explanatory comments in test code. It does not change any program behavior, consensus rules, or production code. There is no security issue here.
No action needed; this is a documentation-only change in test code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies three comments in Bitcoin Core test utilities to clarify that OP_0 appended to coinbase scriptSigs is a dummy extraNonce, also noting its role in satisfying the bad-cb-length consensus rule for early heights. No executable code is changed.
Changed components
src/test/util/mining.cppsrc/test/validation_block_tests.cpptest/functional/test_framework/blocktools.pyInspect captured patch +3 / −2
diff --git a/src/test/util/mining.cpp b/src/test/util/mining.cpp
index da15e678..05f1be77 100644
--- a/src/test/util/mining.cpp
+++ b/src/test/util/mining.cpp
@@ -49,6 +49,7 @@ std::vector<std::shared_ptr<CBlock>> CreateBlockChain(size_t total_height, const
coinbase_tx.vout.resize(1);
coinbase_tx.vout[0].scriptPubKey = P2WSH_OP_TRUE;
coinbase_tx.vout[0].nValue = GetBlockSubsidy(height + 1, params.GetConsensus());
+ // Always include OP_0 as a dummy extraNonce.
coinbase_tx.vin[0].scriptSig = CScript() << (height + 1) << OP_0;
block.vtx = {MakeTransactionRef(std::move(coinbase_tx))};
diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp
index 2303fd4c..dfa66bb8 100644
--- a/src/test/validation_block_tests.cpp
+++ b/src/test/validation_block_tests.cpp
@@ -82,7 +82,7 @@ std::shared_ptr<CBlock> MinerTestingSetup::Block(const uint256& prev_hash)
txCoinbase.vout[1].nValue = txCoinbase.vout[0].nValue;
txCoinbase.vout[0].nValue = 0;
txCoinbase.vin[0].scriptWitness.SetNull();
- // Always pad with OP_0 at the end to avoid bad-cb-length error
+ // Always pad with OP_0 as dummy extraNonce (also avoids bad-cb-length error for block <=16)
const int prev_height{WITH_LOCK(::cs_main, return m_node.chainman->m_blockman.LookupBlockIndex(prev_hash)->nHeight)};
txCoinbase.vin[0].scriptSig = CScript{} << prev_height + 1 << OP_0;
txCoinbase.nLockTime = static_cast<uint32_t>(prev_height);
diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py
index 8ad8ea8a..e1453e3a 100644
--- a/test/functional/test_framework/blocktools.py
+++ b/test/functional/test_framework/blocktools.py
@@ -164,7 +164,7 @@ def add_witness_commitment(block, nonce=0):
def script_BIP34_coinbase_height(height):
if height <= 16:
res = CScriptOp.encode_op_n(height)
- # Append dummy to increase scriptSig size to 2 (see bad-cb-length consensus rule)
+ # Append dummy extraNonce to increase scriptSig size to 2 (see bad-cb-length consensus rule)
return CScript([res, OP_0])
return CScript([CScriptNum(height)])
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.