Skip to content
Bitcoin Roots

v30.3-roots.1 · Commit 3: [PATCH 03/68] feat(policy): preserve Roots relay and network controls on Core 30.3

test/functional/mempool_truc.py

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

File metadata
index 098631b5c414e1d6df76914ea25e695dbcfe103f..dd34685ac585b16b482d9ebfad4d96a82be4eb24 100755

Download original patch · Release notes

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