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
test: Add leaf_version
parameter to taproot_tree_helper()
#29371
base: master
Are you sure you want to change the base?
test: Add leaf_version
parameter to taproot_tree_helper()
#29371
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.
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. |
778c65e
to
fe53feb
Compare
Tested ACK fe53feb I've run The changes make sense in preparation for future expansions, as said. |
assert isinstance(script, tuple) | ||
version = LEAF_VERSION_TAPSCRIPT |
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.
here is where the previous hard coded value was that the parameter is replacing.
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 see that you don't change the hardcoded value 0xc0
, just pass it with function calls.
It does make sense to generalize taproot_tree_helper
and taproot_construct
.
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'm not familiar with taproot, but do you think it does make sense to add a test to check if someone is passing the correct version constants to the functions (maybe in a new PR, since this one is more like refactoring code)?
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 think you probably need to understand Taproot at least a bit to understand why we aren't changing the hard coded constant 0xc0
for now. I would recommend taking a look at #29221 to understand what a new using a new leaf version looks like.
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.
utACK
fe53feb
to
25dc427
Compare
I believe this CI failure is spurious: https://github.com/bitcoin/bitcoin/pull/29371/checks?check_run_id=21277712706 Could someone restart the job ( 🙏 ) or I can push an empty commit to restart everything. |
25dc427
to
00f5d15
Compare
00f5d15
to
accc172
Compare
accc172
to
1ccd751
Compare
Concept ACK In order to avoid changes in functional tests and keep the patch small and simple, it probably would makes sense to set |
This is more philsophical, but I really prefer not to provide default parameters to critical test code like this. It is SO easy to just forget to pass a parameter and have your test cases not test all possible branches of code! In this case, when dealing with consensus critical test cases, I think it should be required that the developer of the unit test pass in the tapscript version they are intending to test rather than us just assuming they want to test Please see #29221 for examples of this. For instance if I forgot to pass Reasonable minds can differ of course, for future readers of the PR leave a comment or give me a 👎 if you disagree and would like to see the default parameter used in this case. If it is clear that I'm in the minority, I will change it. |
tested ACK 1ccd751
Who am I to say, but I philosophically agree with your reasoning on not passing default parameters in critical test code. |
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.
re-ACK (I'm pro default function parameter)
Fix bug remove duplicate version var
1ccd751
to
ac5d855
Compare
This PR adds a
leaf_version
parameter totaproot_tree_helper()
. Previously the leaf version was hard coded, because we only currently support 1 leaf version.Proposed soft forks such as #29221 require new leaf versions to be allocated. This PR allows the test framework to accomodate new leaf versions. This commit is also included in #29221, but in the policy of trying to avoid mega-PRs, I carved this out into a separate PR that can be merged.
This PR does not alter any test functionality, just adds a parameter and uses it across the codebase rather than hard coding the value inside of
taproot_tree_helper()
.