Skip to content

Commit fa7c283

Browse files
committed
Merge bitcoin/bitcoin#30948: test: Add missing sync_mempools() to fill_mempool()
faf8015 test: Add missing sync_mempools() to fill_mempool() (MarcoFalke) fa48be6 test: Refactor fill_mempool to extract send_batch helper (MarcoFalke) Pull request description: Not doing the sync will lead to (intermittent) issues, as explained in bitcoin/bitcoin#30922 (comment). Fix all issues by doing the sync by default and disable it in places that do not need the sync. Fixes #30922 ACKs for top commit: mzumsande: Tested ACK faf8015 ismaelsadeeq: Tested ACK faf8015 marcofleon: Tested ACK faf8015 Tree-SHA512: 2de62d168cbb6857a9fb8bc12c42a9093fedf5e9beb6f83a32b3fa72a5ba3cf03631055fd25ef553399a27a6fe0d71c44cfe60660a4d31986debd13b8ab00228
2 parents d5af7d2 + faf8015 commit fa7c283

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

test/functional/mempool_package_rbf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def test_0fee_package_rbf(self):
554554
self.generate(node, 1)
555555

556556
def test_child_conflicts_parent_mempool_ancestor(self):
557-
fill_mempool(self, self.nodes[0])
557+
fill_mempool(self, self.nodes[0], tx_sync_fun=self.no_op)
558558
# Reset coins since we filled the mempool with current coins
559559
self.coins = self.wallet.get_utxos(mark_as_spent=False, confirmed_only=True)
560560

test/functional/p2p_1p1c_network.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ def set_test_params(self):
4949
def raise_network_minfee(self):
5050
fill_mempool(self, self.nodes[0])
5151

52-
self.log.debug("Wait for the network to sync mempools")
53-
self.sync_mempools()
54-
5552
self.log.debug("Check that all nodes' mempool minimum feerates are above min relay feerate")
5653
for node in self.nodes:
5754
assert_equal(node.getmempoolinfo()['minrelaytxfee'], FEERATE_1SAT_VB)

test/functional/p2p_tx_download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def test_spurious_notfound(self):
250250
def test_rejects_filter_reset(self):
251251
self.log.info('Check that rejected tx is not requested again')
252252
node = self.nodes[0]
253-
fill_mempool(self, node)
253+
fill_mempool(self, node, tx_sync_fun=self.no_op)
254254
self.wallet.rescan_utxos()
255255
mempoolminfee = node.getmempoolinfo()['mempoolminfee']
256256
peer = node.add_p2p_connection(TestP2PConn())

test/functional/test_framework/mempool_util.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@
1919
)
2020

2121

22-
def fill_mempool(test_framework, node):
22+
def fill_mempool(test_framework, node, *, tx_sync_fun=None):
2323
"""Fill mempool until eviction.
2424
2525
Allows for simpler testing of scenarios with floating mempoolminfee > minrelay
26-
Requires -datacarriersize=100000 and
27-
-maxmempool=5.
28-
It will not ensure mempools become synced as it
29-
is based on a single node and assumes -minrelaytxfee
26+
Requires -datacarriersize=100000 and -maxmempool=5 and assumes -minrelaytxfee
3027
is 1 sat/vbyte.
3128
To avoid unintentional tx dependencies, the mempool filling txs are created with a
3229
tagged ephemeral miniwallet instance.
@@ -57,18 +54,25 @@ def fill_mempool(test_framework, node):
5754
tx_to_be_evicted_id = ephemeral_miniwallet.send_self_transfer(
5855
from_node=node, utxo_to_spend=confirmed_utxos.pop(0), fee_rate=relayfee)["txid"]
5956

57+
def send_batch(fee):
58+
utxos = confirmed_utxos[:tx_batch_size]
59+
create_lots_of_big_transactions(ephemeral_miniwallet, node, fee, tx_batch_size, txouts, utxos)
60+
del confirmed_utxos[:tx_batch_size]
61+
6062
# Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
6163
# The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
6264
# by 130 should result in a fee that corresponds to 2x of that fee rate
6365
base_fee = relayfee * 130
66+
batch_fees = [(i + 1) * base_fee for i in range(num_of_batches)]
6467

6568
test_framework.log.debug("Fill up the mempool with txs with higher fee rate")
66-
with node.assert_debug_log(["rolling minimum fee bumped"]):
67-
for batch_of_txid in range(num_of_batches):
68-
fee = (batch_of_txid + 1) * base_fee
69-
utxos = confirmed_utxos[:tx_batch_size]
70-
create_lots_of_big_transactions(ephemeral_miniwallet, node, fee, tx_batch_size, txouts, utxos)
71-
del confirmed_utxos[:tx_batch_size]
69+
for fee in batch_fees[:-3]:
70+
send_batch(fee)
71+
tx_sync_fun() if tx_sync_fun else test_framework.sync_mempools() # sync before any eviction
72+
assert_equal(node.getmempoolinfo()["mempoolminfee"], Decimal("0.00001000"))
73+
for fee in batch_fees[-3:]:
74+
send_batch(fee)
75+
tx_sync_fun() if tx_sync_fun else test_framework.sync_mempools() # sync after all evictions
7276

7377
test_framework.log.debug("The tx should be evicted by now")
7478
# The number of transactions created should be greater than the ones present in the mempool

0 commit comments

Comments
 (0)