Commit Graph

46342 Commits

Author SHA1 Message Date
Suhas Daftuar
bdcefb8a8b Use mempool/txgraph to determine if a tx has descendants
Remove a reference to GetCountWithDescendants() in preparation for removing
this function and the associated cached state from the mempool.
2025-11-18 08:57:51 -05:00
Suhas Daftuar
69e1eaa6ed Add test case for cluster size limits to TRUC logic 2025-11-18 08:57:51 -05:00
Suhas Daftuar
9cda64b86c Stop enforcing ancestor size/count limits
The cluster limits should be sufficient.

Co-Authored-By: Gregory Sanders <gsanders87@gmail.com>
2025-11-18 08:57:51 -05:00
Suhas Daftuar
1f93227a84 Remove dependency on cached ancestor data in mini-miner 2025-11-18 08:57:51 -05:00
Suhas Daftuar
9fbe0a4ac2 rpc: Calculate ancestor data from scratch for mempool rpc calls 2025-11-18 08:57:51 -05:00
Suhas Daftuar
7961496dda Reimplement GetTransactionAncestry() to not rely on cached data
In preparation for removing ancestor data from CTxMemPoolEntry, recalculate the
ancestor statistics on demand wherever needed.
2025-11-18 08:57:51 -05:00
Suhas Daftuar
feceaa42e8 Remove CTxMemPool::GetSortedDepthAndScore
The mempool clusters and linearization permit sorting the mempool topologically
without making use of ancestor counts (as long as the graph is not oversized).

Co-authored-by: Pieter Wuille <pieter@wuille.net>
2025-11-18 08:53:59 -05:00
Suhas Daftuar
21b5cea588 Use cluster linearization for transaction relay sort order
Previously, transaction batches were first sorted by ancestor count and then
feerate, to ensure transactions are announced in a topologically valid order,
while prioritizing higher feerate transactions. Ancestor count is a crude
topological sort criteria, so replace this with linearization order so that the
highest feerate transactions (as would be observed by the mining algorithm) are
relayed before lower feerate ones, in a topologically valid way.

This also fixes a test that only worked due to the ancestor-count-based sort
order.
2025-11-18 08:53:59 -05:00
Suhas Daftuar
6445aa7d97 Remove the ancestor and descendant indices from the mempool 2025-11-18 08:53:59 -05:00
Suhas Daftuar
216e693729 Implement new RBF logic for cluster mempool
With a total ordering on mempool transactions, we are now able to calculate a
transaction's mining score at all times. Use this to improve the RBF logic:

- we no longer enforce a "no new unconfirmed parents" rule

- we now require that the mempool's feerate diagram must improve in order
  to accept a replacement

- the topology restrictions for conflicts in the package rbf setting have been
  eliminated

Revert the temporary change to mempool_ephemeral_dust.py that were previously
made due to RBF validation checks being reordered.

Co-authored-by: Gregory Sanders <gsanders87@gmail.com>, glozow <gloriajzhao@gmail.com>
2025-11-18 08:53:59 -05:00
Suhas Daftuar
ff8f115dec policy: Remove CPFP carveout rule
The addition of a cluster size limit makes the CPFP carveout rule useless,
because carveout cannot be used to bypass the cluster size limit. Remove this
policy rule and update tests to no longer rely on the behavior.
2025-11-18 08:53:59 -05:00
Suhas Daftuar
c3f1afc934 test: rewrite PopulateMempool to not violate mempool policy (cluster size) limits 2025-11-18 08:53:59 -05:00
Suhas Daftuar
47ab32fdb1 Select transactions for blocks based on chunk feerate
Co-Authored-By: Gregory Sanders <gsanders87@gmail.com>
2025-11-18 08:53:58 -05:00
Suhas Daftuar
dec138d1dd fuzz: remove comparison between mini_miner block construction and miner
After cluster mempool, the mini_miner will no longer match the miner's block
construction. Eventually mini_miner should be reworked to directly use
linearizations done in the mempool.
2025-11-18 08:53:58 -05:00
Suhas Daftuar
6c2bceb200 bench: rewrite ComplexMemPool to not create oversized clusters 2025-11-18 08:53:58 -05:00
Suhas Daftuar
1ad4590f63 Limit mempool size based on chunk feerate
Rather than evicting the transactions with the lowest descendant feerate,
instead evict transactions that have the lowest chunk feerate.

Once mining is implemented based on choosing transactions with highest chunk
feerate (see next commit), mining and eviction will be opposites, so that we
will evict the transactions that would be mined last.
2025-11-18 08:53:58 -05:00
Suhas Daftuar
b11c89cab2 Rework miner_tests to not require large cluster limit 2025-11-18 08:53:58 -05:00
Suhas Daftuar
95a8297d48 Check cluster limits when using -walletrejectlongchains 2025-11-18 08:53:58 -05:00
Suhas Daftuar
95762e6759 Do not allow mempool clusters to exceed configured limits
Include an adjustment to mempool_tests.cpp due to the additional memory used by
txgraph.

Includes a temporary change to the mempool_ephemeral_dust.py functional test,
due to validation checks being reordered. This change will revert once the RBF
rules are changed in a later commit.
2025-11-18 08:53:58 -05:00
glozow
edb3e7cdf6 [test] rework/delete feature_rbf tests requiring large clusters 2025-11-18 08:53:58 -05:00
Suhas Daftuar
435fd56711 test: update feature_rbf.py replacement test
Preparatory commit to the rbf functional test, before changes are made to the
rbf rules as part of cluster mempool.
2025-11-18 08:53:58 -05:00
Suhas Daftuar
34e32985e8 Add new (unused) limits for cluster size/count 2025-11-18 08:53:58 -05:00
Suhas Daftuar
838d7e3553 Add transactions to txgraph, but without cluster dependencies
Effectively this is treating all transactions in txgraph as being in a cluster
of size 1.
2025-11-18 08:53:58 -05:00
Suhas Daftuar
d5ed9cb3eb Add accessor for sigops-adjusted weight 2025-11-10 16:01:34 -05:00
Suhas Daftuar
1bf3b51396 Add sigops adjusted weight calculator 2025-11-10 15:55:43 -05:00
Suhas Daftuar
c18c68a950 Create a txgraph inside CTxMemPool 2025-11-10 15:54:53 -05:00
Suhas Daftuar
29a94d5b2f Make CTxMemPoolEntry derive from TxGraph::Ref 2025-11-10 15:46:11 -05:00
Suhas Daftuar
92b0079fe3 Allow moving CTxMemPoolEntry objects, disallow copying 2025-11-10 15:45:55 -05:00
Suhas Daftuar
6c73e47448 mempool: Store iterators into mapTx in mapNextTx
This takes the same amount of space as CTransaction pointers, and saves a map
lookup in many common uses.
2025-10-14 14:03:42 -04:00
Suhas Daftuar
51430680ec Allow moving an Epoch::Marker 2025-10-14 14:03:42 -04: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
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
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
fanquake
c11a3dcc88 doc: archive release notes for v29.2 2025-10-13 16:19:32 +01:00
merge-script
64a7c7cbb9 Merge bitcoin/bitcoin#33558: ci: Use native platform for win-cross task
fa6fd16f36 ci: Use native platform for win-cross task (MarcoFalke)

Pull request description:

  Forcing the architecture to amd64 is no longer required. Dropping it should have some benefits:

  * Faster CI speed on other arches (riscv64, arm, ...)
  * Unlock the CI task to run on riscv64 at all

ACKs for top commit:
  hebasto:
    ACK fa6fd16f36, tested on Ubuntu 24.04, RISC-V.

Tree-SHA512: 68a3fc90cc22ab085d6946deb106e50b22e06eebc61523a9dcb53b38a50021a19da26cc29e2cd20f4673ffc5cc10f441dacca7cc799782258351609d9fa04969
2025-10-13 13:50:41 +01:00
merge-script
93b56e95c0 Merge bitcoin/bitcoin#33601: doc: archive release notes for v30.0
8d6e49158e doc: archive release notes for v30.0 (fanquake)

Pull request description:

  Archive v30.0 release notes.

ACKs for top commit:
  janb84:
    ACK 8d6e49158e
  willcl-ark:
    ACK 8d6e49158e

Tree-SHA512: 322daee16e8d46808c3b669d9c893172eccefe5dafcd79646c9d265360bd606df7be1222a6c12c16517dec88ae1fee6d1aaa7e71761cc5d7fdc8b5e0bdc82292
2025-10-13 13:45:31 +01:00
Hennadii Stepanov
563747971b Merge bitcoin/bitcoin#33580: depends: Use $(package)_file_name when downloading from the fallback
671b774d1b depends: Use $(package)_file_name when downloading from the fallback (Ava Chow)

Pull request description:

  The server hosting the fallbacks uses `make download` so the files are only available with their overridden names rather than the original name on the upstream source. We should therefore also use the overridden name when downloading from the fallback.

  Fixes https://github.com/bitcoin-core/bitcoincore.org/issues/1168

ACKs for top commit:
  theuni:
    utACK 671b774d1b. I was going to PR the same change.
  janb84:
    ut ACK 671b774d1b
  hebasto:
    ACK 671b774d1b, tested with the following patch:

Tree-SHA512: ba010adb64900d8d748487cc1a658e2b163872354f4e7b38c4dfc37a14fcb22fec4379a635d2c6788c64dd46bef0d94aa3eb6f522ec700680e886d5468678031
2025-10-13 11:53:58 +01:00
Pieter Wuille
023cd5a546 txgraph: add SingletonClusterImpl (mem optimization)
This adds a specialized Cluster implementation for singleton clusters, saving
a significant amount of memory by avoiding the need for m_depgraph, m_mapping,
and m_linearization, and their overheads.
2025-10-11 17:46:43 -04:00
Pieter Wuille
e346250732 txgraph: give Clusters a range of intended tx counts (preparation) 2025-10-11 17:32:35 -04:00
Pieter Wuille
e93b0f09cc txgraph: abstract out creation of empty Clusters (refactor) 2025-10-11 17:32:35 -04:00
Pieter Wuille
6baf12621f txgraph: comment fixes (doc fix) 2025-10-11 17:32:35 -04:00
Pieter Wuille
726b995739 txgraph: make Cluster an abstract class (refactor) 2025-10-11 17:32:32 -04:00
Pieter Wuille
2602d89edd txgraph: avoid accessing other Cluster internals (refactor)
This adds 4 functions to Cluster to help implement Merge() and Split() without
needing access to the internals of the other Cluster. This is a preparation for
a follow-up that will make Clusters a virtual class whose internals are abstracted
away.
2025-10-11 17:26:39 -04:00
Pieter Wuille
04c808ac4c txgraph: expose memory usage estimate function (feature) 2025-10-11 17:25:09 -04:00
Pieter Wuille
7680bb8fd4 txgraph: keep track of Cluster memory usage (preparation) 2025-10-11 17:25:09 -04:00
Pieter Wuille
4ba562e5f4 txgraph: keep data structures compact (mem optimization) 2025-10-11 17:25:09 -04:00
Pieter Wuille
bb5cb222ae depgraph: add memory usage control (feature)
Co-Authored-By: Lőrinc <pap.lorinc@gmail.com>
2025-10-11 17:25:09 -04:00
Pieter Wuille
b1637a90de txgraph: avoid holes in DepGraph positions (mem optimization) 2025-10-11 17:25:05 -04:00