diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -743,8 +743,10 @@ true, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-limitancestorcount=", strprintf("Do not accept transactions if number of in-mempool " - "ancestors is or more (default: %u)", - DEFAULT_ANCESTOR_LIMIT), + "ancestors is or more (pre-fork default: %u, " + "post-fork default: %u)", + DEFAULT_ANCESTOR_LIMIT, + DEFAULT_ANCESTOR_LIMIT_LONGER), true, OptionsCategory::DEBUG_TEST); gArgs.AddArg( "-limitancestorsize=", @@ -755,8 +757,9 @@ gArgs.AddArg( "-limitdescendantcount=", strprintf("Do not accept transactions if any ancestor would have " - "or more in-mempool descendants (default: %u)", - DEFAULT_DESCENDANT_LIMIT), + "or more in-mempool descendants (default pre-fork: %u, " + "default post-fork: %u)", + DEFAULT_DESCENDANT_LIMIT, DEFAULT_DESCENDANT_LIMIT_LONGER), true, OptionsCategory::DEBUG_TEST); gArgs.AddArg( "-limitdescendantsize=", diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -742,13 +742,15 @@ // Calculate in-mempool ancestors, up to a limit. CTxMemPool::setEntries setAncestors; - size_t nLimitAncestors = - gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT); + size_t nLimitAncestors = gArgs.GetArg( + "-limitancestorcount", + GetDefaultAncestorLimit(consensusParams, chainActive.Tip())); size_t nLimitAncestorSize = gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT) * 1000; - size_t nLimitDescendants = - gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT); + size_t nLimitDescendants = gArgs.GetArg( + "-limitdescendantcount", + GetDefaultDecendantLimit(consensusParams, chainActive.Tip())); size_t nLimitDescendantSize = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * diff --git a/test/functional/mempool_packages.py b/test/functional/mempool_packages.py --- a/test/functional/mempool_packages.py +++ b/test/functional/mempool_packages.py @@ -8,6 +8,7 @@ from test_framework.messages import COIN from test_framework.test_framework import BitcoinTestFramework +from test_framework.txtools import pad_raw_tx from test_framework.util import ( assert_equal, assert_raises_rpc_error, @@ -16,15 +17,22 @@ sync_mempools, ) -MAX_ANCESTORS = 25 -MAX_DESCENDANTS = 25 +# Phonos dummy activation time +ACTIVATION_TIME = 2000000000 + +# Replay protection time needs to be moved beyond phonos activation +REPLAY_PROTECTION_TIME = ACTIVATION_TIME * 2 class MempoolPackagesTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 - self.extra_args = [["-maxorphantx=1000"], - ["-maxorphantx=1000", "-limitancestorcount=5"]] + + common_params = ["-phononactivationtime={}".format(ACTIVATION_TIME), + "-replayprotectionactivationtime={}".format(REPLAY_PROTECTION_TIME)] + + self.extra_args = [common_params + ["-maxorphantx=1000"], + common_params + ["-maxorphantx=1000", "-limitancestorcount=5"]] def skip_test_if_missing_module(self): self.skip_if_no_wallet() @@ -40,13 +48,22 @@ outputs[node.getnewaddress()] = send_value rawtx = node.createrawtransaction(inputs, outputs) signedtx = node.signrawtransactionwithwallet(rawtx) - txid = node.sendrawtransaction(signedtx['hex']) + txid = node.sendrawtransaction(pad_raw_tx(signedtx['hex'])) fulltx = node.getrawtransaction(txid, 1) # make sure we didn't generate a change output assert len(fulltx['vout']) == num_outputs return (txid, send_value) def run_test(self): + # pre-phonon test + [n.setmocktime(ACTIVATION_TIME - 10000) for n in self.nodes] + self.run_mempool_test(max_ancestors=25, max_descendants=25) + + # post-phonon test + [n.setmocktime(ACTIVATION_TIME) for n in self.nodes] + self.run_mempool_test(max_ancestors=50, max_descendants=50) + + def run_mempool_test(self, *, max_ancestors, max_descendants): # Mine some blocks and have them mature. self.nodes[0].generate(101) utxo = self.nodes[0].listunspent(10) @@ -55,24 +72,24 @@ value = utxo[0]['amount'] fee = Decimal("0.0001") - # MAX_ANCESTORS transactions off a confirmed tx should be fine + # max_ancestors transactions off a confirmed tx should be fine chain = [] - for i in range(MAX_ANCESTORS): + for i in range(max_ancestors): (txid, sent_value) = self.chain_transaction( self.nodes[0], txid, 0, value, fee, 1) value = sent_value chain.append(txid) - # Check mempool has MAX_ANCESTORS transactions in it, and descendant and ancestor + # Check mempool has max_ancestors transactions in it, and descendant and ancestor # count and fees should look correct mempool = self.nodes[0].getrawmempool(True) - assert_equal(len(mempool), MAX_ANCESTORS) + assert_equal(len(mempool), max_ancestors) descendant_count = 1 descendant_fees = 0 descendant_size = 0 ancestor_size = sum([mempool[tx]['size'] for tx in mempool]) - ancestor_count = MAX_ANCESTORS + ancestor_count = max_ancestors ancestor_fees = sum([mempool[tx]['fee'] for tx in mempool]) descendants = [] @@ -235,7 +252,7 @@ # Sign and send up to MAX_DESCENDANT transactions chained off the # parent tx - for i in range(MAX_DESCENDANTS - 1): + for i in range(max_descendants - 1): utxo = transaction_package.pop(0) (txid, sent_value) = self.chain_transaction( self.nodes[0], utxo['txid'], utxo['vout'], utxo['amount'], fee, 10) @@ -247,7 +264,7 @@ mempool = self.nodes[0].getrawmempool(True) assert_equal(mempool[parent_transaction] - ['descendantcount'], MAX_DESCENDANTS) + ['descendantcount'], max_descendants) assert_equal(sorted(mempool[parent_transaction] ['spentby']), sorted(tx_children))