-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Simplify hash.h interface using Spans #19326
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
@jb55 You may be interested in this. |
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. |
yup this will clean up some of my PRs. Concept ACK (I would almost say utACK but I just woke up). |
Concept ACK. Read the code, built/tested/running bitcoind, need to do more detailed code review stepping through the commits. |
Concept ACK: |
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.
ACK 974381f a useful clear abstraction and nice cleanup. Code review, compared the implementation of as_(writable_)bytes
to that shown in https://en.cppreference.com/w/cpp/container/span/as_bytes (if you retouch, s/to_/as_/
in the 45316c2 commit message). Built in various ways, ran tests and benches locally, ran bitcoind without issues for a day.
Rebased and addressed @jonatack's comment. |
re-ACK fc7c518 |
Rebased. |
re-ACK 77c5073 |
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 re-ACK 77c5073 per git range-diff 14ceddd 49fc016 77c5073
77c5073 Make Hash[160] consume range-like objects (Pieter Wuille) 02c4cc5 Make CHash256/CHash160 output to Span (Pieter Wuille) 0ef97b1 Make MurmurHash3 consume Spans (Pieter Wuille) e549bf8 Make CHash256 and CHash160 consume Spans (Pieter Wuille) 2a2182c Make script/standard's BaseHash Span-convertible (Pieter Wuille) e63dcc3 Add MakeUCharSpan, to help constructing Span<[const] unsigned char> (Pieter Wuille) 5678250 Make uint256 Span-convertible by adding ::data() (Pieter Wuille) 131a2f0 scripted-diff: rename base_blob::data to m_data (Pieter Wuille) Pull request description: This makes use of the implicit constructions and conversions to Span introduced in bitcoin#18468 to simplify the hash.h interface: * All functions that take a pointer and a length are changed to take a Span instead. * The Hash() and Hash160() functions are changed to take in "range" objects instead of begin/end iterators. ACKs for top commit: laanwj: re-ACK 77c5073 jonatack: Code review re-ACK 77c5073 per `git range-diff 14ceddd 49fc016 77c5073` Tree-SHA512: 9ec929891b1ddcf30eb14b946ee1bf142eca1442b9de0067ad6a3c181e0c7ea0c99c0e291e7f6e7a18bd7bdf78fe94ee3d5de66e167401674caf91e026269771
Summary: ``` This is in preparation for exposing a ::data member function. -BEGIN VERIFY SCRIPT- sed -i "s/\([^.]\|other.\)data/\1m_data/g" src/uint256.h src/uint256.cpp -END VERIFY SCRIPT- ``` Partial backport of core [[bitcoin/bitcoin#19326 | PR19326]]: bitcoin/bitcoin@131a2f0 The comparison fonction differs due to D1527. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9147
Summary: Partial backport (2/8) of core [[bitcoin/bitcoin#19326 | PR19326]]: bitcoin/bitcoin@5678250 Depends on D9147. Test Plan: ninja Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9148
Summary: Partial backport (3/8) of core [[bitcoin/bitcoin#19326 | PR19326]]: bitcoin/bitcoin@e63dcc3 Depends on D9148. Test Plan: ninja Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9149
Summary: Partial backport (4/8) of core [[bitcoin/bitcoin#19326 | PR19326]]: bitcoin/bitcoin@2a2182c Depends on D9149. Test Plan: ninja Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9150
Summary: Partial backport (5/8) of core [[bitcoin/bitcoin#19326 | PR19326]]: bitcoin/bitcoin@e549bf8 The segwit related parts have been skipped. Depends on D9150. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9151
Summary: Partial backport (6/8) of core [[bitcoin/bitcoin#19326 | PR19326]]: bitcoin/bitcoin@0ef97b1 Depends on D9151. Test Plan: ninja all check Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9152
Summary: Partial backport (7/8) of core [[bitcoin/bitcoin#19326 | PR19326]]: bitcoin/bitcoin@02c4cc5 Depends on D9152. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9153
Summary: Completes backport (8/8) of core [[bitcoin/bitcoin#19326 | PR19326]]: bitcoin/bitcoin@77c5073 Depends on D9156. There is a missing dependency for the `walletdb.cpp` change for which I left a comment to make the later backport easier. This diff also contains a few changes which are specific to our repo. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D9154
Merge bitcoin#19660, bitcoin#19373, bitcoin#19841, bitcoin#13862, bitcoin#13866, bitcoin#17280, bitcoin#17682 and partial bitcoin#19326, bitcoin#14978: Auxiliary Backports
a1f3aed util: make EncodeBase64 consume Spans (furszy) c36754f Add MakeUCharSpan, to help constructing Span<[const] unsigned char> (Pieter Wuille) 1f18199 Make uint256 Span-convertible by adding ::data() (Pieter Wuille) 0067590 Add lifetimebound to attributes for general-purpose usage (Cory Fields) 26eb256 span: add lifetimebound attribute (Cory Fields) 696e91f span: (almost) match std::span's constructor behavior (Cory Fields) da207d4 doc: Mention Span in developer-notes.md (Pieter Wuille) 138053d doc: Document Span pitfalls (Pieter Wuille) e2216d7 Add sanity check asserts to span when -DDEBUG (Pieter Wuille) ebcc978 Add Span constructors for arrays and vectors (Pieter Wuille) 38f105b Make pointer-based Span construction safer (Pieter Wuille) 33d5297 Make Span size type unsigned (Pieter Wuille) 17118e1 Support conversion between Spans of compatible types (Pieter Wuille) f36042f Span front() and back() methods and SpanPopBack function backport (furszy) 1b2e7c8 Add more methods to Span class (Pieter Wuille) Pull request description: Another decouple from #2411. Purely focused on updating the Span sources to be up-to-date with current upstream. Following PRs/commits were back ported: * bitcoin#13697 (only 29943a9) * 2b0fcff (only span changes). * bitcoin#18591 (only 0fbde48). * bitcoin#18468 (without 2676aea). * bitcoin#19367. * bitcoin#19387. * bitcoin#19326 (only 5678250 and e63dcc3 here). * bitcoin#19687 (only e2aa1a5 here, 2bc2071 is inside #2411 and require net related commits that are introduced down the commits line there). Extra side note: Some of the current serialization compiler warnings in master will be fixed with this, other ones are coming down 2411 commits line as they need other previous PRs. ACKs for top commit: random-zebra: Tested ACK a1f3aed Tree-SHA512: 256bc2064724ea6d4f6fac722fafb4ed3e2b4590cdad61bf1e4a5be25e0632bafcff39235ea6ed7badbef4f79dbb4f866356372a1b3c201af23873884baedfea
This makes use of the implicit constructions and conversions to Span introduced in #18468 to simplify the hash.h interface: