Skip to content
Bitcoin Roots

v29.4-roots.3 · Commit 3: [PATCH 03/30] policy: restore conservative relay and network controls

test/functional/mempool_truc.py

Before: test/functional/mempool_truc.py · After: test/functional/mempool_truc.py

File metadata
index d095033a847b18572d7a1baf3d2ee1a8d55d25ca..edbc5b45039f5e9cda6fec3424acfdaeac553f1f 100755

Download original patch · Release notes

Diff rows 1–148 of 148. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

test/functional/mempool_truc.py CHANGED
@@ -4,6 +4,9 @@
4
4
  # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
  from decimal import Decimal
6
6
 
7
+ from test_framework.messages import (
8
+ MAX_BIP125_RBF_SEQUENCE,
9
+ )
7
10
  from test_framework.test_framework import BitcoinTestFramework
8
11
  from test_framework.util import (
9
12
  assert_equal,
@@ -55,7 +58,7 @@ class MempoolTRUC(BitcoinTestFramework):
55
58
  self.log.info("Test TRUC-specific maximum transaction vsize")
56
59
  tx_v3_heavy = self.wallet.create_self_transfer(target_vsize=TRUC_MAX_VSIZE + 1, version=3)
57
60
  assert_greater_than_or_equal(tx_v3_heavy["tx"].get_vsize(), TRUC_MAX_VSIZE)
58
- expected_error_heavy = f"TRUC-violation, version=3 tx {tx_v3_heavy['txid']} (wtxid={tx_v3_heavy['wtxid']}) is too big"
61
+ expected_error_heavy = f"truc-vsize-toobig, version=3 tx {tx_v3_heavy['txid']} (wtxid={tx_v3_heavy['wtxid']}) is too big"
59
62
  assert_raises_rpc_error(-26, expected_error_heavy, node.sendrawtransaction, tx_v3_heavy["hex"])
60
63
  self.check_mempool([])
61
64
 
@@ -75,7 +78,7 @@ class MempoolTRUC(BitcoinTestFramework):
75
78
  version=3
76
79
  )
77
80
  assert_greater_than_or_equal(tx_v3_child_heavy["tx"].get_vsize(), TRUC_CHILD_MAX_VSIZE)
78
- expected_error_child_heavy = f"TRUC-violation, version=3 child tx {tx_v3_child_heavy['txid']} (wtxid={tx_v3_child_heavy['wtxid']}) is too big"
81
+ expected_error_child_heavy = f"truc-child-toobig, version=3 child tx {tx_v3_child_heavy['txid']} (wtxid={tx_v3_child_heavy['wtxid']}) is too big"
79
82
  assert_raises_rpc_error(-26, expected_error_child_heavy, node.sendrawtransaction, tx_v3_child_heavy["hex"])
80
83
  self.check_mempool([tx_v3_parent_normal["txid"]])
81
84
  # tx has no descendants
@@ -113,6 +116,7 @@ class MempoolTRUC(BitcoinTestFramework):
113
116
  from_node=node,
114
117
  fee_rate=DEFAULT_FEE,
115
118
  utxo_to_spend=utxo_v3_bip125,
119
+ sequence=MAX_BIP125_RBF_SEQUENCE,
116
120
  version=3
117
121
  )
118
122
  self.check_mempool([tx_v3_bip125["txid"]])
@@ -155,11 +159,10 @@ class MempoolTRUC(BitcoinTestFramework):
155
159
  utxo_to_spend=tx_v3_parent["new_utxo"],
156
160
  version=2
157
161
  )
158
- expected_error_v2_v3 = f"TRUC-violation, non-version=3 tx {tx_v3_child_rbf_v2['txid']} (wtxid={tx_v3_child_rbf_v2['wtxid']}) cannot spend from version=3 tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']})"
162
+ expected_error_v2_v3 = f"truc-spent-by-nontruc, non-version=3 tx {tx_v3_child_rbf_v2['txid']} (wtxid={tx_v3_child_rbf_v2['wtxid']}) cannot spend from version=3 tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']})"
159
163
  assert_raises_rpc_error(-26, expected_error_v2_v3, node.sendrawtransaction, tx_v3_child_rbf_v2["hex"])
160
164
  self.check_mempool([tx_v3_bip125_rbf_v2["txid"], tx_v3_parent["txid"], tx_v3_child["txid"]])
161
165
 
162
-
163
166
  @cleanup(extra_args=["-datacarriersize=40000"])
164
167
  def test_truc_reorg(self):
165
168
  node = self.nodes[0]
@@ -276,20 +279,20 @@ class MempoolTRUC(BitcoinTestFramework):
276
279
 
277
280
  self.check_mempool([])
278
281
  result = node.submitpackage([tx_v3_parent_normal["hex"], tx_v3_parent_2_normal["hex"], tx_v3_child_multiparent["hex"]])
279
- assert_equal(result['package_msg'], f"TRUC-violation, tx {tx_v3_child_multiparent['txid']} (wtxid={tx_v3_child_multiparent['wtxid']}) would have too many ancestors")
282
+ assert_equal(result['package_msg'], f"truc-ancestors-toomany, tx {tx_v3_child_multiparent['txid']} (wtxid={tx_v3_child_multiparent['wtxid']}) would have too many ancestors")
280
283
  self.check_mempool([])
281
284
 
282
285
  self.check_mempool([])
283
286
  result = node.submitpackage([tx_v3_parent_normal["hex"], tx_v3_child_heavy["hex"]])
284
287
  # tx_v3_child_heavy is heavy based on vsize, not sigops.
285
- assert_equal(result['package_msg'], f"TRUC-violation, version=3 child tx {tx_v3_child_heavy['txid']} (wtxid={tx_v3_child_heavy['wtxid']}) is too big: {tx_v3_child_heavy['tx'].get_vsize()} > 1000 virtual bytes")
288
+ assert_equal(result['package_msg'], f"truc-child-toobig, version=3 child tx {tx_v3_child_heavy['txid']} (wtxid={tx_v3_child_heavy['wtxid']}) is too big: {tx_v3_child_heavy['tx'].get_vsize()} > 1000 virtual bytes")
286
289
  self.check_mempool([])
287
290
 
288
291
  tx_v3_parent = self.wallet.create_self_transfer(version=3)
289
292
  tx_v3_child = self.wallet.create_self_transfer(utxo_to_spend=tx_v3_parent["new_utxo"], version=3)
290
293
  tx_v3_grandchild = self.wallet.create_self_transfer(utxo_to_spend=tx_v3_child["new_utxo"], version=3)
291
294
  result = node.testmempoolaccept([tx_v3_parent["hex"], tx_v3_child["hex"], tx_v3_grandchild["hex"]])
292
- assert all([txresult["package-error"] == f"TRUC-violation, tx {tx_v3_grandchild['txid']} (wtxid={tx_v3_grandchild['wtxid']}) would have too many ancestors" for txresult in result])
295
+ assert all([txresult["package-error"] == f"truc-parent-and-child-both, tx {tx_v3_grandchild['txid']} (wtxid={tx_v3_grandchild['wtxid']}) would have too many ancestors" for txresult in result])
293
296
 
294
297
  @cleanup(extra_args=None)
295
298
  def test_truc_ancestors_package_and_mempool(self):
@@ -318,7 +321,7 @@ class MempoolTRUC(BitcoinTestFramework):
318
321
 
319
322
  # submitpackage(B, C) should fail
320
323
  result = node.submitpackage([tx_0fee_parent["hex"], tx_child_violator["hex"]])
321
- assert_equal(result['package_msg'], f"TRUC-violation, tx {tx_child_violator['txid']} (wtxid={tx_child_violator['wtxid']}) would have too many ancestors")
324
+ assert_equal(result['package_msg'], f"truc-parent-and-child-both, tx {tx_child_violator['txid']} (wtxid={tx_child_violator['wtxid']}) would have too many ancestors")
322
325
  self.check_mempool([tx_in_mempool["txid"]])
323
326
 
324
327
  @cleanup(extra_args=None)
@@ -371,17 +374,17 @@ class MempoolTRUC(BitcoinTestFramework):
371
374
  # Fails with another non-related transaction via testmempoolaccept
372
375
  tx_unrelated = self.wallet.create_self_transfer(version=3)
373
376
  result_test_unrelated = node.testmempoolaccept([tx_sibling_1["hex"], tx_unrelated["hex"]])
374
- assert_equal(result_test_unrelated[0]["reject-reason"], "TRUC-violation")
377
+ assert_equal(result_test_unrelated[0]["reject-reason"], "truc-descendants-toomany")
375
378
 
376
379
  # Fails in a package via testmempoolaccept
377
380
  result_test_1p1c = node.testmempoolaccept([tx_sibling_1["hex"], tx_has_mempool_uncle["hex"]])
378
- assert_equal(result_test_1p1c[0]["reject-reason"], "TRUC-violation")
381
+ assert_equal(result_test_1p1c[0]["reject-reason"], "truc-descendants-toomany")
379
382
 
380
383
  # Allowed when tx is submitted in a package and evaluated individually.
381
384
  # Note that the child failed since it would be the 3rd generation.
382
385
  result_package_indiv = node.submitpackage([tx_sibling_1["hex"], tx_has_mempool_uncle["hex"]])
383
386
  self.check_mempool([tx_mempool_parent["txid"], tx_sibling_1["txid"]])
384
- expected_error_gen3 = f"TRUC-violation, tx {tx_has_mempool_uncle['txid']} (wtxid={tx_has_mempool_uncle['wtxid']}) would have too many ancestors"
387
+ expected_error_gen3 = f"truc-ancestors-toomany, tx {tx_has_mempool_uncle['txid']} (wtxid={tx_has_mempool_uncle['wtxid']}) would have too many ancestors"
385
388
 
386
389
  assert_equal(result_package_indiv["tx-results"][tx_has_mempool_uncle['wtxid']]['error'], expected_error_gen3)
387
390
 
@@ -392,7 +395,7 @@ class MempoolTRUC(BitcoinTestFramework):
392
395
  # Child cannot pay for sibling eviction for parent, as it violates TRUC topology limits
393
396
  result_package_cpfp = node.submitpackage([tx_sibling_3["hex"], tx_bumps_parent_with_sibling["hex"]])
394
397
  self.check_mempool([tx_mempool_parent["txid"], tx_sibling_2["txid"]])
395
- expected_error_cpfp = f"TRUC-violation, tx {tx_mempool_parent['txid']} (wtxid={tx_mempool_parent['wtxid']}) would exceed descendant count limit"
398
+ expected_error_cpfp = f"truc-descendants-toomany, tx {tx_mempool_parent['txid']} (wtxid={tx_mempool_parent['wtxid']}) would exceed descendant count limit"
396
399
 
397
400
  assert_equal(result_package_cpfp["tx-results"][tx_sibling_3['wtxid']]['error'], expected_error_cpfp)
398
401
 
@@ -413,7 +416,7 @@ class MempoolTRUC(BitcoinTestFramework):
413
416
  )
414
417
  self.check_mempool([])
415
418
  result = node.submitpackage([tx_v3_parent["hex"], tx_v2_child["hex"]])
416
- assert_equal(result['package_msg'], f"TRUC-violation, non-version=3 tx {tx_v2_child['txid']} (wtxid={tx_v2_child['wtxid']}) cannot spend from version=3 tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']})")
419
+ assert_equal(result['package_msg'], f"truc-spent-by-nontruc, non-version=3 tx {tx_v2_child['txid']} (wtxid={tx_v2_child['wtxid']}) cannot spend from version=3 tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']})")
417
420
  self.check_mempool([])
418
421
 
419
422
  @cleanup(extra_args=None)
@@ -434,11 +437,11 @@ class MempoolTRUC(BitcoinTestFramework):
434
437
  assert all([result["allowed"] for result in test_accept_v2_and_v3])
435
438
 
436
439
  test_accept_v3_from_v2 = node.testmempoolaccept([tx_v2["hex"], tx_v3_from_v2["hex"]])
437
- expected_error_v3_from_v2 = f"TRUC-violation, version=3 tx {tx_v3_from_v2['txid']} (wtxid={tx_v3_from_v2['wtxid']}) cannot spend from non-version=3 tx {tx_v2['txid']} (wtxid={tx_v2['wtxid']})"
440
+ expected_error_v3_from_v2 = f"truc-spends-nontruc, version=3 tx {tx_v3_from_v2['txid']} (wtxid={tx_v3_from_v2['wtxid']}) cannot spend from non-version=3 tx {tx_v2['txid']} (wtxid={tx_v2['wtxid']})"
438
441
  assert all([result["package-error"] == expected_error_v3_from_v2 for result in test_accept_v3_from_v2])
439
442
 
440
443
  test_accept_v2_from_v3 = node.testmempoolaccept([tx_v3["hex"], tx_v2_from_v3["hex"]])
441
- expected_error_v2_from_v3 = f"TRUC-violation, non-version=3 tx {tx_v2_from_v3['txid']} (wtxid={tx_v2_from_v3['wtxid']}) cannot spend from version=3 tx {tx_v3['txid']} (wtxid={tx_v3['wtxid']})"
444
+ expected_error_v2_from_v3 = f"truc-spent-by-nontruc, non-version=3 tx {tx_v2_from_v3['txid']} (wtxid={tx_v2_from_v3['wtxid']}) cannot spend from version=3 tx {tx_v3['txid']} (wtxid={tx_v3['wtxid']})"
442
445
  assert all([result["package-error"] == expected_error_v2_from_v3 for result in test_accept_v2_from_v3])
443
446
 
444
447
  test_accept_pairs = node.testmempoolaccept([tx_v2["hex"], tx_v3["hex"], tx_v2_from_v2["hex"], tx_v3_from_v3["hex"]])
@@ -450,7 +453,7 @@ class MempoolTRUC(BitcoinTestFramework):
450
453
  tx_v3_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_v3_parent["new_utxos"][0], version=3)
451
454
  tx_v3_child_2 = self.wallet.create_self_transfer(utxo_to_spend=tx_v3_parent["new_utxos"][1], version=3)
452
455
  test_accept_2children = node.testmempoolaccept([tx_v3_parent["hex"], tx_v3_child_1["hex"], tx_v3_child_2["hex"]])
453
- expected_error_2children = f"TRUC-violation, tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']}) would exceed descendant count limit"
456
+ expected_error_2children = f"truc-sibling-known, tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']}) would exceed descendant count limit"
454
457
  assert all([result["package-error"] == expected_error_2children for result in test_accept_2children])
455
458
 
456
459
  # Extra TRUC transaction does not get incorrectly marked as extra descendant
@@ -459,7 +462,7 @@ class MempoolTRUC(BitcoinTestFramework):
459
462
 
460
463
  # Extra TRUC transaction does not make us ignore the extra descendant
461
464
  test_accept_2children_with_exra = node.testmempoolaccept([tx_v3_parent["hex"], tx_v3_child_1["hex"], tx_v3_child_2["hex"], tx_v3_independent["hex"]])
462
- expected_error_extra = f"TRUC-violation, tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']}) would exceed descendant count limit"
465
+ expected_error_extra = f"truc-sibling-known, tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']}) would exceed descendant count limit"
463
466
  assert all([result["package-error"] == expected_error_extra for result in test_accept_2children_with_exra])
464
467
  # Same result if the parent is already in mempool
465
468
  node.sendrawtransaction(tx_v3_parent["hex"])
@@ -596,7 +599,7 @@ class MempoolTRUC(BitcoinTestFramework):
596
599
  utxo_to_spend=tx_with_multi_children["new_utxos"][2],
597
600
  fee_rate=DEFAULT_FEE*50
598
601
  )
599
- expected_error_2siblings = f"TRUC-violation, tx {tx_with_multi_children['txid']} (wtxid={tx_with_multi_children['wtxid']}) would exceed descendant count limit"
602
+ expected_error_2siblings = f"truc-descendants-toomany, tx {tx_with_multi_children['txid']} (wtxid={tx_with_multi_children['wtxid']}) would exceed descendant count limit"
600
603
  assert_raises_rpc_error(-26, expected_error_2siblings, node.sendrawtransaction, tx_with_sibling3["hex"])
601
604
 
602
605
  # However, an RBF (with conflicting inputs) is possible even if the resulting cluster size exceeds 2