test: change low fee parents to 0-fee
What changed, and why it matters
This commit only changes a single test file. It simplifies how test transactions are created by using zero-fee parent transactions instead of carefully calculated low-but-nonzero fees. There is no change to Bitcoin Core's actual network, consensus, or wallet code, so it cannot affect real users or funds.
No security action needed. Review as ordinary test-maintenance cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies test/functional/p2p_1p1c_network.py. It removes helper logic that filled the mempool to raise mempoolminfee above minrelaytxfee, and changes parent transactions in package-relay tests from a computed low feerate to exactly 0 sat/vB. Imports and node startup arguments related to that helper are also removed. The production package-relay and mempool behavior is unchanged.
Changed components
test/functional/p2p_1p1c_network.pyInspect captured patch +4 / −30
diff --git a/test/functional/p2p_1p1c_network.py b/test/functional/p2p_1p1c_network.py
index e4d3b738..cfdfe5ce 100755
--- a/test/functional/p2p_1p1c_network.py
+++ b/test/functional/p2p_1p1c_network.py
@@ -10,11 +10,9 @@ too-low-feerate transactions). The packages should be received and accepted by a
"""
from decimal import Decimal
-from math import ceil
from test_framework.mempool_util import (
DEFAULT_MIN_RELAY_TX_FEE,
- fill_mempool,
)
from test_framework.messages import (
COIN,
@@ -26,7 +24,6 @@ from test_framework.p2p import (
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
- assert_greater_than,
)
from test_framework.wallet import (
MiniWallet,
@@ -39,20 +36,9 @@ class PackageRelayTest(BitcoinTestFramework):
self.num_nodes = 4
# hugely speeds up the test, as it involves multiple hops of tx relay.
self.noban_tx_relay = True
- self.extra_args = [[
- "-maxmempool=5",
- ]] * self.num_nodes
-
- def raise_network_minfee(self):
- fill_mempool(self, self.nodes[0])
-
- self.log.debug("Check that all nodes' mempool minimum feerates are above min relay feerate")
- for node in self.nodes:
- assert_equal(node.getmempoolinfo()['minrelaytxfee'], Decimal(DEFAULT_MIN_RELAY_TX_FEE) / COIN)
- assert_greater_than(node.getmempoolinfo()['mempoolminfee'], Decimal(DEFAULT_MIN_RELAY_TX_FEE) / COIN)
def create_basic_1p1c(self, wallet):
- low_fee_parent = wallet.create_self_transfer(fee_rate=Decimal(DEFAULT_MIN_RELAY_TX_FEE) / COIN, confirmed_only=True)
+ low_fee_parent = wallet.create_self_transfer(fee_rate=0, confirmed_only=True)
high_fee_child = wallet.create_self_transfer(utxo_to_spend=low_fee_parent["new_utxo"], fee_rate=999*Decimal(DEFAULT_MIN_RELAY_TX_FEE)/ COIN)
package_hex_basic = [low_fee_parent["hex"], high_fee_child["hex"]]
return package_hex_basic, low_fee_parent["tx"], high_fee_child["tx"]
@@ -61,25 +47,16 @@ class PackageRelayTest(BitcoinTestFramework):
# First create a tester tx to see the vsize, and then adjust the fees
utxo_for_2outs = wallet.get_utxo(confirmed_only=True)
- low_fee_parent_2outs_tester = wallet.create_self_transfer_multi(
- utxos_to_spend=[utxo_for_2outs],
- num_outputs=2,
- )
-
- # Target 1sat/vB so the number of satoshis is equal to the vsize.
- # Round up. The goal is to be between min relay feerate and mempool min feerate.
- fee_2outs = ceil(low_fee_parent_2outs_tester["tx"].get_vsize() / 2)
-
low_fee_parent_2outs = wallet.create_self_transfer_multi(
utxos_to_spend=[utxo_for_2outs],
num_outputs=2,
- fee_per_output=fee_2outs,
+ fee_per_output=0,
)
# Now create the child
high_fee_child_2outs = wallet.create_self_transfer_multi(
utxos_to_spend=low_fee_parent_2outs["new_utxos"][::-1],
- fee_per_output=fee_2outs*100,
+ fee_per_output=10_000,
)
return [low_fee_parent_2outs["hex"], high_fee_child_2outs["hex"]], low_fee_parent_2outs["tx"], high_fee_child_2outs["tx"]
@@ -93,7 +70,7 @@ class PackageRelayTest(BitcoinTestFramework):
return [parent1["hex"], parent2["hex"], child["hex"]], parent1["tx"], parent2["tx"], child["tx"]
def create_packages(self):
- # 1: Basic 1-parent-1-child package, parent 1sat/vB, child 999sat/vB
+ # 1: Basic 1-parent-1-child package, parent 0sat/vB, child 999sat/vB
package_hex_1, parent_1, child_1 = self.create_basic_1p1c(self.wallet)
# 2: same as 1, parent's txid is the same as its wtxid.
@@ -127,9 +104,6 @@ class PackageRelayTest(BitcoinTestFramework):
self.generate(self.wallet_nonsegwit, 10)
self.generate(self.wallet, 120)
- self.log.info("Fill mempools with large transactions to raise mempool minimum feerates")
- self.raise_network_minfee()
-
# Create the transactions.
self.wallet.rescan_utxos(include_mempool=True)
packages_to_submit, transactions_to_presend = self.create_packages()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.