Commit Graph

46388 Commits

Author SHA1 Message Date
merge-script
211bf6c975 Merge bitcoin/bitcoin#33566: miner: fix empty mempool case for waitNext()
8f7673257a miner: fix empty mempool case for waitNext() (Sjors Provoost)

Pull request description:

  Block template fees are calculated by looping over `new_tmpl->vTxFees` and return (early) once the `fee_threshold` is exceeded.

  This left an edge case when the mempool is empty, which this commit fixes and adds a test for.

  Also update `test/functional/interface_ipc.py` to reflect the new behavior,

  Fixes https://github.com/Sjors/sv2-tp/issues/9

ACKs for top commit:
  optout21:
    ACK 8f7673257a
  cedwies:
    tACK 8f76732
  sipa:
    utACK 8f7673257a
  zaidmstrr:
    Concept ACK [8f76732](8f7673257a)

Tree-SHA512: ef200fe95e96f810e425283bc37f945c4bf5efa16f4b74820b8a07968f30c5146bca213a372124be84b48beead5dfd35f2b5d10d188d0a465f847ebab61de10a
2025-10-23 05:49:29 -04:00
merge-script
d32f9525e4 Merge bitcoin/bitcoin#33679: test: set number of RPC server threads to 2
e9cd45e3d3 test: set number of RPC server threads to 2 (furszy)

Pull request description:

  The default `-rpcthreads` value spawns 16 HTTP server threads for each node.
  Running the functional test suite with default `rpcthreads` can exhaust file
  descriptors or hit other resource limits very easily (more when tests are run
  in parallel).
  Furthermore, having 16 threads is unnecessary since they are mostly idle. We
  run RPC calls on a single RPC connection and wait for it result synchronously.
  There is (almost) never two RPC calls occurring concurrently.
  Because of this, the threads are mostly idle, so we can safely limit the number
  of them to two.

  Note for reviewers:
  I checked this does not introduce any timing regression but would be good
  to double-check it on your end too. We could add another thread if needed.
  Just the 16 threads default value is too high and unnecessary.

ACKs for top commit:
  maflcko:
    lgtm ACK e9cd45e3d3
  l0rinc:
    ACK e9cd45e3d3
  kevkevinpal:
    ACK [e9cd45e](e9cd45e3d3)
  andrewtoth:
    ACK e9cd45e3d3

Tree-SHA512: a777286f4a890fb87f5df72cd2ccfdc628657206a4b3e995044e5a0d12987b8c78a7cf7d684cc4e92605aa782aaeebc44e9f754752c3a524152fac94fa30f4b5
2025-10-23 11:03:42 +02:00
merge-script
1c85d06232 Merge bitcoin/bitcoin#32266: depends: Avoid warning: "_FORTIFY_SOURCE" redefined for libevent
fe71a4b139 depends: Avoid `warning: "_FORTIFY_SOURCE" redefined` for `libevent` (Hennadii Stepanov)

Pull request description:

  On Alpine Linux 3.12.3, compiling the `libevent` package produces multiple warnings:
  ```
  $ gmake -C depends -j $(nproc) libevent
  <snip>
  <command-line>: warning: "_FORTIFY_SOURCE" redefined
  <built-in>: note: this is the location of the previous definition
  <snip>
  ```

  This PR fixes these warnings.

ACKs for top commit:
  shahsb:
    ACK fe71a4b139
  maflcko:
    lgtm ACK fe71a4b139
  theuni:
    utACK fe71a4b139

Tree-SHA512: 0a3ffb2a4cf811bce93addac8e5394cf6b3d79a46245cbdd8488771b9b51e56f66cd9222548138041e69183d52ad4b909d3d1441593f9d79d557d6c000fb324b
2025-10-23 09:45:28 +02:00
merge-script
11684c9ce2 Merge bitcoin/bitcoin#33674: ci: Doc ASLR workaround for sanitizer tasks
fa0e36156c ci: Doc ASLR workaround for sanitizer tasks (MarcoFalke)

Pull request description:

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

ACKs for top commit:
  fanquake:
    ACK fa0e36156c

Tree-SHA512: 9811a35526c707a6b2438e4f15d1ea765c9ecf1786cb37cd23e3bc5d65a25623f276a74b4a70c24492126a87514845111741290fc3095206decf17ee2c52dd2a
2025-10-23 09:18:51 +02:00
furszy
e9cd45e3d3 test: set number of RPC server threads to 2
The default `-rpcthreads` value spawns 16 HTTP server threads for each node.
Running the functional test suite with default `rpcthreads` can exhaust file
descriptors or hit other resource limits very easily.
Moreover, having 16 threads is unnecessary since they are mostly idle. We
run RPC calls on a single RPC connection and wait for it result synchronously.
There is (almost) never two RPC calls occurring concurrently.
Because of this, the threads are mostly idle, so we can safely limit the number
of them to two.
2025-10-22 08:48:41 -04:00
merge-script
7d27af98c7 Merge bitcoin/bitcoin#33461: ci: add Valgrind fuzz
e4b04630bc ci: add Valgrind fuzz (fanquake)

Pull request description:

  Valgrind fuzz runtime?

ACKs for top commit:
  dergoegge:
    ACK e4b04630bc

Tree-SHA512: 0d62da6baf10fb59e3a32df8af72bd0f371e72a725fdea8dfd08f0242634b3c8bcdbf86ff8777ccada0570d13f20ebf8e21a2f935570f3463097b9d411e7b3ce
2025-10-22 12:50:02 +02:00
merge-script
1569bcc387 Merge bitcoin/bitcoin#33639: ci: Only write docker build images to Cirrus cache
fabe0e07de ci: Only write docker build images to Cirrus cache (MarcoFalke)
fab64a5d6f ci: Move buildx command to python script (MarcoFalke)
fa72a2bd5c ci: Remove unused MAYBE_CPUSET (MarcoFalke)

Pull request description:

  The `DOCKER_BUILD_CACHE_ARG` env var holds the options on how to use cache providers. Storing the image layers is useful for the Cirrus cache provider, because it offers 10GB per runner (https://cirrus-runners.app/setup/#speeding-up-the-cache). The cached image layers can help to avoid issues when the upstream package manager infra (apt native, apt llvm, pip, apk, git clone, ...) has outages or network issues.

  However, on the GitHub Actions cache provider, a *total* cache of 10GB is offered for the whole repo. This cache must be shared with the depends cache, and the ccache, as well as the previous releases cache. So it is already full and trying to put the docker build layers into it will lead to an overflow.

  Fix it by only writing to the docker cache on Cirrus.

  Also, `DOCKER_BUILD_CACHE_ARG` requires a `shellcheck disable=SC2086` on the full build command. Fix that as well by using `shlex.split` from Python on just this variable.

ACKs for top commit:
  m3dwards:
    ACK fabe0e07de
  cedwies:
    reACK fabe0e0
  l0rinc:
    Code review ACK fabe0e07de
  willcl-ark:
    ACK fabe0e07de

Tree-SHA512: 4f471f080007fdd0c3bc97b0cfe0e9c0457e5029a7ccde1d784d30eb4752e5eb309cd4b122b182bce31f1b986c8a9f3e9a49da1768bedbb2b1f64f70183680ba
2025-10-22 12:49:05 +02:00
Hennadii Stepanov
98c4994d0f Merge bitcoin/bitcoin#33570: randomenv: Fix MinGW dllimport warning for environ
9610b0d1e2 randomenv: Fix MinGW dllimport warning for `environ` (Lőrinc)

Pull request description:

  Related to https://github.com/bitcoin/bitcoin/pull/33550#issuecomment-3378978210

  Extends 7703884 to guard environ declaration on all Windows builds, not just MSVC.

  In the `mingw-w64` headers (used by `llvm-mingw`), `environ` is defined as a macro which  expands through [`_environ`](cdb052f1d4/mingw-w64-headers/crt/stdlib.h (L262-L264)) to `(* __p__environ())`, a call to a `dllimport` function, causing the same inconsistent linkage warning as MSVC.

  Use `WIN32` instead of `_MSC_VER` to match the platform-specific guards already used throughout the file.

  The warning occurs with `llvm-mingw` (both `UCRT` and `MSVCRT` variants as tested by Hebasto), but not with the `mingw-w64` toolchain currently used in CI (as mentioned by fanquake).

  ----

  The error was reproduced by adding a temporary [nightly build](https://github.com/l0rinc/bitcoin-core-nightly/pull/4) pointing to https://github.com/l0rinc/bitcoin/pull/45. On `master` the failure can be seen in https://github.com/l0rinc/bitcoin-core-nightly/pull/2

  before:
  https://github.com/l0rinc/bitcoin-core-nightly/actions/runs/18327936488/job/52196728885?pr=2

  <details>
  <summary>Details</summary>

  ```
  /home/runner/work/bitcoin-core-nightly/bitcoin-core-nightly/src/randomenv.cpp:61:15: warning: '__p__environ' redeclared without 'dllimport' attribute: previous 'dllimport' ignored [-Winconsistent-dllimport]
     61 | extern char** environ; // NOLINT(readability-redundant-declaration): Necessary on some platforms
        |               ^
  /home/runner/work/bitcoin-core-nightly/bitcoin-core-nightly/llvm_mingw_toolchain/aarch64-w64-mingw32/include/stdlib.h:656:17: note: expanded from macro 'environ'
    656 | #define environ _environ
        |                 ^
  /home/runner/work/bitcoin-core-nightly/bitcoin-core-nightly/llvm_mingw_toolchain/aarch64-w64-mingw32/include/stdlib.h:225:21: note: expanded from macro '_environ'
    225 | #define _environ (* __p__environ())
        |                     ^
  /home/runner/work/bitcoin-core-nightly/bitcoin-core-nightly/llvm_mingw_toolchain/aarch64-w64-mingw32/include/stdlib.h:221:27: note: previous declaration is here
    221 |   _CRTIMP char ***__cdecl __p__environ(void);
        |                           ^
  /home/runner/work/bitcoin-core-nightly/bitcoin-core-nightly/llvm_mingw_toolchain/aarch64-w64-mingw32/include/stdlib.h:221:3: note: previous attribute is here
    221 |   _CRTIMP char ***__cdecl __p__environ(void);
        |   ^
  /home/runner/work/bitcoin-core-nightly/bitcoin-core-nightly/llvm_mingw_toolchain/aarch64-w64-mingw32/include/_mingw.h:52:40: note: expanded from macro '_CRTIMP'
     52 | #      define _CRTIMP  __attribute__ ((__dllimport__))
        |                                        ^
  1 warning generated.
  ```

  </details>

  after:
  https://github.com/l0rinc/bitcoin-core-nightly/actions/runs/18329616268/job/52201940831?pr=4

  <details>
  <summary>Details</summary>

  ```
  [ 28%] Building CXX object src/util/CMakeFiles/bitcoin_util.dir/__/randomenv.cpp.obj
  ```

  </details>

  Note that there are some other remaining warnings in the logs that will be fixed in separate PRs

ACKs for top commit:
  sipa:
    utACK 9610b0d1e2 if this makes the compilers happy
  laanwj:
    Code review ACK 9610b0d1e2
  hebasto:
    re-ACK 9610b0d1e2.

Tree-SHA512: a9e39d288b663ed24cbbbae228850e6f02d417d8781a3ac3d0b3db0b7ff734bbd62fddb9f57b8f77daab4e9c016ff66906ebc5fb2de7635ef539ef7f4dc2eaba
2025-10-22 11:51:05 +02:00
merge-script
c211d18322 Merge bitcoin/bitcoin#33670: test: Use unassigned p2p_port instead of hardcoded 60000 in p2p_i2p_ports.py
fa20275db3 test: Use unassigned p2p_port instead of hardcoded 60000 in p2p_i2p_ports.py (MarcoFalke)

Pull request description:

  The goal is to fix https://github.com/bitcoin/bitcoin/issues/30030.

  The root cause it unclear. However, hard-coding the port to 60000 does not seem ideal anyway. This could break in an unlikely setting where so many functional tests are run, such that the port is occupied. Also, it could fail when `TEST_RUNNER_PORT_MIN` is set sufficiently high. (This is purely theoretical, as I don't think anyone would run a command like this, but on current master it fails, and on this pull it passes: `TEST_RUNNER_PORT_MIN=60000 ./bld-cmake/test/functional/p2p_i2p_ports.py --portseed=0`)

  So fix those issues (and hopefully also 30030) by using an unoccupied p2p_port.

  The logic is similar to the `extra_port()` logic in the `feature_bind_extra.py` test.

ACKs for top commit:
  laanwj:
    Code review ACK fa20275db3
  mzumsande:
    ACK fa20275db3

Tree-SHA512: ac5487ca195db9ca746b78b8add91d0b9ef59cc3be0cdb7fbd9f76d42549eea68a61c32b4f5a162e01f3777959110f9f8d56ff05af6a13a9f61ea5be5b7d8631
2025-10-22 10:22:16 +02:00
fanquake
e4b04630bc ci: add Valgrind fuzz 2025-10-22 10:13:14 +02:00
Hennadii Stepanov
3fee0754a2 Merge bitcoin/bitcoin#33550: Fix windows libc++ fs::path fstream compile errors
c864a4c194 Simplify fs::path by dropping filename() and make_preferred() overloads (Ryan Ofsky)
b0113afd44 Fix windows libc++ fs::path fstream compile errors (Ryan Ofsky)

Pull request description:

  Drop support for passing `fs::path` directly to `std::ifstream` and `std::ofstream` constructors and `open()` functions, because as reported by hebasto in https://github.com/bitcoin/bitcoin/issues/33545, after https://wg21.link/lwg3430 there is no way this can continue to work in windows builds, and there are already compile errors compiling for windows with newer versions of libc++.

  Instead, add an `fs::path::std_path()` method that returns `std::filesystem::path` references and use it where needed.

ACKs for top commit:
  hebasto:
    ACK c864a4c194.
  l0rinc:
    Code review ACK c864a4c194
  maflcko:
    re-ACK c864a4c194 🌥

Tree-SHA512: d22372692ab86244e2b2caf4c5e9c9acbd9ba38df5411606b75e428474eabead152fc7ca1afe0bb0df6b818351211a70487e94b40a17b68db5aa757604a0ddf6
2025-10-22 10:10:27 +02:00
MarcoFalke
fa0e36156c ci: Doc ASLR workaround for sanitizer tasks 2025-10-22 09:14:40 +02:00
MarcoFalke
fa20275db3 test: Use unassigned p2p_port instead of hardcoded 60000 in p2p_i2p_ports.py 2025-10-21 18:28:12 +02:00
merge-script
c862936d16 Merge bitcoin/bitcoin#33370: ci: use Mold linker for asan-lsan-ubsan-integer-no-depends-usdt workflow
f031536f2d ci: use Mold linker for asan-lsan-ubsan-integer-no-depends-usdt workflow (Brandon Odiwuor)

Pull request description:

  Follow up to https://github.com/bitcoin/bitcoin/pull/32888#pullrequestreview-2993523631 and https://github.com/bitcoin/bitcoin/pull/32888#issuecomment-3044773485

  >>Can we use `mold` as a linker in other Linux based system workflows ? dependencies [we have](https://github.com/bitcoin/bitcoin/blob/master/doc/dependencies.md#compiler) seem to satisfy the deps here https://github.com/rui314/mold?tab=readme-ov-file#how-to-build
  >
  > Sure, happy to review a follow-up. Only place to avoid it would probably the ci tasks that mirror the guix build (win-cross, mac-cross)

  Updated the `ASan + LSan + UBSan + integer, no depends, USDT` workflow to use `mold` linker

ACKs for top commit:
  maflcko:
    lgtm ACK f031536f2d

Tree-SHA512: 35a4cb3eec732bee3f18a3ea70e49b1c99b8e88624a0bb28eca8f3d72ed0835af8773307a27c750b89fc6d969ff20dd87b840d755b7fd14d3cb6ab68d9f587b9
2025-10-21 16:37:01 +02:00
MarcoFalke
fabe0e07de ci: Only write docker build images to Cirrus cache
Other cache providers offer too little space for this to be useful.
2025-10-21 15:43:01 +02:00
MarcoFalke
fab64a5d6f ci: Move buildx command to python script
This has a few benefits:

* The shellcheck SC2086 warning is disabled for the whole command, but
  is only needed for the DOCKER_BUILD_CACHE_ARG env var.  So in Python,
  only pass this one env var to shlex.split() for proper word splitting.
* Future logic improvements can be implemented in Python.

The comments are moved, which can be checked via the git options:
--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2025-10-21 15:42:50 +02:00
MarcoFalke
fa72a2bd5c ci: Remove unused MAYBE_CPUSET
The option is currently unused. If it is used again in the future, it
could trivially be added back.

Also, the logic is just a single undocumented python command one-liner.

So remove it for now.
2025-10-21 15:22:52 +02:00
merge-script
abe7cbfe1a Merge bitcoin/bitcoin#33470: build: Move CMAKE_SKIP_INSTALL_RPATH from CMake to Guix script
4b41f99d57 build: Move CMAKE_SKIP_INSTALL_RPATH from CMake to Guix script (Henry Romp)

Pull request description:

  Remove `CMAKE_SKIP_INSTALL_RPATH` from CMakeLists.txt and add `CMAKE_SKIP_RPATH` to the Guix build script. This keeps build-environment-specific settings in the build scripts rather than hardcoded in the CMake configuration.

ACKs for top commit:
  purpleKarrot:
    ACK 4b41f99d57
  janb84:
    re ACK 4b41f99d57

Tree-SHA512: 74d6af382476d731f10f9833978d670e9981c160ba306d0e9d4b1ad1e9b9960b8d03a3b9b608e234edb1c0c2c7a2b4f9f606a2a7887b7a153792159e71ae9b21
2025-10-21 10:44:11 +02:00
merge-script
689ec28d1d Merge bitcoin/bitcoin#33633: test: [move-only] binary utils to utils.py
fa75ef4328 test: Move export_env_build_path to util.py (MarcoFalke)
fa9f495308 test: Move get_binary_paths and Binaries to util.py (MarcoFalke)

Pull request description:

  Having the binary related utils sit in the test_framework.py is fine. However, they are mostly stand-alone utils, which may be used externally.

  So move them to utils.py, to allow easier external use. The diff is trivial and can be reviewed via the git options `--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space`.

ACKs for top commit:
  kevkevinpal:
    ACK [fa75ef4](fa75ef4328)
  Sjors:
    lgtm ACK fa75ef4328
  yuvicc:
    Code review ACK fa75ef4328
  janb84:
    ACK fa75ef4328
  musaHaruna:
    Code Review ACK [fa75ef4](fa75ef4328)
  enirox001:
    ACK [fa75ef4](fa75ef4328)

Tree-SHA512: f382118484cb5495e8888214437e72c81727d54f97b3c09dfd996faab6cb6643c4c2d816b89ab82de73fc091c36ed7b8744c7d34a443b6adc415eb06697ef6ea
2025-10-21 08:39:22 +01:00
merge-script
0eeae4d174 Merge bitcoin/bitcoin#33625: Update secp256k1 subtree to latest master
3cbf7cb3e6 Squashed 'src/secp256k1/' changes from b9313c6e1a..d543c0d917 (fanquake)

Pull request description:

  Updates the subtree to d543c0d917
  Related to #33284.

ACKs for top commit:
  hebasto:
    ACK 879c21045e.
  janb84:
    ACK 879c21045e

Tree-SHA512: 1802cd84959b5c935170792f458651f30431fe8340ead7966ff381c1c0c3a9f6c21bbb8dd96a07482ffed49642ded49e80b61802e688b8351956b111dffd5a78
2025-10-19 15:45:47 +01:00
Henry Romp
4b41f99d57 build: Move CMAKE_SKIP_INSTALL_RPATH from CMake to Guix script
Remove CMAKE_SKIP_INSTALL_RPATH from CMakeLists.txt and add CMAKE_SKIP_RPATH to the Guix build script. This keeps build-environment-specific settings in the build scripts rather than hardcoded in the CMake configuration.
2025-10-17 20:35:53 -04:00
merge-script
d30f149360 Merge bitcoin/bitcoin#33630: doc: correct topology requirements in submitpackage helptext
3d22282564 [doc] correct topology requirements in submitpackage helptext (glozow)

Pull request description:

  This doc is outdated since #31385. Also made it explicit that a singleton is ok.

  Can be backported to 30.x, but doesn't need to be backported earlier ("if any" covers #31096).

ACKs for top commit:
  janb84:
    ACK 3d22282564
  instagibbs:
    ACK 3d22282564

Tree-SHA512: 95e40630a5b2a571029c0657c20a5e2a1cf1789913b868cee314c1a9fcb9a09fccdd3c87f3f15a8eb95c5ff9b83f8adee0661f86619bf21965866b6f6a76dfd0
2025-10-17 15:16:07 +01:00
glozow
3d22282564 [doc] correct topology requirements in submitpackage helptext 2025-10-17 09:29:16 -04:00
merge-script
e744fd1249 Merge bitcoin/bitcoin#33641: Update leveldb subtree to latest master
f21162d819 Squashed 'src/leveldb/' changes from aba469ad6a..cad64b151d (fanquake)

Pull request description:

  Rather than continue to close PRs/"Send these upstream" i.e: #33638, #33148, #22664, #13781; just fix the typos.

  Includes https://github.com/bitcoin-core/leveldb-subtree/pull/57.

ACKs for top commit:
  l0rinc:
    ACK 54ffe3de5b
  cedwies:
    ACK 54ffe3d
  stickies-v:
    ACK 54ffe3de5b

Tree-SHA512: cc4d758ee95a1943f14e800472dfef24d5598a1dfafede32300821bc27e02a80ae97ea12ee87643b395b204262c7bc28e64d421a3d375d46bef7782381fd4362
2025-10-16 20:10:34 +01:00
merge-script
4371740beb Merge bitcoin/bitcoin#33642: doc: archive release notes for v28.3
ceea24b921 doc: archive release notes for v28.3 (fanquake)

Pull request description:

ACKs for top commit:
  stickies-v:
    ACK ceea24b921 - matches da5f5de405/doc/release-notes.md

Tree-SHA512: 56b449c456c221cfb15722356ee3028de8f788c6d35ea6055161024dd03b860a38deeca5f6cf3a70e62a6d02b0d07793fed17aeae514306cdd2bd79aa703f65a
2025-10-16 17:23:12 +01:00
fanquake
ceea24b921 doc: archive release notes for v28.3 2025-10-16 16:49:54 +01:00
fanquake
54ffe3de5b Update leveldb subtree to latest master 2025-10-16 13:49:49 +01:00
fanquake
f21162d819 Squashed 'src/leveldb/' changes from aba469ad6a..cad64b151d
cad64b151d Merge bitcoin-core/leveldb-subtree#57: doc: fix typos
157ed16be9 doc: fix typos

git-subtree-dir: src/leveldb
git-subtree-split: cad64b151dabe9ffe9771a54d7c9dbfb3355cefb
2025-10-16 13:49:49 +01:00
merge-script
e14451ac87 Merge bitcoin/bitcoin#33469: TxGraph: change m_excluded_clusters
9b43428c96 TxGraph: change m_excluded_clusters (Greg Sanders)

Pull request description:

  Change BlockBuilderImpl's m_excluded_clusters to unordered set since ordering is not used.

  Change the set to a set of sequence numbers for a modest stability increase under fuzz testing.

ACKs for top commit:
  sipa:
    ACK 9b43428c96
  marcofleon:
    tACK 9b43428c96
  glozow:
    ACK 9b43428c96

Tree-SHA512: 140a492af93f3eff756847a8168aab2624bb7df407f177dde6f3b07e9db2d0ced6b125e2b126f4957ccd054272056bedf74f9f0e64a80d90c16fd94e0fa86a44
2025-10-15 10:00:49 -04:00
merge-script
f76e1ae389 Merge bitcoin/bitcoin#32313: coins: fix cachedCoinsUsage accounting in CCoinsViewCache
24d861da78 coins: only adjust `cachedCoinsUsage` on `EmplaceCoinInternalDANGER` insert (Lőrinc)
d7c9d6c291 coins: fix `cachedCoinsUsage` accounting to prevent underflow (Lőrinc)
39cf8bb3d0 refactor: remove redundant usage tracking from `CoinsViewCacheCursor` (Lőrinc)
67cff8bec9 refactor: assert newly-created parent cache entry has zero memory usage (Lőrinc)

Pull request description:

  ### Summary

  This PR fixes `cachedCoinsUsage` accounting bugs in `CCoinsViewCache` that caused UBSan `unsigned-integer-overflow` violations during testing. The issues stemmed from incorrect decrement timing in `AddCoin()`, unconditional reset in `Flush()` on failure, and incorrect increment in `EmplaceCoinInternalDANGER()` when insertion fails.

  ### Problems Fixed

  **1. `AddCoin()` underflow on exception**
  - Previously decremented `cachedCoinsUsage` *before* the `possible_overwrite` validation
  - If validation threw, the map entry remained unchanged but counter was decremented
  - This corrupted accounting and later caused underflow
  - **Impact**: Test-only in current codebase, but unsound accounting that could affect future changes

  **2. `Flush()` accounting drift on failure**
  - Unconditionally reset `cachedCoinsUsage` to 0, even when `BatchWrite()` failed
  - Left the map populated while the counter read zero
  - **Impact**: Test-only (production `BatchWrite()` returns `true`), but broke accounting consistency

  **3. Cursor redundant usage tracking**
  - `CoinsViewCacheCursor::NextAndMaybeErase()` subtracted usage when erasing spent entries
  - However, `SpendCoin()` already decremented and cleared the `scriptPubKey`, leaving `DynamicMemoryUsage()` at 0
  - **Impact**: Redundant code that obscured actual accounting behavior

  **4. `EmplaceCoinInternalDANGER()` double-counting**
  - Incremented `cachedCoinsUsage` even when `try_emplace` did not insert (duplicate key)
  - Inflated the counter on duplicate attempts
  - **Impact**: Mostly test-reachable (AssumeUTXO doesn't overwrite in production), but incorrect accounting

  ### Testing

  To reproduce the historical UBSan failures on the referenced baseline and to verify the fix, run:
  ```
  MAKEJOBS="-j$(nproc)" FILE_ENV="./ci/test/00_setup_env_native_fuzz.sh" ./ci/test_run_all.sh
  ```

  The change was tested with the related unit and fuzz test, and asserted before/after each `cachedCoinsUsage` change (in production code and fuzz) that the calculations are still correct by recalculating them from scratch.

  <details>
  <summary>Details</summary>

  ```C++
  bool CCoinsViewCache::CacheUsageValid() const
  {
      size_t actual{0};
      for (auto& entry : cacheCoins | std::views::values) actual += entry.coin.DynamicMemoryUsage();
      return actual == cachedCoinsUsage;
  }
  ```
  or
  ```patch
  diff --git a/src/coins.cpp b/src/coins.cpp
  --- a/src/coins.cpp(revision fd3b1a7f4bb2ac527f23d4eb4cfa40a3215906e5)
  +++ b/src/coins.cpp(revision 872a05633bfdbd06ad82190d7fe34b42d13ebfe9)
  @@ -96,6 +96,7 @@
           fresh = !it->second.IsDirty();
       }
       if (!inserted) {
  +        Assert(cachedCoinsUsage >= it->second.coin.DynamicMemoryUsage());
           cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
       }
       it->second.coin = std::move(coin);
  @@ -133,6 +134,7 @@
   bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) {
       CCoinsMap::iterator it = FetchCoin(outpoint);
       if (it == cacheCoins.end()) return false;
  +    Assert(cachedCoinsUsage >= it->second.coin.DynamicMemoryUsage());
       cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
       TRACEPOINT(utxocache, spent,
              outpoint.hash.data(),
  @@ -226,10 +228,12 @@
               if (itUs->second.IsFresh() && it->second.coin.IsSpent()) {
                   // The grandparent cache does not have an entry, and the coin
                   // has been spent. We can just delete it from the parent cache.
  +                Assert(cachedCoinsUsage >= itUs->second.coin.DynamicMemoryUsage());
                   cachedCoinsUsage -= itUs->second.coin.DynamicMemoryUsage();
                   cacheCoins.erase(itUs);
               } else {
                   // A normal modification.
  +                Assert(cachedCoinsUsage >= itUs->second.coin.DynamicMemoryUsage());
                   cachedCoinsUsage -= itUs->second.coin.DynamicMemoryUsage();
                   if (cursor.WillErase(*it)) {
                       // Since this entry will be erased,
  @@ -279,6 +283,7 @@
   {
       CCoinsMap::iterator it = cacheCoins.find(hash);
       if (it != cacheCoins.end() && !it->second.IsDirty() && !it->second.IsFresh()) {
  +        Assert(cachedCoinsUsage >= it->second.coin.DynamicMemoryUsage());
           cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
           TRACEPOINT(utxocache, uncache,
                  hash.hash.data(),
  ```

  </details>

ACKs for top commit:
  optout21:
    reACK 24d861da78
  andrewtoth:
    ACK 24d861da78
  sipa:
    ACK 24d861da78
  w0xlt:
    ACK 24d861da78

Tree-SHA512: ff1b756b46220f278ab6c850626a0f376bed64389ef7f66a95c994e1c7cceec1d1843d2b24e8deabe10e2bdade2a274d9654ac60eb2b9bf471a71db8a2ff496c
2025-10-15 09:48:04 -04:00
MarcoFalke
fa75ef4328 test: Move export_env_build_path to util.py 2025-10-15 14:25:58 +02:00
MarcoFalke
fa9f495308 test: Move get_binary_paths and Binaries to util.py
Can be reviewed with the git options
--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2025-10-15 14:25:50 +02:00
merge-script
40e7d4cd0d Merge bitcoin/bitcoin#33549: ci: Add macOS cross task for arm64-apple-darwin
fad5a7101c ci: Add macOS cross task for arm64 (MarcoFalke)
fa8c750a0a ci: Refactor get_previous_releases step in win-test-cross task (MarcoFalke)

Pull request description:

  Cross compiling to Intel macOS seems fine, but it would be good to cross compile to arm64-apple-darwin as well.

  Further reading:

  * https://en.wikipedia.org/wiki/Mac_transition_to_Apple_silicon#Timeline.
  * It is harder to find native Intel macOS hardware (E.g. GitHub is in the process of dropping it: https://github.blog/changelog/2025-07-11-upcoming-changes-to-macos-hosted-runners-macos-latest-migration-and-xcode-support-policy-updates/#macos-13-is-closing-down)

ACKs for top commit:
  Sjors:
    utACK fad5a7101c
  hodlinator:
    crACK fad5a7101c

Tree-SHA512: ce96ac9f68f594584dc910555bd34590084e3e45ca02a22d4949e88bb569de3bf87ebf6b5c6718ae82d7750a98212b72f6dab80bddfc9652a57180fbdda97f42
2025-10-15 11:20:27 +01:00
merge-script
ea17618c11 Merge bitcoin/bitcoin#33480: ci: Turn CentOS config into Alpine musl config
444409ff2b ci: Reduce Alpine musl task to md runner size (MarcoFalke)
fa6b2e9efe ci: Turn centos config into alpine musl config (MarcoFalke)

Pull request description:

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

  Historically, the centos task was added to add CI coverage for old packages and 32-bit depends builds, but both are now covered by different tasks.

  The CentOS task aligns with Ubuntu/Debian CI tasks in terms of libc usage, but (slightly) differs in package naming and update philosophy. I am not aware of the task ever discovering a centos-related issue, so it seems fine to recycle it into an Alpine Linux task.

  The main difference would be that musl libc is now used. Also, busybox is used in Alpine, so in theory the busybox install could be removed from the arm CI task in the future.

  Packaging considerations: All packages should roughly be the same (gcc remains at version 14, python remains at version 3.12, etc). Also, all packages are from the Alpine main track, coming with 2 years of support. The only exception is the py3-pip package (https://pkgs.alpinelinux.org/packages?name=py3-pip&branch=v3.22&repo=&arch=riscv64) from the community track, however, I don't expect any issues arising from that.

ACKs for top commit:
  janb84:
    reACK 444409ff2b
  willcl-ark:
    ACK 444409ff2b

Tree-SHA512: fd1a1da0fd766591e44a57dbdb84f9b3b47ca92113a429bba139ee5fef54714b8fe509c321e7b3a470c29b4af7d9eab9786e1660b9effb862ecea52824f458aa
2025-10-15 10:56:45 +01:00
merge-script
b1f8a13702 Merge bitcoin/bitcoin#33624: test: P2SH sig ops are only counted with SCRIPT_VERIFY_P2SH
3a10d700bc test: P2SH sig ops are only counted with `SCRIPT_VERIFY_P2SH` flag (brunoerg)

Pull request description:

  This PR adds a test case for `GetTransactionSigOpCost` to check that P2SH sig ops are only counted when `SCRIPT_VERIFY_P2SH` flag is set.

  Kills the following [mutant](https://corecheck.dev/mutation/src/consensus/tx_verify.cpp#L150):

  ```diff
  diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp
  index 9d09872597..cc7cdaaf8f 100644
  --- a/src/consensus/tx_verify.cpp
  +++ b/src/consensus/tx_verify.cpp
  @@ -147,7 +147,7 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i
       if (tx.IsCoinBase())
           return nSigOps;

  -    if (flags & SCRIPT_VERIFY_P2SH) {
  +    if (1==1) {
           nSigOps += GetP2SHSigOpCount(tx, inputs) * WITNESS_SCALE_FACTOR;
       }
  ```

ACKs for top commit:
  l0rinc:
    Tested ACK 3a10d700bc
  maflcko:
    re-lgtm ACK 3a10d700bc
  instagibbs:
    ACK 3a10d700bc
  janb84:
    tested ACK 3a10d700bc

Tree-SHA512: f560b4f9f2ce5c5fdd0a86e7e1f8ea27a8c6fda0327a6186a0c21e2c06ef13beeb017686db1688cace68812a01701abe46e8e1a095afefc6f2aed6ed96ba8288
2025-10-15 09:55:49 +01:00
fanquake
879c21045e Update secp256k1 subtree to latest master 2025-10-15 09:49:11 +01:00
fanquake
3cbf7cb3e6 Squashed 'src/secp256k1/' changes from b9313c6e1a..d543c0d917
d543c0d917 Merge bitcoin-core/secp256k1#1734: Introduce (mini) unit test framework
f44c1ebd96 Merge bitcoin-core/secp256k1#1719: ci: DRY workflow using anchors
a44a339384 Merge bitcoin-core/secp256k1#1750: ci: Use clang-snapshot in "MSan" job
15d014804e ci: Drop default for `inputs.command` in `run-in-docker-action`
1decc49a1f ci: Use YAML anchor and aliases for repeated "CI script" steps
dff1bc107d ci, refactor: Generalize use of `matrix.configuration.env_vars`
4b644da199 ci: Use YAML anchor and aliases for repeated "Print logs" steps
a889cd93df ci: Bump `actions/checkout` version
574c2f3080 ci: Use YAML anchor and aliases for repeated "Checkout" steps
53585f93b7 ci: Use clang-snapshot in "MSan" job
6894c964f3 Fix Clang 21+ `-Wuninitialized-const-pointer` warning when using MSan
2b7337f63a Merge bitcoin-core/secp256k1#1756: ci: Fix image caching and apply other improvements
f163c35897 ci: Set `DEBIAN_FRONTEND=noninteractive`
70ae177ca0 ci: Bump `docker/build-push-action` version
b2a95a420f ci: Drop `tags` input for `docker/build-push-action`
122014edb3 ci: Add `scope` parameter to `cache-{to,from}` options
2f4546ce56 test: add --log option to display tests execution
95b9953ea4 test: Add option to display all available tests
953f7b0088 test: support running specific tests/modules targets
0302c1a3d7 test: add --help for command-line options
9ec3bfe22d test: adapt modules to the new test infrastructure
48789dafc2 test: introduce (mini) unit test framework
baa265429f Merge bitcoin-core/secp256k1#1727: docs: Clarify that callback can be called more than once
4d90585fea docs: Improve API docs of _context_set_illegal_callback
895f53d1cf docs: Clarify that callback can be called more than once
de6af6ae35 Merge bitcoin-core/secp256k1#1748: bench: improve context creation in ECDH benchmark
5817885153 Merge bitcoin-core/secp256k1#1749: build: Fix warnings in x86_64 assembly check
ab560078aa build: Fix warnings in x86_64 assembly check
10dab907e7 Merge bitcoin-core/secp256k1#1741: doc: clarify API doc of `secp256k1_ecdsa_recover` return value
dfe284ed2d bench: improve context creation in ECDH benchmark
7321bdf27b doc: clarify API doc of `secp256k1_ecdsa_recover` return value
b475654302 Merge bitcoin-core/secp256k1#1745: test: introduce group order byte-array constant for deduplication
9cce703863 refactor: move 'gettime_i64()' to tests_common.h
0c91c56041 test: introduce group order byte-array constant for deduplication
88be4e8d86 Merge bitcoin-core/secp256k1#1735: musig: Invalidate secnonce in secp256k1_musig_partial_sign
36e76952cb Merge bitcoin-core/secp256k1#1738: check-abi: remove support for obsolete CMake library output location (src/libsecp256k1.so)
399b582a5f Split memclear into two versions
4985ac0f89 Merge bitcoin-core/secp256k1#1737: doc: mention ctx requirement for `_ellswift_create` (not secp256k1_context_static)
7ebaa134a7 check-abi: remove support for obsolete CMake library output location (src/libsecp256k1.so)
806de38bfc doc: mention ctx requirement for `_ellswift_create` (not secp256k1_context_static)
03fb60ad2e Merge bitcoin-core/secp256k1#1681: doc: Recommend clang-cl when building on Windows
d93380fb35 Merge bitcoin-core/secp256k1#1731: schnorrsig: Securely clear buf containing k or its negation
8113671f80 Merge bitcoin-core/secp256k1#1729: hash: Use size_t instead of int for RFC6979 outlen copy
325d65a8cf Rename and clear var containing k or -k
960ba5f9c6 Use size_t instead of int for RFC6979 outlen copy
737912430d ci: Add more tests for clang-cl
7379a5bed3 doc: Recommend clang-cl when building on Windows
f36afb8b3d Merge bitcoin-core/secp256k1#1725: tests: refactor tagged hash verification
5153cf1c91 tests: refactor tagged hash tests
d2dcf52091 Merge bitcoin-core/secp256k1#1726: docs: fix broken link to Tromer's cache.pdf paper
489a43d1bf docs: fix broken link to eprint cache.pdf paper
d599714147 Merge bitcoin-core/secp256k1#1722: docs: Exclude modules' `bench_impl.h` headers from coverage report
0458def51e doc: Add `--gcov-ignore-parse-errors=all` option to `gcovr` invocations
1aecce5936 doc: Add `--merge-mode-functions=separate` option to `gcovr` invocations
106a7cbf41 doc: Exclude modules' `bench_impl.h` headers from coverage report
a9e955d3ea autotools, docs: Adjust help string for `--enable-coverage` option
e523e4f90e Merge bitcoin-core/secp256k1#1720: chore(ci): Fix typo in Dockerfile comment
24ba8ff168 chore(ci): Fix typo in Dockerfile comment
74b8068c5d Merge bitcoin-core/secp256k1#1717: test: update wycheproof test vectors
c25c3c8a88 test: update wycheproof test vectors
20e3b44746 Merge bitcoin-core/secp256k1#1688: cmake: Avoid contaminating parent project's cache with `BUILD_SHARED_LIBS`
2c076d907a Merge bitcoin-core/secp256k1#1711: tests: update Wycheproof
7b07b22957 cmake: Avoid contaminating parent project's cache with BUILD_SHARED_LIBS
5433648ca0 Fix typos and spellings
9ea54c69b7 tests: update Wycheproof files

git-subtree-dir: src/secp256k1
git-subtree-split: d543c0d917a76a201578948701cc30ef336e0fe6
2025-10-15 09:49:11 +01:00
merge-script
2f7a50f67c Merge bitcoin/bitcoin#33462: ci: add libcpp hardening flags to macOS fuzz job
e4c04f7759 ci: add libcpp hardening flags to macOS fuzz job (fanquake)

Pull request description:

  Follows up to https://github.com/bitcoin/bitcoin/pull/33425#issuecomment-3323149107.

ACKs for top commit:
  maflcko:
    lgtm ACK e4c04f7759. The qa-assets repo has a libc++ debug run, so this isn't required, but it seems fast enough to not hurt.

Tree-SHA512: 6c0dc90528ca867df49027eebf2d1c417a7395f9f94779076ace48e3e4b21771e7d99e8b3ed75ca56da87153418a446075429aa6b9ec5cd4b6b8cb5b0c25c1d7
2025-10-15 09:39:58 +01:00
merge-script
48aa0e98d0 Merge bitcoin/bitcoin#29675: wallet: Be able to receive and spend inputs involving MuSig2 aggregate keys
ac599c4a9c test: Test MuSig2 in the wallet (Ava Chow)
68ef954c4c wallet: Keep secnonces in DescriptorScriptPubKeyMan (Ava Chow)
4a273edda0 sign: Create MuSig2 signatures for known MuSig2 aggregate keys (Ava Chow)
258db93889 sign: Add CreateMuSig2AggregateSig (Ava Chow)
bf69442b3f sign: Add CreateMuSig2PartialSig (Ava Chow)
512b17fc56 sign: Add CreateMuSig2Nonce (Ava Chow)
82ea67c607 musig: Add MuSig2AggregatePubkeys variant that validates the aggregate (Ava Chow)
d99a081679 psbt: MuSig2 data in Fill/FromSignatureData (Ava Chow)
4d8b4f5336 signingprovider: Add musig2 secnonces (Ava Chow)
c06a1dc86f Add MuSig2SecNonce class for secure allocation of musig nonces (Ava Chow)
9baff05e49 sign: Include taproot output key's KeyOriginInfo in sigdata (Ava Chow)
4b24bfeab9 pubkey: Return tweaks from BIP32 derivation (Ava Chow)
f14876213a musig: Move synthetic xpub construction to its own function (Ava Chow)
fb8720f1e0 sign: Refactor Schnorr sighash computation out of CreateSchnorrSig (Ava Chow)
a4cfddda64 tests: Clarify why musig derivation adds a pubkey and xpub (Ava Chow)
39a63bf2e7 descriptors: Add a doxygen comment for has_hardened output_parameter (Ava Chow)
2320184d0e descriptors: Fix meaning of any_key_parsed (Ava Chow)

Pull request description:

  This PR implements MuSig2 signing so that the wallet can receive and spend from imported `musig(0` descriptors.

  The libsecp musig module is enabled so that it can be used for all of the MuSig2 cryptography.

  Secnonces are handled in a separate class which holds the libsecp secnonce object in a `secure_unique_ptr`. Since secnonces must not be used, this class has no serialization and will only live in memory. A restart of the software will require a restart of the MuSig2 signing process.

ACKs for top commit:
  fjahr:
    tACK ac599c4a9c
  rkrux:
    lgtm tACK ac599c4a9c
  theStack:
    Code-review ACK ac599c4a9c 🗝️

Tree-SHA512: 626b9adc42ed2403e2f4405321eb9ce009a829c07d968e95ab288fe4940b195b0af35ca279a4a7fa51af76e55382bad6f63a23bca14a84140559b3c667e7041e
2025-10-14 16:25:52 -04:00
merge-script
db4bde0b03 Merge bitcoin/bitcoin#33517: multiprocess: Fix high overhead from message logging
0626b90f50 multiprocess: align our logging with libmultiprocess's (Cory Fields)
9d068225ee multiprocess: update multiprocess EventLoop construction to use options (Cory Fields)

Pull request description:

  This fixes https://github.com/bitcoin-core/libmultiprocess/issues/215 on Core's side. ~It depends on https://github.com/bitcoin-core/libmultiprocess/pull/220 being merged upstream, and a PR to update our subtree. I've included a subtree merge from my repo here for now, but will rebase on top of the merge from upstream once it's in.~ Edit: Rebased on top of #33518.

  For context: before https://github.com/bitcoin-core/libmultiprocess/pull/220, libmultiprocess serializesd every log message parameter, even if that message was ultimately going to be discarded. The upstream PR accomplished 2 main things:
  - Creates logging categories, similar to Core's
  - Using macros, avoids serializing parameters for disabled log levels.

  That allowed the expensive serialization to be skipped, but the default log level is `Trace`. This PR updates our usage of libmultiprocess options to honor our log categories and levels.

  Because of the substantial unnecessary overhead (see the [flamegraphs](https://github.com/bitcoin-core/libmultiprocess/issues/215). Logging accounts for 50% of my application's cpu time, and nearly 10% of bitcoin-node's, both of which go to ~0% once fixed), it'd be a shame to ship the first multiprocess binaries without this fixed. So I propose that we also backport this (and the required libmultiprocess subtree merge) ~to v30. Sorry about the timing~ :(

  Edit: Didn't make it for v30, but it would still make sense to backport for a v30.1.

ACKs for top commit:
  Sjors:
    ACK 0626b90f50
  TheCharlatan:
    ACK 0626b90f50
  sipa:
    utACK 0626b90f50

Tree-SHA512: 70b63b62d1f6de547f4d4775538d7bcaf32f57d8a72c5b26762b57755810c8be6942d9dfebab43cf1c1d8d025a555f72a48e9ebf3d84f8d40d6592ca801cda5d
2025-10-14 16:18:13 -04:00
brunoerg
3a10d700bc test: P2SH sig ops are only counted with SCRIPT_VERIFY_P2SH flag 2025-10-14 15:39:45 -03:00
merge-script
9314113b29 Merge bitcoin/bitcoin#33610: doc: archive release notes for v29.2
c11a3dcc88 doc: archive release notes for v29.2 (fanquake)

Pull request description:

ACKs for top commit:
  janb84:
    ACK c11a3dcc88
  stickies-v:
    ACK c11a3dcc88, matches 3226616493/doc/release-notes.md

Tree-SHA512: bb566000d6907f70785f45878208479c01df7aa3a50f46ccf9156478bbc798d56b64f5c3fd6555900e03fe44ad7021c0513ed711c22eec4a783e84cd89f8a73c
2025-10-14 18:18:52 +01:00
Greg Sanders
9b43428c96 TxGraph: change m_excluded_clusters
Change BlockBuilderImpl's m_excluded_clusters to unordered
set since ordering is not used.

Change the set to a set of sequence numbers for a modest
stability increase under fuzz testing.
2025-10-14 12:44:57 -04:00
merge-script
6e1adbbaa1 Merge bitcoin/bitcoin#33612: test: change log rate limit version gate
7b544341c0 test: change log rate limit version gate from 299900 to 290100 (Eugene Siegel)

Pull request description:

  Change the version gate from 299900 to 290100 for bypassing the log rate limit in case an explicit version is set in the functional test framework.

  See discussion here: https://github.com/bitcoin/bitcoin/pull/33225#discussion_r2287838255

ACKs for top commit:
  maflcko:
    lgtm ACK 7b544341c0
  janb84:
    ACK 7b544341c0
  stickies-v:
    ACK 7b544341c0

Tree-SHA512: c07c8741dfdeca87c49748b7082c2ecb829da391908316f35daef7292bc017814a89f04e16e738f3a105541bbc38e4feb5bca3fb6ab718a1dc1de7c70a9c8a58
2025-10-14 17:26:17 +01:00
merge-script
fdcf67de80 Merge bitcoin/bitcoin#33157: cluster mempool: control/optimize TxGraph memory usage
023cd5a546 txgraph: add SingletonClusterImpl (mem optimization) (Pieter Wuille)
e346250732 txgraph: give Clusters a range of intended tx counts (preparation) (Pieter Wuille)
e93b0f09cc txgraph: abstract out creation of empty Clusters (refactor) (Pieter Wuille)
6baf12621f txgraph: comment fixes (doc fix) (Pieter Wuille)
726b995739 txgraph: make Cluster an abstract class (refactor) (Pieter Wuille)
2602d89edd txgraph: avoid accessing other Cluster internals (refactor) (Pieter Wuille)
04c808ac4c txgraph: expose memory usage estimate function (feature) (Pieter Wuille)
7680bb8fd4 txgraph: keep track of Cluster memory usage (preparation) (Pieter Wuille)
4ba562e5f4 txgraph: keep data structures compact (mem optimization) (Pieter Wuille)
bb5cb222ae depgraph: add memory usage control (feature) (Pieter Wuille)
b1637a90de txgraph: avoid holes in DepGraph positions (mem optimization) (Pieter Wuille)
2b1d302508 txgraph: move some sanity checks from Cluster to TxGraphImpl (refactor) (Pieter Wuille)
d40302fbaf txgraph: Make level of Cluster implicit (optimization) (Pieter Wuille)

Pull request description:

  Part of #30289.

  This adds a few optimizations to reduce `TxGraph`'s memory usage, and makes sure that dynamic memory it uses doesn't linger after shrinking clusters. Finally, it exposes a function `GetMainMemoryUsage()` to compute `TxGraph`'s approximate memory usage.

  It makes the `Cluster` type abstract, with two instances (`SingletonClusterImpl` for 1-transaction clusters, and `GenericClusterImpl` for others).

  On my 64-bit system, I obtain the following numbers:
  * `SingletonClusterImpl`: 48 bytes, plus 16 bytes malloc overhead in its `unique_ptr`, plus 8-byte pointer in `m_clusters`
  * `GenericClusterImpl`: 104 bytes, plus 16 bytes malloc overhead in its `unique_ptr`, plus 8-byte pointer in `m_clusters`, plus 72 bytes malloc overhead inside its vectors and `DepGraph`, plus 40 bytes per transaction in those.
  * `TxGraphImpl::Entry`: 72 bytes per transaction
  * `TxGraphImpl::ChunkData`: 8 bytes, plus 56 bytes in `std::set` overhead + malloc overhead, all per chunk.
  * `TxGraph::Ref`: 16 bytes per transaction

  This overall amounts to 200 bytes per cluster, plus 64 bytes per chunk, plus 128 bytes per transaction, but only 224 bytes overall per singleton cluster.

ACKs for top commit:
  l0rinc:
    code review reACK 023cd5a546
  instagibbs:
    reACK 023cd5a546
  ismaelsadeeq:
    reACK 023cd5a546  🚢
  glozow:
    reACK 023cd5a546

Tree-SHA512: c957b27f47318be7c25d71453df2ae9d4e7bf21dab13b6e5e975cca122a221a99b15c584872491225785d276a9165f090675ee0f4460a2775bd3271933e3b246
2025-10-14 11:56:52 -04:00
Eugene Siegel
7b544341c0 test: change log rate limit version gate from 299900 to 290100 2025-10-14 10:57:17 -04:00
Lőrinc
9610b0d1e2 randomenv: Fix MinGW dllimport warning for environ
Extends 7703884 to guard environ declaration on all Windows builds, not just MSVC.
In the mingw-w64 headers (used by llvm-mingw), environ is defined as a macro which expands through _environ to (* __p__environ()), a call to a dllimport function, causing the same inconsistent linkage warning as MSVC.

Use WIN32 instead of _MSC_VER to match the platform-specific guards already used throughout the file.

The warning occurs with llvm-mingw (both UCRT and MSVCRT variants as tested by Hebasto), but not with the mingw-w64 toolchain currently used in CI (as mentioned by fanquake).

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-10-14 10:24:08 -04:00
merge-script
6c4fe401e9 Merge bitcoin/bitcoin#33508: ci: fix buildx gha cache authentication on forks
bc706955d7 ci: expose all ACTIONS_* vars (willcl-ark)

Pull request description:

  When using `docker buildx build` in conjunction with the `gha` backend cache type (as we do in our CI) it's important to specify the URL and TOKEN needed to authenticate.

  On Cirrus runners this is working with only `ACTIONS_CACHE_URL` and `ACTIONS_RUNTIME_TOKEN`, but this is not enough for the GitHub backend.

  Fix this by exporting all `ACTIONS_*` variables.

  This fixes docker build layer cache restore/save on forks or where GH-hosted runners are being used, and addresses https://github.com/bitcoin/bitcoin/issues/31965#issuecomment-3324707093

ACKs for top commit:
  m3dwards:
    ACK bc706955d7
  maflcko:
    lgtm ACK bc706955d7

Tree-SHA512: 13e973bb1c1ca5448dd6c3c176fb5ce39c725886ba2012d3253158205309a7038a1430135b37400e1f2f69408a9d0f4e2b3c5f0515154a593ec382ab7db10266
2025-10-14 09:53:06 +01:00
Sjors Provoost
8f7673257a miner: fix empty mempool case for waitNext()
Block template fees are calculated by looping over new_tmpl->vTxFees
and return (early) once the fee_threshold is exceeded.

This left an edge case when the mempool is empty, which this commit
fixes and adds a test for. It does so by using std::accumulate instead
of manual loops.

Also update interface_ipc.py to account for the new behavior.

Co-authored-by: Raimo33 <claudio.raimondi@protonmail.com>
2025-10-13 18:39:18 +02:00
fanquake
c11a3dcc88 doc: archive release notes for v29.2 2025-10-13 16:19:32 +01:00