The original scripts were done incorrectly, so they are changed to represent two different 2-byte pushes.
Fixes #32114 (review)
The original scripts were done incorrectly, so they are changed to represent two different 2-byte pushes.
Fixes #32114 (review)
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32270.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
Concept ACK | rkrux |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, this pull request conflicts with the following ones:
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.
1239@@ -1240,8 +1240,8 @@ def sample_spenders():
1240 # Create a list of scripts which will be built into a taptree
1241 scripts = [
1242 # leaf label, followed by CScript
1243- ("encodeable_pushdata1", CScript([OP_DROP, OP_PUSHDATA1, b'aa' * 75])),
1244- ("nonstd_encodeable_pushdata1", CScript([OP_PUSHDATA1, b'aa'])),
1245+ ("2byte_pushdata", CScript([OP_DROP, b'\xaa\xaa'])),
1246+ ("nonstd_2byte_pushdata", CScript.fromhex("4c02aaaa")),
nonstd_2byte_pushdata1
because it uses the PUSHDATA1
opcode?
That’s what is mentioned in the comments of the previous PR and in the spender comment down below.
CScript
here?
For better illustration.
pushdata1
in tutorial/nonminpushdata1
later in the spender comment seems unnecessary then.
push
everywhere
Concept ACK
My bad I didn’t look at the scripts thoroughly in the previous PR and focussed more on the design of the examples.
I debugged the scripts in the test and can indeed see the unintended script as described in this comment: #32114 (review)
0('encodeable_pushdata1', CScript([OP_DROP, x('96616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161'), OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP, OP_NOP]))
1262- add_spender(spenders, comment="tutorial/pushdata1redux", tap=tap, leaf="encodeable_pushdata1", inputs=[b'\x00'], failure={"leaf": "dummyleaf"}, **ERR_NO_SUCCESS)
1263+ add_spender(spenders, comment="tutorial/pushdataredux", tap=tap, leaf="2byte_pushdata", inputs=[b'\x00'], failure={"leaf": "dummyleaf"}, **ERR_NO_SUCCESS)
1264
1265 # Spender that is non-standard but otherwise valid, with extraneous signature data from inner key for optional failure condition
1266- add_spender(spenders, comment="tutorial/nonminpushdata1", tap=tap, leaf="nonstd_encodeable_pushdata1", key=secs[0], standard=False, failure={"inputs": [getter("sign")]}, **ERR_CLEANSTACK)
1267+ add_spender(spenders, comment="tutorial/nonminpushdata1", tap=tap, leaf="nonstd_2byte_pushdata", key=secs[0], standard=False, failure={"inputs": [getter("sign")]}, **ERR_CLEANSTACK)
I don’t have a firm grasp on script execution yet (as I have not dealt with enough script execution) and there are few things going on inside the “test_spenders” as well that I have not gone through in its entirety. These seem like focussed test cases that I am trying to reason through.
Are following the ways these 3 tapscript scenarios executed?
The “2byte_pushdata” leaf is overridden with the “dummyleaf”, and because there is no “OP_DROP” now, thus after the script execution, there is the empty string witness data left that leads to the “Script evaluated without error but finished with a false/empty top stack element” error. This shows that the emptiness of the witness data is crucial for this spender case but not so much for the first spender case because in it any witness data gets dropped due to the subsequent “OP_DROP” - I tested with “\x11” and that test case passed.
The “nonstd_2byte_pushdata” leaf contains no “OP_DROP”, and thus after script execution, multiple items are left on the stack: a signature from the “secs[0]” key & the 2 byte data that leads to the “Stack size must be exactly one after execution” error.
1239@@ -1240,8 +1240,8 @@ def sample_spenders():
1240 # Create a list of scripts which will be built into a taptree
1241 scripts = [
1242 # leaf label, followed by CScript
1243- ("encodeable_pushdata1", CScript([OP_DROP, OP_PUSHDATA1, b'aa' * 75])),
1244- ("nonstd_encodeable_pushdata1", CScript([OP_PUSHDATA1, b'aa'])),
1245+ ("2byte_pushdata", CScript([OP_DROP, b'\xaa\xaa'])),
2byte_push
, since there is no pushdata going on here?
The original scripts were done incorrectly,
so they are changed to represent two
different 2-byte pushes.
🐙 This pull request conflicts with the target branch and needs rebase.