test: strengthen the tapscript CHECKMULTISIG asset tests and dump the expected error #36699

Open
azuchi wants to merge 1 commit from taproot-test-disabled-checkmultisig into master AGit
azuchi commented 2026-10-30 08:59:40 +00:00 (Migrated from github.com)

The tapscript/disabled_checkmultisig and tapscript/disabled_checkmultisigverify spenders in feature_taproot.py run OP_CHECKMULTISIG(VERIFY) on a Schnorr signature (0 OP_SWAP 1 <pubkey> 1 OP_CHECKMULTISIG). An implementation which forgets to disable these opcodes in tapscript still fails the case, because a 64 byte Schnorr signature is not a valid DER signature. So the asset tests generated from these spenders cannot tell whether the opcodes are disabled. This came up while running script_assets_test.json against a third-party implementation which executed OP_CHECKMULTISIG in tapscript and passed every case.

This PR does two things:

  1. Adds a 0-of-0 variant for both opcodes (OP_DROP 0 0 0 OP_CHECKMULTISIG and OP_DROP 0 0 0 OP_CHECKMULTISIGVERIFY 1). It needs no signature and leaves a single 1 on the stack, so it succeeds when the opcode is executed and fails only because of the tapscript rule. Checked against the implementation above: it accepts the new failure case while its fixed version rejects it with SCRIPT_ERR_TAPSCRIPT_CHECKMULTISIG.

  2. Writes the expected script error of a failure case into the JSON dump ("error"), taken from the err_msg the spender already declares and which block_submit already checks against the node. script_assets_test then checks the error under exactly the listed flags. Until now a failure case could only be checked for failing, not for failing for the stated reason. A superset of the flags may fail earlier for another reason, so the check is limited to the exact flag set. Consumers which do not know the field are unaffected, and spenders without err_msg get no field.

Verified by running feature_taproot.py --dumptests and test_bitcoin --run_test=script_assets_tests on the regenerated dump (2897 vectors, 2410 of them with an error field).

The `tapscript/disabled_checkmultisig` and `tapscript/disabled_checkmultisigverify` spenders in `feature_taproot.py` run `OP_CHECKMULTISIG(VERIFY)` on a Schnorr signature (`0 OP_SWAP 1 <pubkey> 1 OP_CHECKMULTISIG`). An implementation which forgets to disable these opcodes in tapscript still fails the case, because a 64 byte Schnorr signature is not a valid DER signature. So the asset tests generated from these spenders cannot tell whether the opcodes are disabled. This came up while running `script_assets_test.json` against a third-party implementation which executed `OP_CHECKMULTISIG` in tapscript and passed every case. This PR does two things: 1. Adds a 0-of-0 variant for both opcodes (`OP_DROP 0 0 0 OP_CHECKMULTISIG` and `OP_DROP 0 0 0 OP_CHECKMULTISIGVERIFY 1`). It needs no signature and leaves a single `1` on the stack, so it succeeds when the opcode is executed and fails only because of the tapscript rule. Checked against the implementation above: it accepts the new failure case while its fixed version rejects it with `SCRIPT_ERR_TAPSCRIPT_CHECKMULTISIG`. 2. Writes the expected script error of a failure case into the JSON dump (`"error"`), taken from the `err_msg` the spender already declares and which `block_submit` already checks against the node. `script_assets_test` then checks the error under exactly the listed flags. Until now a failure case could only be checked for failing, not for failing for the stated reason. A superset of the flags may fail earlier for another reason, so the check is limited to the exact flag set. Consumers which do not know the field are unaffected, and spenders without `err_msg` get no field. Verified by running `feature_taproot.py --dumptests` and `test_bitcoin --run_test=script_assets_tests` on the regenerated dump (2897 vectors, 2410 of them with an `error` field).
DrahtBot commented 2026-10-30 08:59:49 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36455 (Test: Add legacy script edge case spender test by benthecarman)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36699 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36699.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36699#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36455](https://github.com/bitcoin/bitcoin/pull/36455) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36455.svg"></sub> (Test: Add legacy script edge case spender test by benthecarman) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

🔵 Suggestion · The asset minimizer can discard the new 0-of-0 CHECKMULTISIG vectors

Because the minimizer distinguishes vectors by interpreter coverage rather than the new error field, pass/fail-only consumers may not receive t37/t38 after regeneration.

Location: test/functional/feature_taproot.py:1056 (head).

Design and approach

The 0-of-0 vectors close a real gap by detecting when CHECKMULTISIG executes, but the new exact error-text assertion makes Core CI depend on an externally maintained qa-assets file that cannot be updated atomically with Core. Rework the check so ScriptError changes do not block Core CI, or split the error field into a separate change that specifies how such reclassifications will be handled. qa-assets PR #33961

Review coverage was incomplete.


Reviewed: 420decb1701b · Full review report · Previous reports

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:7ba49ca38b129bc35f71e566efbd136b17ae87b582376d9eebd04f18959e8274:9b5e0237a3fe9e1d05225291551198f07780ddb92e41e55ade9e98c2687fc127 --> <!-- ralph-base:6ed5aad06111177c39f9b9f07a52634476380ae1 --> <!-- ralph-head:420decb1701b192cb8d40252df227a11401a313c --> <!-- ralph-case:d2f4e59cec685e78b1506409efc3ccb0e226aa7d23ca3f848ef492d8d258cee0 --> **🔵 Suggestion · The asset minimizer can discard the new 0-of-0 CHECKMULTISIG vectors** Because the minimizer distinguishes vectors by interpreter coverage rather than the new `error` field, pass/fail-only consumers may not receive t37/t38 after regeneration. Location: [`test/functional/feature_taproot.py:1056`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/420decb1701b192cb8d40252df227a11401a313c/test/functional/feature_taproot.py#L1056>) (head). ##### Design and approach The 0-of-0 vectors close a real gap by detecting when CHECKMULTISIG executes, but the new exact error-text assertion makes Core CI depend on an externally maintained qa-assets file that cannot be updated atomically with Core. Rework the check so ScriptError changes do not block Core CI, or split the error field into a separate change that specifies how such reclassifications will be handled. [qa-assets](https://github.com/bitcoin-core/qa-assets/raw/main/unit_test_data/script_assets_test.json) [PR #33961](https://git.fish.foo/bitcoin/bitcoin/pulls/33961) Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`420decb1701b`](<https://git.fish.foo/bitcoin/bitcoin/commit/420decb1701b192cb8d40252df227a11401a313c>) · [Full review report](<https://review.fish.foo/traces/36699-420decb1701b192cb8d40252df227a11401a313c-1773-1.html>) · [Previous reports](<https://review.fish.foo/traces/36699/>)
fanquake commented 2026-10-30 09:25:09 +00:00 (Migrated from github.com)

cc @instagibbs

cc @instagibbs
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36699
No description provided.