diff options
author | Andrew Chow <github@achow101.com> | 2022-12-21 12:44:31 -0500 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2022-12-21 12:58:46 -0500 |
commit | f3bc1a72825fe2b51f4bc20e004cef464f05b965 (patch) | |
tree | 2a148bf7b2bef1b45cf05e869cc56d0af0bffa09 /test/functional/test_framework | |
parent | 6d40a1a7e7f09ff2c32e53237f968adf8300d028 (diff) | |
parent | b2aa9e85289fc654106a890c35935e9c76c411fb (diff) | |
download | bitcoin-f3bc1a72825fe2b51f4bc20e004cef464f05b965.tar.xz |
Merge bitcoin/bitcoin#26265: POLICY: Relax MIN_STANDARD_TX_NONWITNESS_SIZE to 65 non-witness bytes
b2aa9e85289fc654106a890c35935e9c76c411fb Add release note for MIN_STANDARD_TX_NONWITNESS_SIZE relaxation (Greg Sanders)
8c5b3646b5afe8a61f5c66478d8e11f0d2ce5108 Relax MIN_STANDARD_TX_NONWITNESS_SIZE to 65 non-witness bytes (Greg Sanders)
Pull request description:
Since the original fix was set to be a "reasonable" transaction to reduce allocations and the true motivation later revealed, it makes sense to relax this check to something more principled.
There are more exotic transaction patterns that could take advantage of a relaxed requirement, such as 1 input, 1 output OP_RETURN to burn a utxo to fees for CPFP purposes when change isn't practical.
Two changes could be accomplished:
1) Anything not 64 bytes could be allowed
2) Anything above 64 bytes could be allowed
In the Great Consensus Cleanup, suggestion (2)
was proposed as a consensus change, and is the simpler of the two suggestions. It would not allow an "empty" OP_RETURN but would reduce the required padding from 22 bytes to 5.
The functional test is also modified to test the actual case
we care about: 64 bytes
Related mailing list discussions here:
https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-October/020995.html
And a couple years earlier:
https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-May/017883.html
ACKs for top commit:
achow101:
reACK b2aa9e85289fc654106a890c35935e9c76c411fb
glozow:
reACK b2aa9e85289fc654106a890c35935e9c76c411fb
pablomartin4btc:
re-ACK https://github.com/bitcoin/bitcoin/commit/b2aa9e85289fc654106a890c35935e9c76c411fb
jonatack:
ACK b2aa9e85289fc654106a890c35935e9c76c411fb with some suggestions
Tree-SHA512: c1ec1af9ddcf31b2272209a4f1ee0c5607399f8172e5a1dfd4604cf98bfb933810dd9369a5917ad122add003327c9fcf6ee26995de3aca41d5c42dba527991ad
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-x | test/functional/test_framework/script_util.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/test/functional/test_framework/script_util.py b/test/functional/test_framework/script_util.py index b114002145..39dcb418b7 100755 --- a/test/functional/test_framework/script_util.py +++ b/test/functional/test_framework/script_util.py @@ -13,12 +13,13 @@ from test_framework.script import ( OP_EQUAL, OP_EQUALVERIFY, OP_HASH160, + OP_RETURN, hash160, sha256, ) # To prevent a "tx-size-small" policy rule error, a transaction has to have a -# non-witness size of at least 82 bytes (MIN_STANDARD_TX_NONWITNESS_SIZE in +# non-witness size of at least 65 bytes (MIN_STANDARD_TX_NONWITNESS_SIZE in # src/policy/policy.h). Considering a Tx with the smallest possible single # input (blank, empty scriptSig), and with an output omitting the scriptPubKey, # we get to a minimum size of 60 bytes: @@ -28,15 +29,15 @@ from test_framework.script import ( # Output: 8 [Amount] + 1 [scriptPubKeyLen] = 9 bytes # # Hence, the scriptPubKey of the single output has to have a size of at -# least 22 bytes, which corresponds to the size of a P2WPKH scriptPubKey. -# The following script constant consists of a single push of 21 bytes of 'a': -# <PUSH_21> <21-bytes of 'a'> -# resulting in a 22-byte size. It should be used whenever (small) fake -# scriptPubKeys are needed, to guarantee that the minimum transaction size is -# met. -DUMMY_P2WPKH_SCRIPT = CScript([b'a' * 21]) -DUMMY_2_P2WPKH_SCRIPT = CScript([b'b' * 21]) - +# least 5 bytes. +MIN_STANDARD_TX_NONWITNESS_SIZE = 65 +MIN_PADDING = MIN_STANDARD_TX_NONWITNESS_SIZE - 10 - 41 - 9 +assert MIN_PADDING == 5 + +# This script cannot be spent, allowing dust output values under +# standardness checks +DUMMY_MIN_OP_RETURN_SCRIPT = CScript([OP_RETURN] + ([OP_0] * (MIN_PADDING - 1))) +assert len(DUMMY_MIN_OP_RETURN_SCRIPT) == MIN_PADDING def key_to_p2pk_script(key): key = check_key(key) |