Skip to content

Commit 7b4a135

Browse files
committed
Merge bitcoin#33183: validation: rename block script verification error from "mandatory" to "block"
c0d91fc Add release note for bitcoin#33050 and bitcoin#33183 error string changes (Antoine Poinsot) b3f781a contrib: adapt max reject string size in tracing demo (Antoine Poinsot) 9a04635 scripted-diff: validation: rename mandatory errors into block errors (Antoine Poinsot) Pull request description: This is a followup to bitcoin#33050 now that it's merged. Using "block"/"mempool" as the error reason is clearer to a user than "mandatory"/"non-mandatory". The "non-mandatory" errors got renamed to "mempool" in bitcoin#33050 (see bitcoin#33050 (comment)). This takes care of the second part of the renaming. ACKs for top commit: fjahr: utACK c0d91fc davidgumberg: lgtm ACK bitcoin@c0d91fc ajtowns: utACK c0d91fc Crypt-iQ: utACK c0d91fc janb84: utACK c0d91fc instagibbs: ACK c0d91fc Tree-SHA512: b463e633c57dd1eae7c49d23239a59066a672f355142ec194982eddc927a7646bc5cde583dc8d6f45075bf5cbb96dbe73f7e339e728929b0eff356b674d1b68c
2 parents c99f5c5 + c0d91fc commit 7b4a135

12 files changed

+37
-30
lines changed

contrib/tracing/mempool_monitor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
PROGRAM = """
1818
# include <uapi/linux/ptrace.h>
1919
20-
// The longest rejection reason is 118 chars and is generated in case of SCRIPT_ERR_EVAL_FALSE by
21-
// strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(check.GetScriptError()))
22-
#define MAX_REJECT_REASON_LENGTH 118
20+
// The longest rejection reason is 114 chars and is generated in case of SCRIPT_ERR_EVAL_FALSE by
21+
// strprintf("block-script-verify-flag-failed (%s)", ScriptErrorString(check.GetScriptError()))
22+
#define MAX_REJECT_REASON_LENGTH 114
2323
// The longest string returned by RemovalReasonToString() is 'sizelimit'
2424
#define MAX_REMOVAL_REASON_LENGTH 9
2525
#define HASH_LENGTH 32

doc/release-notes-33183.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Updated RPCs
2+
------------
3+
4+
Transaction Script validation errors used to return the reason for the error prefixed by either
5+
"mandatory-script-verify-flag-failed" if it was a consensus error, or "non-mandatory-script-verify-flag"
6+
(without "-failed") if it was a standardness error. This has been changed to "block-script-verify-flag-failed"
7+
and "mempool-script-verify-flag-failed" for all block and mempool errors respectively.

src/test/miner_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
450450
tx.vout[0].nValue -= LOWFEE;
451451
hash = tx.GetHash();
452452
AddToMempool(tx_mempool, entry.Fee(LOWFEE).Time(Now<NodeSeconds>()).SpendsCoinbase(false).FromTx(tx));
453-
BOOST_CHECK_EXCEPTION(mining->createNewBlock(options), std::runtime_error, HasReason("mandatory-script-verify-flag-failed"));
453+
BOOST_CHECK_EXCEPTION(mining->createNewBlock(options), std::runtime_error, HasReason("block-script-verify-flag-failed"));
454454

455455
// Delete the dummy blocks again.
456456
while (m_node.chainman->ActiveChain().Tip()->nHeight > nHeight) {

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,7 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
22002200
if (flags & STANDARD_NOT_MANDATORY_VERIFY_FLAGS) {
22012201
return state.Invalid(TxValidationResult::TX_NOT_STANDARD, strprintf("mempool-script-verify-flag-failed (%s)", ScriptErrorString(result->first)), result->second);
22022202
} else {
2203-
return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(result->first)), result->second);
2203+
return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("block-script-verify-flag-failed (%s)", ScriptErrorString(result->first)), result->second);
22042204
}
22052205
}
22062206
}
@@ -2674,7 +2674,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
26742674
if (control) {
26752675
auto parallel_result = control->Complete();
26762676
if (parallel_result.has_value() && state.IsValid()) {
2677-
state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(parallel_result->first)), parallel_result->second);
2677+
state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, strprintf("block-script-verify-flag-failed (%s)", ScriptErrorString(parallel_result->first)), parallel_result->second);
26782678
}
26792679
}
26802680
if (!state.IsValid()) {

test/functional/data/invalid_txs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def get_tx(self):
260260
class NonStandardAndInvalid(BadTxTemplate):
261261
"""A non-standard transaction which is also consensus-invalid should return the first error."""
262262
reject_reason = "mempool-script-verify-flag-failed (Using OP_CODESEPARATOR in non-witness script)"
263-
block_reject_reason = "mandatory-script-verify-flag-failed (OP_RETURN was encountered)"
263+
block_reject_reason = "block-script-verify-flag-failed (OP_RETURN was encountered)"
264264
valid_in_block = False
265265

266266
def get_tx(self):

test/functional/feature_block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def run_test(self):
191191
badblock = self.update_block(blockname, [badtx])
192192
reject_reason = (template.block_reject_reason or template.reject_reason)
193193
if reject_reason.startswith("mempool-script-verify-flag-failed"):
194-
reject_reason = "mandatory-script-verify-flag-failed" + reject_reason[33:]
194+
reject_reason = "block-script-verify-flag-failed" + reject_reason[33:]
195195
self.send_blocks(
196196
[badblock], success=False,
197197
reject_reason=reject_reason,

test/functional/feature_cltv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def run_test(self):
153153
coin_vout = coin.prevout.n
154154
cltv_invalidate(spendtx, i)
155155

156-
blk_rej = "mandatory-script-verify-flag-failed"
156+
blk_rej = "block-script-verify-flag-failed"
157157
tx_rej = "mempool-script-verify-flag-failed"
158158
expected_cltv_reject_reason = [
159159
" (Operation not valid with the current stack size)",

test/functional/feature_csv_activation.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ def run_test(self):
403403

404404
# -1 OP_CSV tx and (empty stack) OP_CSV tx should fail
405405
self.send_blocks([self.create_test_block([bip112tx_special_v1])], success=False,
406-
reject_reason='mandatory-script-verify-flag-failed (Negative locktime)')
406+
reject_reason='block-script-verify-flag-failed (Negative locktime)')
407407
self.send_blocks([self.create_test_block([bip112tx_emptystack_v1])], success=False,
408-
reject_reason='mandatory-script-verify-flag-failed (Operation not valid with the current stack size)')
408+
reject_reason='block-script-verify-flag-failed (Operation not valid with the current stack size)')
409409
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 1 txs should still pass
410410

411411
success_txs = [tx['tx'] for tx in bip112txs_vary_OP_CSV_v1 if tx['sdf']]
@@ -420,15 +420,15 @@ def run_test(self):
420420
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_9_v1 if not tx['sdf']]
421421
for tx in fail_txs:
422422
self.send_blocks([self.create_test_block([tx])], success=False,
423-
reject_reason='mandatory-script-verify-flag-failed (Locktime requirement not satisfied)')
423+
reject_reason='block-script-verify-flag-failed (Locktime requirement not satisfied)')
424424

425425
self.log.info("Test version 2 txs")
426426

427427
# -1 OP_CSV tx and (empty stack) OP_CSV tx should fail
428428
self.send_blocks([self.create_test_block([bip112tx_special_v2])], success=False,
429-
reject_reason='mandatory-script-verify-flag-failed (Negative locktime)')
429+
reject_reason='block-script-verify-flag-failed (Negative locktime)')
430430
self.send_blocks([self.create_test_block([bip112tx_emptystack_v2])], success=False,
431-
reject_reason='mandatory-script-verify-flag-failed (Operation not valid with the current stack size)')
431+
reject_reason='block-script-verify-flag-failed (Operation not valid with the current stack size)')
432432

433433
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 2 txs should pass (all sequence locks are met)
434434
success_txs = [tx['tx'] for tx in bip112txs_vary_OP_CSV_v2 if tx['sdf']]
@@ -444,20 +444,20 @@ def run_test(self):
444444
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_9_v2 if not tx['sdf']]
445445
for tx in fail_txs:
446446
self.send_blocks([self.create_test_block([tx])], success=False,
447-
reject_reason='mandatory-script-verify-flag-failed (Locktime requirement not satisfied)')
447+
reject_reason='block-script-verify-flag-failed (Locktime requirement not satisfied)')
448448

449449
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in nSequence, tx should fail
450450
fail_txs = [tx['tx'] for tx in bip112txs_vary_nSequence_v2 if tx['sdf']]
451451
for tx in fail_txs:
452452
self.send_blocks([self.create_test_block([tx])], success=False,
453-
reject_reason='mandatory-script-verify-flag-failed (Locktime requirement not satisfied)')
453+
reject_reason='block-script-verify-flag-failed (Locktime requirement not satisfied)')
454454

455455
# If sequencelock types mismatch, tx should fail
456456
fail_txs = [tx['tx'] for tx in bip112txs_vary_nSequence_v2 if not tx['sdf'] and tx['stf']]
457457
fail_txs += [tx['tx'] for tx in bip112txs_vary_OP_CSV_v2 if not tx['sdf'] and tx['stf']]
458458
for tx in fail_txs:
459459
self.send_blocks([self.create_test_block([tx])], success=False,
460-
reject_reason='mandatory-script-verify-flag-failed (Locktime requirement not satisfied)')
460+
reject_reason='block-script-verify-flag-failed (Locktime requirement not satisfied)')
461461

462462
# Remaining txs should pass, just test masking works properly
463463
success_txs = [tx['tx'] for tx in bip112txs_vary_nSequence_v2 if not tx['sdf'] and not tx['stf']]

test/functional/feature_dersig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def run_test(self):
133133
block.hashMerkleRoot = block.calc_merkle_root()
134134
block.solve()
135135

136-
with self.nodes[0].assert_debug_log(expected_msgs=['Block validation error: mandatory-script-verify-flag-failed (Non-canonical DER signature)']):
136+
with self.nodes[0].assert_debug_log(expected_msgs=['Block validation error: block-script-verify-flag-failed (Non-canonical DER signature)']):
137137
peer.send_and_ping(msg_block(block))
138138
assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip)
139139
peer.sync_with_ping()

test/functional/feature_nulldummy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from test_framework.wallet_util import generate_keypair
3939

4040
NULLDUMMY_TX_ERROR = "mempool-script-verify-flag-failed (Dummy CHECKMULTISIG argument must be zero)"
41-
NULLDUMMY_BLK_ERROR = "mandatory-script-verify-flag-failed (Dummy CHECKMULTISIG argument must be zero)"
41+
NULLDUMMY_BLK_ERROR = "block-script-verify-flag-failed (Dummy CHECKMULTISIG argument must be zero)"
4242

4343
def invalidate_nulldummy_tx(tx):
4444
"""Transform a NULLDUMMY compliant tx (i.e. scriptSig starts with OP_0)

0 commit comments

Comments
 (0)