Skip to content

Commit 971a4e6

Browse files
committed
Lower default policy limits
Reduce the default limits on maximum number of transactions and the cumulative size of those transactions in both ancestor and descendant packages to 25 txs and 101kb total size.
1 parent 8daffe2 commit 971a4e6

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

qa/rpc-tests/mempool_packages.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
def satoshi_round(amount):
1212
return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
1313

14+
MAX_ANCESTORS = 25
15+
MAX_DESCENDANTS = 25
16+
1417
class MempoolPackagesTest(BitcoinTestFramework):
1518

1619
def setup_network(self):
@@ -45,17 +48,17 @@ def run_test(self):
4548
value = utxo[0]['amount']
4649

4750
fee = Decimal("0.0001")
48-
# 100 transactions off a confirmed tx should be fine
51+
# MAX_ANCESTORS transactions off a confirmed tx should be fine
4952
chain = []
50-
for i in xrange(100):
53+
for i in xrange(MAX_ANCESTORS):
5154
(txid, sent_value) = self.chain_transaction(self.nodes[0], txid, 0, value, fee, 1)
5255
value = sent_value
5356
chain.append(txid)
5457

55-
# Check mempool has 100 transactions in it, and descendant
58+
# Check mempool has MAX_ANCESTORS transactions in it, and descendant
5659
# count and fees should look correct
5760
mempool = self.nodes[0].getrawmempool(True)
58-
assert_equal(len(mempool), 100)
61+
assert_equal(len(mempool), MAX_ANCESTORS)
5962
descendant_count = 1
6063
descendant_fees = 0
6164
descendant_size = 0
@@ -91,18 +94,18 @@ def run_test(self):
9194
for i in xrange(10):
9295
transaction_package.append({'txid': txid, 'vout': i, 'amount': sent_value})
9396

94-
for i in xrange(1000):
97+
for i in xrange(MAX_DESCENDANTS):
9598
utxo = transaction_package.pop(0)
9699
try:
97100
(txid, sent_value) = self.chain_transaction(self.nodes[0], utxo['txid'], utxo['vout'], utxo['amount'], fee, 10)
98101
for j in xrange(10):
99102
transaction_package.append({'txid': txid, 'vout': j, 'amount': sent_value})
100-
if i == 998:
103+
if i == MAX_DESCENDANTS - 2:
101104
mempool = self.nodes[0].getrawmempool(True)
102-
assert_equal(mempool[parent_transaction]['descendantcount'], 1000)
105+
assert_equal(mempool[parent_transaction]['descendantcount'], MAX_DESCENDANTS)
103106
except JSONRPCException as e:
104107
print e.error['message']
105-
assert_equal(i, 999)
108+
assert_equal(i, MAX_DESCENDANTS - 1)
106109
print "tx that would create too large descendant package successfully rejected"
107110

108111
# TODO: check that node1's mempool is as expected

src/main.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ static const bool DEFAULT_ALERTS = true;
4444
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
4545
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
4646
/** Default for -limitancestorcount, max number of in-mempool ancestors */
47-
static const unsigned int DEFAULT_ANCESTOR_LIMIT = 100;
47+
static const unsigned int DEFAULT_ANCESTOR_LIMIT = 25;
4848
/** Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors */
49-
static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT = 900;
49+
static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT = 101;
5050
/** Default for -limitdescendantcount, max number of in-mempool descendants */
51-
static const unsigned int DEFAULT_DESCENDANT_LIMIT = 1000;
51+
static const unsigned int DEFAULT_DESCENDANT_LIMIT = 25;
5252
/** Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants */
53-
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 2500;
53+
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101;
5454
/** Default for -maxmempool, maximum megabytes of mempool memory usage */
5555
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
5656
/** Default for -mempoolexpiry, expiration time for mempool transactions in hours */

0 commit comments

Comments
 (0)