Skip to content

Commit 1cd9ebd

Browse files
MacroFakePastaPastaPasta
authored andcommitted
Merge bitcoin#25503: test: pass datacarriersize option for tests using large outputs (instead of acceptnonstdtxn)
475aae8 test: pass `datacarriersize` option for tests using large outputs (instead of `acceptnonstdtxn`) (Sebastian Falbesoner) b1ba3ed test: let `gen_return_txouts` create a single large OP_RETURN output (Sebastian Falbesoner) f319287 test: assert serialized txouts size of `gen_return_txouts` helper (Sebastian Falbesoner) Pull request description: By specifying the `datacarriersize` option instead of the more generic `acceptnonstdtxn` for functional tests, 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. Transactions with more than one OP_RETURN output are [never considered standard](https://github.com/bitcoin/bitcoin/blob/749b80b29e875cc6afa1c2674cccdfd7115cc16a/src/policy/policy.cpp#L149-L153), i.e. we have to change the `gen_return_txouts` helper to create only a single output in order to get rid of the `acceptnonstdxtn` option. Note that on master there is currently no test using the `datacarriersize` parameter, so this PR indirectly also increases the test coverage. The change affects the tests `mempool_limit.py`, `mining_prioritisetransaction.py` (call `gen_return_txouts` directly) and `feature_maxuploadtarget.py` (calls `gen_return_txouts` indirectly via the `mine_large_block(...)` helper). Top commit has no ACKs. Tree-SHA512: c17f032e00d28f5e5880a4d378773fbc8b1995ea9c377f237598d412628fe117f497a44ebdfa8af8cd8a3b1e3127e0cf7692efbf5c833c713764a71a85301f23
1 parent 083a8b2 commit 1cd9ebd

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

test/functional/feature_maxuploadtarget.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def set_test_params(self):
4646
self.setup_clean_chain = True
4747
self.num_nodes = 1
4848
self.extra_args = [[
49-
"-maxuploadtarget=400",
50-
"-acceptnonstdtxn=1",
49+
"-maxuploadtarget=400M",
50+
"-datacarriersize=100000",
5151
]]
5252
self.supports_cli = False
5353

test/functional/mempool_limit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def set_test_params(self):
2323
self.setup_clean_chain = True
2424
self.num_nodes = 1
2525
self.extra_args = [[
26-
"-acceptnonstdtxn=1",
26+
"-datacarriersize=100000",
2727
"-maxmempool=5",
2828
"-spendzeroconfchange=0",
2929
]]

test/functional/mining_prioritisetransaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def set_test_params(self):
1414
self.num_nodes = 2
1515
self.extra_args = [[
1616
"-printpriority=1",
17-
"-acceptnonstdtxn=1",
17+
"-datacarriersize=100000",
1818
]] * self.num_nodes
1919
self.supports_cli = False
2020

test/functional/test_framework/util.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -602,22 +602,13 @@ def chain_transaction(node, parent_txids, vouts, value, fee, num_outputs):
602602

603603

604604
# Create large OP_RETURN txouts that can be appended to a transaction
605-
# to make it large (helper for constructing large transactions).
605+
# to make it large (helper for constructing large transactions). The
606+
# total serialized size of the txouts is about 66k vbytes.
606607
def gen_return_txouts():
607-
# Some pre-processing to create a bunch of OP_RETURN txouts to insert into transactions we create
608-
# So we have big transactions (and therefore can't fit very many into each block)
609-
# create one script_pubkey
610-
script_pubkey = "6a4d0200" # OP_RETURN OP_PUSH2 512 bytes
611-
for _ in range(512):
612-
script_pubkey = script_pubkey + "01"
613-
# concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change
614-
txouts = []
615608
from .messages import CTxOut
616-
txout = CTxOut()
617-
txout.nValue = 0
618-
txout.scriptPubKey = bytes.fromhex(script_pubkey)
619-
for _ in range(128):
620-
txouts.append(txout)
609+
from .script import CScript, OP_RETURN
610+
txouts = [CTxOut(nValue=0, scriptPubKey=CScript([OP_RETURN, b'\x01'*67437]))]
611+
assert_equal(sum([len(txout.serialize()) for txout in txouts]), 67456)
621612
return txouts
622613

623614

0 commit comments

Comments
 (0)