-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: merge bitcoin#24989, #26135, #26150, #26159, #26489, #26825, #28127, #29275, #29263, partial bitcoin#27790, #27978 (c++20 backports) #6378
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
|
This pull request has conflicts, please rebase. |
…oble`), merge bitcoin#29985 1599cc6 fix: suppress `float-cast-overflow` UBSan error from `qRound(double)` (Kittywhiskers Van Gogh) a57d128 ci: drop i386 conditional altogether, we don't need `wine32` anymore (Kittywhiskers Van Gogh) b862411 ci: drop conflicting `g++-multilib` package and related workaround (Kittywhiskers Van Gogh) 7b1caa9 fix: remove now-invalid package entry (Kittywhiskers Van Gogh) 9f9e965 fix: use default non-root user `ubuntu` introduced in Ubuntu 22.10 (Kittywhiskers Van Gogh) 9b4c95e ci: update containers and CI to use Ubuntu 24.04 LTS (`noble`) (Kittywhiskers Van Gogh) 8aec25b merge bitcoin#29985: Fix build of Qt for 32-bit platforms with recent glibc (Kittywhiskers Van Gogh) Pull request description: ## Motivation Since [dash#6389](#6389), the minimum supported version of GCC has been 11.1 or later. Our current base, Ubuntu 22.04 LTS (`jammy`) ships with GCC 11.2 ([source](https://packages.ubuntu.com/jammy/gcc)). The cross-compilation package for `arm-linux-gnueabihf` is GCC 11.2 as well ([source](https://packages.ubuntu.com/jammy/gcc-arm-linux-gnueabihf)). Unfortunately, this isn't the case for `mingw-w64-x86-64`, which ships with GCC 10.3 ([source](https://packages.ubuntu.com/jammy/gcc-mingw-w64-x86-64-posix)). So far, an workaround was utilized to allow GCC 10.3 to pass muster upstream through bitcoin#28379 ([source](bitcoin@fa67f09#diff-0baeabda402ee522682c25cef25a248ff6d9e2904f6d66f93f6babf55b576675L986)). Dash Core's enablement of C++20 experimental support in [dash#4600](#4600) was relatively even more permissive ([source](https://github.com/dashpay/dash/pull/4600/files#diff-0baeabda402ee522682c25cef25a248ff6d9e2904f6d66f93f6babf55b576675R168)). Though since then, enforcement of those newer minimum requirements through backports like [bitcoin#30228](bitcoin#30228) are frustrated by the version of GCC shipped for Windows cross-compilation. This can be resolved by bumping the image to the next available LTS release, Ubuntu 24.04 (`noble`), which ships with GCC 13.2 natively ([source](https://packages.ubuntu.com/noble/gcc)), for ARM Linux ([source](https://packages.ubuntu.com/noble/gcc-arm-linux-gnueabihf)) and AMD64 Windows ([source](https://packages.ubuntu.com/noble/gcc-mingw-w64-x86-64-posix)), moreover, it is acknowledged as a _de facto_ lowest supported distro needed for Windows cross compilation by [bitcoin#30580](bitcoin#30580 (comment)). Skipping the enforcement of newer minimum requirements is inadvisable, primarily because it will eventually conflict with upcoming code changes ([comment](bitcoin#30228 (comment))) like [dash#6378](#6378). ## Additional Information * Dependency for #6380 * A default unprivileged user named `ubuntu` was introduced in Ubuntu 22.10 ([source](https://bugs.launchpad.net/cloud-images/+bug/2005129)) with UID `1000` and GID `1000`. We allow specifying UID and GID to ensure they match with the ownership of directories expected to be mounted to avoid permissions issues (especially on platforms like macOS where the user can have a UID of `501` and GID of `20`). * To retain this behavior, the `ubuntu` user and the `ubuntu` group will have its UID and GID updated. This is a no-op if defaults are selected. * In some cases where it may be undesirable to have the username or home directory deviate from the present name (`dash`), it will be additionally renamed from `ubuntu`. * GitLab is unhappy if the container doesn't have a user named `dash` ([build](https://gitlab.com/dashpay/dash/-/jobs/9082688485#L24)) and it results in a runner failure. * Due to a conflict between `gcc-multilib` and `gcc-arm-linux-gnueabihf`, installation of the latter will result in the uninstallation of the former. This has been documented behavior for a while now ([source](https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211)) and continues till today (see below). <details> <summary>Error message:</summary> ``` ubuntu@ec46b76eeb2c:/src/dash$ sudo apt install gcc-multilib gcc-arm-linux-gnueabihf Reading package lists... Done Building dependency tree... Done Reading state information... Done gcc-arm-linux-gnueabihf is already the newest version (4:13.2.0-7ubuntu1). gcc-arm-linux-gnueabihf set to manually installed. Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: gcc-arm-linux-gnueabihf : Depends: gcc-13-arm-linux-gnueabihf (>= 13.2.0-11~) but it is not installable E: Unable to correct problems, you have held broken packages. ``` </details> Since [dash#5372](#5372), we have stopped supporting i686 and dropped support for 32-bit Windows even earlier. There doesn't seem to be much reason to keep `gcc-multilib` around, especially since it _cannot_ be around and has been silently uninstalled for a while now, so the package has now been dropped. * Since Wine 7.0, WoW64 support has been included ([source](https://www.winehq.org/announce/7.0)), which allows for some applications to run without a corresponding `wine32` setup ([source](https://wiki.debian.org/Wine#Step_1:_Enable_multiarch)). Support has improved furthermore in Wine 9.0 ([source](https://gitlab.winehq.org/wine/wine/-/releases/wine-9.0)), which is available in `noble` ([source](https://packages.ubuntu.com/noble/wine64)). This allows us to drop the i386 conditional altogether. * `libncurses5`, while a valid package on `jammy` ([source](https://packages.ubuntu.com/jammy/libncurses5)), is not in any future version, including `noble` ([source](https://packages.ubuntu.com/noble/libncurses5), error page) though `libncurses5-dev` continues to remain a valid package ([source](https://packages.ubuntu.com/noble/libncurses5-dev)) and remains used as a Python dependency ([source](https://github.com/dashpay/dash/blob/1930572b05c53d2d8335bcfc22270871d5b0bf2f/contrib/containers/ci/Dockerfile#L91)). As a result, `libncurses5` has been dropped. * A bump in distro base also causes a bump in glibc version, which causes zlib, a Qt dependency to fail a compile-time check ([build](https://github.com/dashpay/dash/actions/runs/13220255380/job/36904408129?pr=6564#step:6:8050)), this is avoided by backporting [bitcoin#29985](bitcoin#29985). * Due to [QTBUG-133261](https://bugreports.qt.io/browse/QTBUG-133261), UBSan will raise a `float-cast-overflow` originating from `qRound(double)` ([build](https://gitlab.com/dashpay/dash/-/jobs/9083558880#L3132)), as of this writing, a fix is currently underway ([source](https://codereview.qt-project.org/c/qt/qtbase/+/621931)) but it is unclear when it would be available in the next Qt 5.15 revision. As this doesn't seem to be a regression ([source](https://bugreports.qt.io/browse/QTBUG-133261?focusedId=860311&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-860311)) despite being undesirable behavior, we can suppress the alarm. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK 1599cc6 UdjinM6: utACK 1599cc6 Tree-SHA512: 92f786e9da1440830057729a5d9cdf6448ef9da8c66e0d4c3b80da2e22dd599353f44a31dcbe0ed103febdf627d2a1a332d72de1c3ec312b6ceb665f4bbcb5d1
|
This pull request has conflicts, please rebase. |
1821d95 to
b24228b
Compare
includes: - 84b2f35 (excludes `src/wallet/test/util.cpp`)
excludes - some changes to `src/wallet/bdb.cpp`
WalkthroughThe changes span a wide range of files and involve refactoring and modernization efforts across the codebase. In configuration scripts, checks for specific endian and byte-swap headers and functions have been removed, simplifying platform-specific handling. Across multiple implementation files—such as cryptographic modules, wallet components, and utility functions—the C-style standard library headers have been replaced with their C++ counterparts (e.g., ✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/test/argsman_tests.cpp (4)
22-22: Acknowledge macro usage in Cppcheck configuration.
The static analysis warning about "unknown macro" is likely due toBOOST_FIXTURE_TEST_SUITEnot being properly recognized. This is a known limitation in some tools.🧰 Tools
🪛 Cppcheck (2.10-2)
[error] 22-22: There is an unknown macro here somewhere. Configuration is required. If BOOST_FIXTURE_TEST_SUITE is a macro then please configure it.
(unknownMacro)
82-166: Consider complementary negative tests.
While the test suite covers a wide range of scenarios forCheckValueTest, you might consider adding explicit negative tests to ensure robust error handling when parsing malformed input or unexpected flags.
243-262: Extend coverage for invalid parameter edge cases.
Currently, the test ensures invalid parameters produce a clear error message. Consider adding corner cases (like unusual spacing, special characters, etc.) to solidify coverage of malformed inputs.
1019-1042: Graceful cleanup inutil_ReadWriteSettings.
Renaming and removing thesettings.jsonfile might fail under restricted conditions. Consider additional logging or fallback strategies to handle file I/O exceptions for improved resilience.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (53)
configure.ac(1 hunks)src/Makefile.test.include(1 hunks)src/bench/ellswift.cpp(1 hunks)src/bitcoin-tx.cpp(1 hunks)src/bitcoind.cpp(1 hunks)src/compat/byteswap.h(2 hunks)src/compat/endian.h(1 hunks)src/crypto/chacha20.h(1 hunks)src/crypto/common.h(1 hunks)src/crypto/hkdf_sha256_32.h(1 hunks)src/crypto/hmac_sha256.h(1 hunks)src/crypto/hmac_sha512.h(1 hunks)src/crypto/pkcs5_pbkdf2_hmac_sha512.h(1 hunks)src/crypto/poly1305.h(1 hunks)src/crypto/ripemd160.h(1 hunks)src/crypto/sha1.h(1 hunks)src/crypto/sha256.h(1 hunks)src/crypto/sha256_sse4.cpp(1 hunks)src/crypto/sha3.h(1 hunks)src/crypto/sha512.h(1 hunks)src/dbwrapper.h(8 hunks)src/httpserver.cpp(1 hunks)src/i2p.cpp(1 hunks)src/ipc/interfaces.cpp(1 hunks)src/ipc/process.cpp(1 hunks)src/llmq/blockprocessor.cpp(3 hunks)src/llmq/instantsend.cpp(3 hunks)src/llmq/signing.cpp(5 hunks)src/memusage.h(1 hunks)src/prevector.h(6 hunks)src/qt/utilitydialog.cpp(1 hunks)src/random.cpp(1 hunks)src/random.h(2 hunks)src/serialize.h(4 hunks)src/span.h(3 hunks)src/streams.h(1 hunks)src/support/cleanse.h(1 hunks)src/test/argsman_tests.cpp(1 hunks)src/test/blockchain_tests.cpp(1 hunks)src/test/bswap_tests.cpp(1 hunks)src/test/crypto_tests.cpp(0 hunks)src/test/fuzz/integer.cpp(0 hunks)src/test/raii_event_tests.cpp(1 hunks)src/test/util/wallet.cpp(1 hunks)src/test/util_tests.cpp(0 hunks)src/util/asmap.cpp(3 hunks)src/util/bip32.cpp(1 hunks)src/util/readwritefile.cpp(1 hunks)src/util/url.cpp(1 hunks)src/wallet/bdb.cpp(3 hunks)src/wallet/bdb.h(1 hunks)src/wallet/crypter.cpp(1 hunks)src/wallet/sqlite.cpp(3 hunks)
💤 Files with no reviewable changes (3)
- src/test/fuzz/integer.cpp
- src/test/crypto_tests.cpp
- src/test/util_tests.cpp
✅ Files skipped from review due to trivial changes (27)
- src/qt/utilitydialog.cpp
- src/memusage.h
- src/util/readwritefile.cpp
- src/random.cpp
- src/util/url.cpp
- src/bitcoind.cpp
- src/test/util/wallet.cpp
- src/util/bip32.cpp
- src/crypto/pkcs5_pbkdf2_hmac_sha512.h
- src/test/raii_event_tests.cpp
- src/crypto/sha512.h
- src/support/cleanse.h
- src/crypto/chacha20.h
- src/crypto/ripemd160.h
- src/streams.h
- src/ipc/interfaces.cpp
- src/httpserver.cpp
- src/test/blockchain_tests.cpp
- src/crypto/sha256.h
- src/bitcoin-tx.cpp
- src/crypto/sha3.h
- src/crypto/sha256_sse4.cpp
- src/crypto/sha1.h
- src/ipc/process.cpp
- src/crypto/hmac_sha512.h
- src/crypto/hkdf_sha256_32.h
- src/crypto/hmac_sha256.h
🧰 Additional context used
🪛 GitHub Actions: Clang Diff Format Check
src/llmq/blockprocessor.cpp
[error] 211-211: Clang format differences found. Please run 'clang-format' to fix formatting issues.
[error] 506-506: Clang format differences found. Please run 'clang-format' to fix formatting issues.
[error] 549-549: Clang format differences found. Please run 'clang-format' to fix formatting issues.
src/llmq/signing.cpp
[error] 169-169: Clang format differences found. Please run 'clang-format' to fix formatting issues.
[error] 208-208: Clang format differences found. Please run 'clang-format' to fix formatting issues.
[error] 296-296: Clang format differences found. Please run 'clang-format' to fix formatting issues.
🪛 Cppcheck (2.10-2)
src/test/argsman_tests.cpp
[error] 22-22: There is an unknown macro here somewhere. Configuration is required. If BOOST_FIXTURE_TEST_SUITE is a macro then please configure it.
(unknownMacro)
🔇 Additional comments (64)
src/test/argsman_tests.cpp (4)
49-80: Validate locking usage inReadConfigString.
The explicit lock aroundm_settings.ro_configandm_config_sectionsadjustments is good. Ensure that all usage ofm_settingsvariables is also consistently guarded bycs_argsin other methods to prevent potential data races.
359-411: Commend concurrency approach withcs_args.
These tests demonstrate consistent usage ofLOCK(testArgs.cs_args)while modifying shared data, which helps mitigate concurrency issues.
578-599: Highlight section-only configuration handling.
Connectivity amongSetNetworkOnlyArgcalls and subsequent network selections is well tested. The approach ensures that section-specific arguments do not leak into global scope.
717-915: Confirm stability of hash-based test validation.
A hash is used to detect unintended behavior changes. If this test starts failing, carefully inspect all new code or updates toArgsManagerlogic to confirm whether the difference is a legitimate break or expected behavior.src/Makefile.test.include (1)
76-76: Great addition to the test suite.
Addingtest/argsman_tests.cppexpands coverage forArgsManagerbehavior. No issues found here.src/compat/byteswap.h (8)
8-9: No issues with the standard library includes.
This addition of<cstdint>and conditional<cstdlib>under_MSC_VERis appropriate and portable.
14-16: Clarifying C++23 upgrade path.
Commenting about future replacement withstd::byteswapis clear and helpful.
18-34: Robust macro handling for built-in byte-swap functions.
Conditionally definingbitcoin_builtin_bswap*ensures optimized paths where supported. Implementation meets portability needs.
38-39: Consistent BSWAP_CONSTEXPR definition.
DefiningBSWAP_CONSTEXPRasconstexprwhen not on MSVC is a sound approach to leverage compile-time evaluation.
41-41: Fallback for MSVC.
OverridingBSWAP_CONSTEXPRfor MSVC ensures compatibility with compiler constraints.
44-51:internal_bswap_16implementation.
Correctly swaps 16-bit values using either built-ins or a simple shift-and-mask fallback.
53-61:internal_bswap_32implementation.
Logic is standard and efficient, handling 32-bit swaps with built-ins or a clearly structured fallback.
63-77:internal_bswap_64implementation.
64-bit swap approach is consistent with the rest, with built-in usage or a reliable fallback.src/compat/endian.h (13)
10-10: Including<bit>header for endian checks.
This is essential for usingstd::endian.
13-17:htobe16_internal: Proper conditional swap.
Uses compile-time endianness checks to swap only when needed.
18-22:htole16_internal: Modern approach.
Mirrors the logic forhtobe16_internaland ensures appropriate swaps.
23-27:be16toh_internal: Correct condition.
Implementation parallelshtobe16_internallogic.
28-32:le16toh_internal: Straightforward fallback.
Consistent usage ofinternal_bswap_16ensures clarity.
33-37:htobe32_internal: Reliable endianness handling.
Follows the same pattern for 32-bit.
38-42:htole32_internal: Maintains uniform approach.
Conditional swap logic is consistent with the rest.
43-47:be32toh_internal: Cohesive design.
Properly reusesinternal_bswap_32for big- to host-endian conversion.
48-52:le32toh_internal: Clear implementation.
Implementation is in line with the established pattern.
53-57:htobe64_internal: Full 64-bit support.
Leveragesinternal_bswap_64for little-endian hosts.
58-62:htole64_internal: Matches the other conversions.
Remains straightforward and robust with compile-time checks.
63-67:be64toh_internal: Minimal and consistent.
Applies the same technique for big to host conversion.
68-72:le64toh_internal: Final 64-bit function.
Ensures complete coverage of little to host scenario.src/test/bswap_tests.cpp (1)
19-21: Switch tointernal_bswap_*in tests.
Tests verify correct swapping with the new function names. Implementation is sound.src/bench/ellswift.cpp (1)
20-25:Details
❓ Verification inconclusive
LGTM! Improved byte span handling.
The changes to use
MakeByteSpanandMakeWritableByteSpanimprove type safety and readability.Let's verify that these span utility functions are consistently used across the codebase:
🏁 Script executed:
#!/bin/bash # Search for any remaining instances of old span handling patterns rg "AsBytes\(Span" rg "BytePtr\("Length of output: 1304
LGTM – Improved byte span handling in
src/bench/ellswift.cpp.The update to use
MakeByteSpanandMakeWritableByteSpanindeed improves type safety and enhances readability in the benchmark code. Note, however, that legacy patterns usingAsBytes(Span{…})still appear in several other parts of the codebase (for example insrc/bls/bls.h,src/pubkey.h,src/serialize.h, andsrc/test/key_tests.cpp). Please verify if these should be updated in tandem or addressed in a separate migration step.src/crypto/common.h (2)
10-12: LGTM! Modernized header includes.Replaced C-style headers with their C++ counterparts, improving consistency with modern C++ practices.
15-83:Details
✅ Verification successful
Verify endian conversion function changes.
The switch to internal versions of endian conversion functions (
*_internal) is consistent throughout the file. This change improves encapsulation and maintainability.Let's verify that all endian conversion functions use the internal versions consistently:
🏁 Script executed:
#!/bin/bash # Search for any remaining non-internal endian conversion function calls rg "htobe|htole|be.*toh|le.*toh" --type cpp | grep -v "_internal"Length of output: 1390
Endianness Conversion in
src/crypto/common.hVerifiedThe verification confirms that all functions in
src/crypto/common.hconsistently use the internal versions (e.g.,le16toh_internal,be32toh_internal, etc.). No non-internal calls were detected in this file; the non-internal matches found are in unrelated parts of the codebase and don’t affect this change.
ReadLE16,ReadLE32,ReadLE64,WriteLE16,WriteLE32,WriteLE64,ReadBE16,ReadBE32,ReadBE64,WriteBE32, andWriteBE64all correctly use the respective_internalfunctions.src/crypto/poly1305.h (1)
11-11: LGTM! Modernized header include.Replaced C-style
stdlib.hwith C++cstdlib, consistent with modern C++ practices.src/wallet/crypter.cpp (1)
114-114: LGTM! Removed redundant type cast.Simplified the
Encryptcall by removing the unnecessary cast, asvchPlaintextis already of typeCKeyingMaterial.src/wallet/bdb.h (1)
171-190: LGTM! Good use of RAII pattern for Dbt management.The
SafeDbtclass is a well-designed RAII wrapper that ensures proper memory management ofDbtobjects. The class provides:
- Automatic cleanup in the destructor
- Clear interface for data access
- Proper encapsulation of the underlying
Dbtobjectsrc/util/asmap.cpp (2)
12-12: LGTM! Good use of C++20 header.Adding the
<bit>header provides access to modern bit manipulation utilities.
111-111: Good modernization using std::bit_width.Replacing
CountBitswithstd::bit_widthis a good improvement:
- Uses standard library functionality
- More efficient implementation
- Better maintainability
src/random.h (2)
14-14: LGTM! Good addition of C++20 header.Adding the
<bit>header provides access to modern bit manipulation utilities.
200-200: Good modernization using std::bit_width.The update to use
std::bit_widthin therandrangefunction is a good improvement:
- Uses modern C++20 features
- More maintainable code
- Consistent with other similar changes in the codebase
src/span.h (3)
9-11: LGTM! Better organization of include directives.The includes are now better organized and use the modern C++ header versions.
250-250: Good improvement in type safety with explicit casts.The direct use of
reinterpret_castinAsBytesandAsWritableBytesmakes the casting intentions more explicit and improves type safety.Also applies to: 255-255
270-273: Good improvement in UCharCast implementations.The updated
UCharCastfunctions with explicitreinterpret_cast:
- Make casting intentions clearer
- Improve type safety
- Are more consistent with modern C++ practices
src/i2p.cpp (1)
357-357:Details
✅ Verification successful
Verify byte order handling in I2P destination data.
The change from
be16tohtobe16toh_internalmaintains the same functionality but uses an internal implementation. Since this affects network protocol data handling, ensure the byte order conversion remains consistent.Run the following script to verify the byte order handling:
🏁 Script executed:
#!/bin/bash # Description: Verify byte order handling in I2P destination data. # Test: Search for all usages of byte order conversion functions. rg -A 5 $'be16toh|be16toh_internal' # Test: Search for any related test files. fd -t f "test.*i2p"Length of output: 1238
Byte Order Conversion Consistency Verified
The usage of
be16toh_internalinsrc/i2p.cppis in line with the project's internal conversion implementation as defined insrc/compat/endian.h. The grep results confirm that this internal function is consistently used across related modules (e.g., serialization and crypto), and its behavior matches that of the originalbe16toh.
Location Verified:
src/i2p.cppusesbe16toh_internal(cert_len)for converting certificate length.- The same internal function appears in
src/serialize.handsrc/crypto/common.h, ensuring consistent conversion throughout the codebase.Next Steps:
- Confirm that any network protocol data handling relying on these conversions is covered by existing tests.
- Maintain vigilance in future changes to ensure the internal function continues to meet the necessary byte order handling across all modules.
src/prevector.h (3)
50-50: LGTM! Improved safety with default member initialization.Default initializing pointer members to
nullptrprevents undefined behavior from uninitialized pointers.Also applies to: 82-82, 102-102, 135-135
56-57: LGTM! Updated iterator traits for C++20 compatibility.The changes:
- Added
element_typeto comply with C++20 iterator requirements- Updated
iterator_categoryto usestd::contiguous_iterator_tagfor more precise iterator categorization
68-72: LGTM! Enhanced const correctness and operator overloading.The changes:
- Added
constqualifiers to arithmetic operators- Added
frienddeclarations for proper operator overloadingsrc/wallet/sqlite.cpp (1)
28-32: LGTM! Improved code reusability and type safety.The new
SpanFromBlobfunction:
- Centralizes blob handling logic
- Uses
std::byteandSpanfor safer binary data handling- Maintains the same functionality while reducing code duplication
src/dbwrapper.h (1)
24-24: LGTM! Improved type safety with encapsulated pointer casting.The new
CharCastfunction:
- Encapsulates pointer casting logic
- Improves code readability
- Maintains consistency with
std::byteusage across the codebasesrc/wallet/bdb.cpp (3)
27-31: LGTM! The newSpanFromDbtfunction enhances safety.The function provides a safer way to handle database data by using
Span<const std::byte>instead of raw pointers, which helps prevent buffer overflows and improves type safety.
696-697: LGTM! Improved stream writing withSpanFromDbt.The code now uses the safer
SpanFromDbtfunction to write data to the stream, replacing the previous raw pointer usage.Also applies to: 699-699
771-772: LGTM! Improved stream writing withSpanFromDbtand explicit clearing.The code now:
- Explicitly clears the value stream before writing
- Uses the safer
SpanFromDbtfunction to write datasrc/llmq/signing.cpp (5)
172-173: LGTM! Consistent use of internal endian conversion function.Changed to use
htobe32_internalfor time-related key generation, aligning with the codebase's move towards internal endian conversion functions.
211-212: LGTM! Consistent use of internal endian conversion function.Changed to use
htobe32_internalfor time-related key generation inRemoveRecoveredSig, maintaining consistency with other changes.
250-252: LGTM! Consistent use of internal endian conversion function.Changed to use
be32toh_internalfor time comparison inCleanupOldRecoveredSigs, maintaining consistency with other changes.
299-300: LGTM! Consistent use of internal endian conversion function.Changed to use
htobe32_internalfor time-related key generation inWriteVoteForId, maintaining consistency with other changes.
324-326: LGTM! Consistent use of internal endian conversion function.Changed to use
be32toh_internalfor time comparison inCleanupOldVotes, maintaining consistency with other changes.src/llmq/blockprocessor.cpp (4)
214-215: LGTM! Consistent use of internal endian conversion function.Changed to use
htobe32_internalfor height-related key generation inBuildInversedHeightKey, maintaining consistency with other changes.
220-221: LGTM! Consistent use of internal endian conversion function.Changed to use
htobe32_internalfor height-related key generation inBuildInversedHeightKeyIndexed, maintaining consistency with other changes.
508-511: LGTM! Consistent use of internal endian conversion function.Changed to use
be32toh_internalfor height comparison inGetMinedCommitmentsUntilBlock, maintaining consistency with other changes.
551-554: LGTM! Consistent use of internal endian conversion function.Changed to use
be32toh_internalfor height comparison inGetLastMinedCommitmentsByQuorumIndexUntilBlock, maintaining consistency with other changes.src/serialize.h (2)
63-64: LGTM! Consistent use of internal endian conversion functions.Changed all endian conversion functions to use their internal counterparts in serialization and deserialization functions, maintaining consistency across the codebase:
htole16→htole16_internalhtobe16→htobe16_internalhtole32→htole32_internalhtobe32→htobe32_internalhtole64→htole64_internalle16toh→le16toh_internalbe16toh→be16toh_internalle32toh→le32toh_internalbe32toh→be32toh_internalle64toh→le64toh_internalAlso applies to: 68-69, 73-74, 78-79, 83-84, 96-97, 102-103, 108-109, 114-115, 120-121
658-663: LGTM! Consistent use of internal endian conversion functions.Changed to use internal endian conversion functions in
CustomUintFormatterfor both serialization and deserialization:
htobe64→htobe64_internalhtole64→htole64_internalbe64toh→be64toh_internalle64toh→le64toh_internalAlso applies to: 672-677
src/llmq/instantsend.cpp (3)
125-125: LGTM! Consistent use of internal byte order conversion function.The change from
htobe32tohtobe32_internalaligns with the codebase's move to use internal byte order conversion functions.
178-178: LGTM! Consistent use of internal byte order conversion function.The change from
be32tohtobe32toh_internalmaintains consistency with the internal byte order conversion functions.
222-222: LGTM! Consistent use of internal byte order conversion function.The change from
be32tohtobe32toh_internalaligns with the codebase's standardization on internal byte order conversion functions.configure.ac (1)
1038-1038: LGTM! Simplified header checks.The changes appropriately:
- Remove platform-specific endianness header checks, aligning with the move to internal byte order conversion functions
- Add checks for essential system headers that are needed for various platform-specific functionality
This simplifies the configuration process while ensuring necessary system headers are available.
|
Compiled locally; all fine with that |
UdjinM6
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.
utACK 8b14cd6
PastaPastaPasta
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.
ACK 8b14cd6; reviewed compiled locally
, bitcoin#29181, bitcoin#29085, bitcoin#29484, bitcoin#29577, bitcoin#29081, bitcoin#29815, bitcoin#28687, bitcoin#31502, partial bitcoin#26707, bitcoin#28894 (c++20 backports: part 2) 2867107 merge bitcoin#31502: Fix CXXFLAGS on NetBSD (Kittywhiskers Van Gogh) 83e8ff0 merge bitcoin#28687: std::views::reverse (Kittywhiskers Van Gogh) 525bf6f merge bitcoin#29815: always use our fallback timingsafe_bcmp rather than libc's (Kittywhiskers Van Gogh) 42aa57a merge bitcoin#29081: Remove gmtime* (Kittywhiskers Van Gogh) d5179ec refactor: move away from `gmtime` (Kittywhiskers Van Gogh) 3a71354 merge bitcoin#29577: ignore deprecated-declarations warnings in objc++ macOS code (Kittywhiskers Van Gogh) 74bcdf0 merge bitcoin#29484: replace char-is-int8_t autoconf detection with c++20 concept (Kittywhiskers Van Gogh) e317a5c merge bitcoin#29085: Use std::rotl (Kittywhiskers Van Gogh) 9f2c278 merge bitcoin#29181: remove systemtap variadic patch (Kittywhiskers Van Gogh) 209488d merge bitcoin#29040: Remove pre-C++20 code, fs::path cleanup (Kittywhiskers Van Gogh) e2eb625 partial bitcoin#28894: batch all individual spkms setup db writes in a single db txn (Kittywhiskers Van Gogh) f29610b partial bitcoin#26707: Fix `performance-*move*` warnings in headers (Kittywhiskers Van Gogh) ee63d4b merge bitcoin#24470: Disallow more unsafe string->path conversions allowed by path append operators (Kittywhiskers Van Gogh) abfd303 merge bitcoin#24469: Correctly decode UTF-8 literal string paths (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Depends on #6378 ## Breaking Changes None expected. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK 2867107 UdjinM6: utACK 2867107 Tree-SHA512: 9ade297d5078063229c297036c36ba2fd82eb0ffc15124d746564844315b6ed9d86f38ddc0f4e9f00e12f8d5eeeb6248c2a86b65a7bee856a234071e1546cf40
Additional Information
Developers are required to rerun
autogen.shif switching between this PR anddevelopdue to changes inconfigure.ac, failing to do so will result in a myriad of compiler errors (see below)Build errors:
Breaking Changes
None expected.
Checklist