Test: Add script vectors for interpreter edges #36458

Manually merged
benthecarman merged 1 commit from script-vectors-interpreter-edges into master 2026-11-05 11:19:34 +00:00 AGit
benthecarman commented 2026-10-07 19:35:17 +00:00 (Migrated from github.com)

Add script_tests.json and tx_invalid.json vectors for edge cases that
other implementations have gotten wrong, including CSV with -2, IFDUP
on negative zero, ROLL with duplicate values, a taproot output key
that is not a valid x coordinate, and single-flag STRICTENC, LOW_S and
NULLFAIL cases.

Some policy cases were only caught by the tx_valid harness adding
flags back, which implementations copying the JSON don't replicate.

Related: #36455

These were discovered by finding gaps in an alternate implementation (bitcoin-s)

Add script_tests.json and tx_invalid.json vectors for edge cases that other implementations have gotten wrong, including CSV with -2, IFDUP on negative zero, ROLL with duplicate values, a taproot output key that is not a valid x coordinate, and single-flag STRICTENC, LOW_S and NULLFAIL cases. Some policy cases were only caught by the tx_valid harness adding flags back, which implementations copying the JSON don't replicate. Related: #36455 These were discovered by finding gaps in an alternate implementation (bitcoin-s)
DrahtBot commented 2026-10-07 19:35:26 +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 darosior, sedited

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

<!--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/36458 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36458.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36458#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 | [darosior](https://github.com/bitcoin/bitcoin/pull/36458#pullrequestreview-5620675342), [sedited](https://github.com/bitcoin/bitcoin/pull/36458#pullrequestreview-5775818869) | 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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: 152a55397e451fed9c10041bddf01aa6839847d5
Head: 5d2fb8d3098703bc4d23d582eb4987cb2dbeda7a

Findings

Suggestions

Correct the minimal-encoding size in the comment (src/test/data/script_tests.json:1041, head)

0xff00000000 is a five-byte little-endian ScriptNum encoding of +255, whose minimal signed encoding ff00 is two bytes, not one. The vector still tests 1ADD rejecting a five-byte operand, but the explanation misstates the sign-bit boundary. Change “1 byte” to “2 bytes,” or use a five-byte encoding of a value such as +127 if a one-byte minimal encoding is intended.

Review coverage was incomplete.

Review limitations
  • adversarial_deepseek: Stage did not complete (ValueError).

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:78d2fcf8f9ff126c05365e10c73177ff8910b0e09bc81c9ec0b230b2aa3a4312:f359184720b19d8f4199eb38e750c73a24dbe6263b5428fbe549b1858030cb9b --> Base: `152a55397e451fed9c10041bddf01aa6839847d5` Head: `5d2fb8d3098703bc4d23d582eb4987cb2dbeda7a` ##### Findings **Suggestions** **Correct the minimal-encoding size in the comment** (src/test/data/script_tests.json:1041, head) `0xff00000000` is a five-byte little-endian ScriptNum encoding of +255, whose minimal signed encoding `ff00` is two bytes, not one. The vector still tests `1ADD` rejecting a five-byte operand, but the explanation misstates the sign-bit boundary. Change “1 byte” to “2 bytes,” or use a five-byte encoding of a value such as +127 if a one-byte minimal encoding is intended. Review coverage was incomplete. <details> <summary>Review limitations</summary> - adversarial_deepseek: Stage did not complete (ValueError). </details> [Full review report](<https://review.fish.foo/traces/36458-5d2fb8d3098703bc4d23d582eb4987cb2dbeda7a-1156-3.html>)
fametrano commented 2026-10-09 09:36:24 +00:00 (Migrated from github.com)

I ran the new vectors at 5d2fb8d through btclib, a Python implementation I maintain. Every new script_tests.json row gives the expected result and error code. Each of the 4 new tx_invalid.json rows fails under its listed flag with the error its comment describes, and is valid with no flags.

I ran the new vectors at 5d2fb8d through btclib, a Python implementation I maintain. Every new script_tests.json row gives the expected result and error code. Each of the 4 new tx_invalid.json rows fails under its listed flag with the error its comment describes, and is valid with no flags.
fanquake commented 2026-10-16 06:22:24 +00:00 (Migrated from github.com)

cc @instagibbs

cc @instagibbs
darosior commented 2026-10-22 14:49:46 +00:00 (Migrated from github.com)

Concept ACK. It's useful to know what re-implementations got wrong, as it's often non-obvious stuff we can better cover in our automated testing.

Concept ACK. It's useful to know what re-implementations got wrong, as it's often non-obvious stuff we can better cover in our automated testing.
darosior (Migrated from github.com) approved these changes 2026-10-22 20:53:28 +00:00
darosior (Migrated from github.com) left a comment
ACK 5d2fb8d3098703bc4d23d582eb4987cb2dbeda7a
darosior (Migrated from github.com) commented 2026-10-22 20:52:55 +00:00

Nice.

Nice.
darosior (Migrated from github.com) commented 2026-10-22 20:51:20 +00:00

Heh, nice. (Though the -1 vector would also catch this, but good to have it spelled out.)

Heh, nice. (Though the -1 vector would also catch this, but good to have it spelled out.)
darosior (Migrated from github.com) commented 2026-10-22 20:49:45 +00:00

Isn't this one redundant with the script_tests.json one you added above?

Isn't this one redundant with the script_tests.json one you added above?
benthecarman (Migrated from github.com) reviewed 2026-10-22 21:31:58 +00:00
benthecarman (Migrated from github.com) commented 2026-10-22 21:31:58 +00:00

yeah i guess, being redundant doesn't really hurt here though

yeah i guess, being redundant doesn't really hurt here though
sedited (Migrated from github.com) approved these changes 2026-11-04 21:07:44 +00:00
sedited (Migrated from github.com) left a comment
LGTM ACK 5d2fb8d3098703bc4d23d582eb4987cb2dbeda7a, but waiting on resolution here: https://github.com/bitcoin/bitcoin/pull/36455#pullrequestreview-5616742117
sedited commented 2026-11-05 11:16:13 +00:00 (Migrated from github.com)

Merging this. If there is more, it can just go into another pull request.

Merging this. If there is more, it can just go into another pull request.
Sign in to join this conversation.
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!36458
No description provided.