scripted-diff: validation: rename mandatory errors into block errors
What changed, and why it matters
This commit is a simple automated rename of user-facing error messages and test expectations. It changes the phrase 'mandatory-script-verify-flag-failed' to 'block-script-verify-flag-failed' across source code and tests. No validation logic, security checks, or behavior changes.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
A scripted diff (sed replacement) renames the string ‘mandatory-script-verify-flag-failed’ to ‘block-script-verify-flag-failed’ in 11 files. The only production code change is in src/validation.cpp where the rejection reason string returned by CheckInputScripts and ConnectBlock is updated. All other changes are comments, tracing scripts, or test assertions matching the new string. The commit message explicitly states this is a clarity rename following PR #33050’s ‘non-mandatory’ to ‘mempool’ rename.
Changed components
src/validation.cpp error message stringscontrib/tracing/mempool_monitor.py commenttest/functional/* test expectationssrc/test/miner_tests.cpp test expectationInspect captured patch +28 / −28
diff --git a/contrib/tracing/mempool_monitor.py b/contrib/tracing/mempool_monitor.py
index eb29b374..ddba9d04 100755
--- a/contrib/tracing/mempool_monitor.py
+++ b/contrib/tracing/mempool_monitor.py
@@ -18,7 +18,7 @@ PROGRAM = """
# include <uapi/linux/ptrace.h>
// The longest rejection reason is 118 chars and is generated in case of SCRIPT_ERR_EVAL_FALSE by
-// strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(check.GetScriptError()))
+// strprintf("block-script-verify-flag-failed (%s)", ScriptErrorString(check.GetScriptError()))
#define MAX_REJECT_REASON_LENGTH 118
// The longest string returned by RemovalReasonToString() is 'sizelimit'
#define MAX_REMOVAL_REASON_LENGTH 9
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp
index 9207f1bf..8729e42e 100644
--- a/src/test/miner_tests.cpp
+++ b/src/test/miner_tests.cpp
@@ -446,7 +446,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
tx.vout[0].nValue -= LOWFEE;
hash = tx.GetHash();
AddToMempool(tx_mempool, entry.Fee(LOWFEE).Time(Now<NodeSeconds>()).SpendsCoinbase(false).FromTx(tx));
- BOOST_CHECK_EXCEPTION(mining->createNewBlock(options), std::runtime_error, HasReason("mandatory-script-verify-flag-failed"));
+ BOOST_CHECK_EXCEPTION(mining->createNewBlock(options), std::runtime_error, HasReason("block-script-verify-flag-failed"));
// Delete the dummy blocks again.
while (m_node.chainman->ActiveChain().Tip()->nHeight > nHeight) {
diff --git a/src/validation.cpp b/src/validation.cpp
index 2a680b1c..8bba3996 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2200,7 +2200,7 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
if (flags & STANDARD_NOT_MANDATORY_VERIFY_FLAGS) {
return state.Invalid(TxValidationResult::TX_NOT_STANDARD, strprintf("mempool-script-verify-flag-failed (%s)", ScriptErrorString(result->first)), result->second);
} else {
- return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(result->first)), result->second);
+ return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("block-script-verify-flag-failed (%s)", ScriptErrorString(result->first)), result->second);
}
}
}
@@ -2674,7 +2674,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
if (control) {
auto parallel_result = control->Complete();
if (parallel_result.has_value() && state.IsValid()) {
- state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(parallel_result->first)), parallel_result->second);
+ state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, strprintf("block-script-verify-flag-failed (%s)", ScriptErrorString(parallel_result->first)), parallel_result->second);
}
}
if (!state.IsValid()) {
diff --git a/test/functional/data/invalid_txs.py b/test/functional/data/invalid_txs.py
index a283945a..a7cdcb05 100644
--- a/test/functional/data/invalid_txs.py
+++ b/test/functional/data/invalid_txs.py
@@ -260,7 +260,7 @@ def getDisabledOpcodeTemplate(opcode):
class NonStandardAndInvalid(BadTxTemplate):
"""A non-standard transaction which is also consensus-invalid should return the first error."""
reject_reason = "mempool-script-verify-flag-failed (Using OP_CODESEPARATOR in non-witness script)"
- block_reject_reason = "mandatory-script-verify-flag-failed (OP_RETURN was encountered)"
+ block_reject_reason = "block-script-verify-flag-failed (OP_RETURN was encountered)"
valid_in_block = False
def get_tx(self):
diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py
index 63bee495..34141a2c 100755
--- a/test/functional/feature_block.py
+++ b/test/functional/feature_block.py
@@ -191,7 +191,7 @@ class FullBlockTest(BitcoinTestFramework):
badblock = self.update_block(blockname, [badtx])
reject_reason = (template.block_reject_reason or template.reject_reason)
if reject_reason.startswith("mempool-script-verify-flag-failed"):
- reject_reason = "mandatory-script-verify-flag-failed" + reject_reason[33:]
+ reject_reason = "block-script-verify-flag-failed" + reject_reason[33:]
self.send_blocks(
[badblock], success=False,
reject_reason=reject_reason,
diff --git a/test/functional/feature_cltv.py b/test/functional/feature_cltv.py
index 75cd38a9..2a958e9d 100755
--- a/test/functional/feature_cltv.py
+++ b/test/functional/feature_cltv.py
@@ -153,7 +153,7 @@ class BIP65Test(BitcoinTestFramework):
coin_vout = coin.prevout.n
cltv_invalidate(spendtx, i)
- blk_rej = "mandatory-script-verify-flag-failed"
+ blk_rej = "block-script-verify-flag-failed"
tx_rej = "mempool-script-verify-flag-failed"
expected_cltv_reject_reason = [
" (Operation not valid with the current stack size)",
diff --git a/test/functional/feature_csv_activation.py b/test/functional/feature_csv_activation.py
index 2abfa843..bef870be 100755
--- a/test/functional/feature_csv_activation.py
+++ b/test/functional/feature_csv_activation.py
@@ -403,9 +403,9 @@ class BIP68_112_113Test(BitcoinTestFramework):
# -1 OP_CSV tx and (empty stack) OP_CSV tx should fail
self.send_blocks([self.create_test_block([bip112tx_special_v1])], success=False,
- reject_reason='mandatory-script-verify-flag-failed (Negative locktime)')
+ reject_reason='block-script-verify-flag-failed (Negative locktime)')
self.send_blocks([self.create_test_block([bip112tx_emptystack_v1])], success=False,
- reject_reason='mandatory-script-verify-flag-failed (Operation not valid with the current stack size)')
+ reject_reason='block-script-verify-flag-failed (Operation not valid with the current stack size)')
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 1 txs should still pass
success_txs = [tx['tx'] for tx in bip112txs_vary_OP_CSV_v1 if tx['sdf']]
@@ -420,15 +420,15 @@ class BIP68_112_113Test(BitcoinTestFramework):
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_9_v1 if not tx['sdf']]
for tx in fail_txs:
self.send_blocks([self.create_test_block([tx])], success=False,
- reject_reason='mandatory-script-verify-flag-failed (Locktime requirement not satisfied)')
+ reject_reason='block-script-verify-flag-failed (Locktime requirement not satisfied)')
self.log.info("Test version 2 txs")
# -1 OP_CSV tx and (empty stack) OP_CSV tx should fail
self.send_blocks([self.create_test_block([bip112tx_special_v2])], success=False,
- reject_reason='mandatory-script-verify-flag-failed (Negative locktime)')
+ reject_reason='block-script-verify-flag-failed (Negative locktime)')
self.send_blocks([self.create_test_block([bip112tx_emptystack_v2])], success=False,
- reject_reason='mandatory-script-verify-flag-failed (Operation not valid with the current stack size)')
+ reject_reason='block-script-verify-flag-failed (Operation not valid with the current stack size)')
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 2 txs should pass (all sequence locks are met)
success_txs = [tx['tx'] for tx in bip112txs_vary_OP_CSV_v2 if tx['sdf']]
@@ -444,20 +444,20 @@ class BIP68_112_113Test(BitcoinTestFramework):
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_9_v2 if not tx['sdf']]
for tx in fail_txs:
self.send_blocks([self.create_test_block([tx])], success=False,
- reject_reason='mandatory-script-verify-flag-failed (Locktime requirement not satisfied)')
+ reject_reason='block-script-verify-flag-failed (Locktime requirement not satisfied)')
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in nSequence, tx should fail
fail_txs = [tx['tx'] for tx in bip112txs_vary_nSequence_v2 if tx['sdf']]
for tx in fail_txs:
self.send_blocks([self.create_test_block([tx])], success=False,
- reject_reason='mandatory-script-verify-flag-failed (Locktime requirement not satisfied)')
+ reject_reason='block-script-verify-flag-failed (Locktime requirement not satisfied)')
# If sequencelock types mismatch, tx should fail
fail_txs = [tx['tx'] for tx in bip112txs_vary_nSequence_v2 if not tx['sdf'] and tx['stf']]
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_v2 if not tx['sdf'] and tx['stf']]
for tx in fail_txs:
self.send_blocks([self.create_test_block([tx])], success=False,
- reject_reason='mandatory-script-verify-flag-failed (Locktime requirement not satisfied)')
+ reject_reason='block-script-verify-flag-failed (Locktime requirement not satisfied)')
# Remaining txs should pass, just test masking works properly
success_txs = [tx['tx'] for tx in bip112txs_vary_nSequence_v2 if not tx['sdf'] and not tx['stf']]
diff --git a/test/functional/feature_dersig.py b/test/functional/feature_dersig.py
index eec1559a..de6d1c09 100755
--- a/test/functional/feature_dersig.py
+++ b/test/functional/feature_dersig.py
@@ -133,7 +133,7 @@ class BIP66Test(BitcoinTestFramework):
block.hashMerkleRoot = block.calc_merkle_root()
block.solve()
- with self.nodes[0].assert_debug_log(expected_msgs=['Block validation error: mandatory-script-verify-flag-failed (Non-canonical DER signature)']):
+ with self.nodes[0].assert_debug_log(expected_msgs=['Block validation error: block-script-verify-flag-failed (Non-canonical DER signature)']):
peer.send_and_ping(msg_block(block))
assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip)
peer.sync_with_ping()
diff --git a/test/functional/feature_nulldummy.py b/test/functional/feature_nulldummy.py
index cd7c4491..95760e6a 100755
--- a/test/functional/feature_nulldummy.py
+++ b/test/functional/feature_nulldummy.py
@@ -38,7 +38,7 @@ from test_framework.wallet import getnewdestination
from test_framework.wallet_util import generate_keypair
NULLDUMMY_TX_ERROR = "mempool-script-verify-flag-failed (Dummy CHECKMULTISIG argument must be zero)"
-NULLDUMMY_BLK_ERROR = "mandatory-script-verify-flag-failed (Dummy CHECKMULTISIG argument must be zero)"
+NULLDUMMY_BLK_ERROR = "block-script-verify-flag-failed (Dummy CHECKMULTISIG argument must be zero)"
def invalidate_nulldummy_tx(tx):
"""Transform a NULLDUMMY compliant tx (i.e. scriptSig starts with OP_0)
diff --git a/test/functional/interface_usdt_mempool.py b/test/functional/interface_usdt_mempool.py
index b69dd2df..7cf936ab 100755
--- a/test/functional/interface_usdt_mempool.py
+++ b/test/functional/interface_usdt_mempool.py
@@ -30,7 +30,7 @@ MEMPOOL_TRACEPOINTS_PROGRAM = """
# include <uapi/linux/ptrace.h>
// The longest rejection reason is 118 chars and is generated in case of SCRIPT_ERR_EVAL_FALSE by
-// strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(check.GetScriptError()))
+// strprintf("block-script-verify-flag-failed (%s)", ScriptErrorString(check.GetScriptError()))
#define MAX_REJECT_REASON_LENGTH 118
// The longest string returned by RemovalReasonToString() is 'sizelimit'
#define MAX_REMOVAL_REASON_LENGTH 9
diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py
index 810b6a47..8a61eaf3 100755
--- a/test/functional/p2p_segwit.py
+++ b/test/functional/p2p_segwit.py
@@ -505,7 +505,7 @@ class SegWitTest(BitcoinTestFramework):
# invalid (transactions are always validated with SCRIPT_VERIFY_WITNESS so a segwit v0 transaction
# without a witness is invalid).
test_witness_block(self.nodes[0], self.test_node, block, accepted=False, with_witness=False,
- reason='mandatory-script-verify-flag-failed (Witness program was passed an empty witness)')
+ reason='block-script-verify-flag-failed (Witness program was passed an empty witness)')
self.utxo.pop(0)
self.utxo.append(UTXO(txid, 2, value))
@@ -977,7 +977,7 @@ class SegWitTest(BitcoinTestFramework):
# Extra witness data should not be allowed.
test_witness_block(self.nodes[0], self.test_node, block, accepted=False,
- reason='mandatory-script-verify-flag-failed (Witness provided for non-witness script)')
+ reason='block-script-verify-flag-failed (Witness provided for non-witness script)')
# Try extra signature data. Ok if we're not spending a witness output.
block.vtx[1].wit.vtxinwit = []
@@ -1002,7 +1002,7 @@ class SegWitTest(BitcoinTestFramework):
# This has extra witness data, so it should fail.
test_witness_block(self.nodes[0], self.test_node, block, accepted=False,
- reason='mandatory-script-verify-flag-failed (Stack size must be exactly one after execution)')
+ reason='block-script-verify-flag-failed (Stack size must be exactly one after execution)')
# Now get rid of the extra witness, but add extra scriptSig data
tx2.vin[0].scriptSig = CScript([OP_TRUE])
@@ -1014,7 +1014,7 @@ class SegWitTest(BitcoinTestFramework):
# This has extra signature data for a witness input, so it should fail.
test_witness_block(self.nodes[0], self.test_node, block, accepted=False,
- reason='mandatory-script-verify-flag-failed (Witness requires empty scriptSig)')
+ reason='block-script-verify-flag-failed (Witness requires empty scriptSig)')
# Now get rid of the extra scriptsig on the witness input, and verify
# success (even with extra scriptsig data in the non-witness input)
@@ -1050,7 +1050,7 @@ class SegWitTest(BitcoinTestFramework):
self.update_witness_block_with_transactions(block, [tx, tx2])
test_witness_block(self.nodes[0], self.test_node, block, accepted=False,
- reason='mandatory-script-verify-flag-failed (Push value size limit exceeded)')
+ reason='block-script-verify-flag-failed (Push value size limit exceeded)')
# Now reduce the length of the stack element
tx2.wit.vtxinwit[0].scriptWitness.stack[0] = b'a' * (MAX_SCRIPT_ELEMENT_SIZE)
@@ -1089,7 +1089,7 @@ class SegWitTest(BitcoinTestFramework):
self.update_witness_block_with_transactions(block, [tx, tx2])
test_witness_block(self.nodes[0], self.test_node, block, accepted=False,
- reason='mandatory-script-verify-flag-failed (Script is too big)')
+ reason='block-script-verify-flag-failed (Script is too big)')
# Try again with one less byte in the witness script
witness_script = CScript([b'a' * MAX_SCRIPT_ELEMENT_SIZE] * 19 + [OP_DROP] * 62 + [OP_TRUE])
@@ -1179,7 +1179,7 @@ class SegWitTest(BitcoinTestFramework):
block.vtx = [block.vtx[0]]
self.update_witness_block_with_transactions(block, [tx2])
test_witness_block(self.nodes[0], self.test_node, block, accepted=False,
- reason='mandatory-script-verify-flag-failed (Operation not valid with the current stack size)')
+ reason='block-script-verify-flag-failed (Operation not valid with the current stack size)')
# Fix the broken witness and the block should be accepted.
tx2.wit.vtxinwit[5].scriptWitness.stack = [b'a', witness_script]
@@ -1535,7 +1535,7 @@ class SegWitTest(BitcoinTestFramework):
sign_p2pk_witness_input(witness_script, tx, 0, hashtype, prev_utxo.nValue + 1, key)
self.update_witness_block_with_transactions(block, [tx])
test_witness_block(self.nodes[0], self.test_node, block, accepted=False,
- reason='mandatory-script-verify-flag-failed (Script evaluated without error '
+ reason='block-script-verify-flag-failed (Script evaluated without error '
'but finished with a false/empty top stack element')
# Too-small input value
@@ -1543,7 +1543,7 @@ class SegWitTest(BitcoinTestFramework):
block.vtx.pop() # remove last tx
self.update_witness_block_with_transactions(block, [tx])
test_witness_block(self.nodes[0], self.test_node, block, accepted=False,
- reason='mandatory-script-verify-flag-failed (Script evaluated without error '
+ reason='block-script-verify-flag-failed (Script evaluated without error '
'but finished with a false/empty top stack element')
# Now try correct value
@@ -1647,7 +1647,7 @@ class SegWitTest(BitcoinTestFramework):
block = self.build_next_block()
self.update_witness_block_with_transactions(block, [tx, tx2])
test_witness_block(self.nodes[0], self.test_node, block, accepted=False,
- reason='mandatory-script-verify-flag-failed (Witness requires empty scriptSig)')
+ reason='block-script-verify-flag-failed (Witness requires empty scriptSig)')
# Move the signature to the witness.
block.vtx.pop()
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.