Commit Graph

29460 Commits

Author SHA1 Message Date
Fibonacci747
2909655fba fix: remove redundant mempool lock in ChainImpl::isInMempool() 2025-11-25 20:22:39 +01:00
Anthony Towns
ade0397f59 txgraph: drop move assignment operator 2025-11-25 07:36:50 -05:00
merge-script
5336bcd578 Merge bitcoin/bitcoin#33855: kernel: add btck_block_tree_entry_equals
096924d39d kernel: add btck_block_tree_entry_equals (stickies-v)

Pull request description:

  `BlockTreeEntry` objects are often compared. This happens frequently in our own codebase and seems likely to be the case for clients, too. Users can already work around this by comparing based on block hash (and optionally height as belt-and-suspenders), but I think this should be part of the interface for performance and consistency reasons.

  Note: perhaps this is too ad-hoc, and we should extend this PR to add the operator for more types? `BlockTreeEntry` is the main one I've needed this for in developing `py-bitcoinkernel`, though.

ACKs for top commit:
  maflcko:
    review ACK 096924d39d 📓
  TheCharlatan:
    ACK 096924d39d
  yuvicc:
    Code Review ACK 096924d39d

Tree-SHA512: a0c08c01ab6c855aec4e2b2b898e9550493cd4cf8c6e1fe9e4fe5039d0d9ef3bffb2f2ab0454c7cc449b9deedd7889f5fd7b5f100fa706a855023af4adb803c6
2025-11-25 12:31:17 +00:00
merge-script
4f65a1c5db Merge bitcoin/bitcoin#33917: clang-format: Set Bitcoin Core IncludeCategories
fa7e222a23 clang-format: Set Bitcoin Core IncludeCategories (MarcoFalke)

Pull request description:

  Replace the default llvm include categories with the ones specific to Bitcoin Core.

  Ref: https://releases.llvm.org/17.0.1/tools/clang/docs/ClangFormatStyleOptions.html#includecategories

  Also, format a file as example. To test this, the diff in src/test needs
  to be reverted. Also `IncludeBlocks: Regroup` needs to be set. Then
  `clang-format -i src/test/blockchain_tests.cpp` should recreate the
  diff.

  ```diff
  diff --git a/src/.clang-format b/src/.clang-format
  index 15335fe9ae..579079095f 100644
  --- a/src/.clang-format
  +++ b/src/.clang-format
  @@ -99,3 +99,3 @@ IfMacros:
     - KJ_IF_MAYBE
  -IncludeBlocks:   Preserve
  +IncludeBlocks:   Regroup
   IncludeCategories:
  ```

ACKs for top commit:
  l0rinc:
    ACK fa7e222a23

Tree-SHA512: f500060858898c48f709e8fecfe4c41fc05645e2ff3b1504cc82ce354129642dd658a2311fd038363068ed682d016c32b56d935783c8084591ac5152b413fa2c
2025-11-25 12:24:26 +00:00
merge-script
fa283d28e2 Merge bitcoin/bitcoin#33629: Cluster mempool
17cf9ff7ef Use cluster size limit for -maxmempool bound, and allow -maxmempool=0 in general (Suhas Daftuar)
315e43e5d8 Sanity check `GetFeerateDiagram()` in CTxMemPool::check() (Suhas Daftuar)
de2e9a24c4 test: extend package rbf functional test to larger clusters (Suhas Daftuar)
4ef4ddb504 doc: update policy/packages.md for new package acceptance logic (Suhas Daftuar)
79f73ad713 Add check that GetSortedScoreWithTopology() agrees with CompareMiningScoreWithTopology() (Suhas Daftuar)
a86ac11768 Update comments for CTxMemPool class (Suhas Daftuar)
9567eaa66d Invoke TxGraph::DoWork() at appropriate times (Suhas Daftuar)
6c5c44f774 test: add functional test for new cluster mempool RPCs (Suhas Daftuar)
72f60c877e doc: Update mempool_replacements.md to reflect feerate diagram checks (Suhas Daftuar)
21693f031a Expose cluster information via rpc (Suhas Daftuar)
72e74e0d42 fuzz: try to add more code coverage for mempool fuzzing (Suhas Daftuar)
f107417490 bench: add more mempool benchmarks (Suhas Daftuar)
7976eb1ae7 Avoid violating mempool policy limits in tests (Suhas Daftuar)
84de685cf7 Stop tracking parents/children outside of txgraph (Suhas Daftuar)
88672e205b Rewrite GatherClusters to use the txgraph implementation (Suhas Daftuar)
1ca4f01090 Fix miniminer_tests to work with cluster limits (Suhas Daftuar)
1902111e0f Eliminate CheckPackageLimits, which no longer does anything (Suhas Daftuar)
3a646ec462 Rework RBF and TRUC validation (Suhas Daftuar)
19b8479868 Make getting parents/children a function of the mempool, not a mempool entry (Suhas Daftuar)
5560913e51 Rework truc_policy to use descendants, not children (Suhas Daftuar)
a4458d6c40 Use txgraph to calculate descendants (Suhas Daftuar)
c8b6f70d64 Use txgraph to calculate ancestors (Suhas Daftuar)
241a3e666b Simplify ancestor calculation functions (Suhas Daftuar)
b9cec7f0a1 Make removeConflicts private (Suhas Daftuar)
0402e6c780 Remove unused limits from CalculateMemPoolAncestors (Suhas Daftuar)
08be765ac2 Remove mempool logic designed to maintain ancestor/descendant state (Suhas Daftuar)
fc4e3e6bc1 Remove unused members from CTxMemPoolEntry (Suhas Daftuar)
ff3b398d12 mempool: eliminate accessors to mempool entry ancestor/descendant cached state (Suhas Daftuar)
b9a2039f51 Eliminate use of cached ancestor data in miniminer_tests and truc_policy (Suhas Daftuar)
ba09fc9774 mempool: Remove unused function CalculateDescendantMaximum (Suhas Daftuar)
8e49477e86 wallet: Replace max descendant count with cluster_count (Suhas Daftuar)
e031085fd4 Eliminate Single-Conflict RBF Carve Out (Suhas Daftuar)
cf3ab8e1d0 Stop enforcing descendant size/count limits (Suhas Daftuar)
89ae38f489 test: remove rbf carveout test from mempool_limit.py (Suhas Daftuar)
c0bd04d18f Calculate descendant information for mempool RPC output on-the-fly (Suhas Daftuar)
bdcefb8a8b Use mempool/txgraph to determine if a tx has descendants (Suhas Daftuar)
69e1eaa6ed Add test case for cluster size limits to TRUC logic (Suhas Daftuar)
9cda64b86c Stop enforcing ancestor size/count limits (Suhas Daftuar)
1f93227a84 Remove dependency on cached ancestor data in mini-miner (Suhas Daftuar)
9fbe0a4ac2 rpc: Calculate ancestor data from scratch for mempool rpc calls (Suhas Daftuar)
7961496dda Reimplement GetTransactionAncestry() to not rely on cached data (Suhas Daftuar)
feceaa42e8 Remove CTxMemPool::GetSortedDepthAndScore (Suhas Daftuar)
21b5cea588 Use cluster linearization for transaction relay sort order (Suhas Daftuar)
6445aa7d97 Remove the ancestor and descendant indices from the mempool (Suhas Daftuar)
216e693729 Implement new RBF logic for cluster mempool (Suhas Daftuar)
ff8f115dec policy: Remove CPFP carveout rule (Suhas Daftuar)
c3f1afc934 test: rewrite PopulateMempool to not violate mempool policy (cluster size) limits (Suhas Daftuar)
47ab32fdb1 Select transactions for blocks based on chunk feerate (Suhas Daftuar)
dec138d1dd fuzz: remove comparison between mini_miner block construction and miner (Suhas Daftuar)
6c2bceb200 bench: rewrite ComplexMemPool to not create oversized clusters (Suhas Daftuar)
1ad4590f63 Limit mempool size based on chunk feerate (Suhas Daftuar)
b11c89cab2 Rework miner_tests to not require large cluster limit (Suhas Daftuar)
95a8297d48 Check cluster limits when using -walletrejectlongchains (Suhas Daftuar)
95762e6759 Do not allow mempool clusters to exceed configured limits (Suhas Daftuar)
edb3e7cdf6 [test] rework/delete feature_rbf tests requiring large clusters (glozow)
435fd56711 test: update feature_rbf.py replacement test (Suhas Daftuar)
34e32985e8 Add new (unused) limits for cluster size/count (Suhas Daftuar)
838d7e3553 Add transactions to txgraph, but without cluster dependencies (Suhas Daftuar)
d5ed9cb3eb Add accessor for sigops-adjusted weight (Suhas Daftuar)
1bf3b51396 Add sigops adjusted weight calculator (Suhas Daftuar)
c18c68a950 Create a txgraph inside CTxMemPool (Suhas Daftuar)
29a94d5b2f Make CTxMemPoolEntry derive from TxGraph::Ref (Suhas Daftuar)
92b0079fe3 Allow moving CTxMemPoolEntry objects, disallow copying (Suhas Daftuar)
6c73e47448 mempool: Store iterators into mapTx in mapNextTx (Suhas Daftuar)
51430680ec Allow moving an Epoch::Marker (Suhas Daftuar)

Pull request description:

  [Reopening #28676 here as a new PR, because GitHub is slow to load the page making it hard to scroll through and see comments.  Also, that PR was originally opened with a prototype implementation which has changed significantly with the introduction of `TxGraph`.]

  This is an implementation of the [cluster mempool proposal](https://delvingbitcoin.org/t/an-overview-of-the-cluster-mempool-proposal/393).

  This branch implements the following observable behavior changes:

   - Maintains a partitioning of the mempool into connected clusters (via the `txgraph` class), which are limited in vsize to 101 kvB by default, and limited in count to 64 by default.
   - Each cluster is sorted ("linearized") to try to optimize for selecting highest-feerate-subsets of a cluster first
   - Transaction selection for mining is updated to use the cluster linearizations, selecting highest feerate "chunks" first for inclusion in a block template.
   - Mempool eviction is updated to use the cluster linearizations, selecting lowest feerate "chunks" first for removal.
   - The RBF rules are updated to: (a) drop the requirement that no new inputs are introduced; (b) change the feerate requirement to instead check that the feerate diagram of the mempool will strictly improve; (c) replace the direct conflicts limit with a directly-conflicting-clusters limit.
   - The CPFP carveout rule is eliminated (it doesn't make sense in a cluster-limited mempool)
   - The ancestor and descendant limits are no longer enforced.
   - New cluster count/cluster vsize limits are now enforced instead.
   - Transaction relay now uses chunk feerate comparisons to determine the order that newly received transactions are announced to peers.

  Additionally, the cached ancestor and descendant data are dropped from the mempool, along with the multi_index indices that were maintained to sort the mempool by ancestor and descendant feerates. For compatibility (eg with wallet behavior or RPCs exposing this), this information is now calculated dynamically instead.

ACKs for top commit:
  instagibbs:
    reACK 17cf9ff7ef
  glozow:
    reACK 17cf9ff7ef
  sipa:
    ACK 17cf9ff7ef

Tree-SHA512: bbde46d913d56f8d9c0426cb0a6c4fa80b01b0a4c2299500769921f886082fb4f51f1694e0ee1bc318c52e1976d7ebed8134a64eda0b8044f3a708c04938eee7
2025-11-25 10:35:11 +00:00
Hennadii Stepanov
238c1c8933 Merge bitcoin-core/gui#914: Revert "gui, qt: brintToFront workaround for Wayland"
0672e727bf Revert "gui, qt: brintToFront workaround for Wayland" (Hennadii Stepanov)

Pull request description:

  This PR reverts a Wayland-specific workaround introduced in https://github.com/bitcoin-core/gui/pull/831, which appears to break the UI, as reported in:
  - https://github.com/bitcoin/bitcoin/issues/33432
  - https://github.com/bitcoin-core/gui/pull/903

  An alternative to https://github.com/bitcoin-core/gui/pull/904, as suggested in https://github.com/bitcoin-core/gui/pull/904#discussion_r2435752838.

  Fixes https://github.com/bitcoin-core/gui/pull/903.-

ACKs for top commit:
  maflcko:
    review ACK 0672e727bf 🎩

Tree-SHA512: 3c2fba4a601de82b8c73553d54e93d133f9f474ee1f55a77320c0fc198735b68559859f7efeb125aa5282b8334bfa09f3927d6d7c984d2f87f54fa1ca45ee60e
2025-11-24 15:22:54 +00:00
Suhas Daftuar
17cf9ff7ef Use cluster size limit for -maxmempool bound, and allow -maxmempool=0 in general
Previously we would sanity check the -maxmempool configuration based on a
multiple of the descendant size limit, but with cluster mempool the maximum
evicted size is now the cluster size limit, so use that instead.

Also allow -maxmempool=0 in general (and not just if
-limitdescendantsize/-limitclustersize is set to 0).
2025-11-21 22:02:07 -05:00
Suhas Daftuar
315e43e5d8 Sanity check GetFeerateDiagram() in CTxMemPool::check() 2025-11-21 22:02:07 -05:00
Suhas Daftuar
79f73ad713 Add check that GetSortedScoreWithTopology() agrees with CompareMiningScoreWithTopology()
We use CompareMiningScoreWithTopology() for sorting transaction announcements
during tx relay, and we use GetSortedScoreWithTopology() in
CTxMemPool::check().
2025-11-21 22:02:07 -05:00
Suhas Daftuar
a86ac11768 Update comments for CTxMemPool class 2025-11-21 22:02:07 -05:00
Suhas Daftuar
9567eaa66d Invoke TxGraph::DoWork() at appropriate times 2025-11-21 19:31:58 -05:00
Ava Chow
0690514d4f Merge bitcoin/bitcoin#33770: init: Require explicit -asmap filename
288b8c30be doc: Drop (default: none) from -i2psam description (Ryan Ofsky)
f6ec3519a3 init: Require explicit -asmap filename (Ryan Ofsky)

Pull request description:

  Currently, if `-asmap` is specified without a filename bitcoind tries to load `ip_asn.map` data file.

  This change now requires `-asmap=ip_asn.map` or another filename to be specified explicitly.

  The change is intended to make behavior of the option explicit and avoid confusion reported https://github.com/bitcoin/bitcoin/issues/33386 where documentation specifies a default file which is not actually loaded by default. It was originally implemented in
  https://github.com/bitcoin/bitcoin/pull/33631#issuecomment-3410302383 and various alternatives are discussed there.

ACKs for top commit:
  brunoerg:
    reACK 288b8c30be
  fjahr:
    re-ACK 288b8c30be
  vostrnad:
    utACK 288b8c30be
  achow101:
    ACK 288b8c30be

Tree-SHA512: 11a38a03892a58d6ccc1505cfbf915f58a86df9891761d89dc54b92d40593ee3cbb2d7c7bdbb922b871b3529072ef7f34cc98393aff6e8f0633b56352315b27c
2025-11-21 15:28:36 -08:00
Hennadii Stepanov
0672e727bf Revert "gui, qt: brintToFront workaround for Wayland"
This reverts commit 15aa7d0236.
2025-11-21 12:38:03 +00:00
Hennadii Stepanov
17072f7005 Merge bitcoin/bitcoin#33912: clang-format: Set PackConstructorInitializers: CurrentLine
fad0c76d0a clang-format: Set PackConstructorInitializers: CurrentLine (MarcoFalke)

Pull request description:

  Now that the minimum supported clang version is larger than 14, the `PackConstructorInitializers` setting can be set to `CurrentLine` in the clang-format file. (This option was added in clang 14. Ref: https://releases.llvm.org/17.0.1/tools/clang/docs/ClangFormatStyleOptions.html#packconstructorinitializers)

  The `CurrentLine` option will either put all constructor initializers on the current line if they fit. Otherwise, it will put each one on its own line.

  The `CurrentLine` option is desirable over the current `BinPack` option, because:

  * It is what the majority of the codebase is currently using.
  * It makes it easier to skim the lines to ensure all fields are properly initialized, without having to parse bin-packed constructor initializers, possibly with nested initializer lists, function calls, or ternary operators.
  * It makes diffs smaller when an initializer is added or removed, because only a single line is touched. Otherwise, the whole bin-packed block could re-flow, making the diff harder to parse.

  Note: The previous `BinPack` option allows any formatting, due to the current `ColumnLimit: 0`. I presume developers manually formatted most constructor initializers to be on separate lines? With the new `CurrentLine` setting, one has to only put the first initializer on a separate line, and clang-format will take care of the rest.

  For example:

  ```sh
  echo 'A::A(O o)
  : m_first{o.a, o.b},
    m_second{fun(o)}, m_third{o.c?o.d:o.e} {}' | clang-format --style=file:./src/.clang-format
  ```

  Will put each on a separate line. Previously, it was left as-is.

ACKs for top commit:
  l0rinc:
    ACK fad0c76d0a
  TheCharlatan:
    ACK fad0c76d0a
  hebasto:
    ACK fad0c76d0a.

Tree-SHA512: f26a0980ecfa01b2a5279561e3df316c10241f8e67830034d493d70a6d0baae8831498233e8986cfa8f3b434cb9bc1e7e525b3d4587dca66b2d609ddae522a88
2025-11-20 21:48:10 +00:00
MarcoFalke
fa7e222a23 clang-format: Set Bitcoin Core IncludeCategories
Replace the default llvm include categories with the ones specific to
Bitcoin Core.
2025-11-20 19:50:52 +01:00
merge-script
ac71df4338 Merge bitcoin/bitcoin#33870: refactor: remove incorrect lifetimebounds
99d012ec80 refactor: return reference instead of pointer (Andrew Toth)
f743e6c5dd refactor: add missing LIFETIMEBOUND annotation for parameter (Andrew Toth)
141117f5e8 refactor: remove incorrect LIFETIMEBOUND annotations (Andrew Toth)

Pull request description:

  The [developer-notes say](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#lifetimebound):

  > You can use the attribute by adding a `LIFETIMEBOUND`
  annotation defined in `src/attributes.h`; please grep the codebase for examples.

  While grepping, I found an incorrect usage of the `LIFETIMEBOUND` annotation on `BlockManager::CheckBlockDataAvailability`. This could be misleading about usage for other greppers. As I was looking, I also noticed a missing `LIFETIMEBOUND` on `BlockManager::GetFirstBlock`. While looking more closely at that method, it should return a reference instead of a pointer. The only reason to return a pointer is if it can be null.

ACKs for top commit:
  maflcko:
    review ACK 99d012ec80 💧
  l0rinc:
    ACK 99d012ec80
  stickies-v:
    ACK 99d012ec80
  optout21:
    ACK 99d012ec80
  vasild:
    ACK 99d012ec80

Tree-SHA512: d6c56ee223d6614d52ee6cf5cd66e787125c98c6ae37705a17e51a6e15774e260ac55b3d60f2fc818132e766ad98dd94232d6c8829119f628498e9d0d2bd977f
2025-11-20 17:27:45 +00:00
MarcoFalke
fad0c76d0a clang-format: Set PackConstructorInitializers: CurrentLine 2025-11-20 10:42:10 +01:00
Ava Chow
1af46cff94 Merge bitcoin/bitcoin#33896: clang-format: Set InsertNewlineAtEOF: true
fa1bf6818f clang-format: Set InsertNewlineAtEOF: true (MarcoFalke)

Pull request description:

  Now that the minimum supported clang version is 17, the `InsertNewlineAtEOF` setting can be set to `true` in the clang-format file. (https://releases.llvm.org/16.0.0/tools/clang/docs/ClangFormatStyleOptions.html#insertnewlineateof)

  This is in line with the already existing newline linter. Can be tested via:

  ```
  truncate --size=-1 src/init.cpp
  git diff

  # Should fail:
  cargo run --manifest-path ./test/lint/test_runner/Cargo.toml -- --lint=trailing_newline

  # Restore newline:
  git diff -U0 | ./contrib/devtools/clang-format-diff.py -p1 -i -v
  ```

ACKs for top commit:
  l0rinc:
    ACK fa1bf6818f
  achow101:
    ACK fa1bf6818f
  hodlinator:
    ACK fa1bf6818f
  stickies-v:
    ACK fa1bf6818f
  hebasto:
    ACK fa1bf6818f.
  janb84:
    ACK fa1bf6818f

Tree-SHA512: 6443f0f9e2710fb31c85e4ece5deb9fa25bf22ef2d5cadad2d54a239194860c3a785ffa5dd97be942e42139336575425499f085aa2e3f29003e529fdc20fce20
2025-11-19 16:23:07 -08:00
Ava Chow
27ac11ea0a Merge bitcoin/bitcoin#33867: kernel: handle null or empty directories in implementation
6657bcbdb4 kernel: allow null data_directory (stickies-v)

Pull request description:

  An empty path may be represented with a `nullptr`. For example, `std::string_view{}.data()` may return nullptr.

  Removes the `BITCOINKERNEL_ARG_NONNULL` attribute for `btck_chainstate_manager_options_create` 's `data_directory` parameter, and instead handles such null arguments in the implementation. [Because an empty path is meaningless](https://github.com/bitcoin/bitcoin/pull/33867#discussion_r2523930442), `btck_chainstate_manager_options_create` now treats both null and empty directories as invalid, tightening the interface.

  Also documents how `BITCOINKERNEL_ARG_NONNULL` should be used.

  Follow-up to https://github.com/bitcoin/bitcoin/pull/33853#pullrequestreview-3454620265

ACKs for top commit:
  stringintech:
    ACK 6657bcb
  maflcko:
    review ACK 6657bcbdb4 🐪
  achow101:
    ACK 6657bcbdb4
  TheCharlatan:
    ACK 6657bcbdb4
  janb84:
    ACK 6657bcbdb4

Tree-SHA512: 11c02b221ff19a5357e94355808e3b503b3a336c16fc5186c9c9137931709e880383ed1f4990fc4cc6b0e23961e2e1e03fc90154a3b546b9490ef66bd63688b7
2025-11-19 16:22:01 -08:00
Ryan Ofsky
288b8c30be doc: Drop (default: none) from -i2psam description
Suggested by Vojtěch Strnad (vostrnad)
https://github.com/bitcoin/bitcoin/pull/33770#discussion_r2529117675
2025-11-19 09:08:24 -05:00
merge-script
509dc91db1 Merge bitcoin/bitcoin#33026: test, refactor: Embedded ASMap [1/3]: Selected minor preparatory work
7f318e1dd0 test: Add better coverage for Autofile size() (Fabian Jahr)
b7af960eb8 refactor: Add AutoFile::size (Fabian Jahr)
ec0f75862e refactor: Modernize logging in util/asmap.cpp (Fabian Jahr)
606a251e0a tests: add unit test vectors for asmap interpreter (Pieter Wuille)

Pull request description:

  This contains some commits from #28792 that can be easily reviewed and merged independently. I hope splitting this change off can make this part move a bit faster and reduce frequency of needed rebases for #28792.

  The commits in order:
  - Add additional unit test vectors to the asmap interpreter (written by sipa). This helps to ensure that the further refactors in #28792 don't change behavior.
  - Modernizes the logging in `util/asmap.cpp`, I added this while touching the rest of the file all over anyway.
  - Adds an `AutoFile::size` helper function with some additional test coverage in a separate commit

ACKs for top commit:
  maflcko:
    review ACK 7f318e1dd0 🏀
  hodlinator:
    tACK 7f318e1dd0
  laanwj:
    Code review ACK 7f318e1dd0

Tree-SHA512: 45156b74e4bd9278a7ec24521dfdafe4dab1ba3384243c7d589ef17e16ca374ee2af7178c86b7229e80ca262dbe78c4d456d80a6ee742ec31d2ab5243dac8b57
2025-11-19 09:28:44 +00:00
Hennadii Stepanov
b126f98194 Merge bitcoin-core/gui#910: Added test coverage for qt gui#901 console history filter
310e4979b3 qt: Added test coverage for qt gui#901 console history filter (WakeTrainDev)

Pull request description:

  Add test coverage for the QT rpc console updated filtered commands in gui#901

ACKs for top commit:
  pablomartin4btc:
    ACK 310e4979b3
  hebasto:
    ACK 310e4979b3, tested on Fedora 42 by reverting 4e352efa2c.

Tree-SHA512: 45bb8583311f145353d8265d28f220d2a318c701346f147979c5d33b27811276d5e18586bf58f35e455701495d2cb87ec54dd78f4ca8631a0c7bd2c1d7fe640c
2025-11-18 23:24:31 +00:00
Hennadii Stepanov
7d7b829c36 Merge bitcoin-core/gui#908: Remove HD seed reference from blank wallet tooltip
929f69d0ff qt: Remove HD seed reference from blank wallet tooltip (John Moffett)

Pull request description:

  Blank descriptor wallets currently do not have HD seeds and none can be added (or 'set') by the user, so remove the reference in the tooltip.

  As I understand it, descriptor wallets don't have a global HD seed and don't store the HD seeds for keys they generate. Currently, no new HD seeds can be added by the user (even for old wallets since `sethdseed` was removed), though it may be possible in the future, eg -  https://github.com/bitcoin/bitcoin/pull/33043

ACKs for top commit:
  maflcko:
    lgtm ACK 929f69d0ff

Tree-SHA512: 85e9c8e18a92b3da6fd62b70570cef58e03843633300b65aee5789d38c7bcaa46738970f0aea63f4e9b3e8814abb5bf1e1aa93f568a875ad1e0443d4dafb0aab
2025-11-18 23:02:50 +00:00
Ava Chow
53b72372da Merge bitcoin/bitcoin#31734: miniscript: account for all StringType variants in Miniscriptdescriptor::ToString()
28a4fcb03c test: check listdescriptors do not return a mix of hardened derivation marker (pythcoiner)
975783cb79 descriptor: account for all StringType in MiniscriptDescriptor::ToStringHelper() (pythcoiner)

Pull request description:

  In `MiniscriptDescriptor::ToStringHelper()` only the `StringType::Private` variant of the `type` argument was handled. This PR implements serializing w/ all variants of `StringType` & add a functional test for the descriptor triggering the related issue.

  Closes #31694: previously when calling `listdescriptors` RPC on a wallet containing a taproot descriptor w/ a (miniscript) taptree, origins of internal key & taptree were serialized w/ differents hardened derivation markers:
   - origin of the internal key were serialized w/ `StringType::Normalized` type (using `h` as marker)
   - origins of taptree keys were serialized w/ `StringType::Private` type (using `'` as marker)

  Note: Origins in segwit (`wsh()`) miniscript descriptors were also serialized w/ `StringType::Private` type (`'` marker) and are now serialized w/ `StringType::Normalized` type (`h` marker).

ACKs for top commit:
  sipa:
    Code review ACK 28a4fcb03c
  achow101:
    ACK 28a4fcb03c
  rkrux:
    Concept ACK 28a4fcb03c

Tree-SHA512: 15d14000b5951ca69a64a05b9a0b138c48a07b81eaf2fa86b91ac20cc8735533355a787363c64ba88403dd8a56ef5232cba57d34bea80835a0f40774d62fbc2b
2025-11-18 14:32:01 -08:00
Ava Chow
a7f9bbe4c5 Merge bitcoin/bitcoin#32821: rpc: Handle -named argument parsing where '=' character is used
f53dbbc505 test: Add functional tests for named argument parsing (zaidmstrr)
694f04e2bd rpc: Handle -named argument parsing where '=' character is used (zaidmstrr)

Pull request description:

  Addresses [comment](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2091886628) and [this](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2092039999).

  The [PR #31375](https://github.com/bitcoin/bitcoin/pull/31375) got merged and enables `-named` by default in the `bitcoin rpc` interface; `bitcoin rpc` corresponds to `bitcoin-cli -named` as it's just a wrapper.  Now, the problem arises when we try to parse the positional paramater which might contain "=" character.  This splits the parameter into two parts first, before the "=" character, which treats this as the parameter name, but the other half is mostly passed as an empty string. Here, the first part of the string is an unknown parameter name; thus, an error is thrown. These types of errors are only applicable to those RPCs which might contain the `=` character as a parameter. Some examples are `finalizepsbt`, `decodepsbt`, `verifymessage` etc.

  This is the one example of the error in `finalizepsbt` RPC:
  ```
  ./bitcoin-cli -named -regtest finalizepsbt cHNidP8BAJoCAAAAAqvNEjSrzRI0q80SNKvNEjSrzRI0q80SNKvNEjSrzRI0AAAAAAD9////NBLNqzQSzas0Es2rNBLNqzQSzas0Es2rNBLNqzQSzasBAAAAAP3///8CoIYBAAAAAAAWABQVQBGVs/sqFAmC8HZ8O+g1htqivkANAwAAAAAAFgAUir7MzgyzDnRMjdkVa7d+Dwr07jsAAAAAAAAAAAA=
  error code: -8
  error message:
  Unknown named parameter cHNidP8BAJoCAAAAAqvNEjSrzRI0q80SNKvNEjSrzRI0q80SNKvNEjSrzRI0AAAAAAD9////NBLNqzQSzas0Es2rNBLNqzQSzas0Es2rNBLNqzQSzasBAAAAAP3///8CoIYBAAAAAAAWABQVQBGVs/sqFAmC8HZ8O+g1htqivkANAwAAAAAAFgAUir7MzgyzDnRMjdkVa7d+Dwr07jsAAAAAAAAAAAA
  ```
  This PR fixes this by updating the `vRPCConvertParams` table that identifies parameters that need special handling in `-named` parameter mode. The parser now recognises these parameters and handles strings with "=" char correctly, preventing them from being incorrectly split as parameter assignments.

ACKs for top commit:
  ryanofsky:
    Code review ACK f53dbbc505. Just applied comment & test suggestions since last review
  kannapoix:
    Code review ACK: f53dbbc505
  achow101:
    ACK f53dbbc505

Tree-SHA512: 1b517144efeff45a4c4256c27a39ddf187f1d6189d133402a45171678214a10ff2925c31edcfd556d67f85bd26d42f63c528b941b68c9880eab443f2c883e681
2025-11-18 14:06:54 -08:00
Suhas Daftuar
21693f031a Expose cluster information via rpc
Co-authored-by: glozow <gloriajzhao@gmail.com>
2025-11-18 11:14:52 -05:00
Suhas Daftuar
72e74e0d42 fuzz: try to add more code coverage for mempool fuzzing
Including test coverage for mempool eviction and expiry
2025-11-18 10:48:23 -05:00
Suhas Daftuar
f107417490 bench: add more mempool benchmarks
Add benchmarks for:

  - adding a transaction
  - calculating mempool ancestors/descendants
2025-11-18 10:48:23 -05:00
Suhas Daftuar
7976eb1ae7 Avoid violating mempool policy limits in tests
Changes AddToMempool() helper to only apply changes if the mempool limits are
respected.

Fix package_rbf fuzz target to handle mempool policy violations
2025-11-18 10:48:23 -05:00
Suhas Daftuar
84de685cf7 Stop tracking parents/children outside of txgraph 2025-11-18 10:48:23 -05:00
Suhas Daftuar
88672e205b Rewrite GatherClusters to use the txgraph implementation 2025-11-18 10:48:23 -05:00
Suhas Daftuar
1ca4f01090 Fix miniminer_tests to work with cluster limits 2025-11-18 10:48:23 -05:00
Suhas Daftuar
1902111e0f Eliminate CheckPackageLimits, which no longer does anything 2025-11-18 10:48:23 -05:00
Suhas Daftuar
3a646ec462 Rework RBF and TRUC validation
Calculating mempool ancestors for a new transaction should not be done until
after cluster size limits have been enforced, to limit CPU DoS potential.

Achieve this by reworking TRUC and RBF validation logic:

- TRUC policy enforcement is now done using only mempool parents of
  new transactions, not all mempool ancestors (note that it's fine to calculate
  ancestors of in-mempool transactions, if the number of such calls is
  reasonably bounded).
- RBF replacement checks are performed earlier (which allows for checking
  cluster size limits earlier, because cluster size checks cannot happen until
  after all conflicts are staged for removal).
- Verifying that a new transaction doesn't conflict with an ancestor now
  happens later, in AcceptSingleTransaction() rather than in PreChecks(). This
  means that the test is not performed at all in AcceptMultipleTransactions(),
  but in package acceptance we already disallow RBF in situations where a
  package transaction has in-mempool parents.

Also to ensure that all RBF validation logic is applied in both the single
transaction and multiple transaction cases, remove the optimization that skips
the PackageMempoolChecks() in the case of a single transaction being validated
in AcceptMultipleTransactions().
2025-11-18 10:48:22 -05:00
Suhas Daftuar
19b8479868 Make getting parents/children a function of the mempool, not a mempool entry 2025-11-18 10:40:31 -05:00
Suhas Daftuar
5560913e51 Rework truc_policy to use descendants, not children 2025-11-18 10:35:19 -05:00
Suhas Daftuar
a4458d6c40 Use txgraph to calculate descendants 2025-11-18 09:29:36 -05:00
Suhas Daftuar
c8b6f70d64 Use txgraph to calculate ancestors 2025-11-18 09:29:36 -05:00
Suhas Daftuar
241a3e666b Simplify ancestor calculation functions
Now that ancestor calculation never fails (due to ancestor/descendant limits
being eliminated), we can eliminate the error handling from
CalculateMemPoolAncestors.
2025-11-18 09:29:36 -05:00
Suhas Daftuar
b9cec7f0a1 Make removeConflicts private 2025-11-18 09:29:36 -05:00
Suhas Daftuar
0402e6c780 Remove unused limits from CalculateMemPoolAncestors 2025-11-18 09:29:35 -05:00
Suhas Daftuar
08be765ac2 Remove mempool logic designed to maintain ancestor/descendant state 2025-11-18 09:28:31 -05:00
Suhas Daftuar
fc4e3e6bc1 Remove unused members from CTxMemPoolEntry 2025-11-18 09:28:31 -05:00
Suhas Daftuar
ff3b398d12 mempool: eliminate accessors to mempool entry ancestor/descendant cached state 2025-11-18 09:28:31 -05:00
Suhas Daftuar
b9a2039f51 Eliminate use of cached ancestor data in miniminer_tests and truc_policy 2025-11-18 09:28:25 -05:00
Suhas Daftuar
ba09fc9774 mempool: Remove unused function CalculateDescendantMaximum 2025-11-18 09:02:48 -05:00
Suhas Daftuar
8e49477e86 wallet: Replace max descendant count with cluster_count
With the descendant size limits removed, replace the concept of "max number of
descendants of any ancestor of a given tx" with the cluster count of the cluster
that the transaction belongs to.
2025-11-18 09:02:48 -05:00
Suhas Daftuar
e031085fd4 Eliminate Single-Conflict RBF Carve Out
The new cluster mempool RBF rules take into account clusters sizes exactly, so
with the removal of descendant count enforcement this idea is obsolete.
2025-11-18 09:02:05 -05:00
Suhas Daftuar
cf3ab8e1d0 Stop enforcing descendant size/count limits
Cluster size limits should be enough.
2025-11-18 08:57:51 -05:00
Suhas Daftuar
c0bd04d18f Calculate descendant information for mempool RPC output on-the-fly
This is in preparation for removing the cached descendant state from the
mempool.
2025-11-18 08:57:51 -05:00