Skip to content

Conversation

@kwvg
Copy link
Collaborator

@kwvg kwvg commented Nov 2, 2024

Additional Information

  • Developers are required to rerun autogen.sh if switching between this PR and develop due to changes in configure.ac, failing to do so will result in a myriad of compiler errors (see below)

    Build errors:
    In file included from /usr/include/x86_64-linux-gnu/sys/types.h:176,
                   from /usr/include/stdlib.h:514,
                   from /usr/include/c++/13/cstdlib:79,
                   from /usr/include/c++/13/ext/string_conversions.h:43,
                   from /usr/include/c++/13/bits/basic_string.h:4109,
                   from /usr/include/c++/13/string:54,
                   from ./blockfilter.h:9,
                   from blockfilter.cpp:8:
    ./compat/endian.h:156:17: error: redefinition of 'uint16_t __bswap_16(uint16_t)'
    156 | inline uint16_t htobe16(uint16_t host_16bits)
          |                 ^~~~~~~
    In file included from /usr/include/endian.h:35:
    /usr/include/x86_64-linux-gnu/bits/byteswap.h:34:1: note: '__uint16_t __bswap_16(__uint16_t)' previously defined here
       34 | __bswap_16 (__uint16_t __bsx)
          | ^~~~~~~~~~
    ./compat/endian.h:163:17: error: redefinition of 'uint16_t __uint16_identity(uint16_t)'
    163 | inline uint16_t htole16(uint16_t host_16bits)
          |                 ^~~~~~~
    In file included from /usr/include/endian.h:36:
    /usr/include/x86_64-linux-gnu/bits/uintn-identity.h:33:1: note: '__uint16_t __uint16_identity(__uint16_t)' previously defined here
       33 | __uint16_identity (__uint16_t __x)
          | ^~~~~~~~~~~~~~~~~
    

Breaking Changes

None expected.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas (note: N/A)
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation (note: N/A)
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@kwvg kwvg added this to the 23 milestone Nov 2, 2024
@github-actions
Copy link

github-actions bot commented Feb 7, 2025

This pull request has conflicts, please rebase.

PastaPastaPasta added a commit that referenced this pull request Feb 12, 2025
…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
@github-actions
Copy link

This pull request has conflicts, please rebase.

@kwvg kwvg changed the title backport: merge bitcoin#24989, #26135, #26150, #26159, #26489, #26825, #28127, #29275, #29263, partial bitcoin#24831, #27790, #27978 (c++20 backports: part 1) backport: merge bitcoin#24989, #26135, #26150, #26159, #26489, #26825, #28127, #29275, #29263, partial bitcoin#27790, #27978 (c++20 backports: part 1) Feb 17, 2025
@kwvg kwvg force-pushed the cxx20_bps1 branch 2 times, most recently from 1821d95 to b24228b Compare February 18, 2025 11:13
@kwvg kwvg changed the title backport: merge bitcoin#24989, #26135, #26150, #26159, #26489, #26825, #28127, #29275, #29263, partial bitcoin#27790, #27978 (c++20 backports: part 1) backport: merge bitcoin#24989, #26135, #26150, #26159, #26489, #26825, #28127, #29275, #29263, partial bitcoin#27790, #27978 (c++20 backports) Feb 18, 2025
@kwvg kwvg marked this pull request as ready for review February 18, 2025 12:24
@kwvg kwvg requested a review from knst February 18, 2025 12:24
@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2025

Walkthrough

The 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., <stdlib.h> to <cstdlib> and <stdio.h> to <cstdio>). Endianness and byte-swapping functions have been renamed (e.g., from bswap_16 to internal_bswap_16) and replaced with inline versions incorporating compile-time evaluation features. Other updates include transitioning from legacy conversion functions to modern equivalents (e.g., using std::bit_width instead of a custom CountBits), changes to iterator properties, and reorganization of data span conversions. Test files have been updated with added cases and removal of obsolete tests to align with the new internal functions and headers.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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 to BOOST_FIXTURE_TEST_SUITE not 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 for CheckValueTest, 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 in util_ReadWriteSettings.
Renaming and removing the settings.json file 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9105e and 8b14cd6.

📒 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 in ReadConfigString.
The explicit lock around m_settings.ro_config and m_config_sections adjustments is good. Ensure that all usage of m_settings variables is also consistently guarded by cs_args in other methods to prevent potential data races.


359-411: Commend concurrency approach with cs_args.
These tests demonstrate consistent usage of LOCK(testArgs.cs_args) while modifying shared data, which helps mitigate concurrency issues.


578-599: Highlight section-only configuration handling.
Connectivity among SetNetworkOnlyArg calls 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 to ArgsManager logic 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.
Adding test/argsman_tests.cpp expands coverage for ArgsManager behavior. 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_VER is appropriate and portable.


14-16: Clarifying C++23 upgrade path.
Commenting about future replacement with std::byteswap is clear and helpful.


18-34: Robust macro handling for built-in byte-swap functions.
Conditionally defining bitcoin_builtin_bswap* ensures optimized paths where supported. Implementation meets portability needs.


38-39: Consistent BSWAP_CONSTEXPR definition.
Defining BSWAP_CONSTEXPR as constexpr when not on MSVC is a sound approach to leverage compile-time evaluation.


41-41: Fallback for MSVC.
Overriding BSWAP_CONSTEXPR for MSVC ensures compatibility with compiler constraints.


44-51: internal_bswap_16 implementation.
Correctly swaps 16-bit values using either built-ins or a simple shift-and-mask fallback.


53-61: internal_bswap_32 implementation.
Logic is standard and efficient, handling 32-bit swaps with built-ins or a clearly structured fallback.


63-77: internal_bswap_64 implementation.
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 using std::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 for htobe16_internal and ensures appropriate swaps.


23-27: be16toh_internal: Correct condition.
Implementation parallels htobe16_internal logic.


28-32: le16toh_internal: Straightforward fallback.
Consistent usage of internal_bswap_16 ensures 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 reuses internal_bswap_32 for 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.
Leverages internal_bswap_64 for 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 to internal_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 MakeByteSpan and MakeWritableByteSpan improve 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 MakeByteSpan and MakeWritableByteSpan indeed improves type safety and enhances readability in the benchmark code. Note, however, that legacy patterns using AsBytes(Span{…}) still appear in several other parts of the codebase (for example in src/bls/bls.h, src/pubkey.h, src/serialize.h, and src/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.h Verified

The verification confirms that all functions in src/crypto/common.h consistently 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, and WriteBE64 all correctly use the respective _internal functions.
src/crypto/poly1305.h (1)

11-11: LGTM! Modernized header include.

Replaced C-style stdlib.h with C++ cstdlib, consistent with modern C++ practices.

src/wallet/crypter.cpp (1)

114-114: LGTM! Removed redundant type cast.

Simplified the Encrypt call by removing the unnecessary cast, as vchPlaintext is already of type CKeyingMaterial.

src/wallet/bdb.h (1)

171-190: LGTM! Good use of RAII pattern for Dbt management.

The SafeDbt class is a well-designed RAII wrapper that ensures proper memory management of Dbt objects. The class provides:

  • Automatic cleanup in the destructor
  • Clear interface for data access
  • Proper encapsulation of the underlying Dbt object
src/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 CountBits with std::bit_width is 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_width in the randrange function 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_cast in AsBytes and AsWritableBytes makes the casting intentions more explicit and improves type safety.

Also applies to: 255-255


270-273: Good improvement in UCharCast implementations.

The updated UCharCast functions with explicit reinterpret_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 be16toh to be16toh_internal maintains 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_internal in src/i2p.cpp is in line with the project's internal conversion implementation as defined in src/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 original be16toh.

  • Location Verified:

    • src/i2p.cpp uses be16toh_internal(cert_len) for converting certificate length.
    • The same internal function appears in src/serialize.h and src/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 nullptr prevents 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_type to comply with C++20 iterator requirements
  • Updated iterator_category to use std::contiguous_iterator_tag for more precise iterator categorization

68-72: LGTM! Enhanced const correctness and operator overloading.

The changes:

  • Added const qualifiers to arithmetic operators
  • Added friend declarations for proper operator overloading
src/wallet/sqlite.cpp (1)

28-32: LGTM! Improved code reusability and type safety.

The new SpanFromBlob function:

  • Centralizes blob handling logic
  • Uses std::byte and Span for 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 CharCast function:

  • Encapsulates pointer casting logic
  • Improves code readability
  • Maintains consistency with std::byte usage across the codebase
src/wallet/bdb.cpp (3)

27-31: LGTM! The new SpanFromDbt function 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 with SpanFromDbt.

The code now uses the safer SpanFromDbt function to write data to the stream, replacing the previous raw pointer usage.

Also applies to: 699-699


771-772: LGTM! Improved stream writing with SpanFromDbt and explicit clearing.

The code now:

  1. Explicitly clears the value stream before writing
  2. Uses the safer SpanFromDbt function to write data
src/llmq/signing.cpp (5)

172-173: LGTM! Consistent use of internal endian conversion function.

Changed to use htobe32_internal for 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_internal for time-related key generation in RemoveRecoveredSig, maintaining consistency with other changes.


250-252: LGTM! Consistent use of internal endian conversion function.

Changed to use be32toh_internal for time comparison in CleanupOldRecoveredSigs, maintaining consistency with other changes.


299-300: LGTM! Consistent use of internal endian conversion function.

Changed to use htobe32_internal for time-related key generation in WriteVoteForId, maintaining consistency with other changes.


324-326: LGTM! Consistent use of internal endian conversion function.

Changed to use be32toh_internal for time comparison in CleanupOldVotes, maintaining consistency with other changes.

src/llmq/blockprocessor.cpp (4)

214-215: LGTM! Consistent use of internal endian conversion function.

Changed to use htobe32_internal for height-related key generation in BuildInversedHeightKey, maintaining consistency with other changes.


220-221: LGTM! Consistent use of internal endian conversion function.

Changed to use htobe32_internal for height-related key generation in BuildInversedHeightKeyIndexed, maintaining consistency with other changes.


508-511: LGTM! Consistent use of internal endian conversion function.

Changed to use be32toh_internal for height comparison in GetMinedCommitmentsUntilBlock, maintaining consistency with other changes.


551-554: LGTM! Consistent use of internal endian conversion function.

Changed to use be32toh_internal for height comparison in GetLastMinedCommitmentsByQuorumIndexUntilBlock, 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:

  • htole16htole16_internal
  • htobe16htobe16_internal
  • htole32htole32_internal
  • htobe32htobe32_internal
  • htole64htole64_internal
  • le16tohle16toh_internal
  • be16tohbe16toh_internal
  • le32tohle32toh_internal
  • be32tohbe32toh_internal
  • le64tohle64toh_internal

Also 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 CustomUintFormatter for both serialization and deserialization:

  • htobe64htobe64_internal
  • htole64htole64_internal
  • be64tohbe64toh_internal
  • le64tohle64toh_internal

Also applies to: 672-677

src/llmq/instantsend.cpp (3)

125-125: LGTM! Consistent use of internal byte order conversion function.

The change from htobe32 to htobe32_internal aligns 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 be32toh to be32toh_internal maintains consistency with the internal byte order conversion functions.


222-222: LGTM! Consistent use of internal byte order conversion function.

The change from be32toh to be32toh_internal aligns with the codebase's standardization on internal byte order conversion functions.

configure.ac (1)

1038-1038: LGTM! Simplified header checks.

The changes appropriately:

  1. Remove platform-specific endianness header checks, aligning with the move to internal byte order conversion functions
  2. 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.

@PastaPastaPasta
Copy link
Member

Compiled locally; all fine with that

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 8b14cd6

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a 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

@PastaPastaPasta PastaPastaPasta merged commit 2484cda into dashpay:develop Feb 21, 2025
28 of 29 checks passed
PastaPastaPasta added a commit that referenced this pull request May 6, 2025
, 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants