-
Notifications
You must be signed in to change notification settings - Fork 37.3k
[Refactor]: Rename Script methods that only work on PreTapScript scripts #22338
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
Conversation
Concept ACK Since BIP 342 is implemented in Bitcoin Core, OP_CHECKSIGADD is the last executable opcode now according to my understanding.
Not sure about this part |
To elaborate, right now this is used while parsing scrpitPubkey and ScrpitSig in a Tx. It is impossible for So, the ideal solution would be to somehow pass the script context and enforce that the |
Concept ACK |
1 similar comment
Concept ACK |
Would it be a better idea to split the baby now and make the handling of pre-v1 and v1 scripts different here? |
src/script/script.h
Outdated
@@ -205,7 +205,7 @@ enum opcodetype | |||
}; | |||
|
|||
// Maximum value that an opcode can be | |||
static const unsigned int MAX_OPCODE = OP_NOP10; | |||
static const unsigned int MAX_OPCODE = OP_CHECKSIGADD; |
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.
context:
OP_NOP10 = 0xb9,
OP_CHECKSIGADD = 0xba,
Concept ACK
The main thing to review here is then that this doesn't create any risk for non-tapscript verification. It seems that
I don't think this should even be labeled "consensus"? Or am I missing something. Code review ACK 90f6a62 |
I am still learning. Not mixing consensus code with utility code would help me. |
I don't think this makes sense? For tapscript, the highest valid opcode is Maybe it would be better to rename |
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.
test fails? Maybe needs rebase?
test/script_parse_tests.cpp(53): error: in "script_parse_tests/parse_script": exception std::runtime_error expected but not raised
@sanket1729 are you interested in following up here? |
@fanquake, sorry I missed this. I will follow up on this in a couple of days. |
Indeed
Agreed, this seems the cleaner way to solve this. |
Changed the PR description. I think there might be other places where we implicitly assume script as PreTapScript. For example, there is also a constant |
Constant: MAX_OPCODE -> MAX_OPCODE_PRE_TAPSCRIPT Functions: ParseScript -> ParseScriptPreTapScript ParseOpcode -> ParseOpCodePreTapScript HasValidOps -> HasValidOpsPreTapScript class: OpCodeParser -> PreTapScriptOpCodeParser
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
Closing this as it has not had any activity in a while. If you are interested in continuing work on this, please leave a comment so that it can be reopened. |
- This change is not really necessary as MAX_OPCODE check is only really used while decoding transactions, but makes the code more consistent(and correct)The tests that use MAX_OPCODE are not failing because they are under P2SH context(where the OP_CHECKSIGADD is invalid anyways). The comment in the test has been updated to accurately reflect what is going on.Based on Aj's comment, I have changed the PR so that it renames the constants/functions that operate on PreTapScript Scripts.
I don't know if this is the ideal way to separate pre-tapscripts and tapscripts. If the new PR is not useful, feel free to close it.