mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-09 21:47:34 +01:00
Merge bitcoin/bitcoin#29496: policy: bump TX_MAX_STANDARD_VERSION to 3
30a01134cd[doc] update bips.md for 431 (glozow)9dbe6a03f0[test] wallet uses CURRENT_VERSION which is 2 (glozow)539404fe0f[policy] make v3 transactions standard (glozow)052ede75af[refactor] use TRUC_VERSION in place of 3 (glozow) Pull request description: Make `nVersion=3` (which is currently nonstandard on mainnet) standard. Note that we will treat these transactions as Topologically Restricted Until Confirmation (TRUC). Spec is in BIP 431 and implementation is in #28948, #29306, and #29873 See #27463 for overall project tracking, and #29319 for information about relevance to cluster mempool. ACKs for top commit: sdaftuar: utACK30a01134cachow101: ACK30a01134cdinstagibbs: utACK30a01134cdmurchandamus: ACK30a01134cdismaelsadeeq: ACK30a01134cd🛰️ Tree-SHA512: 2a4aec0442c860e792a061d83e36483c1f1b426f946efbdf664c8db97a596e498b535707e1d3a900218429486ea69fd4552e3d476526a6883cbd5556c6534b48
This commit is contained in:
@@ -287,7 +287,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
|
||||
self.log.info('Some nonstandard transactions')
|
||||
tx = tx_from_hex(raw_tx_reference)
|
||||
tx.nVersion = 3 # A version currently non-standard
|
||||
tx.nVersion = 4 # A version currently non-standard
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': tx.rehash(), 'allowed': False, 'reject-reason': 'version'}],
|
||||
rawtxs=[tx.serialize().hex()],
|
||||
|
||||
@@ -42,7 +42,7 @@ def cleanup(extra_args=None):
|
||||
class MempoolAcceptV3(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.extra_args = [["-acceptnonstdtxn=1"]]
|
||||
self.extra_args = [[]]
|
||||
self.setup_clean_chain = True
|
||||
|
||||
def check_mempool(self, txids):
|
||||
@@ -51,7 +51,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
assert_equal(len(txids), len(mempool_contents))
|
||||
assert all([txid in txids for txid in mempool_contents])
|
||||
|
||||
@cleanup(extra_args=["-datacarriersize=20000", "-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=["-datacarriersize=20000"])
|
||||
def test_v3_max_vsize(self):
|
||||
node = self.nodes[0]
|
||||
self.log.info("Test v3-specific maximum transaction vsize")
|
||||
@@ -65,7 +65,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
tx_v2_heavy = self.wallet.send_self_transfer(from_node=node, target_weight=(V3_MAX_VSIZE + 1) * WITNESS_SCALE_FACTOR, version=2)
|
||||
self.check_mempool([tx_v2_heavy["txid"]])
|
||||
|
||||
@cleanup(extra_args=["-datacarriersize=1000", "-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=["-datacarriersize=1000"])
|
||||
def test_v3_acceptance(self):
|
||||
node = self.nodes[0]
|
||||
self.log.info("Test a child of a v3 transaction cannot be more than 1000vB")
|
||||
@@ -105,7 +105,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
self.check_mempool([tx_v3_parent_normal["txid"], tx_v3_child_almost_heavy_rbf["txid"]])
|
||||
assert_equal(node.getmempoolentry(tx_v3_parent_normal["txid"])["descendantcount"], 2)
|
||||
|
||||
@cleanup(extra_args=["-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=None)
|
||||
def test_v3_replacement(self):
|
||||
node = self.nodes[0]
|
||||
self.log.info("Test v3 transactions may be replaced by v3 transactions")
|
||||
@@ -162,7 +162,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
self.check_mempool([tx_v3_bip125_rbf_v2["txid"], tx_v3_parent["txid"], tx_v3_child["txid"]])
|
||||
|
||||
|
||||
@cleanup(extra_args=["-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=None)
|
||||
def test_v3_bip125(self):
|
||||
node = self.nodes[0]
|
||||
self.log.info("Test v3 transactions that don't signal BIP125 are replaceable")
|
||||
@@ -186,7 +186,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
)
|
||||
self.check_mempool([tx_v3_no_bip125_rbf["txid"]])
|
||||
|
||||
@cleanup(extra_args=["-datacarriersize=40000", "-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=["-datacarriersize=40000"])
|
||||
def test_v3_reorg(self):
|
||||
node = self.nodes[0]
|
||||
self.log.info("Test that, during a reorg, v3 rules are not enforced")
|
||||
@@ -208,7 +208,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
node.reconsiderblock(block[0])
|
||||
|
||||
|
||||
@cleanup(extra_args=["-limitdescendantsize=10", "-datacarriersize=40000", "-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=["-limitdescendantsize=10", "-datacarriersize=40000"])
|
||||
def test_nondefault_package_limits(self):
|
||||
"""
|
||||
Max standard tx size + v3 rules imply the ancestor/descendant rules (at their default
|
||||
@@ -241,7 +241,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
self.generate(node, 1)
|
||||
|
||||
self.log.info("Test that a decreased limitancestorsize also applies to v3 parent")
|
||||
self.restart_node(0, extra_args=["-limitancestorsize=10", "-datacarriersize=40000", "-acceptnonstdtxn=1"])
|
||||
self.restart_node(0, extra_args=["-limitancestorsize=10", "-datacarriersize=40000"])
|
||||
tx_v3_parent_large2 = self.wallet.send_self_transfer(
|
||||
from_node=node,
|
||||
target_weight=parent_target_weight,
|
||||
@@ -261,7 +261,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
assert_raises_rpc_error(-26, f"too-long-mempool-chain, exceeds ancestor size limit", node.sendrawtransaction, tx_v3_child_large2["hex"])
|
||||
self.check_mempool([tx_v3_parent_large2["txid"]])
|
||||
|
||||
@cleanup(extra_args=["-datacarriersize=1000", "-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=["-datacarriersize=1000"])
|
||||
def test_v3_ancestors_package(self):
|
||||
self.log.info("Test that v3 ancestor limits are checked within the package")
|
||||
node = self.nodes[0]
|
||||
@@ -304,7 +304,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
result = node.testmempoolaccept([tx_v3_parent["hex"], tx_v3_child["hex"], tx_v3_grandchild["hex"]])
|
||||
assert all([txresult["package-error"] == f"v3-violation, tx {tx_v3_grandchild['txid']} (wtxid={tx_v3_grandchild['wtxid']}) would have too many ancestors" for txresult in result])
|
||||
|
||||
@cleanup(extra_args=["-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=None)
|
||||
def test_v3_ancestors_package_and_mempool(self):
|
||||
"""
|
||||
A v3 transaction in a package cannot have 2 v3 parents.
|
||||
@@ -334,7 +334,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
assert_equal(result['package_msg'], f"v3-violation, tx {tx_child_violator['txid']} (wtxid={tx_child_violator['wtxid']}) would have too many ancestors")
|
||||
self.check_mempool([tx_in_mempool["txid"]])
|
||||
|
||||
@cleanup(extra_args=["-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=None)
|
||||
def test_sibling_eviction_package(self):
|
||||
"""
|
||||
When a transaction has a mempool sibling, it may be eligible for sibling eviction.
|
||||
@@ -410,7 +410,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
assert_equal(result_package_cpfp["tx-results"][tx_sibling_3['wtxid']]['error'], expected_error_cpfp)
|
||||
|
||||
|
||||
@cleanup(extra_args=["-datacarriersize=1000", "-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=["-datacarriersize=1000"])
|
||||
def test_v3_package_inheritance(self):
|
||||
self.log.info("Test that v3 inheritance is checked within package")
|
||||
node = self.nodes[0]
|
||||
@@ -429,7 +429,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
assert_equal(result['package_msg'], f"v3-violation, non-v3 tx {tx_v2_child['txid']} (wtxid={tx_v2_child['wtxid']}) cannot spend from v3 tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']})")
|
||||
self.check_mempool([])
|
||||
|
||||
@cleanup(extra_args=["-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=None)
|
||||
def test_v3_in_testmempoolaccept(self):
|
||||
node = self.nodes[0]
|
||||
|
||||
@@ -479,7 +479,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
test_accept_2children_with_in_mempool_parent = node.testmempoolaccept([tx_v3_child_1["hex"], tx_v3_child_2["hex"]])
|
||||
assert all([result["package-error"] == expected_error_extra for result in test_accept_2children_with_in_mempool_parent])
|
||||
|
||||
@cleanup(extra_args=["-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=None)
|
||||
def test_reorg_2child_rbf(self):
|
||||
node = self.nodes[0]
|
||||
self.log.info("Test that children of a v3 transaction can be replaced individually, even if there are multiple due to reorg")
|
||||
@@ -510,7 +510,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
self.check_mempool([ancestor_tx["txid"], child_1_conflict["txid"], child_2["txid"]])
|
||||
assert_equal(node.getmempoolentry(ancestor_tx["txid"])["descendantcount"], 3)
|
||||
|
||||
@cleanup(extra_args=["-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=None)
|
||||
def test_v3_sibling_eviction(self):
|
||||
self.log.info("Test sibling eviction for v3")
|
||||
node = self.nodes[0]
|
||||
@@ -583,7 +583,7 @@ class MempoolAcceptV3(BitcoinTestFramework):
|
||||
node.sendrawtransaction(tx_v3_child_3["hex"])
|
||||
self.check_mempool(txids_v2_100 + [tx_v3_parent["txid"], tx_v3_child_3["txid"]])
|
||||
|
||||
@cleanup(extra_args=["-acceptnonstdtxn=1"])
|
||||
@cleanup(extra_args=None)
|
||||
def test_reorg_sibling_eviction_1p2c(self):
|
||||
node = self.nodes[0]
|
||||
self.log.info("Test that sibling eviction is not allowed when multiple siblings exist")
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
from test_framework.messages import (
|
||||
tx_from_hex,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
@@ -33,6 +36,7 @@ class CreateTxWalletTest(BitcoinTestFramework):
|
||||
self.test_anti_fee_sniping()
|
||||
self.test_tx_size_too_large()
|
||||
self.test_create_too_long_mempool_chain()
|
||||
self.test_version3()
|
||||
|
||||
def test_anti_fee_sniping(self):
|
||||
self.log.info('Check that we have some (old) blocks and that anti-fee-sniping is disabled')
|
||||
@@ -106,6 +110,23 @@ class CreateTxWalletTest(BitcoinTestFramework):
|
||||
|
||||
test_wallet.unloadwallet()
|
||||
|
||||
def test_version3(self):
|
||||
self.log.info('Check wallet does not create transactions with nVersion=3 yet')
|
||||
wallet_rpc = self.nodes[0].get_wallet_rpc(self.default_wallet_name)
|
||||
|
||||
self.nodes[0].createwallet("v3")
|
||||
wallet_v3 = self.nodes[0].get_wallet_rpc("v3")
|
||||
|
||||
tx_data = wallet_rpc.send(outputs=[{wallet_v3.getnewaddress(): 25}], options={"change_position": 0})
|
||||
wallet_tx_data = wallet_rpc.gettransaction(tx_data["txid"])
|
||||
tx_current_version = tx_from_hex(wallet_tx_data["hex"])
|
||||
|
||||
# While v3 transactions are standard, the CURRENT_VERSION is 2.
|
||||
# This test can be removed if CURRENT_VERSION is changed, and replaced with tests that the
|
||||
# wallet handles v3 rules properly.
|
||||
assert_equal(tx_current_version.nVersion, 2)
|
||||
wallet_v3.unloadwallet()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
CreateTxWalletTest().main()
|
||||
|
||||
Reference in New Issue
Block a user