Test: Add legacy script edge case spender test #36455

Open
benthecarman wants to merge 2 commits from taproot-legacy-edge-spenders into master AGit
benthecarman commented 2026-10-07 19:18:54 +00:00 (Migrated from github.com)

Move the spender framework from feature_taproot.py to test_framework/spenders.py, and use it in a new feature_legacy_script.py test for script edge cases that other implementations have gotten wrong: CSV with -2, a 5-byte operand whose value fits in 1 byte, IFDUP on negative or non-minimal zero, ROLL with duplicate values, OP_16 in a P2SH scriptSig, and a P2SH scriptSig that leaves 1,000 items for the scriptPubKey to run on.

The first commit is move-only. The new test supports --dumptests like feature_taproot.py, which is how the cases get into the script assets.

These were discovered by finding gaps in alternate implementations (bitcoin-s and rbitcoin)

Script assets: bitcoin-core/qa-assets#297

Move the spender framework from feature_taproot.py to test_framework/spenders.py, and use it in a new feature_legacy_script.py test for script edge cases that other implementations have gotten wrong: CSV with -2, a 5-byte operand whose value fits in 1 byte, IFDUP on negative or non-minimal zero, ROLL with duplicate values, OP_16 in a P2SH scriptSig, and a P2SH scriptSig that leaves 1,000 items for the scriptPubKey to run on. The first commit is move-only. The new test supports --dumptests like feature_taproot.py, which is how the cases get into the script assets. These were discovered by finding gaps in alternate implementations (bitcoin-s and rbitcoin) Script assets: bitcoin-core/qa-assets#297
DrahtBot commented 2026-10-07 19:19:01 +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.

Type Reviewers
ACK instagibbs

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36990 (test: replace hard-coded RPC error codes by l0rinc)
  • #36699 (test: strengthen the tapscript CHECKMULTISIG asset tests and dump the expected error by azuchi)
  • #35793 (Implement BIP 54 (Consensus Cleanup) without mainnet activation by darosior)
  • #29491 ([EXPERIMENTAL] Schnorr batch verification for blocks by fjahr)

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/36455 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36455.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36455#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. | Type | Reviewers | | ---- | --------- | | ACK | [instagibbs](https://github.com/bitcoin/bitcoin/pull/36455#pullrequestreview-5603645180) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36990](https://github.com/bitcoin/bitcoin/pull/36990) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36990.svg"></sub> (test: replace hard-coded RPC error codes by l0rinc) * [#36699](https://github.com/bitcoin/bitcoin/pull/36699) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36699.svg"></sub> (test: strengthen the tapscript CHECKMULTISIG asset tests and dump the expected error by azuchi) * [#35793](https://github.com/bitcoin/bitcoin/pull/35793) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35793.svg"></sub> (Implement BIP 54 (Consensus Cleanup) without mainnet activation by darosior) * [#29491](https://github.com/bitcoin/bitcoin/pull/29491) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/29491.svg"></sub> ([EXPERIMENTAL] Schnorr batch verification for blocks by fjahr) 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

No verified findings are available from this review.

Review coverage was incomplete.


Reviewed: d7e3279392f4 · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:4d44b6ffa09c54db24f8f0ab27ae388beae06a733efcae741ca64db76bb1c938:7efd3c3ba41667382004cfa7a7db56605da7d8f9b7ab69bc483f27117390ba48 --> <!-- ralph-base:902190b6242a30c9ecacf90c599d18dc790c0ef3 --> <!-- ralph-head:d7e3279392f41c6b241bf9f5d93f08a776d3a324 --> <!-- ralph-case:ef5842cf98e7ef0f665cd362ed0cb583356283b8efef9fb88fa7f32f8208ac48 --> No verified findings are available from this review. Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`d7e3279392f4`](<https://git.fish.foo/bitcoin/bitcoin/commit/d7e3279392f41c6b241bf9f5d93f08a776d3a324>) · [Full review report](<https://review.fish.foo/traces/36455-d7e3279392f41c6b241bf9f5d93f08a776d3a324-2171-5.html>) · [Previous reports](<https://review.fish.foo/traces/36455/>) [permalink](<https://review.fish.foo/traces/36455-d7e3279392f41c6b241bf9f5d93f08a776d3a324-2171-5.html>)
fanquake commented 2026-10-16 06:20:11 +00:00 (Migrated from github.com)
cc @instagibbs cc @marcofleon can you look at https://github.com/bitcoin-core/qa-assets/pull/297.
instagibbs commented 2026-10-19 13:11:35 +00:00 (Migrated from github.com)

ACK fcfd8aa09b

Though IIUC these will still be dropped on regeneration?

ACK fcfd8aa09b482531b61c9481d169a54b66ea0cee Though IIUC these will still be dropped on regeneration?
sedited commented 2026-10-19 13:28:17 +00:00 (Migrated from github.com)

Though IIUC these will still be dropped on regeneration?

Should these even go into the functional tests then?

> Though IIUC these will still be dropped on regeneration? Should these even go into the functional tests then?
benthecarman commented 2026-10-21 17:25:42 +00:00 (Migrated from github.com)

Though IIUC these will still be dropped on regeneration?

I tested this and they don't.

Should these even go into the functional tests then?

Since they survive regeneration and add coverage, I don't see why not. The dumps are how they get into the script assets.

I also moved the P2SH stack-size spender here from #36465, as you suggested there. I'll update qa-assets#297 as well

> Though IIUC these will still be dropped on regeneration? I tested this and they don't. > Should these even go into the functional tests then? Since they survive regeneration and add coverage, I don't see why not. The dumps are how they get into the script assets. I also moved the P2SH stack-size spender here from #36465, as you suggested there. I'll update qa-assets#297 as well
instagibbs (Migrated from github.com) approved these changes 2026-10-21 17:29:58 +00:00
instagibbs (Migrated from github.com) left a comment

reACK 660c159220

reACK 660c1592205fb80b258e9926db80575d5e7957ae
instagibbs (Migrated from github.com) commented 2026-10-21 17:29:07 +00:00

dont think we need this comment

dont think we need this comment
darosior (Migrated from github.com) reviewed 2026-10-22 15:31:30 +00:00
darosior (Migrated from github.com) left a comment

Test coverage for surprising consensus-critical logic should take precedence, so not a blocker, but i dislike that this adds legacy-only cases to a test supposed to test Taproot logic. If we find the framework of this test is useful, which clearly is the case, then i think it should be exported to other non-Taproot specific tests. But also non-Taproot script test cases need less structure, so if you can just add those to script_tests.json & co as part of #36458 that's also a refactor we can punt down to another time.

Test coverage for surprising consensus-critical logic should take precedence, so not a blocker, but i dislike that this adds legacy-only cases to a test supposed to test Taproot logic. If we find the framework of this test is useful, which clearly is the case, then i think it should be exported to other non-Taproot specific tests. But also non-Taproot script test cases need less structure, so if you can just add those to script_tests.json & co as part of #36458 that's also a refactor we can punt down to another time.
sedited commented 2026-11-04 21:08:06 +00:00 (Migrated from github.com)

@benthecarman how do you want to proceed here?

@benthecarman how do you want to proceed here?
benthecarman commented 2026-11-04 21:33:56 +00:00 (Migrated from github.com)

Moved the test infra out of the taproot specific stuff so we do this in a more clean way

Moved the test infra out of the taproot specific stuff so we do this in a more clean way
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!36455
No description provided.