-
Notifications
You must be signed in to change notification settings - Fork 36.6k
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
Make VerifyWitnessProgram use a Span stack #18388
Conversation
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. |
utACK c7b0131 wondering if there's some short-hand we could do to "split" the |
@instagibbs No reason why a |
@sipa took the words right out of my mouth :) I think the latter is perfect for our use-case |
c7b0131
to
ef540f7
Compare
@instagibbs Done. |
utACK ef540f7 |
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.
Code-Review ACK ef540f7
(By the way, getting used to Span, I'm more and more surprised that such a useful lightweight representation hasn't been in the C++ standard for years.)
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.
tACK ef540f7
Read the code, couldn't spot any logic change.
ran unit tests+functional tests
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.
Code review ACK.
This allows for very cheap transformations on the range of elements that are to be passed to ExecuteWitnessScript.
ef540f7
to
2b0fcff
Compare
ReACK on the diff 2b0fcff |
ACK 2b0fcff |
re-ACK 2b0fcff |
re-ACK 2b0fcff |
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 2b0fcff
@@ -27,6 +28,8 @@ class Span | |||
constexpr C* data() const noexcept { return m_data; } | |||
constexpr C* begin() const noexcept { return m_data; } | |||
constexpr C* end() const noexcept { return m_data + m_size; } | |||
constexpr C& front() const noexcept { return m_data[0]; } |
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.
Note for reviewers: these functions front()
and back()
are no longer used in this PR, but are used in the taproot implementation, so there's no harm in including them here.
ACK 2b0fcff |
Summary: 2b0fcff7f26d59fed4bcafd1602325122a206c67 Make VerifyWitnessProgram use a Span stack (Pieter Wuille) Pull request description: Here is a follow-up to #18002, again with the goal of simplifying (potential) BIP341 code. Instead of passing a begin and end iterator of the initial stack to `ExecuteWitnessScript`, they are turned into a `Span<const valtype>`, representing a span of `valtype`s in memory. This allows `VerifyWitnessProgram` to operate on that span directly, instead of juggling iterators around (which would be exacerbated by #17977 if trying to avoid copying the stack). --- Ignored the SegWit stuff but brought in the Span functionality, might be used in the future also less merge conflicts Backport of Core [[bitcoin/bitcoin#18388 | PR18388]] Test Plan: ninja Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D8495
Here is a follow-up to #18002, again with the goal of simplifying (potential) BIP341 code.
Instead of passing a begin and end iterator of the initial stack to
ExecuteWitnessScript
, they are turned into aSpan<const valtype>
, representing a span ofvaltype
s in memory. This allowsVerifyWitnessProgram
to operate on that span directly, instead of juggling iterators around (which would be exacerbated by #17977 if trying to avoid copying the stack).