44822 Commits

Author SHA1 Message Date
MarcoFalke
fab4c2967d
net: Reject + sign when parsing subnet mask
It does not make sense and it is rejected by other parsers as well:

>>> ipaddress.ip_network("1.2.3.0/+24")
ValueError: '1.2.3.0/+24' does not appear to be an IPv4 or IPv6 network
2025-05-15 22:11:52 +02:00
MarcoFalke
fa89652e68
init: Reject + sign in -*port parsing
It would be confusing to specify the sign for an unsigned value here, so
reject it.
2025-05-15 22:11:46 +02:00
MarcoFalke
fa9c45577d
cli: Reject + sign in -netinfo level parsing
It would be confusing to specify the sign for an unsigned value here, so
reject it.
2025-05-15 19:48:38 +02:00
MarcoFalke
fa98041325
refactor: Use ToIntegral in CreateFromDump
The unsigned version is never serialized with a `+` prefix, so the
stricter ToIntegral can be used.
2025-05-15 19:34:08 +02:00
MarcoFalke
fa23ed7fc2
refactor: Use ToIntegral in ParseHDKeypath
ToIntegral<uint32_t> only accepts numbers, so just use that to replace
the equivalent but more verbose way with find_first_not_of+ParseUInt32.
2025-05-15 19:33:58 +02:00
merge-script
bdc1cef1de
Merge bitcoin/bitcoin#32507: ci: Exclude failing wallet_reorgsrestore.py from valgrind task for now
fa981b90f53101bff2eda606d9479233e71736b5 ci: Exclude failing wallet_reorgsrestore.py from valgrind task for now (MarcoFalke)

Pull request description:

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

  For some reason terminate or kill do not work inside the CI system under valgrind.

  So disable the test for now, until a solution is found.

ACKs for top commit:
  fanquake:
    ACK fa981b90f53101bff2eda606d9479233e71736b5
  mzumsande:
    utACK fa981b90f53101bff2eda606d9479233e71736b5

Tree-SHA512: ce591fa7ffffbf757e2c15744e36a9e57300edf743400938e49fd02291f3977c551a3af1635bc7a6ccc1900d5ea150a64ee2ace46c1d765019ab11bd51035139
2025-05-15 16:24:42 +01:00
MarcoFalke
fa981b90f5
ci: Exclude failing wallet_reorgsrestore.py from valgrind task for now 2025-05-15 12:57:30 +02:00
merge-script
c779ee3a40
Merge bitcoin/bitcoin#32492: test: add skip_if_running_under_valgrind()
75a185ea3db3177e8e479ee61a39bcb51e08d9a6 test: add skip_if_running_under_valgrind() (fanquake)

Pull request description:

  Enable it in the USDT tests. The context (from 0xB10C):

  > every time the tracepoint is reached a SIGTRAP is fired.
  > No matter the tracepoint contents, even with an empty one.
  > Valgrind intercepts SIGTRAP and aborts.

  See discussion in #32374.

ACKs for top commit:
  maflcko:
    lgtm ACK 75a185ea3db3177e8e479ee61a39bcb51e08d9a6
  willcl-ark:
    ACK 75a185ea3db3177e8e479ee61a39bcb51e08d9a6

Tree-SHA512: 7f45c3049ab39cc514024067bd6ac26598e99202c114b48459834c26c2e1273fa58af693878298e628a10c561b954850e49e76b39567b771bb0c0534a063a524
2025-05-15 10:17:50 +01:00
merge-script
89c7b6b97a
Merge bitcoin/bitcoin#32498: doc: remove Carls substitute server from Guix docs
3b824169c7766460794bb445028ac55a7111ee3e doc: remove Carls substitute server from Guix docs (fanquake)

Pull request description:

  This no-longer exists. Use one of the other Guix servers in the example.

ACKs for top commit:
  achow101:
    ACK 3b824169c7766460794bb445028ac55a7111ee3e
  hebasto:
    ACK 3b824169c7766460794bb445028ac55a7111ee3e, the listed substitute servers are the same as in https://guix.gnu.org/manual/en/html_node/Official-Substitute-Servers.html.

Tree-SHA512: dc3a362ccaa9ce8039d3c02158de9cd71082eb4dd790368bfb11c2942a5aae57e67779b5ff3108b532c4fb765811bd9e145eedb390fc48b52b43d334d5864865
2025-05-15 09:39:42 +01:00
Ava Chow
31d3eebfb9
Merge bitcoin/bitcoin#32343: common: Close non-std fds before exec in RunCommandJSON
a0eed55398f882d9390e50582b10272d18f2b836 run_command: Enable close_fds option to avoid lingering fds (Luke Dashjr)
c7c356a448657e154e6bad6c39a296cfd6dce30c cpp-subprocess: Iterate through /proc/self/fd for close_fds option on Linux (Luke Dashjr)
4f5e04da135080291853f71e6f81dd0302224c3a Revert "remove unneeded close_fds option from cpp-subprocess" (Luke Dashjr)

Pull request description:

  Picks up stale #30756, while addressing my fallback comment (https://github.com/bitcoin/bitcoin/pull/30756#discussion_r2030844440).

  > Currently, RunCommandParseJSON runs its target with whatever fds happen to be open inherited on POSIX platforms. I don't think there's any practical scenario where this is a problem right now, but there's a lot of potential for weird problems (eg, if a process manages to outlive bitcoind - perhaps it's hanging - the listening port(s) won't get released and starting bitcoind again will fail). It's also a potential security issue if a child process is intended to be sandboxed at some point. Not to mention plain ugly :)
  >
  > cpp-subprocess has a feature to address this called close_fds. Not sure why it was removed in https://github.com/bitcoin/bitcoin/pull/29961 rather than fixing this during the migration, but this PR restores it, enables it for RunCommandParseJSON, and optimises it by iterating over /proc/self/fd/ like most other libraries do these days ([eg, glib]> (487b1fd20c/glib/gspawn.c (L1094))) since iterating all possible fd numbers [has been found to be problematic](https://bugzilla.redhat.com/show_bug.cgi?id=1537564).
  >
  > (Equivalent to https://github.com/bitcoin/bitcoin/pull/22417 was for boost::process)

ACKs for top commit:
  achow101:
    ACK a0eed55398f882d9390e50582b10272d18f2b836
  hebasto:
    ACK a0eed55398f882d9390e50582b10272d18f2b836, tested on Ubuntu 25.04:
  vasild:
    ACK a0eed55398f882d9390e50582b10272d18f2b836

Tree-SHA512: 7dc1cb6cc1f45ff7c4f53512e400baad1a033b4ebf14ba6f6ffa38588314932d6d01ef67b197f081e8202bb802659ac6a87998277797721d6d7b20efde8e9a6b
2025-05-14 16:13:59 -07:00
Ava Chow
4b26ca0e2f
Merge bitcoin/bitcoin#32502: wallet: Drop unused fFromMe from CWalletTx
5bf91ba8800d23402536d758f02198eac0fd7d61 wallet: Drop unused fFromMe from CWalletTx (David Gumberg)

Pull request description:

  This has been unused since commit fe52346, this is a re-opening of #9351.

ACKs for top commit:
  maflcko:
    lgtm ACK 5bf91ba8800d23402536d758f02198eac0fd7d61
  achow101:
    ACK 5bf91ba8800d23402536d758f02198eac0fd7d61

Tree-SHA512: b9a84f27b6cfe7796dcf629be6a8e01a97d931ea81ef088951d54d6691ffe79d22138baacc632375093cf3176a22c265e30a80f1f63c3bc620d08bf16f6a488f
2025-05-14 15:05:43 -07:00
Ava Chow
d5786bc19a
Merge bitcoin/bitcoin#32490: refactor: Remove UB in prevector reverse iterators
faf9082a5f689e2e51a474bf654e4e9b6ca29685 test: Fix whitespace in prevector_tests.cpp (MarcoFalke)
fa7f04c8a7b7cbb4a1728bf2c9c6c7c8408b432a refactor: Remove UB in prevector reverse iterators (MarcoFalke)

Pull request description:

  `rend()` creates a pointer with offset `-1`. This is UB, according to the C++ standard: https://eel.is/c++draft/expr.add#4:

      When an expression J that has integral type is added to [...] an
      expression P of pointer type, the result has the type of P.

      ... if P points to a (possibly-hypothetical) array element i of an
      array object x with n elements [...] the expressions P + J and J + P
      (where J has the value j) point to the (possibly-hypothetical) array
      element i+j of x if 0≤i+j≤n [...]

      Otherwise, the behavior is undefined.

  Also, it is unclear why the functions exist at all, when stdlib utils such as `std::reverse_iterator{it}` or `std::views::reverse` can be used out of the box.

  So remove them, along with the ubsan suppressions, that are no longer used.

  I've tagged this a refactor, because the code was always dead (unused outside of tests). And since commit 2925bd537cbd8c70594e23f6c4298b7101f7f73d it was completely dead. Also, I could not find a sanitizer that detects this type of UB.

ACKs for top commit:
  l0rinc:
    tested ACK faf9082a5f689e2e51a474bf654e4e9b6ca29685
  achow101:
    ACK faf9082a5f689e2e51a474bf654e4e9b6ca29685
  stickies-v:
    ACK faf9082a5f689e2e51a474bf654e4e9b6ca29685, nice find.
  theuni:
    utACK faf9082a5f689e2e51a474bf654e4e9b6ca29685

Tree-SHA512: 31511d520a1c0fdd65c2e5f1a8ef6fd17464303b6bff88a5d9d9577adfee849d431deb510882b6f4e15e8fb7168861bc0d26fca3bed4278f57a9d6e7b1235dce
2025-05-14 14:34:32 -07:00
Ava Chow
53eb5593f0
Merge bitcoin/bitcoin#32305: test: add test for decoding PSBT with MuSig2 PSBT key types (BIP 373)
4b241867567203b204823a4558c2aa5767acf028 test: add test for decoding PSBT with MuSig2 PSBT key types (BIP 373) (Sebastian Falbesoner)
8ba245cb8318c9be375ac2fb2a3e7ded875b4408 test: add constants for MuSig2 PSBT key types (BIP 373) (Sebastian Falbesoner)

Pull request description:

  This PR is a follow-up to #31247 (see https://github.com/bitcoin/bitcoin/pull/31247#pullrequestreview-2427834909) and adds a functional test for decoding PSBTs (using the `decodepsbt` RPC) with MuSig2 per-input and per-output types. The first commit adds the new MuSig2 key types to the test frameworks and extends the PSBT serialization to cope with lists of bytestrings.

ACKs for top commit:
  achow101:
    ACK 4b241867567203b204823a4558c2aa5767acf028
  rkrux:
    re-ACK 4b24186

Tree-SHA512: f12919f71b3fff74df1d7ddaa8db455b1b139f7abd51d7f3fa5d750fc7dd613454b438c4e0dedad679476d414fa1da43ef1121e486b0bdfd97d5ef8bdf37f060
2025-05-14 13:19:43 -07:00
Ava Chow
e7a9372376
Merge bitcoin/bitcoin#32378: interfaces: refactor: move Mining and BlockTemplate implementation to miner
62fc42d475df4f23bd93313f95ee7b7eb0d4683f interfaces: refactor: move `waitTipChanged` implementation to miner (ismaelsadeeq)
c39ca9d4f7bc9ca155692ac949be2e61c0598a97 interfaces: move getTip implementation to miner (Sjors Provoost)
720f201e652885b9e0aec8e62a1bf9590052b320 interfaces: refactor: move `waitNext` implementation to miner (ismaelsadeeq)
e6c2f4ce7a841153510971f0236c527d1a499649 interfaces: refactor: move `submitSolution` implementation to miner (ismaelsadeeq)
02d4bc776bbe002ee624ec2c09d7c3f981be1b17 interfaces: remove redundant coinbase fee check in `waitNext` (ismaelsadeeq)

Pull request description:

  #### Motivation

  In  [Internal interface guidelines](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#internal-interface-guidelines)

  It's stated that

  > Interface method definitions should wrap existing functionality instead of implementing new functionality. Any substantial new node or wallet functionality should be implemented in [src/node/](https://github.com/bitcoin/bitcoin/blob/master/src/node) or [src/wallet/](https://github.com/bitcoin/bitcoin/blob/master/src/wallet) and just exposed in [src/interfaces/](https://github.com/bitcoin/bitcoin/blob/master/src/interfaces) instead of being implemented there, so it can be more modular and accessible to unit tests.

  However the some methods in the newly added  `BlockTemplateImpl` and `MinerImpl`  classes partially enforces this guideline, as the implementations of the `submitSolution`, `waitNext`, and `waitTipChanged` methods reside within the class itself.

  #### What the PR Does

  This PR introduces a simple refactor by moving certain method implementations from `BlockTemplateImpl` into the miner module. It introduces three new functions:

  1.  Remove rundundant coinbase fee check in `waitNext`
  2. **`AddMerkleRootAndCoinbase`**: Computes the block's Merkle root, inserts the coinbase transaction, and sets the Merkle root in the block. This function is called by `submitSolution` before the block is submitted for processing.

  3. **`WaitAndCreateNewBlock`**: Returns a new block template either when transaction fees reach a certain threshold or when a new tip is detected. If a timeout is reached, it returns `nullptr`. The `waitNext` method in `BlockTemplateImpl` now simply wraps this function.
  4. Move `GetTip` implementation to miner.

  5. **`WaitTipChanged`**: Returns the tip when the chain it changes, or `nullopt` if a timeout or interrupt occurs. The `waitTipChanged` method in `MinerImpl` now calls `GetTip` after invoking `ChainTipChanged`, and returns the tip.

  #### Behavior Change

  - We now only `Assert` for  a valid chainman and notifications pointer once.

ACKs for top commit:
  achow101:
    ACK 62fc42d475df4f23bd93313f95ee7b7eb0d4683f
  Sjors:
    ACK 62fc42d475df4f23bd93313f95ee7b7eb0d4683f
  ryanofsky:
    Code review ACK 62fc42d475df4f23bd93313f95ee7b7eb0d4683f. Lots of suggest suggest changes made since last review, altering function names and signatures and also adding new commit to drop negative fee handling. I like the idea of making the wait function return a BlockRef, that is clearer than what I suggested. Left some comments below but they are not important and this looks good as-is

Tree-SHA512: 502632f94ced81f576b2c43cf015f1527e2c259e6ca253f670f5a6889171e2246372b4e709575701afa3f01d488d6633557fef54f48fe83bbaf1836ac5326c4f
2025-05-14 12:57:50 -07:00
David Gumberg
5bf91ba880 wallet: Drop unused fFromMe from CWalletTx
This has been unused since commit fe52346, previously attempted to be
removed in PR #9351 (https://github.com/bitcoin/bitcoin/pull/9351/)

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-05-14 11:23:22 -07:00
fanquake
3b824169c7
doc: remove Carls substitute server from Guix docs
This no-longer exists. Use one of the other Guix servers in the example.
2025-05-14 15:07:17 +01:00
Ryan Ofsky
f1d78a3087
Merge bitcoin/bitcoin#31624: doc: warn that CheckBlock() underestimates sigops
a04f17a1882407db09b0a07338e12877ac1d9e92 doc: warn that CheckBlock() underestimates sigops (Sjors Provoost)

Pull request description:

  Counting sigops in the witness requires context that `CheckBlock()`  does not have, so it only counts sigops for non-segwit transactions.

  It's useful to document, but it should not be a problem.

  The commit message contains some historical context.

ACKs for top commit:
  ismaelsadeeq:
    ACK a04f17a1882407db09b0a07338e12877ac1d9e92
  ryanofsky:
    Code review ACK a04f17a1882407db09b0a07338e12877ac1d9e92

Tree-SHA512: 26528367a7f3cfa8540ef0b90f7aa912c8f0bc057428f20a1fd1d4e232dac77747bc20044f0fcb0ffab8a2e1fb3dbe3dab46be749553a917744ddc7a829025cb
2025-05-14 10:05:41 -04:00
ismaelsadeeq
62fc42d475 interfaces: refactor: move waitTipChanged implementation to miner
- This commit creates a function `WaitTipChanged` that waits for the connected
  tip to change until timeout elapsed.

- This function is now used by `waitTipChanged`

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-05-14 13:55:12 +01:00
Sjors Provoost
c39ca9d4f7
interfaces: move getTip implementation to miner 2025-05-14 13:55:05 +01:00
merge-script
33dfbbdff6
Merge bitcoin/bitcoin#32483: test: fix two intermittent failures in wallet_basic.py
e7ad86e1ca3b0b2f2795e91c2f9959486c67dd90 test: fix another intermittent failure in wallet_basic.py (Martin Zumsande)
07350e204dedfba20da461d9cdcd469dc95e01c3 test: Fix intermittent failure in wallet_basic.py (Martin Zumsande)

Pull request description:

  Fixes two rare failures that happened in the CI:

  #27249:
  There could be a race with outstanding TxAddedToMempool notifications being applied to the soon-to-be created wallet:
  1. importdescriptors during rescan sets status to `TxStateConfirmed`
  2. old `transactionAddedToMempool` notification changes status back to  `TxStateInMempool`
  3. If the listunspent call happens here the test will fail
  4. blockConnected notification will change the status back to `TxStateConfirmed` (so it's not a persistent failure)

  I could reproduce this by adding a 100 microsecond sleep to `AddToWallet()`, the fix is to add a sync, so `transactionAddedToMempool` notifications won't affect the new wallet anymore.

  #32456:
  During init, the test framework will start using rpc after the mempool was loaded.
  It will not wait for `start()` / `postInitProcess` or outstanding `transactionAddedToMempool` notifications (which would both set the status to `TxStateInMempool`), leading to
  a possible race, in which `listunspent` can be called while the tx is still in `Inactive` status.

  Can be reproduced by adding two sleeps: To init  before calling `start()` for the chain clients, plus to `transactionAddedToMempool` in `wallet.cpp`.
  Prevent this by processing outstanding notifications.

  Fixes #27249
  Fixes #32456

ACKs for top commit:
  maflcko:
    review ACK e7ad86e1ca3b0b2f2795e91c2f9959486c67dd90 🎩

Tree-SHA512: 1f1a11e5c8e1c6d3c39a49401c2c5122befdbbec25c0451953f5bfe8dfb53221ada552a68006e266570addda12bb16c1b9b1e49ad2198c33d91c4b96b764d73e
2025-05-14 13:22:27 +01:00
merge-script
8a65f03894
Merge bitcoin/bitcoin#32488: fuzz: Properly setup wallet in wallet_fees target
fa427ffceeefd368a1ade273501ce4b01133ad4d fuzz: Properly setup wallet in wallet_fees target (MarcoFalke)

Pull request description:

  `g_wallet_ptr` is destructed after the `testing_setup`. This is not supported and will lead to issues such as https://github.com/bitcoin/bitcoin/pull/30221#issuecomment-2863875857 or https://github.com/bitcoin/bitcoin/pull/32409#issuecomment-2855259932.

  This could be fixed by fixing the initialization order.

  However, the global wallet is also modified in the fuzz target, which is bad fuzzing practise.

  So instead fix it by constructing a fresh wallet for each fuzz iteration.

ACKs for top commit:
  brunoerg:
    code review ACK fa427ffceeefd368a1ade273501ce4b01133ad4d
  hebasto:
    ACK fa427ffceeefd368a1ade273501ce4b01133ad4d, this change fixes the issue when building the "Debug" configuration with MSVC on Windows.
  marcofleon:
    Code review ACK fa427ffceeefd368a1ade273501ce4b01133ad4d

Tree-SHA512: 161b93fc39a609cb16d9ffea7366c5e339bd01712577f0782aedff46c00f79edd2a907807ac83f9fcec687b4bbbe0fd6e6f75e32169639a310e4e7b771078b3b
2025-05-14 11:36:20 +01:00
fanquake
75a185ea3d
test: add skip_if_running_under_valgrind()
Enable it in the USDT tests. The context (from 0xB10C):

> every time the tracepoint is reached a SIGTRAP is fired.
> No matter the tracepoint contents, even with an empty one.
> Valgrind intercepts SIGTRAP and aborts.

See discussion in #32374.
2025-05-14 10:55:26 +01:00
MarcoFalke
faf9082a5f
test: Fix whitespace in prevector_tests.cpp
Bitcoin Core uses 4 spaces indent, but the test was in some lines using
5 or more.

Just clang-format the whole file.
2025-05-14 09:55:27 +02:00
MarcoFalke
fa7f04c8a7
refactor: Remove UB in prevector reverse iterators
rend() creates a pointer with offset -1. This is UB, according to the
C++ standard: https://eel.is/c++draft/expr.add#4:

    When an expression J that has integral type is added to [...] an
    expression P of pointer type, the result has the type of P.

    ... if P points to a (possibly-hypothetical) array element i of an
    array object x with n elements [...] the expressions P + J and J + P
    (where J has the value j) point to the (possibly-hypothetical) array
    element i+j of x if 0≤i+j≤n [...]

    Otherwise, the behavior is undefined.

Also, it is unclear why the functions exist at all, when stdlib utils
such as std::reverse_iterator{it} or std::views::reverse can be used out
of the box.

So remove them, along with the ubsan suppressions, that are no longer
used.
2025-05-14 09:35:32 +02:00
MarcoFalke
fa427ffcee
fuzz: Properly setup wallet in wallet_fees target
Co-Authored-By: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-05-13 22:58:38 +02:00
merge-script
f9d8910539
Merge bitcoin/bitcoin#31080: fees: document non-monotonic estimation edge case
1e0de7a6ba926487c8a075856b74af2a3a0eb8ef fees: document non-monotonic estimation edge case (willcl-ark)

Pull request description:

  Closes: https://github.com/bitcoin/bitcoin/issues/11800

  In scenarios where data is available for higher targets but not for lower ones, this method *may* return lower fee rates for higher confirmation targets. This could occur if `estimateCombinedFee` returns no valid data (`-1`) for some estimates for a low target, but **does** return valid data for a higher target.

  Users of this function should be aware of this potential, if unlikely, inconsistency in behaviour in data-sparse scenarios.

ACKs for top commit:
  adamandrews1:
    Code review ACK 1e0de7a
  ismaelsadeeq:
    Code review ACK 1e0de7a6ba926487c8a075856b74af2a3a0eb8ef
  glozow:
    ACK 1e0de7a6ba926487c8a075856b74af2a3a0eb8ef

Tree-SHA512: 161e5dafdd131570853a89491753ae39a7b725d1a86cab5a7294c2a5939da1a9a5f2c4aca0900e9ad810e828b6e0e636f256384e3d1fda6dd552da189bbbe747
2025-05-13 16:49:46 -04:00
merge-script
31650b458b
Merge bitcoin/bitcoin#32386: mining: rename gbt_force and gbt_force_name
0750249289c092fc8e2e29669fec73a58b873767 mining: document gbt_rule_value helper (Sjors Provoost)
5e87c3ec094d68a7a27dfb7ae665b225ff4dfdb6 scripted-diff: rename gbt_force and gbt_force_name (Sjors Provoost)

Pull request description:

  The term "force" is ambiguous and not used in [BIP9](https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate-changes) where there ! rule prefix is introduced.

  E.g. this code is hard to read:

  ```cpp
  if (!gbt_force) {
     s.insert(s.begin(), '!');
  ```

  Additionally, #29039 renamed `gbt_vb_name` to `gbt_force_name` which, at least for me, further increased the confusion.

  This is a pure (variable rename) refactor (plus documentation) and does not change behavior.

  Reminder of how to verify a scripted diff:

  ```sh
  test/lint/commit-script-check.sh origin/master..HEAD
  ```

ACKs for top commit:
  achow101:
    ACK 0750249289c092fc8e2e29669fec73a58b873767
  janb84:
    ACK [0750249](0750249289)
  musaHaruna:
    ACK [0750249](0750249289)
  glozow:
    ACK 0750249289c092fc8e2e29669fec73a58b873767, seems sensible

Tree-SHA512: 8c88a273a3b36040f6c641843bd20579d0065b051aad4b39fc14f0d2af2808690dff6772bd8b1a4d9699b72279a700d2661012651bc315433a123dcc8996adaa
2025-05-13 16:42:49 -04:00
merge-script
bac43b957e
Merge bitcoin/bitcoin#32312: test: Fix feature_pruning test after nTime typo fix
2aa63d511affdcc9980b58fc4ff18b8ad10b0f8c test: Use uninvolved pruned node in feature_pruning undo test (enoch)
772ba7f9ce09e836a51636524a8a96a23946d658 test: Fix nTimes typo in feature_pruning test (enoch)

Pull request description:

  This PR contains two commits:

  1. Fixes a typo in feature_pruning.py where 'nTimes' was incorrectly
     used instead of 'nTime'. This typo caused the test to always reset
     mine_large_blocks.nTime to 0, rather than only on the first run.

  2. Fixes the test failure exposed by the typo fix. The
     test_pruneheight_undo_presence test was failing because it was using
     node 2, which is involved in reorg testing and could be on a
     different chain than other nodes. The solution switches to using
     node 5, which is also a pruned node but isn't involved in reorg
     testing.

  Testing:
  - Ran test/functional/feature_pruning.py multiple times to verify
    consistent passing
  - Verified that the test now passes with the correct nTime variable name
  - Confirmed the test behavior matches the intended functionality of
    verifying pruned block availability
  - Ran the full test suite to ensure the changes did not introduce any
    regressions or affect other tests

  Thanks to fjahr for his assistance in diagnosing the issue and
  suggesting the solution.

  This fixes the test failure reported in #32249

ACKs for top commit:
  fjahr:
    tACK 2aa63d511affdcc9980b58fc4ff18b8ad10b0f8c
  maflcko:
    lgtm ACK 2aa63d511affdcc9980b58fc4ff18b8ad10b0f8c
  naiyoma:
     tACK 2aa63d511affdcc9980b58fc4ff18b8ad10b0f8c
  stratospher:
    tested ACK 2aa63d5. verified that `nTime` is being incremented now.

Tree-SHA512: a543528fd4eeb30e978c0b43cfa109768252edaf1f94679dbbc7fe684122c00da34224e2cc1abd2a265af1b267eef1cd34246207946cf7d8e93d2c0f11aa56d8
2025-05-13 16:30:25 -04:00
merge-script
c9ab10910c
Merge bitcoin/bitcoin#31444: cluster mempool: add txgraph diagrams/mining/eviction
8673e8f01917b48a5f5476792f759f44ea49d5a5 txgraph: Special-case singletons in chunk index (optimization) (Pieter Wuille)
abdd9d35a34dd9cd589c1b925ab4241d15e6446c txgraph: Skipping end of cluster has no impact (optimization) (Pieter Wuille)
604acc2c289fb187f55439a29dca02d39163df25 txgraph: Reuse discarded chunkindex entries (optimization) (Pieter Wuille)
c734081454d7d7552b1388a27de648bcdd2e4b3a txgraph: Introduce TxGraph::GetWorstMainChunk (feature) (Pieter Wuille)
394dbe21427ee30cca73d2b1e31f18a00a76a1a1 txgraph: Introduce BlockBuilder interface (feature) (Pieter Wuille)
883df3648ee92841e515bb6d8d259cb7054493b1 txgraph: Generalize GetClusterRefs to support subsections (preparation) (Pieter Wuille)
c28a602e007fcc0275bc34f58690820ebe4c9162 txgraph: Introduce TxGraphImpl observer tracking (preparation) (Pieter Wuille)
9095d8ac1c319cdf1b9d44a1fa5993e9a55ccb21 txgraph: Maintain chunk index (preparation) (Pieter Wuille)
87e74e1242ece5fc30e65d4881f24be3a0d02e44 txgraph: abstract out transaction ordering (refactor) (Pieter Wuille)
2614fea17fe3c179ca3a256fadf498ae8cbc03e0 txgraph: Add GetMainStagingDiagrams function (feature) (Pieter Wuille)

Pull request description:

  Part of cluster mempool: #30289.

  This adds more functionality to the txgraph module, specifically:
  * `TxGraph::GetMainStagingDiagrams()`, a function to obtain feerate diagrams for both the main graph and the staged changes to it, including only the clusters that differ between the two.
  * `TxGraph::GetBlockBuilder()`, a function to obtain an object which can efficiently iterate the chunks of the (main) graph from high to low chunk feerate, allowing each to be skipped or included.
  * `TxGraph::GetWorstMainChunk()`, a function to obtain the last chunk that would be returned by `GetBlockBuilder()`'s returned object, intended for eviction.

ACKs for top commit:
  monlovesmango:
    reACK 8673e8f01917b48a5f5476792f759f44ea49d5a5
  instagibbs:
    reACK 8673e8f01917b48a5f5476792f759f44ea49d5a5
  glozow:
    reACK 8673e8f0191

Tree-SHA512: 5c98c54919c44eb2f9545dfc130e54dfc25b5b54d43cf5ca9bcf46e019b9fd405a572fcd70e71e2a7c5b4b096cfd540a4d09ef1f52ba188504418682f1dfc4af
2025-05-13 16:27:30 -04:00
Martin Zumsande
e7ad86e1ca test: fix another intermittent failure in wallet_basic.py
During init, the test framework will start using rpc after the
mempool was loaded. It will not wait for postInitProcess or
outstanding transactionAddedToMempool notifications, leading to
a possible race, in which listunspent is being called while the
tx is still in Inactive status. Prevent this by processing
outstanding notifications.
2025-05-13 13:09:33 -04:00
Martin Zumsande
07350e204d test: Fix intermittent failure in wallet_basic.py
There could be a race with outstanding TxAddedToMempool notifications
being applied to the soon-to-be created wallet.

Fixes an intermittent timeout reproducable by adding a sleep to
AddToWallet.
2025-05-13 13:09:25 -04:00
merge-script
8309a9747a
Merge bitcoin/bitcoin#32028: Update secp256k1 subtree to latest master
c31fcaaad38b68fa170cf9fd900f2237c24016e3 Squashed 'src/secp256k1/' changes from 0cdc758a56..4187a46649 (Hennadii Stepanov)

Pull request description:

  This PR updates the `secp256k1` subtree to 4ba1ba2af9, which includes the following changes:
  - https://github.com/bitcoin-core/secp256k1/pull/1633
  - https://github.com/bitcoin-core/secp256k1/pull/1634
  - https://github.com/bitcoin-core/secp256k1/pull/1641
  - https://github.com/bitcoin-core/secp256k1/pull/1650
  - https://github.com/bitcoin-core/secp256k1/pull/1646
  - https://github.com/bitcoin-core/secp256k1/pull/1654
  - https://github.com/bitcoin-core/secp256k1/pull/1642
  - https://github.com/bitcoin-core/secp256k1/pull/1639
  - https://github.com/bitcoin-core/secp256k1/pull/1614
  - https://github.com/bitcoin-core/secp256k1/pull/1656
  - https://github.com/bitcoin-core/secp256k1/pull/1647
  - https://github.com/bitcoin-core/secp256k1/pull/1655
  - https://github.com/bitcoin-core/secp256k1/pull/1593
  - https://github.com/bitcoin-core/secp256k1/pull/1359
  - https://github.com/bitcoin-core/secp256k1/pull/1657
  - https://github.com/bitcoin-core/secp256k1/pull/1660
  - https://github.com/bitcoin-core/secp256k1/pull/1659
  - https://github.com/bitcoin-core/secp256k1/pull/1661
  - https://github.com/bitcoin-core/secp256k1/pull/1662
  - https://github.com/bitcoin-core/secp256k1/pull/1669
  - https://github.com/bitcoin-core/secp256k1/pull/1492

  https://github.com/bitcoin-core/secp256k1/pull/1647 is required for https://github.com/bitcoin/bitcoin/pull/31507.

ACKs for top commit:
  fanquake:
    ACK 915c1fa72c07a1908f7dc18a065230c7c4a64db2

Tree-SHA512: 2c409ef2cd14fb14c2ea108f65411b673da786e886aabf75015be25220d5a3983ad8d9e76db1cb95453357a07fbaf05497ef4e5bb83d92b96caf62c1cddaa616
2025-05-13 16:39:22 +01:00
ismaelsadeeq
720f201e65 interfaces: refactor: move waitNext implementation to miner
- We now assert for a valid chainman and notifications once when
 invoking WaitAndCreateNewBlock function.
2025-05-13 16:22:56 +01:00
ismaelsadeeq
e6c2f4ce7a interfaces: refactor: move submitSolution implementation to miner
- Create a new function `AddMerkleRootAndCoinbase` that compute the
  block's merkle root, insert the coinbase transaction and the merkle
  root into the block.
2025-05-13 16:22:56 +01:00
ismaelsadeeq
02d4bc776b interfaces: remove redundant coinbase fee check in waitNext
- vTxFees now does not include the negative coinbase fee,
  hence this check can be removed.
2025-05-13 16:22:56 +01:00
merge-script
cbd8e3d511
Merge bitcoin/bitcoin#32476: refactor: Remove unused HaveKey and HaveWatchOnly
fabdc5ad06bce8cd3b0e525071d10f616a30bb04 Remove unused LegacyDataSPKM::HaveWatchOnly() (MarcoFalke)
fa7b7f796ac8cd99de19722af68a570b49f37939 Remove HaveKey helper, unused after sethdseed removal (MarcoFalke)

Pull request description:

  removes some dead code

ACKs for top commit:
  Sjors:
    utACK fabdc5ad06bce8cd3b0e525071d10f616a30bb04

Tree-SHA512: 3cf6838eff6cedfe6a7337071d41e17d34033a2875b3661a6a1741e13c7a8e81b57eb874aebbb9d96d05ea7efa261a3a98e1bcf982b12cfafb163405d860b8bf
2025-05-13 12:34:36 +01:00
Hennadii Stepanov
915c1fa72c
Update secp256k1 subtree to latest master 2025-05-13 11:31:34 +01:00
Hennadii Stepanov
c31fcaaad3 Squashed 'src/secp256k1/' changes from 0cdc758a56..4187a46649
4187a46649 Merge bitcoin-core/secp256k1#1492: tests: Add Wycheproof ECDH vectors
e266ba11ae tests: Add Wycheproof ECDH vectors
13906b7154 Merge bitcoin-core/secp256k1#1669: gitignore: Add Python cache files
c1bcb03276 gitignore: Add Python cache files
70f149b9a1 Merge bitcoin-core/secp256k1#1662: bench: add ellswift to bench help output
6b3fe51fb6 bench: add ellswift to bench help output
d84bb83e26 Merge bitcoin-core/secp256k1#1661: configure: Show exhaustive tests in summary
3f54ed8c1b Merge bitcoin-core/secp256k1#1659: include: remove WARN_UNUSED_RESULT for functions always returning 1
20b05c9d3f configure: Show exhaustive tests in summary
e56716a3bc Merge bitcoin-core/secp256k1#1660: ci: Fix exiting from ci.sh on error
d87c3bc58f ci: Fix exiting from ci.sh on error
1b6e081538 include: remove WARN_UNUSED_RESULT for functions always returning 1
2abb35b034 Merge bitcoin-core/secp256k1#1657: tests: remove unused uncounting_illegal_callback_fn
51907fa918 tests: remove unused uncounting_illegal_callback_fn
a7a5117144 Merge bitcoin-core/secp256k1#1359: Fix symbol visibility issues, add test for it
13ed6f65dc Merge bitcoin-core/secp256k1#1593: Remove deprecated `_ec_privkey_{negate,tweak_add,tweak_mul}` aliases from API
d1478763a5 build: Drop no longer needed  `-fvisibility=hidden` compiler option
8ed1d83d92 ci: Run `tools/symbol-check.py`
41d32ab2de test: Add `tools/symbol-check.py`
88548058b3 Introduce `SECP256K1_LOCAL_VAR` macro
03bbe8c615 Merge bitcoin-core/secp256k1#1655: gha: Print all *.log files, in a separate action
59860bcc24 gha: Print all *.log files, in a separate action
4ba1ba2af9 Merge bitcoin-core/secp256k1#1647: cmake: Adjust diagnostic flags for `clang-cl`
abd25054a1 Merge bitcoin-core/secp256k1#1656: musig: Fix clearing of pubnonces
961ec25a83 musig: Fix clearing of pubnonces
3186082387 Merge bitcoin-core/secp256k1#1614: Add _ge_set_all_gej and use it in musig for own public nonces
6c2a39dafb Merge bitcoin-core/secp256k1#1639: Make static context const
37d2c60bec Remove deprecated _ec_privkey_{negate,tweak_add,tweak_mul} aliases
432ac57705 Make static context const
1b1fc09341 Merge bitcoin-core/secp256k1#1642: Verify `compressed` argument in `secp256k1_eckey_pubkey_serialize`
c0d9480fbb Merge bitcoin-core/secp256k1#1654: use `EXIT_` constants over magic numbers for indicating program execution status
13d389629a CONTRIBUTING: mention that `EXIT_` codes should be used
c855581728 test, bench, precompute_ecmult: use `EXIT_...` constants for `main` return values
965393fcea examples: use `EXIT_...` constants for `main` return values
2e3bf13653 Merge bitcoin-core/secp256k1#1646: README: add instructions for verifying GPG signatures
b682dbcf84 README: add instructions for verifying GPG signatures
00774d0723 Merge bitcoin-core/secp256k1#1650: schnorrsig: clear out masked secret key in BIP-340 nonce function
a82287fb85 schnorrsig: clear out masked secret key in BIP-340 nonce function
4c50d73dd9 ci: Add new "Windows (clang-cl)" job
84c0bd1f72 cmake: Adjust diagnostic flags for clang-cl
f79f46c703 Merge bitcoin-core/secp256k1#1641: doc: Improve cmake instructions in README
2ac9f558c4 doc: Improve cmake instructions in README
1823594761 Verify `compressed` argument in `secp256k1_eckey_pubkey_serialize`
8deef00b33 Merge bitcoin-core/secp256k1#1634: Fix some misspellings
39705450eb Fix some misspellings
ec329c2501 Merge bitcoin-core/secp256k1#1633: release cleanup: bump version after 0.6.0
c97059f594 release cleanup: bump version after 0.6.0
64228a648f musig: Use _ge_set_all_gej for own public nonces
300aab1c05 tests: Improve _ge_set_all_gej(_var) tests
365f274ce3 group: Simplify secp256k1_ge_set_all_gej
d3082ddead group: Add constant-time secp256k1_ge_set_all_gej

git-subtree-dir: src/secp256k1
git-subtree-split: 4187a4664914dc6f6fb6a619c6b85c854fc33033
2025-05-13 11:31:34 +01:00
MarcoFalke
fabdc5ad06
Remove unused LegacyDataSPKM::HaveWatchOnly() 2025-05-13 09:31:25 +02:00
MarcoFalke
fa7b7f796a
Remove HaveKey helper, unused after sethdseed removal 2025-05-13 09:31:07 +02:00
Pieter Wuille
8673e8f019 txgraph: Special-case singletons in chunk index (optimization) 2025-05-12 17:07:30 -04:00
Pieter Wuille
abdd9d35a3 txgraph: Skipping end of cluster has no impact (optimization) 2025-05-12 17:07:30 -04:00
Pieter Wuille
604acc2c28 txgraph: Reuse discarded chunkindex entries (optimization) 2025-05-12 17:07:30 -04:00
Pieter Wuille
c734081454 txgraph: Introduce TxGraph::GetWorstMainChunk (feature)
It returns the last chunk that would be suggested for mining by BlockBuilder
objects. This is intended for eviction.
2025-05-12 17:07:30 -04:00
Pieter Wuille
394dbe2142 txgraph: Introduce BlockBuilder interface (feature)
This interface lets one iterate efficiently over the chunks of the main
graph in a TxGraph, in the same order as CompareMainOrder. Each chunk
can be marked as "included" or "skipped" (and in the latter case,
dependent chunks will be skipped).
2025-05-12 17:07:30 -04:00
Pieter Wuille
883df3648e txgraph: Generalize GetClusterRefs to support subsections (preparation)
This is preparation for a next commit which will need a way to extract Refs
for just individual chunks from a cluster.
2025-05-12 17:07:30 -04:00
Pieter Wuille
c28a602e00 txgraph: Introduce TxGraphImpl observer tracking (preparation)
This is preparation for a next commit which will introduce a class whose
objects hold references to internals in TxGraphImpl, which disallows
modifications to the graph while such objects exist.
2025-05-12 17:07:30 -04:00
Pieter Wuille
9095d8ac1c txgraph: Maintain chunk index (preparation)
This is preparation for exposing mining and eviction functionality in
TxGraph.
2025-05-12 17:07:28 -04:00
Pieter Wuille
87e74e1242 txgraph: abstract out transaction ordering (refactor) 2025-05-12 17:00:33 -04:00
Pieter Wuille
2614fea17f txgraph: Add GetMainStagingDiagrams function (feature)
This allows determining whether the changes in a staging diagram unambiguously improve
the graph, through CompareChunks().
2025-05-12 16:00:24 -04:00