-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: Allow CScript construction from any std::input_iterator #29369
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 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. ConflictsNo conflicts as of last run. |
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
Concept ACK dddd56c Looks like a nice code change to me. "previous releases" CI is turning up an issue in script/interpreter
|
looks like a few issues in that file |
@delta1 This is an issue in the C++ standard library. Basically, the standard assumes that |
@maflcko interesting, thanks for the context. does that mean that the previous releases CI job needs to be changed to use a newer gcc? |
Yes, either use a newer GCC, or remove the |
dddd56c
to
fa9ef95
Compare
Removed unused |
ACK fa9ef95 |
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 fa9ef95
LGTM. Could change template<typename InputIterator>prevector(...)
to also expect std::input_iterator
.
The prevector functions that take two iterators first increase the capacity by last - first
then run fill(ptr, first, last)
-- that's buggy if the passed in iterators specify a greater range than a size_type
(or difference_type
for insert()
) can hold. Could perhaps be worth changing:
- template<typename InputIterator>
- void fill(T* dst, InputIterator first, InputIterator last) {
- while (first != last) {
+ template<std::input_iterator InputIterator>
+ void fill(T* dst, InputIterator first, size_type n) {
+ while (n-- > 0) {
Sure, done for all InputIterators in this file.
I think it will in all cases be buggy if the range can not be held in |
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 fa40ae2
Also, remove the value_type alias, which is not needed when element_type is present.
fa40ae2
to
fa7b9b9
Compare
reACK fa7b9b9 |
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 fa7b9b9
Verified that it resolved the issue I was having on other PR (#30377 (comment)) through cherry-picking the commits in this PR, undoing the local workaround, and pushing to a personal GitHub branch 239709e to see if Windows CI compiled it successfully, which it did (https://github.com/hodlinator/bitcoin/actions/runs/10419824929/job/28858657327).
nit: I'd prefer the removal of value_type
from prevector
was its own commit and the remaining changes were squashed into a second commit as they appear to belong closer together.
Yeah, they are related, but the prevector one adds requirements on the code, and the cscript one removes requirements on the code, which is why they are in two commits. |
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 fa7b9b9
rfm with 5 acks on the first commit (2 stale and 3 current), and 3 acks on the second commit? |
I haven't been merging anything just because I think we are in feature freeze #29891 |
ACK fa7b9b9 |
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.
Post-merge utACK fa7b9b9. I had a similar commit while hacking on allocators a while back: theuni@3d34f21 . This is even more elegant :)
8756ccd scripted-diff: Replace ParseHex[<std::byte>]("str") -> "str"_hex[_u8] (Hodlinator) 9cb6873 refactor: Prepare for ParseHex -> ""_hex scripted-diff (Hodlinator) 50bc017 refactor: Hand-replace some ParseHex -> ""_hex (Hodlinator) 5b74a84 util: Add consteval ""_hex[_v][_u8] literals (l0rinc) dc5f6f6 test refactor: util_tests - parse_hex clean up (Hodlinator) 2b5e6ef refactor: Make XOnlyPubKey tolerate constexpr std::arrays (Hodlinator) 403d86f refactor: vector -> span in CCrypter (Hodlinator) bd0830b refactor: de-Hungarianize CCrypter (Hodlinator) d99c816 refactor: Improve CCrypter related lines (Hodlinator) 7e1d9a8 refactor: Enforce lowercase hex digits for consteval uint256 (Hodlinator) Pull request description: Motivation: * Validates and converts the hex string into bytes at compile time instead of at runtime like `ParseHex()`. * Eliminates runtime dependencies: #30377 (comment), #30048 (comment) * Has stricter requirements than `ParseHex()` (disallows whitespace and uppercase hex digits) and replaces it in a bunch of places. * Makes it possible to derive other compile time constants. * Minor: should shave off a few runtime CPU cycles. `""_hex` produces `std::array<std::byte>` as the momentum in the codebase is to use `std::byte` over `uint8_t`. Also makes `uint256` hex string constructor disallow uppercase hex digits. Discussed: #30560 (comment) Surprisingly does not change the size of the Guix **bitcoind** binary (on x86_64-linux-gnu) by 1 single byte. Spawned already merged PRs: #30436, #30482, #30532, #30560. ACKs for top commit: l0rinc: ACK 8756ccd stickies-v: Rebase re-ACK 8756ccd, no changes since a096215 ryanofsky: Code review ACK 8756ccd, just rebasing since last review and taking advantage of CScript constructors in #29369, also tweaking a code comment Tree-SHA512: 9b2011b7c37e0ef004c669f8601270a214b388916316458370f5902c79c2856790b1b2c7c123efa65decad04886ab5eff95644301e0d84358bb265cf1f8ec195
Currently only (pre)vector iterators and raw pointers are accepted. However, this makes it harder to construct from input iterators provided by other classes, such as
std::span
.Fix that.