-
Notifications
You must be signed in to change notification settings - Fork 38.7k
fuzz: Expand script verification flag testing to segwit v0 and tapscript #31460
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
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31460. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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. |
…seSignatureChecker
54b6ec7 to
ddec30a
Compare
ddec30a to
f9bc6ba
Compare
|
@reardencode @0xBEEFCAF3 @EthanHeilman Perhaps this is interesting for you all to review as it is relevant to testing your soft-fork proposals (i.e. #29247, #29269). |
| Span<const unsigned char> program, | ||
| const CScript& exec_script) const | ||
| { | ||
| assert(program.size() >= uint256::size()); |
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.
In 70ec9f2: Instead of asserting that the program size is greater or equal to uint256 size, could we assert that the program size is exactly the WITNESS_V0_SCRIPTHASH_SIZE?
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 mostly added that assertion to prevent a buffer overflow in the memcmp below, which won't happen as long as the program span is 32 bytes in size or larger.
I can see the value in asserting that program is an actually a v0 script hash (i.e. 32 bytes exactly). I'll consider changing it if I retouch.
The same applies to |
|
An alternative to touching consensus code to test this is to fuzz |
Yes that would be an alternative to some extend but I want to keep this test to
That is possible but I would consider that out of scope for this PR. |
|
@dergoegge This PR encouraged me to break the unit testing improvements I made to the Tapscript unit tests out the OP_CAT PR and into their own PR here: #31640 |
darosior
left a comment
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.
Concept ACK.
| FuzzedSignatureChecker(const CTransaction* tx, unsigned int in, | ||
| const CAmount& amount, const PrecomputedTransactionData& tx_data, | ||
| MissingDataBehavior mdb) {} |
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 seems unnecessary, none of that is used.
| SigVersion sig_version, ScriptExecutionData& exec_data, | ||
| ScriptError* script_error = nullptr) const override | ||
| { | ||
| uint64_t fuzz_hash{HashSig(sig)}; |
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.
What does hashing adds here? If you need more than one bit why not take it out of sig directly (and have a default value if it's too small)?
| } | ||
| bool CheckLockTime(const CScriptNum& lock_time) const override | ||
| { | ||
| return HashScriptNum(lock_time); |
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.
Same here, you could just variate based on the value itself?
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
⌛ There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
1 similar comment
|
⌛ There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
|
Can be marked up for grabs. Happy to review! |
The
script_flagsharness aims to test that our script verification flags are soft-forks (i.e. applying flags can only tighten the verification rules and not widen them).SigVersion::WITNESS_V0andSigVersion::TAPSCRIPTscripts are currently not covered by this test, as fuzzers are blocked from e.g. creating a valid taproot script path spend commitment.This PR:
BaseSignatureChecker(real impl inGenericTransactionSignatureChecker)script_flags_mockedwhich uses aBaseSignatureCheckermock, unblocking fuzzers from reaching segwit v{0,1} interpreter code (as well as paths relating to valid signatures)