test: consolidate mempool constants #36611

Manually merged
fanquake merged 5 commits from consolidate_testframework_mempool into master 2026-10-31 00:00:57 +00:00 AGit
fanquake commented 2026-10-22 17:01:08 +00:00 (Migrated from github.com)

Consolidate usage of mempool constants in the functional tests.
As well as one instance of MAX_FUTURE_BLOCK_TIME.

Consolidate usage of mempool constants in the functional tests. As well as one instance of `MAX_FUTURE_BLOCK_TIME`.
DrahtBot commented 2026-10-22 17:01:30 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK stickies-v, mercie-ux, hodlinator

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36192 (test: cover unsatisfiable mining timestamp by Sjors)
  • #35793 (Implement BIP 54 (Consensus Cleanup) without mainnet activation by darosior)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36611 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36611.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36611#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [stickies-v](https://github.com/bitcoin/bitcoin/pull/36611#issuecomment-6446617276), [mercie-ux](https://github.com/bitcoin/bitcoin/pull/36611#issuecomment-6447688795), [hodlinator](https://github.com/bitcoin/bitcoin/pull/36611#pullrequestreview-5672587357) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36192](https://github.com/bitcoin/bitcoin/pull/36192) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36192.svg"></sub> (test: cover unsatisfiable mining timestamp by Sjors) * [#35793](https://github.com/bitcoin/bitcoin/pull/35793) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35793.svg"></sub> (Implement BIP 54 (Consensus Cleanup) without mainnet activation by darosior) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: aa76bd266df9742a266d52e0e5da8dbf033658f6
Head: d8cca0c110b264be0cca69fb4c55ebee0e8152a7

I found no actionable issues in this static review.

Review tier: routine

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:ab973404fb8e3c0d560a5f0df76c1f96a2e0e21182cfc208ac10a039068cb623:00633cd9cb08c8f4661c30fbf00eaba6318f037423dd36deda26cc4a9d01c2c2 --> Base: `aa76bd266df9742a266d52e0e5da8dbf033658f6` Head: `d8cca0c110b264be0cca69fb4c55ebee0e8152a7` <!-- ralph-case:8c8a0f35126fccc32f524ca4ea2e0860076aade5e3402bf06f8325072927461d --> I found no actionable issues in this static review. Review tier: routine [Full review report](<https://review.fish.foo/traces/36611-d8cca0c110b264be0cca69fb4c55ebee0e8152a7-1517-9.html>)
mercie-ux commented 2026-10-23 04:39:55 +00:00 (Migrated from github.com)

ACK 4385d415eb

Non-blocking feature_rbf.py still defines MAX_REPLACEMENT_LIMIT = 100 and uses it in the “too many conflicting clusters” test. Since this is the same limit, could this test also import and use MAX_REPLACEMENT_CANDIDATES from mempool_util?
github.com/bitcoin/bitcoin@4385d415eb/test/functional/feature_rbf.py (L25)

ACK 4385d415eb5dbcce28051f40687cc844c5f8dfdb Non-blocking `feature_rbf.py` still defines `MAX_REPLACEMENT_LIMIT = 100` and uses it in the “too many conflicting clusters” test. Since this is the same limit, could this test also import and use `MAX_REPLACEMENT_CANDIDATES` from `mempool_util`? https://github.com/bitcoin/bitcoin/blob/4385d415eb5dbcce28051f40687cc844c5f8dfdb/test/functional/feature_rbf.py#L25
stickies-v (Migrated from github.com) approved these changes 2026-10-23 08:39:18 +00:00
stickies-v (Migrated from github.com) left a comment
ACK 6cbef1aa02ea1445f0a3ad9e514e98b2feca78be
stickies-v (Migrated from github.com) commented 2026-10-23 08:26:44 +00:00

nit: docstring could be preserved:

git diff on 4385d415eb
diff --git a/test/functional/feature_taproot.py b/test/functional/feature_taproot.py
index 7a1a2d9a6b..2cba934648 100755
--- a/test/functional/feature_taproot.py
+++ b/test/functional/feature_taproot.py
@@ -1638,6 +1638,7 @@ class TaprootTest(BitcoinTestFramework):
                     fail_input is None  # Must be valid to be standard
                     and (all(utxo.spender.is_standard for utxo in input_utxos))  # All inputs must be standard
                     and tx.version in TX_STANDARD_VERSIONS # The tx version must be standard
+                    # test doesn't cover in-mempool spends, so only TRUC_MAX_VSIZE limit is hit
                     and not (tx.version == 3 and tx.get_vsize() > TRUC_MAX_VSIZE)  # Topological standardness rules must be followed
                 )
                 msg = ','.join(utxo.spender.comment + ("*" if n == fail_input else "") for n, utxo in enumerate(input_utxos))

nit: docstring could be preserved: <details> <summary>git diff on 4385d415eb</summary> ```diff diff --git a/test/functional/feature_taproot.py b/test/functional/feature_taproot.py index 7a1a2d9a6b..2cba934648 100755 --- a/test/functional/feature_taproot.py +++ b/test/functional/feature_taproot.py @@ -1638,6 +1638,7 @@ class TaprootTest(BitcoinTestFramework): fail_input is None # Must be valid to be standard and (all(utxo.spender.is_standard for utxo in input_utxos)) # All inputs must be standard and tx.version in TX_STANDARD_VERSIONS # The tx version must be standard + # test doesn't cover in-mempool spends, so only TRUC_MAX_VSIZE limit is hit and not (tx.version == 3 and tx.get_vsize() > TRUC_MAX_VSIZE) # Topological standardness rules must be followed ) msg = ','.join(utxo.spender.comment + ("*" if n == fail_input else "") for n, utxo in enumerate(input_utxos)) ``` </details>
stickies-v (Migrated from github.com) commented 2026-10-23 08:23:00 +00:00

nit: replace further usage of the literal:

git diff on 4385d415eb
diff --git a/test/functional/mempool_package_rbf.py b/test/functional/mempool_package_rbf.py
index c8f6a7c11a..6a2a011476 100755
--- a/test/functional/mempool_package_rbf.py
+++ b/test/functional/mempool_package_rbf.py
@@ -196,7 +196,7 @@ class PackageRBFTest(BitcoinTestFramework):
         parent_coins = self.coins[:num_coins]
         del self.coins[:num_coins]
 
-        # Original transactions: 101 transactions with 2 descendants each -> 303 total transactions, 101 clusters
+        # Original transactions: num_coins transactions with 2 descendants each -> num_coins * 3 total transactions, num_coins clusters
         size_three_clusters = []
         for coin in parent_coins:
             size_three_clusters.append(self.wallet.send_self_transfer_chain(from_node=node, chain_length=3, utxo_to_spend=coin))
@@ -211,13 +211,13 @@ class PackageRBFTest(BitcoinTestFramework):
         parent_fee_per_conflict = 10000
         child_feerate = 10000 * DEFAULT_FEE
 
-        # Conflict against all transactions by double-spending each parent, causing 101 cluster conflicts
+        # Conflict against all transactions by double-spending each parent, causing num_coins cluster conflicts
         package_parent = self.wallet.create_self_transfer_multi(utxos_to_spend=parent_coins, fee_per_output=parent_fee_per_conflict)
         package_child = self.wallet.create_self_transfer(fee_rate=child_feerate, utxo_to_spend=package_parent["new_utxos"][0])
 
         pkg_results = node.submitpackage([package_parent["hex"], package_child["hex"]], maxfeerate=0)
         assert_equal("transaction failed", pkg_results["package_msg"])
-        assert_equal(f"too many potential replacements, rejecting replacement {package_parent['txid']}; too many conflicting clusters (101 > 100)", pkg_results["tx-results"][package_parent["wtxid"]]["error"])
+        assert_equal(f"too many potential replacements, rejecting replacement {package_parent['txid']}; too many conflicting clusters ({num_coins} > {MAX_REPLACEMENT_CANDIDATES})", pkg_results["tx-results"][package_parent["wtxid"]]["error"])
         self.assert_mempool_contents(expected=expected_txns)
 
         # Make singleton tx to conflict with in next batch
@@ -233,7 +233,7 @@ class PackageRBFTest(BitcoinTestFramework):
         package_child = self.wallet.create_self_transfer(fee_rate=child_feerate, utxo_to_spend=package_parent["new_utxos"][0])
         pkg_results = node.submitpackage([package_parent["hex"], package_child["hex"]], maxfeerate=0)
         assert_equal("transaction failed", pkg_results["package_msg"])
-        assert_equal(f"too many potential replacements, rejecting replacement {package_parent['txid']}; too many conflicting clusters (101 > 100)", pkg_results["tx-results"][package_parent["wtxid"]]["error"])
+        assert_equal(f"too many potential replacements, rejecting replacement {package_parent['txid']}; too many conflicting clusters ({num_coins} > {MAX_REPLACEMENT_CANDIDATES})", pkg_results["tx-results"][package_parent["wtxid"]]["error"])
         self.assert_mempool_contents(expected=expected_txns)
 
         # Finally, conflict with MAX_REPLACEMENT_CANDIDATES clusters

nit: replace further usage of the literal: <details> <summary>git diff on 4385d415eb</summary> ```diff diff --git a/test/functional/mempool_package_rbf.py b/test/functional/mempool_package_rbf.py index c8f6a7c11a..6a2a011476 100755 --- a/test/functional/mempool_package_rbf.py +++ b/test/functional/mempool_package_rbf.py @@ -196,7 +196,7 @@ class PackageRBFTest(BitcoinTestFramework): parent_coins = self.coins[:num_coins] del self.coins[:num_coins] - # Original transactions: 101 transactions with 2 descendants each -> 303 total transactions, 101 clusters + # Original transactions: num_coins transactions with 2 descendants each -> num_coins * 3 total transactions, num_coins clusters size_three_clusters = [] for coin in parent_coins: size_three_clusters.append(self.wallet.send_self_transfer_chain(from_node=node, chain_length=3, utxo_to_spend=coin)) @@ -211,13 +211,13 @@ class PackageRBFTest(BitcoinTestFramework): parent_fee_per_conflict = 10000 child_feerate = 10000 * DEFAULT_FEE - # Conflict against all transactions by double-spending each parent, causing 101 cluster conflicts + # Conflict against all transactions by double-spending each parent, causing num_coins cluster conflicts package_parent = self.wallet.create_self_transfer_multi(utxos_to_spend=parent_coins, fee_per_output=parent_fee_per_conflict) package_child = self.wallet.create_self_transfer(fee_rate=child_feerate, utxo_to_spend=package_parent["new_utxos"][0]) pkg_results = node.submitpackage([package_parent["hex"], package_child["hex"]], maxfeerate=0) assert_equal("transaction failed", pkg_results["package_msg"]) - assert_equal(f"too many potential replacements, rejecting replacement {package_parent['txid']}; too many conflicting clusters (101 > 100)", pkg_results["tx-results"][package_parent["wtxid"]]["error"]) + assert_equal(f"too many potential replacements, rejecting replacement {package_parent['txid']}; too many conflicting clusters ({num_coins} > {MAX_REPLACEMENT_CANDIDATES})", pkg_results["tx-results"][package_parent["wtxid"]]["error"]) self.assert_mempool_contents(expected=expected_txns) # Make singleton tx to conflict with in next batch @@ -233,7 +233,7 @@ class PackageRBFTest(BitcoinTestFramework): package_child = self.wallet.create_self_transfer(fee_rate=child_feerate, utxo_to_spend=package_parent["new_utxos"][0]) pkg_results = node.submitpackage([package_parent["hex"], package_child["hex"]], maxfeerate=0) assert_equal("transaction failed", pkg_results["package_msg"]) - assert_equal(f"too many potential replacements, rejecting replacement {package_parent['txid']}; too many conflicting clusters (101 > 100)", pkg_results["tx-results"][package_parent["wtxid"]]["error"]) + assert_equal(f"too many potential replacements, rejecting replacement {package_parent['txid']}; too many conflicting clusters ({num_coins} > {MAX_REPLACEMENT_CANDIDATES})", pkg_results["tx-results"][package_parent["wtxid"]]["error"]) self.assert_mempool_contents(expected=expected_txns) # Finally, conflict with MAX_REPLACEMENT_CANDIDATES clusters ``` </details>
fanquake commented 2026-10-23 10:17:05 +00:00 (Migrated from github.com)

Took all the suggestions here.

Took all the suggestions here.
stickies-v commented 2026-10-23 11:19:22 +00:00 (Migrated from github.com)

re-ACK 9d48c8af46

re-ACK 9d48c8af469fa63c79a3b234bc7fe9fe3a25c288
mercie-ux commented 2026-10-23 14:38:23 +00:00 (Migrated from github.com)

re-ACK 9d48c8af46

re-ACK 9d48c8af469fa63c79a3b234bc7fe9fe3a25c288
hodlinator (Migrated from github.com) approved these changes 2026-10-27 12:28:30 +00:00
hodlinator (Migrated from github.com) left a comment
ACK 9d48c8af469fa63c79a3b234bc7fe9fe3a25c288
hodlinator (Migrated from github.com) commented 2026-10-27 12:26:12 +00:00

nit: Could move comment to remaining definition of DEFAULT_CLUSTER_LIMIT in mempool_util.py.

nit: Could move comment to remaining definition of `DEFAULT_CLUSTER_LIMIT` in mempool_util.py.
fanquake (Migrated from github.com) reviewed 2026-10-27 15:35:27 +00:00
fanquake (Migrated from github.com) commented 2026-10-27 15:35:27 +00:00

Moved.

Moved.
stickies-v commented 2026-10-27 15:50:40 +00:00 (Migrated from github.com)

re-ACK d8cca0c110

re-ACK d8cca0c110b264be0cca69fb4c55ebee0e8152a7
mercie-ux commented 2026-10-27 16:36:54 +00:00 (Migrated from github.com)
re-ACK https://github.com/bitcoin/bitcoin/commit/d8cca0c110b264be0cca69fb4c55ebee0e8152a7
hodlinator (Migrated from github.com) approved these changes 2026-10-27 18:48:58 +00:00
hodlinator (Migrated from github.com) left a comment

re-ACK d8cca0c110

re-ACK d8cca0c110b264be0cca69fb4c55ebee0e8152a7
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36611
No description provided.