Test unexecuted OP_CODESEPARATOR #5421

pull petertodd wants to merge 1 commits into bitcoin:master from petertodd:unexecuted-codeseparators changing 2 files +21 −0
  1. petertodd commented at 5:54 AM on December 4, 2014: contributor

    OP_CODESEPARATOR is an actual executed instruction, not a declarative thing, so if it's wrapped in an OP_IF it can be turned off. Looks like we weren't testing this before.

    Using this to implement Rivest's Paywords is left as an exercise for the reader. (seriously, this is the first time I've found something useful to do with OP_CODESEPARATOR right now)

  2. Test unexecuted OP_CODESEPARATOR
    OP_CODESEPARATOR is an actual executed instruction, not a declarative
    thing, so if it's wrapped in an OP_IF it can be turned off.
    
    Using this to implement Rivest's Paywords is left as an exercise for the
    reader.
    cac15bedb1
  3. aalness commented at 8:38 AM on December 4, 2014: contributor

    tACK

    scriptPubKey: IF CODESEPARATOR ENDIF 0x21 0x0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 CHECKSIGVERIFY CODESEPARATOR 1

    Valid

    scriptSig: 304502207a6974a77c591fa13dff60cabbb85a0de9e025c09c65a4b2285e47ce8e22f761022100f0efaac9ff8ac36b10721e0aae1fb975c90500b50c56e8a0cc52b0403f0425dd01 0

    data: IF ENDIF 0x21 0x0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 CHECKSIGVERIFY 1

    scriptSig: 3045022100fa4a74ba9fd59c59f46c3960cf90cbe0d2b743c471d24a3d5d6db6002af5eebb02204d70ec490fd0f7055a7c45f86514336e3a7f03503dacecabb247fc23f15c835101 1

    data: ENDIF 0x21 0x0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 CHECKSIGVERIFY 1

    Invalid

    scriptSig: 304502207a6974a77c591fa13dff60cabbb85a0de9e025c09c65a4b2285e47ce8e22f761022100f0efaac9ff8ac36b10721e0aae1fb975c90500b50c56e8a0cc52b0403f0425dd01 1

    data: ENDIF 0x21 0x0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 CHECKSIGVERIFY 1

    scriptSig: 3045022100fa4a74ba9fd59c59f46c3960cf90cbe0d2b743c471d24a3d5d6db6002af5eebb02204d70ec490fd0f7055a7c45f86514336e3a7f03503dacecabb247fc23f15c835101 0

    data: IF ENDIF 0x21 0x0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 CHECKSIGVERIFY 1

    Will read up on PayWords.

  4. laanwj added the label Tests on Dec 4, 2014
  5. laanwj commented at 12:28 PM on December 4, 2014: member

    Tested (on x86_64 and ARM) ACK cac15bedb1398a1eb72837b74ab76266305172e1 (signature)

  6. laanwj commented at 9:00 AM on December 15, 2014: member
  7. sipa commented at 11:19 AM on December 16, 2014: member

    untested ACK; this should be safe in any case.

    I would prefer it if TestBuilder could be used, so it's easier to add variations later without needing to manually build the signatures. TestBuilder right now has no way to correctly deal with OP_CODESEPARATORs, so I'll see if I can add that after this PR.

  8. petertodd commented at 11:27 AM on December 16, 2014: contributor

    Semi NACK re: testbuilder - I think there's a lot of value in a skilled human going through this stuff manually. Testbuilder + a skilled human can be useful, but there has to be a core set of tests built manually.

    For example, I have another codebase I'm working on where the unittests test some fairly complex cryptographic hashing code by manually building up trees of hashes from scratch.

  9. sipa commented at 11:43 AM on December 16, 2014: member

    @petertodd I think that whatever tests can be built automatically, should be built automatically. They're just more readable and reusable. Currently this is a type of test which we can't build automatically, so ACK on adding it manually.

    Note that the TestBuilder tests are included in the JSON code (and verified that they are), so they are available to other codebases, and modifications which would unintentionally modify both the actual implementation and the testing code in a way that is consistent with each other will still be caught.

  10. petertodd commented at 11:50 AM on December 16, 2014: contributor

    @sipa Yeah, I don't fully agree there for consensus critical stuff. "More readable" can easily mean you've missed what the test actually does because you're at too high a level of abstraction. For instance for that hashing code mentioned above you really did need that assurance that what you thought was being hashed actually was.

    Having additional automatically built tests on top of that case be useful to get more coverage, but you gotta start with the basics.

  11. sipa commented at 11:50 AM on December 16, 2014: member

    @petertodd No objection to having both automated and manual tests for tricky cases.

  12. petertodd commented at 12:03 PM on December 16, 2014: contributor

    @sipa Just reminding people that 95% of Bitcoin is a tricky case. :)

  13. laanwj merged this on Dec 19, 2014
  14. laanwj closed this on Dec 19, 2014

  15. laanwj referenced this in commit 886eb57507 on Dec 19, 2014
  16. 0xartem referenced this in commit 15f3496d01 on Jun 1, 2018
  17. MarcoFalke locked this on Sep 8, 2021
Labels

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-04-17 12:15 UTC

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