Merge #15681: [mempool] Allow one extra single-ancestor transaction per package
50cede3f5a4d4fbfbb7c420b94e661a6a159bced [mempool] Allow one extra single-ancestor transaction per package (Matt Corallo)
Pull request description:
This implements the proposed policy change from [1], which allows
certain classes of contract protocols involving revocation
punishments to use CPFP. Note that some such use-cases may still
want some form of one-deep package relay, though even this alone
may greatly simplify some lightning fee negotiation.
[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
ACKs for top commit:
ajtowns:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced -- looked over code again, compared with previous commit, compiles, etc.
sdaftuar:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced
ryanofsky:
utACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced. Changes since last review: adding EXTRA_DESCENDANT_TX_SIZE_LIMIT constant, changing max ancestor size from 1,000,000 to nLimitAncestorSize constant (101,000), fixing test comment and getting rid of unused test node.
Tree-SHA512: b052c2a0f384855572b4579310131897b612201214b5abbb225167224e4f550049e300b471dbf320928652571e92ca2d650050b7cf39ac92b3bc1d2bcd386c1c
2019-07-19 19:56:12 +02:00
#!/usr/bin/env python3
2020-12-31 18:50:11 +01:00
# Copyright (c) 2014-2020 The Bitcoin Core developers
Merge #15681: [mempool] Allow one extra single-ancestor transaction per package
50cede3f5a4d4fbfbb7c420b94e661a6a159bced [mempool] Allow one extra single-ancestor transaction per package (Matt Corallo)
Pull request description:
This implements the proposed policy change from [1], which allows
certain classes of contract protocols involving revocation
punishments to use CPFP. Note that some such use-cases may still
want some form of one-deep package relay, though even this alone
may greatly simplify some lightning fee negotiation.
[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
ACKs for top commit:
ajtowns:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced -- looked over code again, compared with previous commit, compiles, etc.
sdaftuar:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced
ryanofsky:
utACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced. Changes since last review: adding EXTRA_DESCENDANT_TX_SIZE_LIMIT constant, changing max ancestor size from 1,000,000 to nLimitAncestorSize constant (101,000), fixing test comment and getting rid of unused test node.
Tree-SHA512: b052c2a0f384855572b4579310131897b612201214b5abbb225167224e4f550049e300b471dbf320928652571e92ca2d650050b7cf39ac92b3bc1d2bcd386c1c
2019-07-19 19:56:12 +02:00
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
""" Test descendant package tracking carve-out allowing one final transaction in
an otherwise - full package as long as it has only one parent and is < = 10 k in
size .
"""
from decimal import Decimal
2021-05-31 11:26:16 +02:00
from test_framework . blocktools import COINBASE_MATURITY
Merge #15681: [mempool] Allow one extra single-ancestor transaction per package
50cede3f5a4d4fbfbb7c420b94e661a6a159bced [mempool] Allow one extra single-ancestor transaction per package (Matt Corallo)
Pull request description:
This implements the proposed policy change from [1], which allows
certain classes of contract protocols involving revocation
punishments to use CPFP. Note that some such use-cases may still
want some form of one-deep package relay, though even this alone
may greatly simplify some lightning fee negotiation.
[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
ACKs for top commit:
ajtowns:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced -- looked over code again, compared with previous commit, compiles, etc.
sdaftuar:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced
ryanofsky:
utACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced. Changes since last review: adding EXTRA_DESCENDANT_TX_SIZE_LIMIT constant, changing max ancestor size from 1,000,000 to nLimitAncestorSize constant (101,000), fixing test comment and getting rid of unused test node.
Tree-SHA512: b052c2a0f384855572b4579310131897b612201214b5abbb225167224e4f550049e300b471dbf320928652571e92ca2d650050b7cf39ac92b3bc1d2bcd386c1c
2019-07-19 19:56:12 +02:00
from test_framework . test_framework import BitcoinTestFramework
from test_framework . util import assert_equal , assert_raises_rpc_error , satoshi_round
MAX_ANCESTORS = 25
MAX_DESCENDANTS = 25
class MempoolPackagesTest ( BitcoinTestFramework ) :
def set_test_params ( self ) :
self . num_nodes = 1
self . extra_args = [ [ " -maxorphantxsize=100000 " ] ]
def skip_test_if_missing_module ( self ) :
self . skip_if_no_wallet ( )
# Build a transaction that spends parent_txid:vout
# Return amount sent
def chain_transaction ( self , node , parent_txids , vouts , value , fee , num_outputs ) :
send_value = satoshi_round ( ( value - fee ) / num_outputs )
inputs = [ ]
for ( txid , vout ) in zip ( parent_txids , vouts ) :
inputs . append ( { ' txid ' : txid , ' vout ' : vout } )
outputs = { }
2020-08-11 02:50:34 +02:00
for _ in range ( num_outputs ) :
Merge #15681: [mempool] Allow one extra single-ancestor transaction per package
50cede3f5a4d4fbfbb7c420b94e661a6a159bced [mempool] Allow one extra single-ancestor transaction per package (Matt Corallo)
Pull request description:
This implements the proposed policy change from [1], which allows
certain classes of contract protocols involving revocation
punishments to use CPFP. Note that some such use-cases may still
want some form of one-deep package relay, though even this alone
may greatly simplify some lightning fee negotiation.
[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
ACKs for top commit:
ajtowns:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced -- looked over code again, compared with previous commit, compiles, etc.
sdaftuar:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced
ryanofsky:
utACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced. Changes since last review: adding EXTRA_DESCENDANT_TX_SIZE_LIMIT constant, changing max ancestor size from 1,000,000 to nLimitAncestorSize constant (101,000), fixing test comment and getting rid of unused test node.
Tree-SHA512: b052c2a0f384855572b4579310131897b612201214b5abbb225167224e4f550049e300b471dbf320928652571e92ca2d650050b7cf39ac92b3bc1d2bcd386c1c
2019-07-19 19:56:12 +02:00
outputs [ node . getnewaddress ( ) ] = send_value
rawtx = node . createrawtransaction ( inputs , outputs )
signedtx = node . signrawtransactionwithwallet ( rawtx )
txid = node . sendrawtransaction ( signedtx [ ' hex ' ] )
fulltx = node . getrawtransaction ( txid , 1 )
assert len ( fulltx [ ' vout ' ] ) == num_outputs # make sure we didn't generate a change output
return ( txid , send_value )
def run_test ( self ) :
# Mine some blocks and have them mature.
2021-05-31 11:26:16 +02:00
self . nodes [ 0 ] . generate ( COINBASE_MATURITY + 1 )
Merge #15681: [mempool] Allow one extra single-ancestor transaction per package
50cede3f5a4d4fbfbb7c420b94e661a6a159bced [mempool] Allow one extra single-ancestor transaction per package (Matt Corallo)
Pull request description:
This implements the proposed policy change from [1], which allows
certain classes of contract protocols involving revocation
punishments to use CPFP. Note that some such use-cases may still
want some form of one-deep package relay, though even this alone
may greatly simplify some lightning fee negotiation.
[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
ACKs for top commit:
ajtowns:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced -- looked over code again, compared with previous commit, compiles, etc.
sdaftuar:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced
ryanofsky:
utACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced. Changes since last review: adding EXTRA_DESCENDANT_TX_SIZE_LIMIT constant, changing max ancestor size from 1,000,000 to nLimitAncestorSize constant (101,000), fixing test comment and getting rid of unused test node.
Tree-SHA512: b052c2a0f384855572b4579310131897b612201214b5abbb225167224e4f550049e300b471dbf320928652571e92ca2d650050b7cf39ac92b3bc1d2bcd386c1c
2019-07-19 19:56:12 +02:00
utxo = self . nodes [ 0 ] . listunspent ( 10 )
txid = utxo [ 0 ] [ ' txid ' ]
vout = utxo [ 0 ] [ ' vout ' ]
value = utxo [ 0 ] [ ' amount ' ]
fee = Decimal ( " 0.0002 " )
# MAX_ANCESTORS transactions off a confirmed tx should be fine
chain = [ ]
for _ in range ( 4 ) :
( txid , sent_value ) = self . chain_transaction ( self . nodes [ 0 ] , [ txid ] , [ vout ] , value , fee , 2 )
vout = 0
value = sent_value
chain . append ( [ txid , value ] )
for _ in range ( MAX_ANCESTORS - 4 ) :
( txid , sent_value ) = self . chain_transaction ( self . nodes [ 0 ] , [ txid ] , [ 0 ] , value , fee , 1 )
value = sent_value
chain . append ( [ txid , value ] )
( second_chain , second_chain_value ) = self . chain_transaction ( self . nodes [ 0 ] , [ utxo [ 1 ] [ ' txid ' ] ] , [ utxo [ 1 ] [ ' vout ' ] ] , utxo [ 1 ] [ ' amount ' ] , fee , 1 )
# Check mempool has MAX_ANCESTORS + 1 transactions in it
assert_equal ( len ( self . nodes [ 0 ] . getrawmempool ( True ) ) , MAX_ANCESTORS + 1 )
# Adding one more transaction on to the chain should fail.
2019-07-29 18:55:12 +02:00
assert_raises_rpc_error ( - 26 , " too-long-mempool-chain, too many unconfirmed ancestors [limit: 25] " , self . chain_transaction , self . nodes [ 0 ] , [ txid ] , [ 0 ] , value , fee , 1 )
Merge #15681: [mempool] Allow one extra single-ancestor transaction per package
50cede3f5a4d4fbfbb7c420b94e661a6a159bced [mempool] Allow one extra single-ancestor transaction per package (Matt Corallo)
Pull request description:
This implements the proposed policy change from [1], which allows
certain classes of contract protocols involving revocation
punishments to use CPFP. Note that some such use-cases may still
want some form of one-deep package relay, though even this alone
may greatly simplify some lightning fee negotiation.
[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
ACKs for top commit:
ajtowns:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced -- looked over code again, compared with previous commit, compiles, etc.
sdaftuar:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced
ryanofsky:
utACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced. Changes since last review: adding EXTRA_DESCENDANT_TX_SIZE_LIMIT constant, changing max ancestor size from 1,000,000 to nLimitAncestorSize constant (101,000), fixing test comment and getting rid of unused test node.
Tree-SHA512: b052c2a0f384855572b4579310131897b612201214b5abbb225167224e4f550049e300b471dbf320928652571e92ca2d650050b7cf39ac92b3bc1d2bcd386c1c
2019-07-19 19:56:12 +02:00
# ...even if it chains on from some point in the middle of the chain.
2019-07-29 18:55:12 +02:00
assert_raises_rpc_error ( - 26 , " too-long-mempool-chain, too many descendants " , self . chain_transaction , self . nodes [ 0 ] , [ chain [ 2 ] [ 0 ] ] , [ 1 ] , chain [ 2 ] [ 1 ] , fee , 1 )
assert_raises_rpc_error ( - 26 , " too-long-mempool-chain, too many descendants " , self . chain_transaction , self . nodes [ 0 ] , [ chain [ 1 ] [ 0 ] ] , [ 1 ] , chain [ 1 ] [ 1 ] , fee , 1 )
Merge #15681: [mempool] Allow one extra single-ancestor transaction per package
50cede3f5a4d4fbfbb7c420b94e661a6a159bced [mempool] Allow one extra single-ancestor transaction per package (Matt Corallo)
Pull request description:
This implements the proposed policy change from [1], which allows
certain classes of contract protocols involving revocation
punishments to use CPFP. Note that some such use-cases may still
want some form of one-deep package relay, though even this alone
may greatly simplify some lightning fee negotiation.
[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
ACKs for top commit:
ajtowns:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced -- looked over code again, compared with previous commit, compiles, etc.
sdaftuar:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced
ryanofsky:
utACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced. Changes since last review: adding EXTRA_DESCENDANT_TX_SIZE_LIMIT constant, changing max ancestor size from 1,000,000 to nLimitAncestorSize constant (101,000), fixing test comment and getting rid of unused test node.
Tree-SHA512: b052c2a0f384855572b4579310131897b612201214b5abbb225167224e4f550049e300b471dbf320928652571e92ca2d650050b7cf39ac92b3bc1d2bcd386c1c
2019-07-19 19:56:12 +02:00
# ...even if it chains on to two parent transactions with one in the chain.
2019-07-29 18:55:12 +02:00
assert_raises_rpc_error ( - 26 , " too-long-mempool-chain, too many descendants " , self . chain_transaction , self . nodes [ 0 ] , [ chain [ 0 ] [ 0 ] , second_chain ] , [ 1 , 0 ] , chain [ 0 ] [ 1 ] + second_chain_value , fee , 1 )
Merge #15681: [mempool] Allow one extra single-ancestor transaction per package
50cede3f5a4d4fbfbb7c420b94e661a6a159bced [mempool] Allow one extra single-ancestor transaction per package (Matt Corallo)
Pull request description:
This implements the proposed policy change from [1], which allows
certain classes of contract protocols involving revocation
punishments to use CPFP. Note that some such use-cases may still
want some form of one-deep package relay, though even this alone
may greatly simplify some lightning fee negotiation.
[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
ACKs for top commit:
ajtowns:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced -- looked over code again, compared with previous commit, compiles, etc.
sdaftuar:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced
ryanofsky:
utACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced. Changes since last review: adding EXTRA_DESCENDANT_TX_SIZE_LIMIT constant, changing max ancestor size from 1,000,000 to nLimitAncestorSize constant (101,000), fixing test comment and getting rid of unused test node.
Tree-SHA512: b052c2a0f384855572b4579310131897b612201214b5abbb225167224e4f550049e300b471dbf320928652571e92ca2d650050b7cf39ac92b3bc1d2bcd386c1c
2019-07-19 19:56:12 +02:00
# ...especially if its > 40k weight
2019-07-29 18:55:12 +02:00
assert_raises_rpc_error ( - 26 , " too-long-mempool-chain, too many descendants " , self . chain_transaction , self . nodes [ 0 ] , [ chain [ 0 ] [ 0 ] ] , [ 1 ] , chain [ 0 ] [ 1 ] , fee , 350 )
Merge #15681: [mempool] Allow one extra single-ancestor transaction per package
50cede3f5a4d4fbfbb7c420b94e661a6a159bced [mempool] Allow one extra single-ancestor transaction per package (Matt Corallo)
Pull request description:
This implements the proposed policy change from [1], which allows
certain classes of contract protocols involving revocation
punishments to use CPFP. Note that some such use-cases may still
want some form of one-deep package relay, though even this alone
may greatly simplify some lightning fee negotiation.
[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
ACKs for top commit:
ajtowns:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced -- looked over code again, compared with previous commit, compiles, etc.
sdaftuar:
ACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced
ryanofsky:
utACK 50cede3f5a4d4fbfbb7c420b94e661a6a159bced. Changes since last review: adding EXTRA_DESCENDANT_TX_SIZE_LIMIT constant, changing max ancestor size from 1,000,000 to nLimitAncestorSize constant (101,000), fixing test comment and getting rid of unused test node.
Tree-SHA512: b052c2a0f384855572b4579310131897b612201214b5abbb225167224e4f550049e300b471dbf320928652571e92ca2d650050b7cf39ac92b3bc1d2bcd386c1c
2019-07-19 19:56:12 +02:00
# But not if it chains directly off the first transaction
self . chain_transaction ( self . nodes [ 0 ] , [ chain [ 0 ] [ 0 ] ] , [ 1 ] , chain [ 0 ] [ 1 ] , fee , 1 )
# and the second chain should work just fine
self . chain_transaction ( self . nodes [ 0 ] , [ second_chain ] , [ 0 ] , second_chain_value , fee , 1 )
# Finally, check that we added two transactions
assert_equal ( len ( self . nodes [ 0 ] . getrawmempool ( True ) ) , MAX_ANCESTORS + 3 )
if __name__ == ' __main__ ' :
MempoolPackagesTest ( ) . main ( )