mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
[policy] make v3 transactions standard
Note that, as CURRENT_VERSION = 2, the wallet will not make transactions with nVersion=3 yet.
This commit is contained in:
parent
052ede75af
commit
539404fe0f
3 changed files with 18 additions and 18 deletions
|
@ -131,7 +131,7 @@ bool IsStandard(const CScript& scriptPubKey, const std::optional<unsigned>& max_
|
|||
// Changing the default transaction version requires a two step process: first
|
||||
// adapting relay policy by bumping TX_MAX_STANDARD_VERSION, and then later
|
||||
// allowing the new transaction version in the wallet/RPC.
|
||||
static constexpr decltype(CTransaction::nVersion) TX_MAX_STANDARD_VERSION{2};
|
||||
static constexpr decltype(CTransaction::nVersion) TX_MAX_STANDARD_VERSION{3};
|
||||
|
||||
/**
|
||||
* Check for standard transaction types
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Reference in a new issue