44684 Commits

Author SHA1 Message Date
w0xlt
ff35a4b021 docs: Improve keypoolrefill RPC docs 2025-05-07 14:44:10 -03:00
merge-script
44057fe38c
Merge bitcoin/bitcoin#32287: build: Fix macdeployqtplus after switching to Qt 6
84de8c93e7d4979575161a2bb8f7eb64e1317b89 ci: Add `deploy` target for native macOS CI job (Hennadii Stepanov)
fad57e9e0fe2b57e9569aa26307c6344522c2a43 build: Fix `macdeployqtplus` after switching to Qt 6 (Hennadii Stepanov)
938208d91a27e3354f42eedbd6c5bf26117c4610 build: Resolve `@rpath` in `macdeployqtplus` (Hennadii Stepanov)

Pull request description:

  Homebrew's Qt 6 package — namely `qt` or `qt@6` — introduces a few differences that must be properly handled by the `macdeployqtplus` script:

  1. Use of `@rpath` references:
  ```
  % objdump --macho --dylibs-used $(brew --prefix qt@5)/Frameworks/QtGui.framework/QtGui
  /usr/local/opt/qt@5/Frameworks/QtGui.framework/QtGui:
  /usr/local/opt/qt@5/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.15.0, current version 5.15.16)
  /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2575.30.19)
  /System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 367.6.0)
  /usr/local/Cellar/qt@5/5.15.16_1/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.15.0, current version 5.15.16)
  /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
  /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1889.2.7)
  /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 3208.0.0)
  /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
  /usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 64.0.0, current version 64.0.0)
  /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
  /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 65.0.0)
  /usr/local/opt/md4c/lib/libmd4c.0.dylib (compatibility version 0.0.0, current version 0.5.2)
  /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1800.105.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)
  /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 3208.0.0)
  /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText (compatibility version 1.0.0, current version 844.2.0)
  /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
  % objdump --macho --dylibs-used $(brew --prefix qt@6)/Frameworks/QtGui.framework/QtGui
  /usr/local/opt/qt/Frameworks/QtGui.framework/QtGui:
  /usr/local/opt/qt/lib/QtGui.framework/Versions/A/QtGui (compatibility version 6.0.0, current version 6.9.0)
  /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2575.30.19)
  /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 170.0.0)
  /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 3208.0.0)
  /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1889.2.7)
  /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText (compatibility version 1.0.0, current version 844.2.0)
  /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 3208.0.0)
  /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
  /System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 367.6.0)
  /usr/local/opt/glib/lib/libglib-2.0.0.dylib (compatibility version 8401.0.0, current version 8401.0.0)
  @rpath/QtDBus.framework/Versions/A/QtDBus (compatibility version 6.0.0, current version 6.9.0)
  /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
  /usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 64.0.0, current version 64.0.0)
  /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
  /usr/local/opt/harfbuzz/lib/libharfbuzz.0.dylib (compatibility version 61100.0.0, current version 61100.0.0)
  /usr/local/opt/md4c/lib/libmd4c.0.dylib (compatibility version 0.0.0, current version 0.5.2)
  /usr/local/opt/freetype/lib/libfreetype.6.dylib (compatibility version 27.0.0, current version 27.2.0)
  /usr/local/opt/glib/lib/libgthread-2.0.0.dylib (compatibility version 8401.0.0, current version 8401.0.0)
  @rpath/QtCore.framework/Versions/A/QtCore (compatibility version 6.0.0, current version 6.9.0)
  /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
  /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/UniformTypeIdentifiers.framework/Versions/A/UniformTypeIdentifiers (compatibility version 1.0.0, current version 709.0.0)
  /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1800.105.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)
  /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1226.0.0)
  /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
  ```

  2. Different directory layout:
  ```
  % ls -l $(brew --prefix qt@5)/
  total 544
  drwxr-xr-x   79 hebasto  admin    2528 13 Nov 06:22 Frameworks
  -rw-r--r--    1 hebasto  admin    7533 16 Apr 09:09 INSTALL_RECEIPT.json
  -rw-r--r--    1 hebasto  admin   22961 13 Nov 06:22 LICENSE.FDL
  -rw-r--r--    1 hebasto  admin   36363 13 Nov 06:22 LICENSE.GPL3-EXCEPT
  -rw-r--r--    1 hebasto  admin   15351 13 Nov 06:22 LICENSE.GPLv2
  -rw-r--r--    1 hebasto  admin   35641 13 Nov 06:22 LICENSE.GPLv3
  -rw-r--r--    1 hebasto  admin   26828 13 Nov 06:22 LICENSE.LGPLv21
  -rw-r--r--    1 hebasto  admin    8174 13 Nov 06:22 LICENSE.LGPLv3
  -rw-r--r--    1 hebasto  admin  106262 13 Nov 06:22 LICENSE.QT-LICENSE-AGREEMENT
  -rw-r--r--    1 hebasto  admin    3842 13 Nov 06:22 README
  drwxr-xr-x   57 hebasto  admin    1824 16 Apr 09:09 bin
  drwxr-xr-x    4 hebasto  admin     128 13 Nov 06:22 doc
  drwxr-xr-x   95 hebasto  admin    3040 13 Nov 06:22 include
  drwxr-xr-x  119 hebasto  admin    3808 16 Apr 09:09 lib
  drwxr-xr-x    8 hebasto  admin     256 13 Nov 06:22 libexec
  drwxr-xr-x   79 hebasto  admin    2528 16 Apr 09:09 mkspecs
  drwxr-xr-x   15 hebasto  admin     480 13 Nov 06:22 phrasebooks
  drwxr-xr-x   31 hebasto  admin     992 13 Nov 06:22 plugins
  drwxr-xr-x   28 hebasto  admin     896 13 Nov 06:22 qml
  -rw-r--r--    1 hebasto  admin    6952 16 Apr 09:09 sbom.spdx.json
  drwxr-xr-x    3 hebasto  admin      96 13 Nov 06:22 share
  drwxr-xr-x  347 hebasto  admin   11104 13 Nov 06:22 translations
  % ls -l $(brew --prefix qt@6)/share/qt/
  total 0
  drwxr-xr-x    4 hebasto  admin   128 30 Mar 09:49 doc
  drwxr-xr-x   35 hebasto  admin  1120 16 Apr 09:16 libexec
  drwxr-xr-x  167 hebasto  admin  5344 30 Mar 09:49 metatypes
  drwxr-xr-x   70 hebasto  admin  2240 16 Apr 09:16 mkspecs
  drwxr-xr-x  178 hebasto  admin  5696 30 Mar 09:49 modules
  drwxr-xr-x   15 hebasto  admin   480 30 Mar 09:49 phrasebooks
  drwxr-xr-x   31 hebasto  admin   992 30 Mar 09:49 plugins
  drwxr-xr-x   34 hebasto  admin  1088 30 Mar 09:49 qml
  drwxr-xr-x   45 hebasto  admin  1440 30 Mar 09:49 sbom
  drwxr-xr-x  285 hebasto  admin  9120 30 Mar 09:49 translations
  ```

  This PR addresses both issues and additionally adds a `deploy` target to the native macOS CI job to prevent any similar recessions in the future.

  Fixes https://github.com/bitcoin/bitcoin/issues/32267.

ACKs for top commit:
  fanquake:
    ACK 84de8c93e7d4979575161a2bb8f7eb64e1317b89

Tree-SHA512: 27a0eff3cd9317647529ff4571bd79c5dd8f007775b19415c8c27ca4912a60d85074c840cf0443be314d9a404f78bb015029d46dab18e292462249a5d90c6c47
2025-05-06 18:10:22 +01:00
merge-script
229943b513
Merge bitcoin/bitcoin#32086: Shuffle depends instructions and recommend modern make for macOS
22cff32319de64cb98e1c89b9a7ed35611e89e27 doc: recommend gmake for FreeBSD (Sjors Provoost)
b645c520714cc7cd4d50e62a3f90cbbdb5521336 doc: recommend modern make for macOS depends (Sjors Provoost)
99e6490dc51adde35b58e8d193aca7c1c422dbf3 doc: shuffle depends instructions (Sjors Provoost)

Pull request description:

  macOS ships with GNU Make 3.81 from 2006. This has caused
  difficult to debug issues, e.g. #32070 and #30978.

  Tell users / developers who use the depends system to install a modern version of `make`.

  This PR does not change the non-depends build.

  Although Homebrew allows overriding the system `make`, we instead just instruct users to build with `gmake`. This way there should be no impact on other projects they wish to compile.

  To increase the likeliness of anyone actually seeing and following this instruction, the first commit moves things around in `depends/README.md`. It now starts with instructions for a local build and moves cross-compilation to the end. For each platform it shows what to install (`apt install`, `brew install`, etc) and what command to run (`make` or `gmake`).

  There previously was no macOS specific section, so this is added. It points to the general `build-osx.md` for how to install the Xcode Command Line Tools and Homebrew Package Manager.

  I didn't test on an empty system.

  Preview: https://github.com/Sjors/bitcoin/tree/2025/03/mc-make/depends#depends-build

ACKs for top commit:
  maflcko:
    review ACK 22cff32319de64cb98e1c89b9a7ed35611e89e27 🏣
  hebasto:
    re-ACK 22cff32319de64cb98e1c89b9a7ed35611e89e27.
  willcl-ark:
    ACK 22cff32319de64cb98e1c89b9a7ed35611e89e27

Tree-SHA512: 11648ae73f3b70bc2df771e4eddca37221cd88b88bea4139a183e3f67f24a4c3e5aadf61a713ed73f3fc206511dfcf8670e4c4143c49dd4e56e501030be9c7ba
2025-05-06 18:06:38 +01:00
Sjors Provoost
22cff32319
doc: recommend gmake for FreeBSD
Consistent with doc/build-freebsd.md
2025-05-06 11:24:32 +02:00
Sjors Provoost
b645c52071
doc: recommend modern make for macOS depends
macOS ships with GNU Make 3.81 from 2006. This has caused
difficult to debug issues, see e.g.
9157d9e449870851ef455e077249ac46fc2df24c.

Also add ninja, needed since qt6.
2025-05-06 11:24:32 +02:00
Sjors Provoost
99e6490dc5
doc: shuffle depends instructions
Native compilation is explained before cross-compilation. Move
install and (g)make steps up.

In the Configuring section, use Linux native compilation as the
example instead of Windows cross-compile.
2025-05-06 11:24:16 +02:00
Hennadii Stepanov
baa848b8d3
Merge bitcoin/bitcoin#32405: build: replace header checks with __has_include
e1f543823b300b28c9edaf5d1a3e1e9badde471b build: replace header checks with __has_include (fanquake)

Pull request description:

  Replace the checks in CMake, with the equivalent functionality provided by the standard library (since C++17).
  See https://en.cppreference.com/w/cpp/preprocessor/include.

  Guix Build:
  ```bash
  66d71c866bd111ffe65bc03b9e1653a95eb678f0b04451759c56af868bfc03d5  guix-build-e1f543823b30/output/aarch64-linux-gnu/SHA256SUMS.part
  1a4130d801620a63d86c3069b1fbca39ebc963e610101451d3f48b1c191ca4b3  guix-build-e1f543823b30/output/aarch64-linux-gnu/bitcoin-e1f543823b30-aarch64-linux-gnu-debug.tar.gz
  745adbc7767344a8cd0ebe1e7592239614d89f949558c9b6a2ae58f7b2602a32  guix-build-e1f543823b30/output/aarch64-linux-gnu/bitcoin-e1f543823b30-aarch64-linux-gnu.tar.gz
  cb69d205a20715ee58a324cc2b8475c2bae0443a062f5de2820baa45f822292c  guix-build-e1f543823b30/output/arm-linux-gnueabihf/SHA256SUMS.part
  081774dd903256dafa187ee47a569cd44b01eb16adc9dbfeb54b721abc39e944  guix-build-e1f543823b30/output/arm-linux-gnueabihf/bitcoin-e1f543823b30-arm-linux-gnueabihf-debug.tar.gz
  1dd857fe6b9e75fae746e73fbfc6b77302b4dbb13685baebb10e9686da7bad01  guix-build-e1f543823b30/output/arm-linux-gnueabihf/bitcoin-e1f543823b30-arm-linux-gnueabihf.tar.gz
  e035ba959da69263de2f29282328d4e5b455f94a800a15891801f26ba3b8b325  guix-build-e1f543823b30/output/arm64-apple-darwin/SHA256SUMS.part
  ebf973e0e44be688ea5e1ebae804dfce6e71b7ca8aaca5d8249a14d130f37c3f  guix-build-e1f543823b30/output/arm64-apple-darwin/bitcoin-e1f543823b30-arm64-apple-darwin-codesigning.tar.gz
  3ea687b53032b30d7c4a0760f8a35d19e2f60a8cb3f1f5e2c5cba05897f04e43  guix-build-e1f543823b30/output/arm64-apple-darwin/bitcoin-e1f543823b30-arm64-apple-darwin-unsigned.tar.gz
  ebb6a935f2fbc75167f5e61a039d13f231621f7eb0cbd1292616425f7677739c  guix-build-e1f543823b30/output/arm64-apple-darwin/bitcoin-e1f543823b30-arm64-apple-darwin-unsigned.zip
  9e77422977506f0c3f0373ee19d24c3ad86cbaf3a97cfcf5db202d4fff9c3ae4  guix-build-e1f543823b30/output/dist-archive/bitcoin-e1f543823b30.tar.gz
  62d7c8f63a3702b066f88498f829b2c371baa06c596b71b6d8969f638cc2d356  guix-build-e1f543823b30/output/powerpc64-linux-gnu/SHA256SUMS.part
  60c00fc85dea24548c212330e5fa097020f17bb74f511e7e764b8b33224afce0  guix-build-e1f543823b30/output/powerpc64-linux-gnu/bitcoin-e1f543823b30-powerpc64-linux-gnu-debug.tar.gz
  97b1aa4dc967c9a3767476a262a503900ea77e15b4b292928c6cdddf306cafc9  guix-build-e1f543823b30/output/powerpc64-linux-gnu/bitcoin-e1f543823b30-powerpc64-linux-gnu.tar.gz
  ed67fbb0768ce7b1d4d053de2ba0ea3b2798d01a276adf6430c4a2a413461ee2  guix-build-e1f543823b30/output/riscv64-linux-gnu/SHA256SUMS.part
  83f7b4e6c244d97caa2eb41b67cdef2bfa71f2f3ef1cfa378fae32db18fc8e25  guix-build-e1f543823b30/output/riscv64-linux-gnu/bitcoin-e1f543823b30-riscv64-linux-gnu-debug.tar.gz
  c8ca7793fdfac2346a21d5fc8f6e00f1feb6556d048896fef8148ac614921050  guix-build-e1f543823b30/output/riscv64-linux-gnu/bitcoin-e1f543823b30-riscv64-linux-gnu.tar.gz
  a3e99dd3369aa97cad2437fc1b29f84a8950327fd0f0a1c0a8a3e7ce49369f1a  guix-build-e1f543823b30/output/x86_64-apple-darwin/SHA256SUMS.part
  1c22d2967c72a5b901d54b9914d243aaf8f52216e48399f09bf17f34455369ec  guix-build-e1f543823b30/output/x86_64-apple-darwin/bitcoin-e1f543823b30-x86_64-apple-darwin-codesigning.tar.gz
  28c731d91d84f41a0b94cfb420474f150edd2bd33db1e9c38d52c9452e44b3f1  guix-build-e1f543823b30/output/x86_64-apple-darwin/bitcoin-e1f543823b30-x86_64-apple-darwin-unsigned.tar.gz
  f6b74d1756af4de4a7e250c11f0a48a93fafc67139951afc4a55888ce24dc01a  guix-build-e1f543823b30/output/x86_64-apple-darwin/bitcoin-e1f543823b30-x86_64-apple-darwin-unsigned.zip
  16d7a33003e89f53b3d8ce31a121250a4f836c83482f39b0c40721a2dd32faca  guix-build-e1f543823b30/output/x86_64-linux-gnu/SHA256SUMS.part
  d17606b3fec3c045d84dadff4b107186cc6e51daa80a16588de4e213585a98cd  guix-build-e1f543823b30/output/x86_64-linux-gnu/bitcoin-e1f543823b30-x86_64-linux-gnu-debug.tar.gz
  52ee77c9ff6bbe6965100165847d107c4e3ddcf8c2a960746f663ade074295a5  guix-build-e1f543823b30/output/x86_64-linux-gnu/bitcoin-e1f543823b30-x86_64-linux-gnu.tar.gz
  daeba27cb9ce21e3a6a01b9487ef81738eec0c84ad80ca0ba1287412c0d4eeda  guix-build-e1f543823b30/output/x86_64-w64-mingw32/SHA256SUMS.part
  38ccc35fe32895688f4fc0f22ed8a03233d06636a487b49de74a215fc6b67002  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-codesigning.tar.gz
  22863abb1a4d1fed1e4753e602f33a743296caf297bdc7ed9330010f5d3f79f3  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-debug.zip
  1cbc8ae43899d96664e75fa2c3fce2efbb2cfac34b279fe1e240a616646cb3e9  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-setup-unsigned.exe
  b6d22f62c083aca24dc788df1676bfc2ce0abc85a796a4823e5802d71482082c  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-unsigned.zip
  ```

ACKs for top commit:
  shahsb:
    ACK e1f543823b
  purpleKarrot:
    ACK e1f543823b300b28c9edaf5d1a3e1e9badde471b
  TheCharlatan:
    ACK e1f543823b300b28c9edaf5d1a3e1e9badde471b
  hebasto:
    ACK e1f543823b300b28c9edaf5d1a3e1e9badde471b, I have reviewed the code and it looks OK.

Tree-SHA512: d4bcbc37d431113f0e6367e8f61e71ab9d9ef8a08c38a2db961d9f9cc8473636124f5f2bd4d66cbb3e5032f9d5f978d7d286033d80f7e148f9d571ff09f005ff
2025-05-05 15:19:20 +01:00
Hennadii Stepanov
53ccb75f0c
Merge bitcoin/bitcoin#32358: subprocess: Backport upstream changes
cd95c9d6a7ec08cca0f9c98328c759be586720f8 subprocess: check and handle fcntl(F_GETFD) failure (Tomás Andróil)
b7288decdf534391b3f917cfb11ec62580407c3f subprocess: Proper implementation of wait() on Windows (Haowen Liu)
7423214d8deebbbcdab66090e185129decfaa799 subprocess: Do not escape double quotes for command line arguments on Windows (Hennadii Stepanov)
bb9ffea53fb021580f069c431aee02f547039831 subprocess: Explicitly define move constructor of Streams class (Shunsuke Shimizu)
174bd43f2e46a0ccc6f5ad486bb587c72c1241c3 subprocess: Avoid leaking POSIX name aliases beyond `subprocess.h` (Hennadii Stepanov)
7997b7656f99c5415cfa02cb1206226d0a82efd6 subprocess: Fix cross-compiling with mingw toolchain (Hennadii Stepanov)
647630462f10cacc7a75da7c82ca7c6d33bbde4b subprocess: Get Windows return code in wait() (Haowen Liu)
d3f511b4583b3771bf941ebc7884477430115039 subprocess: Fix string_arg when used with rref (Haowen Liu)
2fd3f2fec67a3bb62378c286fbf9667e6fb3cc3b subprocess: Fix memory leaks (Haoran Peng)

Pull request description:

  Most of these changes were developed during work on https://github.com/bitcoin/bitcoin/pull/29868 and https://github.com/bitcoin/bitcoin/pull/32342 and have since been upstreamed.

  As they are now merged, this PR backports them to our `src/util/subprocess.h` header.

  Required for https://github.com/bitcoin/bitcoin/pull/29868.

  A list of the backported PRs:
   - https://github.com/arun11299/cpp-subprocess/pull/106
  - https://github.com/arun11299/cpp-subprocess/pull/110
  - https://github.com/arun11299/cpp-subprocess/pull/109
  - https://github.com/arun11299/cpp-subprocess/pull/99
  - https://github.com/arun11299/cpp-subprocess/pull/112
  - https://github.com/arun11299/cpp-subprocess/pull/107
  - https://github.com/arun11299/cpp-subprocess/pull/113
  - https://github.com/arun11299/cpp-subprocess/pull/116
  - https://github.com/arun11299/cpp-subprocess/pull/117

  The following PRs were skipped for backporting:
  - https://github.com/arun11299/cpp-subprocess/pull/108 because we are not planning to support this feature.
  - https://github.com/arun11299/cpp-subprocess/pull/101 because that change has been already landed in https://github.com/bitcoin/bitcoin/pull/29849.

ACKs for top commit:
  theStack:
    Light ACK cd95c9d6a7ec08cca0f9c98328c759be586720f8
  laanwj:
    Code review re-ACK cd95c9d6a7ec08cca0f9c98328c759be586720f8

Tree-SHA512: f9b60b932957d2e1cad1d87f2ad8bb68c97136e9735eb78547018a42cc50c4652750367f29462eadb0512c27db1dd8a7d4b17a2f0aeab62b3dbf86db5f51a61c
2025-05-05 12:35:42 +01:00
Hennadii Stepanov
fa2c548429
Merge bitcoin/bitcoin#32417: doc: Explain that .gitignore is not for IDE-specific excludes
fada115cbeaa8c0ca3d19178499079b66ee5f499 doc: Explain that .gitignore is not for IDE-specific excludes (MarcoFalke)

Pull request description:

  This comes up frequently, so document it.

  Examples:

  * https://github.com/bitcoin/bitcoin/pull/27275
  * https://github.com/bitcoin/bitcoin/pull/21894
  * https://github.com/bitcoin/bitcoin/pull/32392
  * https://github.com/bitcoin/bitcoin/pull/17868

  ...

ACKs for top commit:
  l0rinc:
    ACK fada115cbeaa8c0ca3d19178499079b66ee5f499
  hebasto:
    ACK fada115cbeaa8c0ca3d19178499079b66ee5f499.
  janb84:
    ACK [fada115](fada115cbe)

Tree-SHA512: 6fd1e48de54b40118a49ef61ad157fea278bba568286a022559a4815e53f26650db98a779a1ea2b3085237ded5cbee20d4c2dd1ef51e6a2d3d6085d7063f5309
2025-05-05 07:40:08 +01:00
MarcoFalke
fada115cbe
doc: Explain that .gitignore is not for IDE-specific excludes 2025-05-04 19:45:11 +02:00
Ava Chow
eba5f9c4b6
Merge bitcoin/bitcoin#32403: test: remove Boost SIGCHLD workaround.
3add6ab9adcd722d57c6d488581358ae9b377f1a test: remove Boost SIGCHLD workaround. (fanquake)

Pull request description:

  The related code was removed from Boost in 2e3bd1025d.

ACKs for top commit:
  achow101:
    ACK 3add6ab9adcd722d57c6d488581358ae9b377f1a
  laanwj:
    ACK 3add6ab9adcd722d57c6d488581358ae9b377f1a
  hebasto:
    ACK 3add6ab9adcd722d57c6d488581358ae9b377f1a, I have reviewed the code and it looks OK.
  mabu44:
    ACK 3add6ab9adcd722d57c6d488581358ae9b377f1a

Tree-SHA512: a0db2bb4e6a476c920a97183bd807e800d935114ff28f8802373a08b5330df42a9be953e7ea6e3c09f2ed45175f60c26c33bb4e25010269e6e491f12867ba008
2025-05-02 14:10:23 -07:00
fanquake
e1f543823b
build: replace header checks with __has_include
See https://en.cppreference.com/w/cpp/preprocessor/include.
2025-05-02 16:41:04 +01:00
fanquake
3add6ab9ad
test: remove Boost SIGCHLD workaround.
The related code was removed from Boost in
2e3bd1025d.
2025-05-02 10:59:46 +01:00
Tomás Andróil
cd95c9d6a7
subprocess: check and handle fcntl(F_GETFD) failure
Add missing error check for fcntl(fd, F_GETFD, 0) in set_clo_on_exec.
Raise OSError on failure to align with existing FD_SETFD behavior.
This improves robustness in subprocess setup and error visibility.

Github-Pull: arun11299/cpp-subprocess#117
Rebased-From: 9974ff69cdd5fc1a2722cb63f006df9308628b35
2025-05-01 22:16:11 +01:00
Haowen Liu
b7288decdf
subprocess: Proper implementation of wait() on Windows
This commit makes sure:
1. WaitForSingleObject returns with expected
code before proceeding.
2. Process handle is properly closed.

Github-Pull: arun11299/cpp-subprocess#116
Rebased-From: 625a8775791e62736f20f3fa3e6cc4f1b24aa89a
2025-05-01 22:15:57 +01:00
Hennadii Stepanov
7423214d8d
subprocess: Do not escape double quotes for command line arguments on Windows
* refactor: Guard `util::quote_argument()` with `#ifdef __USING_WINDOWS__`

The `util::quote_argument()` function is specific to Windows and is used
in code already guarded by `#ifdef __USING_WINDOWS__`.

* Do not escape double quotes for command line arguments on Windows

This change fixes the handling of double quotes and aligns the behavior
with Python's `Popen` class. For example:
```
>py -3
>>> import subprocess
>>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True)
>>> print(f"Captured stdout:\n{stdout}")
```

Currently, the same command line processed by the `quote_argument()`
function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is
broken.

With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`.

Github-Pull: arun11299/cpp-subprocess#113
Rebased-From: ed313971c04ac10dc006104aba07d016ffc6542a
2025-05-01 22:15:19 +01:00
Shunsuke Shimizu
bb9ffea53f
subprocess: Explicitly define move constructor of Streams class
This suppresses the following warning caused by clang-20.

```
error: definition of implicit copy constructor for 'Streams' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
```

Copy constructor or move constructor is called when std::vector re-allocates
memory. In this case, move constructor should be called, because copying
Streams instances breaks file-descriptor management.

Communication class is modified as well, since it's instance is a member of
Streams class.

Github-Pull: arun11299/cpp-subprocess#107
Rebased-From: 38d98d9d20be50c7187b98ac9bc9a6e66920f6ef
2025-05-01 22:14:29 +01:00
Hennadii Stepanov
174bd43f2e
subprocess: Avoid leaking POSIX name aliases beyond subprocess.h
The commit a32c0f3df4b6bcd1d2e93f19e8f380bb890cd507 introduced code to
silence MSVC's "warning C4996: The POSIX name for this item is
deprecated."

However, it exhibits several issues:
1. The aliases may leak into code outside the `subprocess.hpp` header.
2. They are unnecessarily applied when using the MinGW-w64 toolchain.
3. The fix is incomplete: downstream projects still see C4996 warnings.
4. The implementation lacks documentation.

This change addresses all of the above shortcomings.

Github-Pull: arun11299/cpp-subprocess#112
Rebased-From: 778543b2f2ca7f5d1c4f0241b635bbb265d750dd

Co-authored-by: Luke Dashjr <luke-jr+git@utopios.org>
2025-05-01 22:10:35 +01:00
Hennadii Stepanov
7997b7656f
subprocess: Fix cross-compiling with mingw toolchain
Github-Pull: arun11299/cpp-subprocess#99
Rebased-From: 34033d03deacfdba892a708b7d8092b4d9e5e889
2025-05-01 22:07:39 +01:00
Haowen Liu
647630462f
subprocess: Get Windows return code in wait()
Currently, wait() returns 0 on windows regardless
of the actual return code of processes.

Github-Pull: arun11299/cpp-subprocess#109
Rebased-From: 04b015a8e52ead4d8bb5f0eb486419c77e418a17
2025-05-01 22:07:21 +01:00
Haowen Liu
d3f511b458
subprocess: Fix string_arg when used with rref
When passing in a rvalue reference, compiler
considers it ambiguous between std::string and
std::string&&. Making one of them take a lvalue
reference makes compilers correctly pick the right
one depending on whether the passed in value binds
to a rvalue or lvalue reference.

Github-Pull: arun11299/cpp-subprocess#110
Rebased-From: 2d8a8eebb03e509840e2c3c755d1abf32d930f33
2025-05-01 22:06:28 +01:00
Haoran Peng
2fd3f2fec6
subprocess: Fix memory leaks
I encountered this issue while running my code with Valgrind today.
Below is part of the Valgrind error message:

```
==1578139== 472 bytes in 1 blocks are still reachable in loss record 1 of 1
==1578139==    at 0x4848899: malloc (...)
==1578139==    by 0x4B3AF62: fdopen@@GLIBC_2.2.5 (...)
==1578139==    by 0x118B09: subprocess::Popen::execute_process() (...)
```

I noticed that a similar fix had been proposed by another contributor
previously. I did not mean to scoop their work, but merely hoping to fix
it sooner so other people don't get confused by it just as I did today.

Github-Pull: arun11299/cpp-subprocess#106
Rebased-From: 3afe581c1f22f106d59cf54b9b65251e6c554671
2025-05-01 22:04:59 +01:00
Ava Chow
5b8046a6e8
Merge bitcoin/bitcoin#30611: validation: write chainstate to disk every hour
e976bd3045010ee217aa0f2dca4c962aabb789d5 validation: add randomness to periodic write interval (Andrew Toth)
2e2f41068128c38120a5b44d24ee30f71970455a refactor: replace m_last_write with m_next_write (Andrew Toth)
b557fa7a175f139614932fbb3a4ad0af8271c73c refactor: rename fDoFullFlush to should_write (Andrew Toth)
d73bd9fbe483ad1397f62dc1d580314202351ace validation: write chainstate to disk every hour (Andrew Toth)
0ad7d7abdbcffc11a46413545a214a716f56dc95 test: chainstate write test for periodic chainstate flush (Andrew Toth)

Pull request description:

  Since #28233, periodically writing the chainstate to disk every 24 hours does not clear the dbcache. Since #28280, periodically writing the chainstate to disk is proportional only to the amount of dirty entries in the cache. Due to these changes, it is no longer beneficial to only write the chainstate to disk every 24 hours. The periodic flush interval was necessary because every write of the chainstate would clear the dbcache. Now, we can get rid of the periodic flush interval and simply write the chainstate along with blocks and block index at least every hour.

  Three benefits of doing this:
  1. For IBD or reindex-chainstate with a combination of large dbcache setting, slow CPU, slow internet speed/unreliable peers, it could be up to 24 hours until the chainstate is persisted to disk. A power outage or crash could potentially lose up to 24 hours of progress. If there is a very large amount of dirty cache entries, writing to disk when a flush finally does occur will take a very long time. Crashing during this window of writing can cause https://github.com/bitcoin/bitcoin/issues/11600. By syncing every hour in unison with the block index we avoid this problem. Only a maximum of one hour of progress can be lost, and the window for crashing during writing is much smaller. For IBD with lower dbcache settings, faster CPU, or better internet speed/reliable peers, chainstate writes are already triggered more often than every hour so this change will have no effect on IBD.
  2. Based on discussion in #28280, writing only once every 24 hours during long running operation of a node causes IO spikes. Writing smaller chainstate changes every hour like we do with blocks and block index will reduce IO spikes.
  3. Faster shutdown speeds. All dirty chainstate entries must be persisted to disk on shutdown. If we have a lot of dirty entries, such as when close to 24 hours or if we sync with a large dbcache, it can take a long time to shutdown. By keeping the chainstate clean we avoid this problem.

  Inspired by [this comment](https://github.com/bitcoin/bitcoin/pull/28280#issuecomment-2121088705).

  Resolves https://github.com/bitcoin/bitcoin/issues/11600

ACKs for top commit:
  achow101:
    ACK e976bd3045010ee217aa0f2dca4c962aabb789d5
  davidgumberg:
    utACK e976bd3045
  sipa:
    utACK e976bd3045010ee217aa0f2dca4c962aabb789d5
  l0rinc:
    ACK  e976bd3045010ee217aa0f2dca4c962aabb789d5

Tree-SHA512: 5bccd8f1dea47f9820a3fd32fe3bb6841c0167b3d6870cc8f3f7e2368f124af1a914bca6acb06889cd7183638a8dbdbace54d3237c3683f2b567eb7355e015ee
2025-05-01 12:11:55 -07:00
merge-script
fc6346dbc8
Merge bitcoin/bitcoin#32389: doc: Fix test_bitcoin path
6cbc28b8dd629062950f195facc009fd8ba86310 doc: Fix test_bitcoin path (monlovesmango)

Pull request description:

  This commit fixes a couple command paths for interacting with the test_bitcoin binary within the Unit Test documentation.

  If the commands are run as is a `command not found` error is returned.

  ```bash
  ❯ test_bitcoin --list_content
  bash: test_bitcoin: command not found
  ```

  ```bash
  ❯ test_bitcoin --help
  bash: test_bitcoin: command not found
  ```

ACKs for top commit:
  davidgumberg:
    ACK 6cbc28b8dd

Tree-SHA512: 0b10bc3aead360fa499beef7c9715f95a9acacdda44cbfac15566428594a7a8bdece24114a42618355959e20754bedc7a903bdddbf21b819c7b75375bdc80a93
2025-05-01 10:21:31 +01:00
monlovesmango
6cbc28b8dd doc: Fix test_bitcoin path
This commit fixes a couple command paths for interacting with the
test_bitcoin binary within the Unit Test documentation.
2025-05-01 03:05:57 +00:00
Andrew Toth
e976bd3045
validation: add randomness to periodic write interval
Co-Authored-By: Pieter Wuille <pieter@wuille.net>
Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
2025-04-30 18:35:03 -04:00
Andrew Toth
2e2f410681
refactor: replace m_last_write with m_next_write
Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
2025-04-30 18:33:43 -04:00
Andrew Toth
b557fa7a17 refactor: rename fDoFullFlush to should_write 2025-04-30 18:32:51 -04:00
Andrew Toth
d73bd9fbe4
validation: write chainstate to disk every hour
Remove the 24 hour periodic flush interval and
write the chainstate along with blocks and block
index every hour
2025-04-30 18:32:41 -04:00
Ava Chow
68ac9f116c
Merge bitcoin/bitcoin#32383: util: Remove fsbridge::get_filesystem_error_message()
97eaadc3bf9f621ba397e29bb1c0cd99af55f2e3 util: Remove `fsbridge::get_filesystem_error_message()` (Hennadii Stepanov)

Pull request description:

  The `fsbridge::get_filesystem_error_message()` function exhibits several drawbacks:

  1. It was introduced in https://github.com/bitcoin/bitcoin/pull/14192 to account for platform-specific variations in
  `boost::filesystem::filesystem_error::what()`. Since [migrating](https://github.com/bitcoin/bitcoin/pull/20744) to `std::filesystem`, those discrepancies no longer exist.

  2. It fails to display UTF-8 paths correctly on Windows:
  ```
  > build\bin\Release\bitcoind.exe -datadir="C:\Users\hebasto\dd_₿_🏃" -regtest
  ...
  2025-04-30T00:17:48Z DeleteAuthCookie: Unable to remove random auth cookie file: remove: Access is denied.: "C:\Users\hebasto\dd_?_??\regtest\.cookie"
  ...
  ```

  3. It relies on `std::wstring_convert`, which was deprecated in C++17 and removed in C++26 (also see https://github.com/bitcoin/bitcoin/issues/32361).

  This PR removes the obsolete `fsbridge::get_filesystem_error_message()` function, thereby resolving all of the above issues.

ACKs for top commit:
  maflcko:
    lgtm re-ACK 97eaadc3bf9f621ba397e29bb1c0cd99af55f2e3
  davidgumberg:
    untested crACK 97eaadc3bf
  achow101:
    ACK 97eaadc3bf9f621ba397e29bb1c0cd99af55f2e3
  laanwj:
    Code review ACK 97eaadc3bf9f621ba397e29bb1c0cd99af55f2e3

Tree-SHA512: 3c7378a9b143ac2a71add967318a13c346ae3bccbec6e9879d7873083f3fa469b3eef529b2c9c142b2489ba9563e4e12f685745c09a8a219d58b384f7ecf1be1
2025-04-30 10:56:14 -07:00
Hennadii Stepanov
97eaadc3bf
util: Remove fsbridge::get_filesystem_error_message()
The `fsbridge::get_filesystem_error_message()` function exhibits several
drawbacks:

1. It was introduced in https://github.com/bitcoin/bitcoin/pull/14192 to
account for platform-specific variations in
`boost::filesystem::filesystem_error::what()`. Since migrating to
`std::filesystem`, those discrepancies no longer exist.

2. It fails to display UTF-8 paths correctly on Windows.

3. It relies on `std::wstring_convert`, which was deprecated in C++17
and removed in C++26.

This change removes the `fsbridge::get_filesystem_error_message()`
function, thereby resolving all of the above issues.

Additionally, filesystem error messages now use the "Warning" log level.
2025-04-30 10:41:34 +01:00
Ava Chow
14b8dfb2bd
Merge bitcoin/bitcoin#31398: wallet: refactor: various master key encryption cleanups
a8333fc9ff9adaa97a1f9024f5783cc071777150 scripted-diff: wallet: rename plain and encrypted master key variables (Sebastian Falbesoner)
5a92077fd5317f936da2fa0aa45e0173248f765b wallet: refactor: dedup master key decryption (Sebastian Falbesoner)
846545947cd3b993c40362b9d0afcd7b4f5f05bd wallet: refactor: dedup master key encryption / derivation rounds setting (Sebastian Falbesoner)
a6d9b415aa3afcfe463887d0fde00c3d2d32672a wallet: refactor: introduce `CMasterKey::DEFAULT_DERIVE_ITERATIONS` constant (Sebastian Falbesoner)
62c209f50d9c33fde5062ebca317b9a4233aff62 wallet: doc: remove mentions of unavailable scrypt derivation method (Sebastian Falbesoner)

Pull request description:

  This PR contains various cleanups around the wallet's master key encryption logic. The default/minimum key derivation rounds magic number of 25000 is hoisted into a constant (member of `CMasterKey`) and two new functions `EncryptMasterKey`/`DecryptMasterKey` are introduced in order to deduplicate code for the derivation round determination and master key en/decryption. Also, mentions of the never-implemented derivation method `scrypt` are removed from the wallet crypter header and both plain and encrypted master key instances are renamed to adapt to moderning coding style (hopefully improving readability).

ACKs for top commit:
  davidgumberg:
    ACK a8333fc9ff
  achow101:
    ACK a8333fc9ff9adaa97a1f9024f5783cc071777150

Tree-SHA512: 5a66d3b26f481347d0b5b4f742dd237803a35aad6e3480ed15fd38b7fa3700650bd5f67f4c30ed88f5fad45d6cd4c893fe4f1657e36e563b4294fd3596187724
2025-04-29 16:32:21 -07:00
Ava Chow
a60445cd04
Merge bitcoin/bitcoin#32355: Bugfix: Miner: Don't reuse block_reserved_weight for "block is full enough to give up" weight delta
524f981bb87319fdd6ff2ab4a932c4b4e31a7398 Bugfix: Miner: Don't reuse block_reserved_weight for "block is full enough to give up" weight delta (Luke Dashjr)

Pull request description:

  PR #30356 incorrectly changed a constant of `4000` to `m_options.coinbase_max_additional_weight` in the check for when to give up finding another transaction to fill the block:

  ```diff
               if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockWeight >
  -                    m_options.nBlockMaxWeight - 4000) {
  +                    m_options.nBlockMaxWeight - m_options.block_reserved_weight) {
                   // Give up if we're close to full and haven't succeeded in a while
                   break;
               }
  ```

  But this constant did not deal with the reserved weight at all. It was in fact simply checking if the block was close to full, and if so, giving up finding another transaction to pad it with after `MAX_CONSECUTIVE_FAILURES` failed attempts.

  It doesn't seem very logical to reuse the reserve weight for this purpose, and it would be overcomplicated to add yet another setting, so this PR changes it to a new constexpr.

ACKs for top commit:
  achow101:
    ACK 524f981bb87319fdd6ff2ab4a932c4b4e31a7398
  darosior:
    utACK 524f981bb87319fdd6ff2ab4a932c4b4e31a7398
  ismaelsadeeq:
    ACK 524f981bb87319fdd6ff2ab4a932c4b4e31a7398

Tree-SHA512: c066debc34a021380424bd21b40444071b736325e41779a41590c2c8a6822ceeaf910fe067817c1dba108210b24c574977b0350b29520502e7af79d3b405928b
2025-04-29 15:51:18 -07:00
Ava Chow
2d5b424414
Merge bitcoin/bitcoin#32351: test: avoid stack overflow in FindChallenges via manual iteration
7e8ef959d0637ca5543ed33d3919937e0d053e70 refactor: Fix Sonar rule `cpp:S4998` - avoid unique_ptr const& as parameter (Lőrinc)
e400ac53524d143467740e2f59698a7c94644c21 refactor: simplify repeated comparisons in `FindChallenges` (Lőrinc)
f670836112c01feb3cb71618192e9c0c2e55767f test: remove old recursive `FindChallenges_recursive` implementation (Lőrinc)
b80d0bdee4603aa8ab69587d0c311aad1a9b3c7a test: avoid stack overflow in `FindChallenges` via manual iteration (Lőrinc)

Pull request description:

  `FindChallenges` explores the `Miniscript` node tree by going deep into the first child's subtree, then the second, and so on - effectively performing a pre-order Traversal (Depth-First Search) recursively, using the call stack which can result in stack overflows on Windows debug builds.

  This change replaces the recursive implementation with an iterative version using an explicit stack. The new implementation also performs a pre-order depth-first traversal, though it processes children in right-to-left order (rather than left-to-right) due to the LIFO nature of the stack. Since both versions store results in a `std::set`, which automatically sorts and deduplicates elements, the exact traversal order doesn't affect the final result.

  It is an alternative to increasing the Windows stack size, as proposed in #32349, and addresses the issue raised in #32341 by avoiding deep recursion altogether.

  The change is done in two commits:
  * add a new iterative `FindChallenges` method and rename the old method to `*_recursive` (to simplify the next commit where we remove it), asserting that its result matches the original;
  * remove the original recursive implementation.

  This approach avoids ignoring the `misc-no-recursion` warning as well.

  I tried modifying the new method to store results in a vector instead, but it demonstrated that the deduplication provided by `std::set` was necessary. One example showing the need for deduplication:

  Recursive (using set):
  ```
    (6, 9070746)
    (6, 19532513)
    (6, 3343376967)
  ```
  Iterative (using vector attempt):
  ```
    (6, 19532513)
    (6, 9070746)
    (6, 3343376967)
    (6, 9070746)  // Duplicate entry
  ```

  The performance of the test is the same as before, with the recursive method.

  Fixes https://github.com/bitcoin/bitcoin/issues/32341

ACKs for top commit:
  achow101:
    ACK 7e8ef959d0637ca5543ed33d3919937e0d053e70
  sipa:
    utACK 7e8ef959d0637ca5543ed33d3919937e0d053e70
  hodlinator:
    re-ACK 7e8ef959d0637ca5543ed33d3919937e0d053e70

Tree-SHA512: 9e52eff82a7d76f5d37e3b74c508f08e5fced5386dad504bed111b27ed2b529008a6dd12a5116f009609a94c7ee7ebe3e80a759dda55dd1cb3ae52078f65ec71
2025-04-29 15:29:50 -07:00
Ava Chow
0ed5f37afe
Merge bitcoin/bitcoin#31014: net: Use GetAdaptersAddresses to get local addresses on Windows
b9d4d5f66a5a35c47e7abc9ec6ef5ab242b3f1e1 net: Use GetAdaptersAddresses to get local addresses on Windows (laanwj)

Pull request description:

  Instead of a `gethostname` hack, which is not guaranteed to return all addresses, use the official way of calling `GetAdaptersAddresses` to get local network addresses on Windows.

  Do the same checks as the UNIX path: interface is up, interface is not loopback.

  Suggested by Ava Chow.

  Addiional changes:

  - Cleanup: move out `FromSockAddr` in `netif.cpp` from MacOS and use it everywhere appropriate. This avoids code duplication.

ACKs for top commit:
  davidgumberg:
    utreACK b9d4d5f66a
  achow101:
    ACK b9d4d5f66a5a35c47e7abc9ec6ef5ab242b3f1e1

Tree-SHA512: e9f0a7ec0c46f21c0377d5174e054a6569f858630727f94dac00c0cb7c241c56892d0b902706d6dd53880cc3b5ae1f2dba9caa1fec40e64cd4cf0d34493a49c1
2025-04-29 15:13:39 -07:00
Ava Chow
7a4a2a38ea
Merge bitcoin/bitcoin#27826: validation: log which peer sent us a header
abe43dfadd6325f80975a76aea57a549c3162191 doc: release note for #27826 (Sjors Provoost)
f9fa28788e63e2bd059a21ec0e76ae6903b2a6be Use LogBlockHeader for compact blocks (Sjors Provoost)
bad7c914793134abe2f64d96c367d5e9b07e60fd Log which peer sent us a header (Sjors Provoost)
9d3e39c29c31775fd82af319d1d4dfbbd3e21bfa Log block header in net_processing (Sjors Provoost)

Pull request description:

  Fixes #27744

  Since #27278 we log received headers. For compact blocks we also log which peer sent it (e5ce8576349d404c466b2f4cab1ca7bf920904b2), but not for regular headers. That required an additional refactor, which this PR provides.

  Move the logging from validation to net_processing.

  This also reduces the number of log entries (under default configuration) per compact block header from 3 to 2: one for the header and one for the connected tip.

  The PR introduces a new helper method `LogBlockHeader`.

  When receiving a _compact block_ we call `LogBlockHeader` from the exact same place as where we previously logged. So that log message doesn't change. What does change is that we no longer _also_ log from `AcceptBlockHeader`.

  When receiving a regular header(s) message, _we only log the last one_. This is a change in behaviour because it was simpler to implement, but it's probably better anyway. It does mean that if a peer sends of a bunch of headers of which _any_ is invalid, we won't log it (here).

  Lastly I expanded the code comment explaining why we log this. It initially only covered selfish mining, but we also care about peers sending us headers but not following up (see e.g. #27626).

  Example log:

  ```
  2023-06-05T13:12:21Z Saw new header hash=000000000000000000045910263ef84b575ae3af151865238f1e5c619e69c330 height=792964 peer=0
  2023-06-05T13:12:23Z UpdateTip: new best=000000000000000000045910263ef84b575ae3af151865238f1e5c619e69c330 height=792964 version=0x20000000 log2_work=94.223098 tx=848176824 date='2023-06-05T13:11:49Z' progress=1.000000 cache=6.4MiB(54615txo)
  2023-06-05T13:14:05Z Saw new cmpctblock header hash=00000000000000000003c6fd4ef2e1246a3f9e1fffab7247344f94cadb9de979 height=792965 peer=0
  2023-06-05T13:14:05Z UpdateTip: new best=00000000000000000003c6fd4ef2e1246a3f9e1fffab7247344f94cadb9de979 height=792965 version=0x20000000 log2_work=94.223112 tx=848179461 date='2023-06-05T13:13:58Z' progress=1.000000 cache=7.2MiB(61275txo)
  2023-06-05T13:14:41Z Saw new header hash=000000000000000000048e6d69c8399992782d08cb57f5d6cbc81a9f996c3f43 height=792966 peer=8
  2023-06-05T13:14:42Z UpdateTip: new best=000000000000000000048e6d69c8399992782d08cb57f5d6cbc81a9f996c3f43 height=792966 version=0x2db3c000 log2_work=94.223126 tx=848182944 date='2023-06-05T13:14:35Z' progress=1.000000 cache=8.0MiB(69837txo)
  ```

ACKs for top commit:
  danielabrozzoni:
    tACK abe43dfadd6325f80975a76aea57a549c3162191
  achow101:
    ACK abe43dfadd6325f80975a76aea57a549c3162191
  vasild:
    ACK abe43dfadd6325f80975a76aea57a549c3162191

Tree-SHA512: 081e0de62cbd8a0b35cf54daaa09e3e6991d0cc9f706ef3eb50908752fe7815de69b367f7313381c90cd8d5de0ae5f532d1cd54948c5c1133b1832f266d9c232
2025-04-29 14:48:16 -07:00
Ava Chow
4694732bc4
Merge bitcoin/bitcoin#32338: net: remove unnecessary check from AlreadyConnectedToAddress()
f1b142856a4ecd0a0d90bc3d73ef5137997b14ff test: Same addr, diff port is already connected (David Gumberg)
94e85a82a753a0aa5ad688fc46330e83c9a697fe net: remove unnecessary check from AlreadyConnectedToAddress() (Vasil Dimov)

Pull request description:

  `CConnman::AlreadyConnectedToAddress()` searches the existent nodes by address or by address-and-port:

  ```cpp
  FindNode(static_cast<CNetAddr>(addr)) || FindNode(addr.ToStringAddrPort())
  ```

  but:

  * if there is a match by just the address, then the address-and-port search will not be evaluated and the whole condition will be `true`
  * if the there is no node with the same address, then the second search by address-and-port will not find a match either.

  The search by address-and-port is comparing against `CNode::m_addr_name` which could be a hostname, e.g. `"node.foobar.com:8333"`, but `addr.ToStringAddrPort()` is always going to be numeric.

  ---

  In other words: let `A` be "CNetAddr equals" and `B` be "addr:port string matches", then:

  * If `A` (is `true`), then `B` is irrelevant, so the condition `A || B` is equivalent to `A` is `true`.
  * Observation in this PR: if `!A` (`A` is `false`), then `!B` for sure, thus the condition `A || B` is equivalent to `A` is `false`.

  So, simplify `A || B` to `A`.

  https://en.wikipedia.org/wiki/Modus_tollens `!A => !B` is equivalent to `B => A`. So the added fuzz test asserts that if `B` is `true`, then `A` is `true`.

ACKs for top commit:
  davidgumberg:
    crACK f1b142856a4ecd0a0d90bc3d
  achow101:
    ACK f1b142856a4ecd0a0d90bc3d73ef5137997b14ff
  theuni:
    utACK f1b142856a4ecd0a0d90bc3d73ef5137997b14ff
  mzumsande:
    Code Review ACK f1b142856a4ecd0a0d90bc3d73ef5137997b14ff

Tree-SHA512: d744b60e9bace121faa3a746463f6b6e0e6ef08eac0e7879326cbd5f4721e47e6e10f6203dfd3870a2057c4ddd1860692c070ef048a76d773b84e6c2f840cc86
2025-04-29 14:31:59 -07:00
Ava Chow
7db096121d
Merge bitcoin/bitcoin#29039: versionbits refactoring
e3014017bacff42d8d69f3061ce1ee621aaa450a test: add IsActiveAfter tests for versionbits (Anthony Towns)
60950f77c35e54e2884cfc14ab67623f3e325099 versionbits: docstrings for BIP9Info (Anthony Towns)
7565563bc7a5bb98ebf03a7d6881912a74d3f302 tests: refactor versionbits fuzz test (Anthony Towns)
2e4e9b9608c722aaf767638e9dba498d8dc3e772 tests: refactor versionbits unit test (Anthony Towns)
525c00f91bb27d0f2a1b2e5532aebec7fac97d3a versionbits: Expose VersionBitsConditionChecker via impl header (Anthony Towns)
e74a7049b477d1853191ded75fdf25024a6e233f versionbits: Expose StateName function (Anthony Towns)
d00d1ed52c8ee95eeed665d68d6715a694bd4c1f versionbits: Split out internal details into impl header (Anthony Towns)
37b9b67a39554465104c9cf1a74690f40019dbad versionbits: Simplify VersionBitsCache API (Anthony Towns)
1198e7d2fd665bf2bc49fd26773d4fd5fbc2b716 versionbits: Move BIP9 status logic for getblocktemplate to versionbits (Anthony Towns)
b1e967c3ec92738affb22d3b58483ebcdd8dfea2 versionbits: Move getdeploymentinfo logic to versionbits (Anthony Towns)
3bd32c20550e69688a4ff02409fb34b9a637b9c4 versionbits: Move WarningBits logic from validation to versionbits (Anthony Towns)
5da119e5d0e61f0b583f0fe21b9a00ee815a3e46 versionbits: Change BIP9Stats to uint32_t types (Anthony Towns)
a679040ec19ef17f3f03988a52207f1c03af701e consensus/params: Move version bits period/threshold to bip9 param (Anthony Towns)
e9d617095d4ce9525a4337d33624cac9d6b4abe6 versionbits: Remove params from AbstractThresholdConditionChecker (Anthony Towns)
9bc41f1b48b2e0cc6abf9714e860a29989d7809c versionbits: Use std::array instead of C-style arrays (Anthony Towns)

Pull request description:

  Increases the encapsulation/modularity of the versionbits code, moving more of the logic into the versionbits module rather than having it scattered across validation and rpc code. Updates unit/fuzz tests to test the actual code used rather than just a close approximation of it.

ACKs for top commit:
  achow101:
    ACK e3014017bacff42d8d69f3061ce1ee621aaa450a
  TheCharlatan:
    Re-ACK e3014017bacff42d8d69f3061ce1ee621aaa450a
  darosior:
    ACK e3014017bacff42d8d69f3061ce1ee621aaa450a

Tree-SHA512: 2978db5038354b56fa1dd6aafd511099e9c16504d6a88daeac2ff2702c87bcf3e55a32e2f0a7697e3de76963b68b9d5ede7976ee007e45862fa306911194496d
2025-04-29 14:06:45 -07:00
Ava Chow
51d76634fb
Merge bitcoin/bitcoin#32365: descriptors: Reject + sign while parsing unsigned
fa655da159876861251d1149a5c31a830bd35596 test: [refactor] Use ToIntegral in CheckInferDescriptor (MarcoFalke)
fa55dd01df8384e0d57fbb442d170c8a60d0260b descriptors: Reject + sign when parsing multi threshold (MarcoFalke)
fa6f77ed3c152e0ff695c36b7a4ebb2c2efe916f descriptors: Reject + sign in ParseKeyPathNum (MarcoFalke)

Pull request description:

  As a follow-up to https://github.com/bitcoin/bitcoin/pull/30577, reject `+` for unsigned values in key-path parsing and multi threshold parsing as well.

  Both of those are using unsigned, and Bitcoin Core would never serialize a descriptor string with a stray `+`. Accepting stray `+` signs could lead to checksum mismatches, or other incompatibilities later on.

  Just like https://github.com/bitcoin/bitcoin/pull/30577, both changes are breaking changes on the RPC interface, but hopefully no one should be relying on this behavior in production. Similarly, both changes should be fine for the wallet, because it normalizes the strings on import, see https://github.com/bitcoin/bitcoin/pull/30577#pullrequestreview-2218436014.

ACKs for top commit:
  achow101:
    ACK fa655da159876861251d1149a5c31a830bd35596
  brunoerg:
    code review ACK fa655da159876861251d1149a5c31a830bd35596
  janb84:
    tACK [fa655da](fa655da159)

Tree-SHA512: d0c7262a167f7ba98b44ed8bf49ff4c15a1eb647cbac39a59b83c7cc379903c24dae3996e5f557497eb08e16d7121417916147058d97bdf168cd6eada57dceef
2025-04-29 10:25:21 -07:00
merge-script
c5e44a0435
Merge bitcoin/bitcoin#32369: test: Use the correct node for doubled keypath test
32d55e28af69ef09094ba921289bf4d1ad79905a test: Use the correct node for doubled keypath test (Ava Chow)

Pull request description:

  #29124 had a silent merge conflict with #32350 which resulted in it using the wrong node. Fix the test to use the correct v22 node.

ACKs for top commit:
  maflcko:
    lgtm ACK 32d55e28af69ef09094ba921289bf4d1ad79905a
  rkrux:
    ACK 32d55e28af69ef09094ba921289bf4d1ad79905a
  BrandonOdiwuor:
    Code Review ACK 32d55e28af69ef09094ba921289bf4d1ad79905a

Tree-SHA512: 1e0231985beb382b16e1d608c874750423d0502388db0c8ad450b22d17f9d96f5e16a6b44948ebda5efc750f62b60d0de8dd20131f449427426a36caf374af92
2025-04-29 09:59:42 +01:00
Ava Chow
32d55e28af test: Use the correct node for doubled keypath test 2025-04-28 14:44:17 -07:00
Ava Chow
65714c162c
Merge bitcoin/bitcoin#32327: test: Add missing check for empty stderr in util tester
fadf12a56c294696052c4cb6ee5284030ada7498 test: Add missing check for empty stderr in util tester (MarcoFalke)

Pull request description:

  Now that wine support was removed from the CI in 25b56fd9b469f8e5d36f0132c3b79a5214e3372a, it can probably be removed from the util tester as well.

  If someone really needs this, they can comment the new check out, or submit a patch to add an option/env var to silence the new check.

ACKs for top commit:
  achow101:
    ACK fadf12a56c294696052c4cb6ee5284030ada7498
  i-am-yuvi:
    tACK fadf12a56c294696052c4cb6ee5284030ada7498
  BrandonOdiwuor:
    Code Review ACK fadf12a56c294696052c4cb6ee5284030ada7498
  ismaelsadeeq:
    Tested ACK fadf12a56c294696052c4cb6ee5284030ada7498

Tree-SHA512: d9e4d7a7f724e114391070ea7f17b585a7e4c4f3221c3bf510eeb11df6ccd089b881ab5654adfef8d3a1f8fa7ec6bf5e3a3feeb0cdfe724a8f3e5a146c388e66
2025-04-28 14:43:32 -07:00
merge-script
a4eee6d50b
Merge bitcoin/bitcoin#29124: test: Test that migration automatically repairs corrupted metadata with doubled derivation path
c7e2b9e2644442b147880becb8a659f3d00092d9 tests: Test migration cleans up bad inactive chain derivation path (Ava Chow)

Pull request description:

  A bug in 0.21.x and 22.x resulted in some wallets having invalid derivation paths that are the concatenation of two derivation paths. These appear only when inactive hd chains are topped up.

  Since key metadata is a legacy wallet only record, migrating legacy wallets to descriptor wallets will fix this issue as all key metadata records are deleted. The derivation path information is derived on-the-fly from the descriptor that is produced for the inactive hd chain.

  Thus we only need a test to verify that the derivation paths are good, and that all key metadata records are deleted from the migrated wallet.

ACKs for top commit:
  murchandamus:
    re-ACK c7e2b9e2644442b147880becb8a659f3d00092d9 via range-diff:
  rkrux:
    re-ACK c7e2b9e2644442b147880becb8a659f3d00092d9
  furszy:
    utACK c7e2b9e2644442b147880becb8a659f3d00092d9

Tree-SHA512: 3117c4a43798972109fe2d3539341a8b69db70c6457fcabdd019e6044834dc4b17212abbc006d7b8008f560dce4b7856142b057981b9404f406d58fa0955cbd9
2025-04-28 17:13:42 -04:00
Ava Chow
af6cffa36d
Merge bitcoin/bitcoin#32350: test: Slim down previous releases bdb check
fa58f40b898ba6c57655bf38a241fb10107d4a3a test: Slim down previous releases bdb check (MarcoFalke)

Pull request description:

  The check iterates over several previous BDB-only releases to check that descriptor wallets are considered "corrupt" when loading. It is unclear why this needs to be done for more than one release.

  Avoid the confusion by removing the unused releases from the test and from the download script.

ACKs for top commit:
  achow101:
    ACK fa58f40b898ba6c57655bf38a241fb10107d4a3a
  rkrux:
    ACK fa58f40b898ba6c57655bf38a241fb10107d4a3a

Tree-SHA512: 8084392481bfe1fba9b80bb865ffbdfa454e9e6e14e02c39fa3f61c1a596b1def2c531c5da1c7566e5fddb77ac7e56f19feabaaf9b5af043fa6c230d9e2370b5
2025-04-28 12:56:22 -07:00
Ava Chow
33e6538b30
Merge bitcoin/bitcoin#32360: test: Force named args for RPCOverloadWrapper optional args
fa48be3ba443d2436f754265b86331f84b866130 test: Force named args for RPCOverloadWrapper optional args (MarcoFalke)
aaaa45399ca3f9a5ed19c176b25e3165e1e4e0d9 test: Remove unused createwallet_passthrough (MarcoFalke)
cccc1f4e91902f2e95481630fd534b8c72452b44 test: Remove unused RPCOverloadWrapper is_cli field (MarcoFalke)

Pull request description:

  This can avoid bugs and makes the test code easier to read, because the
  order of positional args does not have to be known or assumed.

  Also, contains two commits to remove dead code.

ACKs for top commit:
  achow101:
    ACK fa48be3ba443d2436f754265b86331f84b866130
  rkrux:
    tACK fa48be3ba443d2436f754265b86331f84b866130
  janb84:
    tACK [fa48be3](fa48be3ba4)

Tree-SHA512: d938fbc18be5035ad0d0e1ad2bf7297b2b66ede3bb2d3f10b8d27aa2a19d27a897b024a5f5a2a1cceca467837890729c26054928cb06acbe282b9e9eea94ae69
2025-04-28 12:41:00 -07:00
merge-script
3a29ba33dc
Merge bitcoin/bitcoin#32357: depends: Fix cross-compiling qt package from macOS to Windows
35e57fbe336cdcb348ff088fc04216f1f5cf2742 depends: Fix cross-compiling `qt` package from macOS to Windows (Hennadii Stepanov)

Pull request description:

  Native packages cannot be used during cross-compiling. However, Qt still unconditionally tries to find them, which causes issues in some cases, such as when [cross-compiling from macOS to Windows](https://github.com/bitcoin/bitcoin/issues/32346).

  This PR explicitly disables this unnecessary Qt behaviour.

  Fixes https://github.com/bitcoin/bitcoin/issues/32346.

  Here is a full workflow on my macOS Sequoia 15.4.1 (Intel):
  ```
  % brew install make cmake ninja mingw-w64 nsis
  % gmake -C depends -j 10 HOST=x86_64-w64-mingw32
  % cmake -B build --toolchain depends/x86_64-w64-mingw32/toolchain.cmake
  % cmake --build build -j 10 -t deploy
  ```

ACKs for top commit:
  shahsb:
    ACK 35e57fbe33
  fanquake:
    ACK 35e57fbe336cdcb348ff088fc04216f1f5cf2742

Tree-SHA512: 2822fb49bc84dd094dbd189d8a9ca0f023e1e48127db7beaefb9db92de53df63bb0f399c9c430c33941f9a9ee6976b9161d80467d889f7717385b9d1ea9fee43
2025-04-28 16:15:13 +01:00
MarcoFalke
fa655da159
test: [refactor] Use ToIntegral in CheckInferDescriptor 2025-04-28 17:05:43 +02:00
MarcoFalke
fa55dd01df
descriptors: Reject + sign when parsing multi threshold 2025-04-28 17:05:37 +02:00
MarcoFalke
fa6f77ed3c
descriptors: Reject + sign in ParseKeyPathNum 2025-04-28 17:05:36 +02:00
Lőrinc
7e8ef959d0 refactor: Fix Sonar rule cpp:S4998 - avoid unique_ptr const& as parameter
Changed `FindChallenges()` parameter from `const std::unique_ptr<const Node<Key>>&` to const `Node*`.

Sonar rule `cpp:S4998` - https://sonarcloud.io/project/issues?issueStatuses=OPEN%2CCONFIRMED&branch=32351-8c0e673c4ac31c1c04750756de749fb813b2c33f&id=aureleoules_bitcoin&open=AZZ2q88IvFhp-eMuMy96:
> Replace this use of "unique_ptr" by a raw pointer or a reference (possibly const).
> Function parameters should not be of type "std::unique_ptr<T> const &" cpp:S4998
> Software qualities impacted: Maintainability
2025-04-28 16:10:35 +02:00