[validation] Make script error messages uniform for parallel/single validation

This makes the debug output mostly the same for -par=1 and parallel validation runs. Of course,
parallel validation is non-deterministic in what error it may encounter first if there are
multiple issues. Also, the way certain script-related and non-script-related checks are
performed differs between the two modes still, which may result in discrepancies.
This commit is contained in:
Pieter Wuille
2024-10-18 06:01:23 -04:00
parent 1ac1c33f3f
commit 146a3d5426
9 changed files with 11 additions and 19 deletions

View File

@@ -214,6 +214,9 @@ class SegWitTest(BitcoinTestFramework):
self.noban_tx_relay = True
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
self.extra_args = [
# -par=1 should not affect validation outcome or logging/reported failures. It is kept
# here to exercise the code path still (as it is distinct for multithread script
# validation).
["-acceptnonstdtxn=1", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}", "-par=1"],
["-acceptnonstdtxn=0", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}"],
]
@@ -507,10 +510,6 @@ class SegWitTest(BitcoinTestFramework):
# When the block is serialized without witness, validation fails because the transaction is
# invalid (transactions are always validated with SCRIPT_VERIFY_WITNESS so a segwit v0 transaction
# without a witness is invalid).
# Note: The reject reason for this failure could be
# 'block-validation-failed' (if script check threads > 1) or
# 'mandatory-script-verify-flag-failed (Witness program was passed an
# empty witness)' (otherwise).
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)')
@@ -1015,7 +1014,7 @@ class SegWitTest(BitcoinTestFramework):
tx2.vout.append(CTxOut(tx.vout[0].nValue, CScript([OP_TRUE])))
tx2.wit.vtxinwit.extend([CTxInWitness(), CTxInWitness()])
tx2.wit.vtxinwit[0].scriptWitness.stack = [CScript([CScriptNum(1)]), CScript([CScriptNum(1)]), witness_script]
tx2.wit.vtxinwit[1].scriptWitness.stack = [CScript([OP_TRUE])]
tx2.wit.vtxinwit[1].scriptWitness.stack = []
block = self.build_next_block()
self.update_witness_block_with_transactions(block, [tx2])