Test: Add script vectors for interpreter edges #36458

pull benthecarman wants to merge 1 commits into bitcoin:master from benthecarman:script-vectors-interpreter-edges changing 2 files +38 −1
  1. benthecarman commented at 7:35 PM on October 7, 2026: contributor

    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)

  2. Test: Add script vectors for interpreter edges
    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.
    5d2fb8d309
  3. DrahtBot added the label Tests on Oct 7, 2026
  4. DrahtBot commented at 7:35 PM on October 7, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK darosior

    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-->

  5. fametrano commented at 9:36 AM on October 9, 2026: contributor

    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.

  6. fanquake commented at 6:22 AM on October 16, 2026: member
  7. darosior commented at 2:49 PM on October 22, 2026: member

    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.

  8. in src/test/data/tx_invalid.json:239 in 5d2fb8d309
     235 | @@ -224,6 +236,10 @@
     236 |  [[["0000000000000000000000000000000000000000000000000000000000000100", 0, "-1 CHECKSEQUENCEVERIFY"]],
     237 |  "020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "CHECKSEQUENCEVERIFY"],
     238 |  
     239 | +["Argument -2 with by-blockheight txin.nSequence=0, even though -2 has the disable flag bit set"],
    


    darosior commented at 8:49 PM on October 22, 2026:

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


    benthecarman commented at 9:31 PM on October 22, 2026:

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

  9. in src/test/data/script_tests.json:2616 in 5d2fb8d309
    2612 | @@ -2616,6 +2613,8 @@
    2613 |  ["CHECKSEQUENCEVERIFY tests"],
    2614 |  ["", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "INVALID_STACK_OPERATION", "CSV automatically fails on an empty stack"],
    2615 |  ["-1", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "NEGATIVE_LOCKTIME", "CSV automatically fails if stack top is negative"],
    2616 | +["-2", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "NEGATIVE_LOCKTIME", "CSV fails for any negative operand, even though -2 has the disable flag bit set"],
    


    darosior commented at 8:51 PM on October 22, 2026:

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

  10. in src/test/data/script_tests.json:1041 in 5d2fb8d309
    1037 | @@ -1036,6 +1038,8 @@
    1038 |  ["-2147483648", "1ADD 1", "P2SH,STRICTENC", "SCRIPTNUM", "Because we use a sign bit, -2147483648 is also 5 bytes"],
    1039 |  ["2147483647", "1ADD 1SUB 1", "P2SH,STRICTENC", "SCRIPTNUM", "We cannot do math on 5-byte integers, even if the result is 4-bytes"],
    1040 |  ["2147483648", "1SUB 1", "P2SH,STRICTENC", "SCRIPTNUM", "We cannot do math on 5-byte integers, even if the result is 4-bytes"],
    1041 | +["0x05 0xff00000000", "1ADD DROP 1", "P2SH,STRICTENC", "SCRIPTNUM", "We cannot do math on 5-byte integers, even if the value fits in 1 byte when minimally encoded"],
    


    darosior commented at 8:52 PM on October 22, 2026:

    Nice.

  11. darosior approved
  12. darosior commented at 8:53 PM on October 22, 2026: member

    ACK 5d2fb8d3098703bc4d23d582eb4987cb2dbeda7a


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-29 06:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me