From f319287d819cc97b5422248aacf447ca190e20f6 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Wed, 29 Jun 2022 17:28:33 +0200 Subject: [PATCH 1/3] test: assert serialized txouts size of `gen_return_txouts` helper This assures that changing the internals of the helper function still leads to the expected outcome sizewise (preparation for the next commit). --- test/functional/test_framework/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 6a588275ea..eab94c32d9 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -499,7 +499,8 @@ def chain_transaction(node, parent_txids, vouts, value, fee, num_outputs): # Create large OP_RETURN txouts that can be appended to a transaction -# to make it large (helper for constructing large transactions). +# to make it large (helper for constructing large transactions). The +# total serialized size of the txouts is about 66k vbytes. def gen_return_txouts(): # Some pre-processing to create a bunch of OP_RETURN txouts to insert into transactions we create # So we have big transactions (and therefore can't fit very many into each block) @@ -515,6 +516,7 @@ def gen_return_txouts(): txout.scriptPubKey = bytes.fromhex(script_pubkey) for _ in range(128): txouts.append(txout) + assert_equal(sum([len(txout.serialize()) for txout in txouts]), 67456) return txouts From b1ba3ed155e89fb6e30237cba8bc8028c7906830 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Wed, 29 Jun 2022 17:42:51 +0200 Subject: [PATCH 2/3] test: let `gen_return_txouts` create a single large OP_RETURN output Transactions with more than one datacarrier (OP_RETURN) output are never considered standard, i.e. this change is necessary in order to to get rid of the `acceptnonstdtxn` option for some tests. --- test/functional/test_framework/util.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index eab94c32d9..1ee23f7574 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -502,20 +502,9 @@ def chain_transaction(node, parent_txids, vouts, value, fee, num_outputs): # to make it large (helper for constructing large transactions). The # total serialized size of the txouts is about 66k vbytes. def gen_return_txouts(): - # Some pre-processing to create a bunch of OP_RETURN txouts to insert into transactions we create - # So we have big transactions (and therefore can't fit very many into each block) - # create one script_pubkey - script_pubkey = "6a4d0200" # OP_RETURN OP_PUSH2 512 bytes - for _ in range(512): - script_pubkey = script_pubkey + "01" - # concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change - txouts = [] from .messages import CTxOut - txout = CTxOut() - txout.nValue = 0 - txout.scriptPubKey = bytes.fromhex(script_pubkey) - for _ in range(128): - txouts.append(txout) + from .script import CScript, OP_RETURN + txouts = [CTxOut(nValue=0, scriptPubKey=CScript([OP_RETURN, b'\x01'*67437]))] assert_equal(sum([len(txout.serialize()) for txout in txouts]), 67456) return txouts From 475aae846e71e355e8f70c0a1857339b1124bcc0 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Wed, 29 Jun 2022 17:51:39 +0200 Subject: [PATCH 3/3] test: pass `datacarriersize` option for tests using large outputs (instead of `acceptnonstdtxn`) By specifying the `datacarriersize` option instead of the more generic `acceptnonstdtxn`, we can be more specific about what part of the transaction is non-standard and can be sure that all other aspects follow the standard policy. --- test/functional/feature_maxuploadtarget.py | 2 +- test/functional/mempool_limit.py | 2 +- test/functional/mining_prioritisetransaction.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/functional/feature_maxuploadtarget.py b/test/functional/feature_maxuploadtarget.py index 0b9d651226..3ea412002a 100755 --- a/test/functional/feature_maxuploadtarget.py +++ b/test/functional/feature_maxuploadtarget.py @@ -46,7 +46,7 @@ class MaxUploadTest(BitcoinTestFramework): self.num_nodes = 1 self.extra_args = [[ "-maxuploadtarget=800M", - "-acceptnonstdtxn=1", + "-datacarriersize=100000", ]] self.supports_cli = False diff --git a/test/functional/mempool_limit.py b/test/functional/mempool_limit.py index e92f73304b..7080662b49 100755 --- a/test/functional/mempool_limit.py +++ b/test/functional/mempool_limit.py @@ -23,7 +23,7 @@ class MempoolLimitTest(BitcoinTestFramework): self.setup_clean_chain = True self.num_nodes = 1 self.extra_args = [[ - "-acceptnonstdtxn=1", + "-datacarriersize=100000", "-maxmempool=5", "-spendzeroconfchange=0", ]] diff --git a/test/functional/mining_prioritisetransaction.py b/test/functional/mining_prioritisetransaction.py index fb3974c1d5..64e66ac30a 100755 --- a/test/functional/mining_prioritisetransaction.py +++ b/test/functional/mining_prioritisetransaction.py @@ -26,7 +26,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework): self.num_nodes = 1 self.extra_args = [[ "-printpriority=1", - "-acceptnonstdtxn=1", + "-datacarriersize=100000", ]] * self.num_nodes self.supports_cli = False