Commit graph

43972 commits

Author SHA1 Message Date
Ava Chow
77bf99012a
Merge bitcoin/bitcoin#30302: doc: clarify loadwallet path loading for wallets
ca6aa0b9be doc: loadwallet loads from relative walletdir (am-sq)

Pull request description:

  ## Why this change?

  https://github.com/bitcoin/bitcoin/issues/30269 describes a need for documentation improvement with the `loadwallet` RPC. Namely, [some users have found](https://bitcoin.stackexchange.com/questions/123331/how-do-you-load-a-regtest-wallet) the usage description confusing when it comes to loading wallets that are not in the normal case of being in the default wallet directory.

  The default wallet directory, depending on the machine OS, has the base directory defined here: 9c5cdf07f3/src/common/args.cpp (L699) which is then appended with `/wallets`. So for example, for MacOS, it would be `~/Library/Application Support/Bitcoin/wallets`.

  ## The changes implemented
  1. Change the help text to indicate that the filename (or directory) passed in to `loadwallet` is relative to the base wallet directory
  2. Adds additional examples to the help page showing how to fetch a wallet within a subdirectory of the base data directory for wallets, or from an absolute path

ACKs for top commit:
  achow101:
    ACK ca6aa0b9be
  maflcko:
    lgtm ACK ca6aa0b9be
  rkrux:
    ACK ca6aa0b9be
  jonatack:
    ACK ca6aa0b9be

Tree-SHA512: 123ae118c79ee1843ed65861e7a008658a53e47d4d14f2b7612561bba1b1dbdb6744f9aaac1587aac231c62d0c1804de848a6d732f1382788b437d9fe6474012
2025-02-20 11:40:59 -08:00
merge-script
46a9c73083
Merge bitcoin/bitcoin#31906: ci: Switch to gcr.io mirror to avoid rate limits
fa8de4706a ci: Switch to gcr.io mirror to avoid rate limits (MarcoFalke)

Pull request description:

  dockerhub seems to have recently started to increase their rate limits further, beyond what is documented, even to the extent where pulling the same image twice at the same time results in a ban. See https://github.com/bitcoin/bitcoin/issues/31797#issuecomment-2656374222

  Fix all issues by just using another mirror, as documented in https://cloud.google.com/artifact-registry/docs/pull-cached-dockerhub-images

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

ACKs for top commit:
  0xB10C:
    ACK fa8de4706a

Tree-SHA512: 83d021059772adf473bd6c01443b53f787259e873016238869d716992a2451e18ab98f034e1ac9cd05f2ddbe45eba86cb9ea690be8e16b69c87dd8649d7ac7d4
2025-02-20 13:42:19 -05:00
merge-script
82ba925715
Merge bitcoin/bitcoin#31366: cmake: Check -Wno-* compiler options for leveldb target
9e4a4b4832 cmake: Check `-Wno-*` compiler options for `leveldb` target (Hennadii Stepanov)

Pull request description:

  Otherwise, https://cirrus-ci.com/task/4830737755537408:
  ```
  At global scope:
  cc1plus: note: unrecognized command-line option ‘-Wno-conditional-uninitialized’ may have been intended to silence earlier diagnostics
  ```

ACKs for top commit:
  TheCharlatan:
    ACK 9e4a4b4832

Tree-SHA512: 05553c80399180e01d45c3f02074ca0ce620011b29b03bef5433b87c9d88fd281fb6bf0203fc6fff590f3780c182a3fab8307002536b6350e03748420c346602
2025-02-20 12:22:20 -05:00
merge-script
f236854a5b
Merge bitcoin/bitcoin#31731: doc: update translation generation cmake example
758a93d621 doc: update translation generation cmake example (Lőrinc)

Pull request description:

  While investigating https://github.com/bitcoin/bitcoin/pull/31730 I noticed that
  * the `dev-mode` preset already contained [`-DWITH_BDB=ON`](https://github.com/bitcoin/bitcoin/blob/master/CMakePresets.json#L83) and [`-DBUILD_GUI=ON`](https://github.com/bitcoin/bitcoin/blob/master/CMakePresets.json#L70);
  * the preset already contained a [default binary dir](https://github.com/bitcoin/bitcoin/blob/master/CMakePresets.json#L64) which we could use;
  * the command only runs on my Mac if we disable `USDT`, and `MULTIPROCESS` and on Linux also without `MULTIPROCESS`.

ACKs for top commit:
  hebasto:
    ACK 758a93d621.

Tree-SHA512: f5bef99bff090f53dae04018f17e60655698fea23084f6a3d38affd830ca041d5c56466633206b63ae01e85c55b784d003e323b2de7c59028b595d4e8f50783c
2025-02-20 12:18:34 -05:00
merge-script
eb51963d87
Merge bitcoin/bitcoin#31884: cmake: Make implicit libbitcoinkernel dependencies explicit
3b42e05aa9 cmake: Make implicit `libbitcoinkernel` dependencies explicit (Hennadii Stepanov)
3fd64efb43 cmake: Avoid using `OBJECT` libraries (Hennadii Stepanov)

Pull request description:

  This PR fixes two regressions introduced in https://github.com/bitcoin/bitcoin/pull/30911.

  For example, on the master branch @ 28dec6c5f8:
  - first regression:
  ```
  $ cmake -B build -G "Ninja" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
  $ cmake --build build -j $(nproc) -t libbitcoinkernel
  $ cmake --install build --component libbitcoinkernel
  - Install configuration: "RelWithDebInfo"
  CMake Error at build/src/kernel/cmake_install.cmake:46 (file):
    file INSTALL cannot find
    "/home/hebasto/dev/bitcoin/build/src/crypto/libbitcoin_crypto.a": No such
    file or directory.
  Call Stack (most recent call first):
    build/src/cmake_install.cmake:172 (include)
    build/cmake_install.cmake:57 (include)

  ```

  - second regression:
  ```
  $ cmake -B build -G "Unix Makefiles" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
  $ cmake --build build -j $(nproc) -t libbitcoinkernel
  ...
  gmake[3]: *** No rule to make target 'src/CMakeFiles/bitcoin_clientversion.dir/clientversion.cpp.o', needed by 'src/kernel/libbitcoinkernel.a'.  Stop.
  gmake[2]: *** [CMakeFiles/Makefile2:1360: src/kernel/CMakeFiles/bitcoinkernel.dir/all] Error 2
  gmake[1]: *** [CMakeFiles/Makefile2:1367: src/kernel/CMakeFiles/bitcoinkernel.dir/rule] Error 2
  gmake: *** [Makefile:647: bitcoinkernel] Error 2
  ```

  With this PR:
  ```
  $ cmake -B build -G "Ninja" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
  $ cmake --build build -j $(nproc) -t libbitcoinkernel
  $ cmake --install build --component libbitcoinkernel
  ```
  and
  ```
  $ cmake -B build -G "Unix Makefiles" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
  $ cmake --build build -j $(nproc) -t libbitcoinkernel
  $ cmake --install build --component libbitcoinkernel
  ```

  ---

  **A note for reviewers:** An alternative approach would be to disable the `OPTIMIZE_DEPENDENCIES` property for the `bitcoinkernel` target. However, I contend that this PR is preferable because (1) it preserves parallel builds for the `libbitcoinkernel` target, and (2) the resulting code has one less workaround for a CMake bug.

ACKs for top commit:
  TheCharlatan:
    ACK 3b42e05aa9
  theuni:
    utACK 3b42e05aa9

Tree-SHA512: 73e9da845688a02e5d61770b7cfd5e1a17440182eb524c7329a47df8f1daa6fe0f9cbde5274832bf43f52e17de86473881dc876dee4276c9c06b173b1b78b7a2
2025-02-20 12:08:35 -05:00
merge-script
58f15d4b21
Merge bitcoin/bitcoin#31379: cmake: Fix passing APPEND_*FLAGS to secp256k1 subtree
c4c5cf1748 cmake: Fix passing `APPEND_*FLAGS` to `secp256k1` subtree (Hennadii Stepanov)
eb540a2629 cmake: Remove `core_sanitizer_{cxx,linker}_flags` helper variables (Hennadii Stepanov)

Pull request description:

  On the master branch @ 70e20ea024, the `APPEND_CPPFLAGS`, `APPEND_CFLAGS`  and `APPEND_LDFLAGS` are not correctly applied when building C code in the  `secp256k1` subtree, as intended.

  This behaviour occurs due to two issues:
  1. The command here: 70e20ea024/src/CMakeLists.txt (L77)
  does not affect the code in `add_subdirectory(secp256k1)` above it.

  2.  `APPEND_LDFLAGS`  is not passed to the subtree's build system at all.

  This PR fixes both issues.

  Additionally, the helper variables `core_sanitizer_cxx_flags` and `core_sanitizer_linker_flags` have been removed.

ACKs for top commit:
  theuni:
    utACK c4c5cf1748.
  TheCharlatan:
    ACK c4c5cf1748

Tree-SHA512: 707acfa623f0436e34e9e6ba8ce2979e0fde5e196e2242fd1cde4c50f433938549781193d8a06419a0866bbe6d69d76f8383d973afbd87d944407963b318c5c9
2025-02-20 09:36:48 -05:00
merge-script
e606c577cb
Merge bitcoin/bitcoin#31899: cmake: Exclude generated sources from translation
ff4ddd3d2e Revert "cmake: Ensure generated sources are up to date for `translate` target" (Hennadii Stepanov)
03b3166aac cmake: Exclude generated sources from translation (Hennadii Stepanov)

Pull request description:

  This PR fixes an error encountered when building the `translate` target:
  ```
  $ gmake -j $(nproc) -C depends MULTIPROCESS=1
  $ cmake -G "Unix Makefiles" --preset dev-mode --toolchain depends/x86_64-pc-linux-gnu/toolchain.cmake -DWITH_USDT=OFF
  $ cmake --build build_dev_mode -t translate
  gmake[3]: *** No rule to make target 'src/test/ipc_test.capnp.c++', needed by 'src/qt/CMakeFiles/translate'. Stop.
  gmake[2]: *** [CMakeFiles/Makefile2:1646: src/qt/CMakeFiles/translate.dir/all] Error 2
  gmake[1]: *** [CMakeFiles/Makefile2:1653: src/qt/CMakeFiles/translate.dir/rule] Error 2
  gmake: *** [Makefile:699: translate] Error 2
  ```

  The previous [attempt](864386a744) to address this issue worked only with Ninja generators and has been reverted.

  Essentially, this PR modifies the `translate` target so that it ignores generated sources rather than attempting to update them.

  At present, multiprocess-specific sources do not contain any translatable strings. Nonetheless, it is prudent to maintain a general approach.

ACKs for top commit:
  TheCharlatan:
    ACK ff4ddd3d2e
  pablomartin4btc:
    tACK ff4ddd3d2e

Tree-SHA512: 6471498a33b145e073f76bd007591b0449e5d520f141c3e3afeca02a09c160fd0f572ec7172dd84703cdc2a1175ad8f3c91e8b0bf705d671338d760786765f56
2025-02-19 16:11:22 -05:00
Lőrinc
758a93d621 doc: update translation generation cmake example
The command only runs on my Mac if we disable USDT which won't affect translation
2025-02-19 20:46:43 +01:00
Ava Chow
fd14995b6a
Merge bitcoin/bitcoin#31908: Revert merge of PR #31826
3e9b12b3e0 Revert "Merge bitcoin/bitcoin#31826: random: Check `GetRNDRRS` is supported in `InitHardwareRand` to avoid infinite loop" (Antoine Poinsot)

Pull request description:

  PR #31826 was merged [despite the code not compiling](https://github.com/bitcoin/bitcoin/pull/31826#discussion_r1961315638).

  #31902 was opened to fix the code but since this code is only targeting a not officially supported platform, we don't have a CI in place to compile and run tests on this platform, neither apparently reviewers do (nor does the author?), don't take more risk right before 29 and revert the original broken PR.

ACKs for top commit:
  sipa:
    ACK 3e9b12b3e0
  achow101:
    ACK 3e9b12b3e0
  TheCharlatan:
    ACK 3e9b12b3e0
  eval-exec:
    ACK 3e9b12b3e0
  laanwj:
    ACK 3e9b12b3e0

Tree-SHA512: e90f8ffb2eebe77e5b6f1c273fbeb29dd5bd6a76698d9a6048c33f3349033c56ea984dd9b64704698da01ecad4c47f98acac1a30312bf2499dbdd1931596953f
2025-02-19 10:03:26 -08:00
Antoine Poinsot
3e9b12b3e0 Revert "Merge bitcoin/bitcoin#31826: random: Check GetRNDRRS is supported in InitHardwareRand to avoid infinite loop"
This reverts commit 139640079f, reversing
changes made to dc3a714633.
2025-02-19 10:28:13 -05:00
MarcoFalke
fa8de4706a
ci: Switch to gcr.io mirror to avoid rate limits 2025-02-19 15:48:04 +01:00
Ava Chow
785649f397
Merge bitcoin/bitcoin#29881: guix: use GCC 13 to build releases
0c1b29a057 ci: use GCC 13 for some jobs (fanquake)
cbc65b3ad5 guix: use GCC 13.3.0 for base toolchain. (fanquake)

Pull request description:

  Switch release builds to using GCC 13.3.0: https://gcc.gnu.org/gcc-13/, which landed in Guix in: https://git.savannah.gnu.org/cgit/guix.git/commit/?id=750148ce1ea6c65a7c14424546db0078161f7e17.

  Does not solve the cross-arch non-determinism for `powerpc64le-linux-gnu` builds.

ACKs for top commit:
  achow101:
    ACK 0c1b29a057
  hebasto:
    ACK 0c1b29a057.
  TheCharlatan:
    Re-ACK 0c1b29a057

Tree-SHA512: eb3f091278d371166eb1df4718b6d0d68b09db65291d563dddd581964f2b488f901e4ba43831a699e2d0fd053d6e9038a307cbea78d5597da77699c34b440ea6
2025-02-18 21:12:42 -08:00
Ava Chow
139640079f
Merge bitcoin/bitcoin#31826: random: Check GetRNDRRS is supported in InitHardwareRand to avoid infinite loop
09b150bb8a In `InitHardwareRand`, do trail test for `RNDRRS` by `VerifyRNDRRS` (Eval EXEC)

Pull request description:

  This PR want to fix #31817 by added a maximum retry limit (`max_retries`) to the `GetRNDRRS` function to prevent it from entering an infinite loop if the hardware random number generator fails to return a valid random number. This change improves stability and ensures that the function terminates after a predefined number of retries.

ACKs for top commit:
  achow101:
    ACK 09b150bb8a
  sipa:
    utACK 09b150bb8a

Tree-SHA512: 5626b6b182a55d344a3aba11b782259ecc6bbec513771d50077874c5f70934750e68add8f63aa0bf69c6b7b313112940a85508af5447622c703cc5e92439ab4a
2025-02-18 18:43:12 -08:00
Ava Chow
dc3a714633
Merge bitcoin/bitcoin#31794: wallet: abandon orphan coinbase txs, and their descendants, during startup
e4dd5a351b test: wallet, abandon coinbase txs and their descendants during startup (furszy)
474139aa9b wallet: abandon inactive coinbase tx and their descendants during startup (furszy)

Pull request description:

  Since #26499, we mark coinbase transactions and their descendants as abandoned when a reorg arises through the "block disconnection" signal handler. However, this does not cover all scenarios; external wallets could contain coinbase transactions from blocks the node has not seen yet, or the user could have replaced the chain with an earlier or different version (one without the coinbase chain).

  This affects balance calculation as well as mempool rebroadcast (descendants shouldn't be relayed).
  Fix this by marking orphaned coinbase transactions and their descendants as abandoned during wallet startup.

ACKs for top commit:
  achow101:
    ACK e4dd5a351b
  rkrux:
    tACK e4dd5a351b
  mzumsande:
    Code Review ACK e4dd5a351b

Tree-SHA512: 461a43de7a6f5a580f2e6e3b56ec9bc92239cd45e850a2ff594ab5488dcd4a507f68fbbf550a33d7173b2add0de80de1e1b3841e1dfab0c95b284212d8ced08a
2025-02-18 18:39:00 -08:00
Ava Chow
06757af2da
Merge bitcoin/bitcoin#29156: tests: add functional test for miniscript decaying multisig
bb633c9407 tests: add functional test for miniscript decaying multisig (Michael Dietz)

Pull request description:

  This is very closely based on [test/functional/wallet_multisig_descriptor_psbt.py](https://github.com/bitcoin/bitcoin/blob/master/test/functional/wallet_multisig_descriptor_psbt.py) both in code and concept. It should serve as some integration testing for Miniscript descriptors, and also documents a simple multisig that starts as 4-of-4 and decays to 3-of-4, 2-of-4, and finally 1-of-4 at block heights (I think in the real world aligning this to halvenings would be nice).

ACKs for top commit:
  achow101:
    ACK bb633c9407
  rkrux:
    reACK bb633c9407
  hodlinator:
    ACK bb633c9407

Tree-SHA512: 1f8e8e50258d45d8f2b882b5f86dcd390d86c543ff4801f397733017102e0854ac387960b6e296bb164603545615d224a4b400247cbbc07bf21b2f4b718ab2ff
2025-02-18 18:22:59 -08:00
am-sq
ca6aa0b9be doc: loadwallet loads from relative walletdir
Improves the documentation of help output for loadwallet
to clarify that filename is relative to the default
wallet directory. Adds examples that get a wallet from
sub-directories.
2025-02-18 15:38:34 -08:00
Hennadii Stepanov
ff4ddd3d2e
Revert "cmake: Ensure generated sources are up to date for translate target"
This reverts commit 864386a744.
2025-02-18 16:05:08 +00:00
Hennadii Stepanov
03b3166aac
cmake: Exclude generated sources from translation 2025-02-18 16:02:56 +00:00
merge-script
43e287b3ff
Merge bitcoin/bitcoin#31892: build: remove ENABLE_HARDENING condition from check-security
113a7a363f build: remove ENABLE_HARDENING cond from check-security (fanquake)

Pull request description:

  This check is only used in release builds, where hardening should always be enabled. I can't think of a reason we'd want to silently skip these checks if hardening was inadvertently disabled.

ACKs for top commit:
  maflcko:
    lgtm ACK 113a7a363f
  TheCharlatan:
    ACK 113a7a363f
  hebasto:
    ACK 113a7a363f.

Tree-SHA512: 46217e8ab238e23374d758b12e5b6bdc22353d8bf272aa0d2260cdea023b5b80aba972dccaa0a4fb8da21c8c665991848f7fd79966d20ac2489d499c68d95639
2025-02-18 15:37:29 +00:00
merge-script
63d625f761
Merge bitcoin/bitcoin#31893: test: remove scanning check on wallet_importdescriptors
405dd0e647 test: remove scanning check on `wallet_importdescriptors` (brunoerg)

Pull request description:

  Reverts recently merged https://github.com/bitcoin/bitcoin/pull/31768 due to CI failures, see issue https://github.com/bitcoin/bitcoin/issues/31881.

ACKs for top commit:
  hodlinator:
    cr-ACK 405dd0e647
  BrandonOdiwuor:
    Code Review ACK 405dd0e647
  theStack:
    ACK 405dd0e647

Tree-SHA512: 7f6182f073c12e44b76ac3069307990ba1d70310173f1adefdb1aa3eda3bdd2e81172dee75355f2e2e4f8edf9b8979256e2ed8c3fa5c953e99ecd0bb53bec3ed
2025-02-18 15:14:41 +00:00
Hennadii Stepanov
3b42e05aa9
cmake: Make implicit libbitcoinkernel dependencies explicit
This change fixes a regression introduced by enabling the
`OPTIMIZE_DEPENDENCIES` property.
2025-02-18 12:30:41 +00:00
Hennadii Stepanov
3fd64efb43
cmake: Avoid using OBJECT libraries
`OBJECT` libraries have historically exhibited poor support for various
features, both in the past and now. For example, see one of the latest
issues:
- https://gitlab.kitware.com/cmake/cmake/-/issues/24058

Furthermore, CMake maintainers have acknowledged:
> In general, however, where there is a choice, static libraries will
> typically be the more convenient choice in CMake projects.

This change:
1. Converts the `bitcoin_clientversion` library from an `OBJECT` library
   to a `STATIC` library.
2. Removes an obsolete workaround.
2025-02-18 12:29:18 +00:00
merge-script
28dec6c5f8
Merge bitcoin/bitcoin#31268: cmake: add optional source files to bitcoin_crypto and crc32c directly
9cf746d663 cmake: add optional source files to crc32c directly (Daniel Pfeifer)
9c7823c5b5 cmake: add optional source files to bitcoin_crypto directly (Daniel Pfeifer)

Pull request description:

  Avoid having many static libraries by adding the optional sources to the target `bitcoin_crypto` directly.
  Set the necessary compile options at the source file level, rather than the target level.

  fixes: #31697

ACKs for top commit:
  s373nZ:
    ACK 9cf746d663
  hebasto:
    re-ACK 9cf746d663.
  TheCharlatan:
    ACK 9cf746d663

Tree-SHA512: 04b468ccbd284d63fc83b382177bb8183b325369835c3b92e555e159955c73d71712a63a2e556f8da68a1232ac07d3845e11f1057c50666843db91db98fca979
2025-02-18 12:08:51 +00:00
merge-script
50afaf3a38
Merge bitcoin/bitcoin#31836: contrib: Add deterministic-fuzz-coverage
fa3e409c9a contrib: Add deterministic-fuzz-coverage (MarcoFalke)

Pull request description:

  The goal of this script is to detect and debug the remaining fuzz determinism and stability issues (https://github.com/bitcoin/bitcoin/issues/29018).

ACKs for top commit:
  marcofleon:
    Tested ACK fa3e409c9a
  brunoerg:
    tested ACK fa3e409c9a

Tree-SHA512: f336537d64188d6bc3c53880f4552a09cc498841c539cb7b4f14e622c9542531b970c1a6910981f7506e7bf659d2ce83471d58f5f51b0a411868f4c11eaf6b2a
2025-02-18 10:36:02 +00:00
brunoerg
405dd0e647 test: remove scanning check on wallet_importdescriptors 2025-02-17 18:44:01 -03:00
fanquake
113a7a363f
build: remove ENABLE_HARDENING cond from check-security
This check is only used in release builds, where hardening should always
be enabled. I can't think of a reason we'd want to silently skip these
checks if hardening was inadvertently disabled.
2025-02-17 16:35:28 +00:00
merge-script
9da0820ec5
Merge bitcoin/bitcoin#31869: cmake: Add libbitcoinkernel target
3a914ab96b cmake: Rename `bitcoinkernel` component to `libbitcoinkernel` (Hennadii Stepanov)
7ce09a5992 cmake: Add `libbitcoinkernel` target (Hennadii Stepanov)

Pull request description:

  This PR amends https://github.com/bitcoin/bitcoin/pull/31844 by:
  1.  Adding a convenience `libbitcoinkernel` target as a synonym for `bitcoinkernel`.
  2. Renaming the `bitcoinkernel` component to `libbitcoinkernel`, as initially intended in https://github.com/bitcoin/bitcoin/pull/31844

  Here is an example of usage:
  ```sh
  cmake -B build -DBUILD_UTIL_CHAINSTATE=ON
  cmake --build build --target libbitcoinkernel
  cmake --install build --component libbitcoinkernel
  ```

ACKs for top commit:
  s373nZ:
    ACK 3a914ab96b
  theuni:
    ACK 3a914ab96b
  TheCharlatan:
    ACK 3a914ab96b
  BrandonOdiwuor:
    Tested ACK 3a914ab96b

Tree-SHA512: 3576ce6261413ba803711a4448ab8da8a5ad161189ab22be51d40f85b3847547060f537f37cc2d6062c193258f1c61f25df21a1e73cf86336f37705cdfd16d7e
2025-02-17 15:31:06 +00:00
merge-script
db36a92c02
Merge bitcoin/bitcoin#31879: doc: add release note for #27432 (utxo-to-sqlite tool)
95722d048a doc: add release note for #27432 (utxo-to-sqlite tool) (Sebastian Falbesoner)

Pull request description:

  This PR adds a missing release note for https://github.com/bitcoin/bitcoin/pull/27432.

ACKs for top commit:
  kevkevinpal:
    ACK [95722d0](95722d048a)

Tree-SHA512: 47714182e814fb825dbaeede46a1b496c4b87f3c5bfa61ada00138926a6bf9eb9a3f99636eb698a7bcda6642f73d0a8c5bf531a726750d594decca8ba6a56e3a
2025-02-16 12:20:06 +01:00
Sebastian Falbesoner
95722d048a doc: add release note for #27432 (utxo-to-sqlite tool) 2025-02-16 02:24:04 +01:00
furszy
e4dd5a351b
test: wallet, abandon coinbase txs and their descendants during startup 2025-02-15 10:49:08 -05:00
Eval EXEC
09b150bb8a
In InitHardwareRand, do trail test for RNDRRS by VerifyRNDRRS
Signed-off-by: Eval EXEC <execvy@gmail.com>
2025-02-15 11:38:00 +08:00
Ava Chow
43e71f7498
Merge bitcoin/bitcoin#27432: contrib: add tool to convert compact-serialized UTXO set to SQLite database
4080b66cbe test: add test for utxo-to-sqlite conversion script (Sebastian Falbesoner)
ec99ed7380 contrib: add tool to convert compact-serialized UTXO set to SQLite database (Sebastian Falbesoner)

Pull request description:

  ## Problem description

  There is demand from users to get the UTXO set in form of a SQLite database (#24628). Bitcoin Core currently only supports dumping the UTXO set in a binary _compact-serialized_ format, which was crafted specifically for AssumeUTXO snapshots (see PR #16899), with the primary goal of being as compact as possible. Previous PRs tried to extend the `dumptxoutset` RPC with new formats, either in human-readable form (e.g. #18689, #24202), or most recently, directly as SQLite database (#24952). Both are not optimal: due to the huge size of the ever-growing UTXO set with already more than 80 million entries on mainnet, human-readable formats are practically useless, and very likely one of the first steps would be to put them in some form of database anyway. Directly adding SQLite3 dumping support on the other hand introduces an additional dependency to the non-wallet part of bitcoind and the risk of increased maintenance burden (see e.g. https://github.com/bitcoin/bitcoin/pull/24952#issuecomment-1163551060, https://github.com/bitcoin/bitcoin/issues/24628#issuecomment-1108469715).

  ## Proposed solution

  This PR follows the "external tooling" route by adding a simple Python script for achieving the same goal in a two-step process (first create compact-serialized UTXO set via `dumptxoutset`, then convert it to SQLite via the new script). Executive summary:
  - single file, no extra dependencies (sqlite3 is included in Python's standard library [1])
  - ~150 LOC, mostly deserialization/decompression routines ported from the Core codebase and (probably the most difficult part) a little elliptic curve / finite field math to decompress pubkeys (essentialy solving the secp256k1 curve equation y^2 = x^3 + 7 for y given x, respecting the proper polarity as indicated by the compression tag)
  - creates a database with only one table `utxos` with the following schema:
    ```(txid TEXT, vout INT, value INT, coinbase INT, height INT, scriptpubkey TEXT)```
  - the resulting file has roughly 2x the size of the compact-serialized UTXO set (this is mostly due to encoding txids and scriptpubkeys as hex-strings rather than bytes)

  [1] note that there are some rare cases of operating systems like FreeBSD though, where the sqlite3 module has to installed explicitly (see #26819)

  A functional test is also added that creates UTXO set entries with various output script types (standard and also non-standard, for e.g. large scripts) and verifies that the UTXO sets of both formats match by comparing corresponding MuHashes. One MuHash is supplied by the bitcoind instance via `gettxoutsetinfo muhash`, the other is calculated in the test by reading back the created SQLite database entries and hashing them with the test framework's `MuHash3072` module.

  ## Manual test instructions
  I'd suggest to do manual tests also by comparing MuHashes. For that, I've written a go tool some time ago which would calculate the MuHash of a sqlite database in the created format (I've tried to do a similar tool in Python, but it's painfully slow).
  ```
  $ [run bitcoind instance with -coinstatsindex]
  $ ./src/bitcoin-cli dumptxoutset ~/utxos.dat
  $ ./src/bitcoin-cli gettxoutsetinfo muhash <block height returned in previous call>
  (outputs MuHash calculated from node)

  $ ./contrib/utxo-tools/utxo_to_sqlite.py ~/utxos.dat ~/utxos.sqlite
  $ git clone https://github.com/theStack/utxo_dump_tools
  $ cd utxo_dump_tools/calc_utxo_hash
  $ go run calc_utxo_hash.go ~/utxos.sqlite
  (outputs MuHash calculated from the SQLite UTXO set)

  => verify that both MuHashes are equal
  ```
  For a demonstration what can be done with the resulting database, see https://github.com/bitcoin/bitcoin/pull/24952#pullrequestreview-956290477 for some example queries. Thanks go to LarryRuane who gave me to the idea of rewriting this script in Python and adding it to `contrib`.

ACKs for top commit:
  ajtowns:
    ACK 4080b66cbe - light review
  achow101:
    ACK 4080b66cbe
  romanz:
    tACK 4080b66cbe on signet (using [calc_utxo_hash](8981aa3e85/calc_utxo_hash/calc_utxo_hash.go)):
  tdb3:
    ACK 4080b66cbe

Tree-SHA512: be8aa0369a28c8421a3ccdf1402e106563dd07c082269707311ca584d1c4c8c7b97d48c4fcd344696a36e7ab8cdb64a1d0ef9a192a15cff6d470baf21e46ee7b
2025-02-14 15:22:10 -08:00
Ava Chow
e53310c47a
Merge bitcoin/bitcoin#30529: Fix -norpcwhitelist, -norpcallowip, and similar corner case behavior
a85e8c0e61 doc: Add some general documentation about negated options (Ryan Ofsky)
490c8fa178 doc: Add release notes summarizing negated option behavior changes. (Ryan Ofsky)
458ef0a11b refactor: Avoid using IsArgSet() on -connect list option (Ryan Ofsky)
752ab9c3c6 test: Add test to make sure -noconnect disables -dnsseed and -listen by default (Ryan Ofsky)
3c2920ec98 refactor: Avoid using IsArgSet() on -signetseednode and -signetchallenge list options (Ryan Ofsky)
d05668922a refactor: Avoid using IsArgSet() on -debug, -loglevel, and -vbparams list options (Ryan Ofsky)
3d1e8ca53a Normalize inconsistent -noexternalip behavior (Ryan Ofsky)
ecd590d4c1 Normalize inconsistent -noonlynet behavior (Ryan Ofsky)
5544a19f86 Fix nonsensical bitcoin-cli -norpcwallet behavior (Ryan Ofsky)
6e8e7f433f Fix nonsensical -noasmap behavior (Ryan Ofsky)
b6ab350806 Fix nonsensical -notest behavior (Ryan Ofsky)
6768389917 Fix nonsensical -norpcwhitelist behavior (Ryan Ofsky)
e03409c70f Fix nonsensical -norpcbind and -norpcallowip behavior (Ryan Ofsky)
40c4899bc2 Fix nonsensical -nobind and -nowhitebind behavior (Ryan Ofsky)
5453e66fd9 Fix nonsensical -noseednode behavior (Ryan Ofsky)

Pull request description:

  The PR changes behavior of negated `-noseednode`, `-nobind`, `-nowhitebind`, `-norpcbind`, `-norpcallowip`, `-norpcwhitelist`, `-notest`, `-noasmap`, `-norpcwallet`, `-noonlynet`, and `-noexternalip` options, so negating these options just clears previously specified values doesn't have other side effects.

  Negating options on the command line can be a useful way of resetting options that may have been set earlier in the command line or config file. But before this change, negating these options wouldn't fully reset them, and would have confusing and undocumented side effects (see commit descriptions for details). Now, negating these options just resets them and behaves the same as not specifying them.

  Motivation for this PR is to fix confusing behaviors and also to remove incorrect usages of the `IsArgSet()` function. Using `IsArgSet()` tends to lead to negated option bugs in general, but it especially causes bugs when used with list settings returned by `GetArgs()`, because when these settings are negated, `IsArgSet()` will return true but `GetArgs()` will return an empty list. This PR eliminates all uses of `IsArgSet()` and `GetArgs()` together, and followup PR #17783 makes it an error to use `IsArgSet()` on list settings, since calling `IsArgSet()` is never actually necessary. Most of the changes here were originally made in #17783 and then moved here to be easier to review and avoid a dependency on #16545.

ACKs for top commit:
  achow101:
    ACK a85e8c0e61
  danielabrozzoni:
    re-ACK a85e8c0e61
  hodlinator:
    re-ACK a85e8c0e61

Tree-SHA512: dd4b19faac923aeaa647b1c241d929609ce8242b43e3b7bc32523cc48ec92a83ac0dc5aee79f1eba8794535e0314b96cb151fd04ac973671a1ebb9b52dd16697
2025-02-14 15:10:09 -08:00
Ava Chow
254fd89d39
Merge bitcoin/bitcoin#31863: random: Initialize variables in hardware RNG functions
99755e04ff random: Initialize variables in hardware RNG functions (Eval EXEC)

Pull request description:

  See: https://github.com/bitcoin/bitcoin/pull/31826#discussion_r1955045279 , So this PR want to prevent potential uninitialized value issues and improve code clarity.

ACKs for top commit:
  sipa:
    utACK 99755e04ff
  achow101:
    ACK 99755e04ff

Tree-SHA512: 4cf9c214617769cf051b4f36453275b407e37d96315b6a206102d17019375b3834ba07e2ccb28c7650c90ff8e1f1034522fccafaa33e136dfe63cc68396a1f6e
2025-02-14 15:03:32 -08:00
Ava Chow
75f8396c90
Merge bitcoin/bitcoin#30746: test: cover base[32|58|64] with symmetric roundtrip fuzz (and padding) tests
f919d919eb fuzz: Add fuzzing for max_ret_len in DecodeBase58/DecodeBase58Check (Lőrinc)
635bc58f46 test: Fuzz Base32/Base58/Base64 roundtrip conversions (Lőrinc)
5dd3a0d8a8 test: Extend base58_encode_decode.json with edge cases (Lőrinc)
ae40cf1a8e test: Add padding tests for Base32/Base64 (Lőrinc)

Pull request description:

  Added fuzzed roundtrips for `base[32|58|64]` encoding to make sure encoding/decoding are symmetric.
  Note that if we omit the padding in `EncodeBase32` we won't be able to decode it with `DecodeBase32`.
  Added dedicated padding tests to cover failure behavior
  Also moved over the Base58 json test edge cases from https://github.com/bitcoin/bitcoin/pull/30035

ACKs for top commit:
  hodlinator:
    re-ACK f919d919eb
  achow101:
    ACK f919d919eb

Tree-SHA512: 6a6c63d0a659b70d42aad7a8f37ce6e372756e2c88c84e7be5c1ff1f2a7c58860ed7113acbe1a9658a7d19deb91f0abe2ec527ed660335845cd1e0a9380b4295
2025-02-14 14:48:01 -08:00
Ava Chow
c4b46b4589
Merge bitcoin/bitcoin#31629: wallet: fix rescanning inconsistency
4818da809f wallet: fix rescanning inconsistency (Martin Zumsande)

Pull request description:

  If the chain advances during a rescan, ScanForWalletTransactions would previously process the new blocks without adjusting `m_last_processed_block`, which would leave the wallet in an inconsistent state temporarily, and could lead to crashes in the GUI reported in #31474.
  Fix this by not rescanning blocks beyond `m_last_processed_block` - for all blocks beyond that height, there will be pending BlockConnected notifications that will process them after the rescan is finished.

  This means that if rescanning was triggered with `cs_wallet` permanently held (`AttachChain`), additional blocks that were connected during the rescan will only be processed with the pending `blockConnected` notifications after the lock is released.
  If rescanning without a permanent `cs_wallet` lock (`RescanFromTime`), additional blocks that were connected during the rescan can be re-processed here because `m_last_processed_block` was already updated by `blockConnected`.

  Fixes #31474

ACKs for top commit:
  psgreco:
    Not that it matters much, but UTACK 4818da809f
  achow101:
    ACK 4818da809f
  furszy:
    utACK 4818da809f

Tree-SHA512: 8e7dbc9e00019aef4f80a11776f3089cd671e0eadd3c548cc6267b5c722433f80339a9b2b338ff9b611863de75ed0a817a845e1668e729b71af70c9038b075af
2025-02-14 14:42:12 -08:00
Ava Chow
d0dfd6d3f6
Merge bitcoin/bitcoin#31865: build: move rpc/external_signer to node library
e501246e77 build: move rpc/external_signer to node library (fanquake)

Pull request description:

  Move `rpc/external_signer` from `bitcoin_common` to `bitcoin_node`.
  Remove the check-deps suppression.

ACKs for top commit:
  maflcko:
    lgtm ACK e501246e77
  achow101:
    ACK e501246e77
  TheCharlatan:
    ACK e501246e77

Tree-SHA512: d535da9038a6b37bd83e852721b42c0806b9ddf060a9b96544027a34d11c1728b3b97385768fca1acc483c6632c28050e2194e2d2ac831d944f332431bfd6792
2025-02-14 14:32:28 -08:00
Ava Chow
ce4dbfc359
Merge bitcoin/bitcoin#31851: doc: build: Fix instructions for msvc gui builds
c3fa043ae5 doc: build: Fix instructions for msvc gui builds (David Gumberg)

Pull request description:

  If the instructions in `doc/build-windows-msvc.md` are followed as-is, and "Developer (PowerShell|Command Prompt) for VS 2022" is used to execute the suggested build commands, the root directory of vcpkg (e.g. in VS 2022 Community edition: `C:\Program Files\Microsoft Visual Studio\2022\Community\VC\vcpkg`), is too long, and when vcpkg attempts to build any of the QT packages, it will fail because of build steps that require path lengths greater than Windows' `MAX_PATH` 260 character limit. This can be avoided without needing to move the vcpkg root dir by setting [`--x-buildtrees-root`](https://learn.microsoft.com/en-us/vcpkg/commands/common-options#buildtrees-root) to a short path, like `C:\vcpkg`.

  See e.g. https://github.com/microsoft/vcpkg/issues/28451, https://github.com/microsoft/vcpkg/issues/28083, https://github.com/microsoft/vcpkg/issues/24751.

ACKs for top commit:
  achow101:
    ACK c3fa043ae5
  hebasto:
    ACK c3fa043ae5.
  TheCharlatan:
    ACK c3fa043ae5

Tree-SHA512: 7de11d38b9125de63e72415f79d82f18818123a1b37f679f2229c4c82f5628dd7d1039dbc5dcdf1bc1c8c382e3e29de74a31d256e73872cbf1fa2687c52185ca
2025-02-14 14:11:54 -08:00
Ava Chow
504d0c21e2
Merge bitcoin/bitcoin#31439: validation: In case of a continued reindex, only activate chain in the end
c9136ca906 validation: fix issue with an interrupted -reindex (Martin Zumsande)
a2675897e2 validation: Don't loop over all chainstates in LoadExternalBlock (Martin Zumsande)

Pull request description:

  If a user interrupts a reindex while it is iterating over the block files, it will continue to reindex with the next node start (if the `-reindex` arg is dropped, otherwise it will start reindexing from scratch).
  However, due to an early call to `ActivateBestChainState()` that only exists to connect the genesis block during
  the original `-reindex`, it wil start connecting blocks immediately before having iterated through all block files.
  Because later headers above the minchainwork threshold won't be loaded in this case, `-assumevalid` will not
  be applied and the process is much slower due to script validation being done.

  Fix this by only calling `ActivateBestChainState()` here if Genesis is not connected yet (equivalent to `ActiveHeight() == -1`).
  Also simplify this spot by only doing this for the active chainstate instead of looping over all chainstates (first commit).

  This issue was discussed in the thread below https://github.com/bitcoin/bitcoin/pull/31346#discussion_r1856824817, the impact on assumevalid was found by l0rinc.

  The fix can be tested by manually aborting a `-reindex` e.g. on signet and observing in the debug log the order in which blockfiles are indexed / blocks are connected with this branch vs master.

ACKs for top commit:
  achow101:
    ACK c9136ca906
  ryanofsky:
    Code review ACK c9136ca906. Only comments changed since last review. Appreciate the new comments, I think they make a little clearer what things code is trying to do and what things are just side-effects.
  TheCharlatan:
    Re-ACK c9136ca906

Tree-SHA512: 6f34abc317ad7e605ccc0c2f4615e4ea6978223d207f80f768f39cc135a9ac0adf31681fadfa2aed45324a5d27a4f68c5e118ee7eec18ca5c40ef177caa9cc47
2025-02-14 13:59:34 -08:00
Ava Chow
0b48f77e10
Merge bitcoin/bitcoin#31413: rpc: Remove deprecated dummy alias for listtransactions::label
fa8e0956c2 rpc: Remove deprecated dummy alias for listtransactions::label (MarcoFalke)

Pull request description:

  The RPC arg is not a dummy, but a label, so offering an undocumented alias is inconsistent with all other label interfaces and confusing at best, if not entirely unused.

  Fix it by removing the deprecated alias.

  This pull is a breaking change, but it should be limited, because it only affects someone using the deprecated named arg on this RPC. I can't imagine anyone doing this, because in all other places where label args are accepted, they are called `label`. If someone really didn't use `label` here as named arg, it would be trivial and less confusing for them to fix it up.

ACKs for top commit:
  achow101:
    ACK fa8e0956c2
  rkrux:
    tACK fa8e0956c2
  ryanofsky:
    Code review ACK fa8e0956c2

Tree-SHA512: 0d0f3f53237ff9fac8c065b7d0a4245f5ff86efa427dbeeca711765494b7315a9d72b44751d346c76422847daf3d7ff90dbccb5ba200b089fb96128bd95da9f0
2025-02-14 13:29:17 -08:00
Ava Chow
21a0efaf8c
Merge bitcoin/bitcoin#29858: test: Add test for rpcwhitelistdefault
f0e5e4cdbe test: Add test for rpcwhitelistdefault (naiyoma)

Pull request description:

  This PR adds tests for `rpcwhitelistdefault.` The implementation is a continuation of this [PR](https://github.com/bitcoin/bitcoin/pull/17805).

  Applied suggestions  to include the tests in` rpc_whitelist.py` and to use a single node.

  PR covers three test cases:
  - rpcwhitelistdefault = 0, no permissions
  - rpcwhitelistdefault = 1, no permissions
  - rpcwhitelistdefault = 1, with user permissions

  I didn't add tests for rpcwhitelistdefault = 0 with user permissions since that is already tested here: [rpc_whitelist.py#L77](https://github.com/bitcoin/bitcoin/blob/master/test/functional/rpc_whitelist.py#L77).

ACKs for top commit:
  achow101:
    ACK f0e5e4cdbe
  ryanofsky:
    Code review ACK f0e5e4cdbe. PR seems very clear and simple, moving 1 test and adding 3 new tests.
  ismaelsadeeq:
    Tested and Code review ACK f0e5e4cdbe

Tree-SHA512: c3652940d2f23746e769ebe834e43dee47b7af8f258cbb133e38663aa8a05a1a8d0194d3008c3a10b0c54d11b5b95420c9cad0aa761c0fc1b9559277443b0696
2025-02-14 11:27:01 -08:00
Ava Chow
8a00b755e9
Merge bitcoin/bitcoin#31634: doc: Improve dependencies documentation
a759ea3e92 doc: Improve dependencies documentation (Nicola Leonardo Susca)

Pull request description:

  Initially there was a distinction between the compiler dependencies and
  other required dependencies (refs https://github.com/bitcoin/bitcoin/pull/23565) but the distinction was
  removed (refs https://github.com/bitcoin/bitcoin/pull/24585) which is why having two distinct tables could lead
  to confusion now.

ACKs for top commit:
  achow101:
    ACK a759ea3e92
  hodlinator:
    re-ACK a759ea3e92
  rkrux:
    ACK a759ea3e92

Tree-SHA512: 14aaf9356d65bd150c9993dcbc51b1b98c835a760b95e6d91e69460c97c18f1dd10eb52b9f1d70129e6aa5e361af3a55619fd35787ed4e1ec48909568adbb604
2025-02-14 11:04:24 -08:00
Ava Chow
e58605e04f
Merge bitcoin/bitcoin#31854: net: reduce CAddress usage to CService or CNetAddr
cd4bfaee10 net: reduce CAddress usage to CService or CNetAddr (Vasil Dimov)

Pull request description:

  Using `CAddress` when only `CService` or `CNetAddr` is needed is excessive and confusing. Fix those occurrences to use the class they need:

  * `CConnman::CalculateKeyedNetGroup()` needs `CNetAddr`, not `CAddress`, thus change its argument.

  * Both callers of `CConnman::CreateNodeFromAcceptedSocket()` create a dummy `CAddress` from `CService`, so use `CService` instead.

  * `GetBindAddress()` only needs to return `CService`.

  * `CNode::addrBind` only needs to be `CService`.

ACKs for top commit:
  Sjors:
    ACK cd4bfaee10
  achow101:
    ACK cd4bfaee10
  hodlinator:
    ACK cd4bfaee10
  laanwj:
    Code review ACK cd4bfaee10

Tree-SHA512: 0b41c1519784eeeaf9926c6a4d24f583b90c3376741f37a3199a3808b0dd6d143d3f929bd7c06f87b031f4fc1c2bd7a6dfc7d715ec1f79bf36b862c00fd67085
2025-02-14 10:56:14 -08:00
Hennadii Stepanov
3a914ab96b
cmake: Rename bitcoinkernel component to libbitcoinkernel
The new component name is more convenient for the library and aligns
with the `libbitcoinkernel` target introduced in the previous commit.
2025-02-14 17:06:14 +00:00
merge-script
06b9236f43
Merge bitcoin/bitcoin#31359: cmake: Add CheckLinkerSupportsPIE module
81c174e318 cmake: Refer to the configure log instead of printing PIE test error (Hennadii Stepanov)
65a0920ca6 cmake: Add `CheckLinkerSupportsPIE` module (Hennadii Stepanov)

Pull request description:

  This new module is a wrapper around CMake's `CheckPIESupported` module that fixes an upstream bug.

  See: https://gitlab.kitware.com/cmake/cmake/-/issues/26463.

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

ACKs for top commit:
  theuni:
    utACK 81c174e318.
  vasild:
    ACK 81c174e318

Tree-SHA512: 77d7022238551a4e69c59d1fe6b78975bb552cbbed5339459853d7ebf0086813036081f464fed230be330b3bd7d6cf8590b536b064028d2f786d6ae40f342f95
2025-02-14 18:02:35 +01:00
Hennadii Stepanov
7ce09a5992
cmake: Add libbitcoinkernel target
This is a convenience target as a synonym for `bitcoinkernel`.
2025-02-14 17:02:11 +00:00
fanquake
e501246e77
build: move rpc/external_signer to node library 2025-02-14 14:38:41 +01:00
merge-script
73e2ec1373
Merge bitcoin/bitcoin#31844: cmake: add a component for each binary
9b033bebb1 cmake: rename Kernel component to bitcoinkernel for consistency (Cory Fields)
2e0c92558e cmake: add and use install_binary_component (Cory Fields)
0264c5d86c cmake: use per-target components for bitcoin-qt and bitcoin-gui (Cory Fields)
fb0546b1c5 ci: don't try to install for a fuzz build (Cory Fields)

Pull request description:

  This makes it possible to build/install only the desired binaries regardless of the configuration.
  For consistency, the component names match the binary names. `Kernel` and `GUI` have been renamed.

  Additionally it fixes #31762 by installing only the manpages for the configured targets (and includes them in the component installs for each).

  Also fixes #31745.

  Alternative to #31765 which is (imo) more correct/thorough.

  Can be tested using (for ex):
  ```bash
  $ cmake -B build
  $ cmake --build build -t bitcoind -t bitcoin-cli
  $ cmake --install build --component bitcoind
  $ cmake --install build --component bitcoin-cli
  ```

ACKs for top commit:
  hebasto:
    ACK 9b033bebb1.
  TheCharlatan:
    Re-ACK 9b033bebb1
  stickies-v:
    re-ACK 9b033bebb1

Tree-SHA512: fd4818e76f190dbeafbf0c246b466f829771902c9d6d7111ed917093b811c8a5536a4a45e20708f73e7f581d6cb77c8e61cfa69e065788dcf0886792f553a355
2025-02-14 14:19:12 +01:00
Eval EXEC
99755e04ff
random: Initialize variables in hardware RNG functions 2025-02-14 19:26:29 +08:00
merge-script
7bbd761e81
Merge bitcoin/bitcoin#31421: cmake: Improve compatibility with Python version managers
dead908654 cmake: Improve compatibility with Python version managers (Hennadii Stepanov)

Pull request description:

  This PR resolves the issue [highlighted](https://github.com/bitcoin/bitcoin/pull/31411#issuecomment-2516745547) in https://github.com/bitcoin/bitcoin/pull/31411:
  > Here's another case where CMake just picks some other Python...

  The fix leverages two [hints](https://cmake.org/cmake/help/latest/module/FindPython3.html#hints) for the CMake `FindPython3` module:
  1. `Python3_FIND_FRAMEWORK` is set to `LAST`. This ensures that Unix-style package components are preferred over frameworks on macOS. As a side effect, the `FindPython3` module reports a shim or symlink (e.g., from `pyenv`) rather than the underlying framework's binary.  The module's output aligns with the result of the `which` command.
  2. `Python3_FIND_UNVERSIONED_NAMES` is set to `FIRST`. This supports scenarios where tools like `pyenv`—which use shims—have multiple Python versions installed.

  Here are examples of output on my macOS 15.1.1 (Intel) with installed Homebrew's [Python 3.13.0](https://formulae.brew.sh/formula/python@3.13):
  - without any Python version manager:
  ```
  % which -a python3
  /usr/local/bin/python3
  /usr/bin/python3
  % cmake -B build
  <snip>
  -- Found Python3: /usr/local/bin/python3 (found suitable version "3.13.0", minimum required is "3.10") found components: Interpreter
  <snip>
  ```
  - using `pyenv`:
  ```
  % pyenv versions
    system
  * 3.10.14 (set by /Users/hebasto/dev/bitcoin/.python-version)
    3.12.8
    3.13.1
  % which -a python3
  /Users/hebasto/.pyenv/shims/python3
  /usr/local/bin/python3
  /usr/bin/python3
  % cmake -B build
  <snip>
  -- Found Python3: /Users/hebasto/.pyenv/shims/python3 (found suitable version "3.10.14", minimum required is "3.10") found components: Interpreter
  <snip>
  ```

  Both variables, `Python3_FIND_FRAMEWORK` and `Python3_FIND_UNVERSIONED_NAMES`, can still be overridden by the user via the command line if needed.

ACKs for top commit:
  theuni:
    No opinion on the python selection changes themselves, but code-review ACK dead908654
  willcl-ark:
    ACK dead908654

Tree-SHA512: 69f8541223e5b6c35c892b4ba2a2dcfc24b41a10cf20accc75d3008b16434db8a9240c99c886c3a4566ba24269c5b0e0d856357891811f0a77b39f4afbee3634
2025-02-14 11:38:22 +01:00