-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SigVersion
parameter to IsOpSuccess()
#29265
Add SigVersion
parameter to IsOpSuccess()
#29265
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process. ConflictsReviewers, 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. |
I think you'd want to pass SigVersion rather than leaf_version. The SigVersion defines what script/signature rules are active, while the leaf_version is one of several ways of encoding that information in scripts. It also answers your comment: we don't care about unknown leaf_versions because they will never occur (under an unknown leaf version, no script execution happens at all). That said, I think a change like this belongs in the PR that implements a consensus change that needs it. It's generally better not to touch consensus code unless necessary. |
Small quibble here, there are other consensus PRs out there that probably would need this change ( #29247 , #29050 , #28550 ). Its unclear to me right now if I was just "lucky" with my opcode byte selection such that I ran into a test case that failed with witness redeemScript ( That said, if you don't find that argument compelling i will close this in the next few days and add it to #29221 |
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
While they're just drafts, they can just each include the commit; DrahtBot will report them as conflicting, but that's not big deal. If/when it becomes apparent that there's wide consensus in favour of adopting/merging/activating one or more of the changes, we can pull that commit out as a preparatory step prior to the consensus changes. Compare with #16902 or #18002 perhaps. |
1498198
to
5600629
Compare
IsOpSuccess()
SigVersion
parameter to IsOpSuccess()
done in 5600629 , however I still have the |
src/script/script.cpp
Outdated
@@ -7,6 +7,7 @@ | |||
|
|||
#include <crypto/common.h> | |||
#include <hash.h> | |||
#include <script/interpreter.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This triggers the linter
A new circular dependency in the form of "script/interpreter -> script/script -> script/interpreter" appears to have been introduced.
Is there an easy way to get around this? The include is for SigVersion
seems like putting SigVersion
in its own file would fix this, is that the correct approach?
5600629
to
fd9776d
Compare
src/script/script.cpp
Outdated
case SigVersion::BASE: | ||
case SigVersion::WITNESS_V0: | ||
case SigVersion::TAPROOT: | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using default
in a switch will disable compiler warnings and make code more brittle. See the developer notes on how to handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I attempted to fix this in c1fe710
Is that what things should look like? From Pieter's original comment, it seemed like asserting false in the case of non tapscript sig versions are was desirable.
fd9776d
to
b84c861
Compare
6126c56
to
f4907a9
Compare
Rework IsOpSuccess() to use SigVersion rather than leaf_version Use switch based impl for IsOpSuccess() Remove default in switch statement Fix compiler warning Move SigVersion to sigversion.h Fix includes try to fix compile Add sigversion.h Add include guards
f4907a9
to
50b7286
Compare
Closing this PR on this recommendation. For future readers that might find this useful, you can cherry-pick this commit: 50b7286 or find the latest in #29221 |
This PR adds a
SigVersion
parameter toIsOpSuccess()
. This is needed to make continued progress on #29221 .Problem
As per BIP341
This is occurring on #29221, in script_assets_test.json there exists a witness redeemScript
de4c
. In #29221 this translates toOP_GREATHERTHAN64 OP_PUSHDATA1
.When looking at parsing logic for
GetScriptOp
we see thatOP_PUSHDATA1
requires a data element following it to specify the push size. Since this is not available, the script fails to parse and thus fails the entire script.Solution
Make
IsOpSuccess()
dependent onSigVersion
. Now forSigVersion::TAPSCRIPT
leaf versions, we retain theOP_SUCCESSx
semantics, thus trivially parsing and passing the witness redeemScriptde4c
If you want to see how this works with #29221, please see this commit that shows this logic working in tandem with the new op codes proposed in the 64 bit arithmetic BIP: