v30.3-roots.1 · Commit 10: [PATCH 10/68] fix: harden Roots priority and wallet policy boundaries
test/functional/mining_basic.py
Before: test/functional/mining_basic.py · After: test/functional/mining_basic.py
File metadata
index 7e71761ae65479752990d9d6c32e828d90d41c4d..0289893b07c28724ec73351135f83d4288c50894 100755
Download original patch · Release notes
Diff rows 1–68 of 68. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
test/functional/mining_basic.py
CHANGED
|
@@ -55,13 +55,13 @@ MAX_FUTURE_BLOCK_TIME = 2 * 3600
|
|
|
55
55
|
MAX_TIMEWARP = 600
|
|
56
56
|
VERSIONBITS_TOP_BITS = 0x20000000
|
|
57
57
|
VERSIONBITS_DEPLOYMENT_TESTDUMMY_BIT = 28
|
|
58
|
-
DEFAULT_BLOCK_MIN_TX_FEE = 1 # default `-blockmintxfee` setting [sat/kvB]
|
|
58
|
+
DEFAULT_BLOCK_MIN_TX_FEE = 1000 # default `-blockmintxfee` setting [sat/kvB]
|
|
59
59
|
|
|
60
60
|
class MiningTest(BitcoinTestFramework):
|
|
61
61
|
def set_test_params(self):
|
|
62
62
|
self.num_nodes = 3
|
|
63
63
|
self.extra_args = [
|
|
64
|
-
[],
|
|
64
|
+
["-permitbarepubkey=1"],
|
|
65
65
|
[],
|
|
66
66
|
["-fastprune", "-prune=1"]
|
|
67
67
|
]
|
|
@@ -140,18 +140,19 @@ class MiningTest(BitcoinTestFramework):
|
|
|
140
140
|
|
|
141
141
|
def test_blockmintxfee_parameter(self):
|
|
142
142
|
self.log.info("Test -blockmintxfee setting")
|
|
143
|
-
self.restart_node(0, extra_args=['-minrelaytxfee=0', '-persistmempool=0'])
|
|
143
|
+
self.restart_node(0, extra_args=['-blockprioritysize=0', '-minrelaytxfee=0', '-persistmempool=0'])
|
|
144
144
|
node = self.nodes[0]
|
|
145
145
|
|
|
146
146
|
# test default (no parameter), zero and a bunch of arbitrary blockmintxfee rates [sat/kvB]
|
|
147
|
-
for blockmintxfee_sat_kvb in (DEFAULT_BLOCK_MIN_TX_FEE, 0, 5, 10, 50, 100, 500, 1000, 2500, 5000, 21000, 333333, 2500000):
|
|
147
|
+
for blockmintxfee_sat_kvb in (DEFAULT_BLOCK_MIN_TX_FEE, 0, 5, 10, 50, 100, 500, 2500, 5000, 21000, 333333, 2500000):
|
|
148
148
|
blockmintxfee_btc_kvb = blockmintxfee_sat_kvb / Decimal(COIN)
|
|
149
149
|
if blockmintxfee_sat_kvb == DEFAULT_BLOCK_MIN_TX_FEE:
|
|
150
150
|
self.log.info(f"-> Default -blockmintxfee setting ({blockmintxfee_sat_kvb} sat/kvB)...")
|
|
151
151
|
else:
|
|
152
152
|
blockmintxfee_parameter = f"-blockmintxfee={blockmintxfee_btc_kvb:.8f}"
|
|
153
153
|
self.log.info(f"-> Test {blockmintxfee_parameter} ({blockmintxfee_sat_kvb} sat/kvB)...")
|
|
154
|
-
self.restart_node(0, extra_args=[blockmintxfee_parameter, '-minrelaytxfee=0', '-persistmempool=0'])
|
|
154
|
+
self.restart_node(0, extra_args=[blockmintxfee_parameter, '-blockprioritysize=0', '-minrelaytxfee=0', '-persistmempool=0'])
|
|
155
|
+
self.wallet.rescan_utxos() # to avoid spending outputs of txs that are not in mempool anymore after restart
|
|
155
156
|
assert_equal(node.getmininginfo()['blockmintxfee'], blockmintxfee_btc_kvb)
|
|
156
157
|
|
|
157
158
|
# submit one tx with exactly the blockmintxfee rate, and one slightly below
|
|
@@ -291,6 +292,7 @@ class MiningTest(BitcoinTestFramework):
|
|
|
291
292
|
LARGE_TXS_COUNT = 10
|
|
292
293
|
LARGE_VSIZE = int(((MAX_BLOCK_WEIGHT - DEFAULT_BLOCK_RESERVED_WEIGHT) / WITNESS_SCALE_FACTOR) / LARGE_TXS_COUNT)
|
|
293
294
|
HIGH_FEERATE = Decimal("0.0003")
|
|
295
|
+
self.restart_node(0, extra_args=["-blockprioritysize=0", f"-blockmaxweight={MAX_BLOCK_WEIGHT}", f"-datacarriersize={LARGE_VSIZE}", f"-maxscriptsize={LARGE_VSIZE}"])
|
|
294
296
|
|
|
295
297
|
# Ensure the mempool is empty
|
|
296
298
|
assert_equal(len(self.nodes[0].getrawmempool()), 0)
|
|
@@ -318,7 +320,7 @@ class MiningTest(BitcoinTestFramework):
|
|
|
318
320
|
# Test block template creation with custom -blockmaxweight
|
|
319
321
|
custom_block_weight = MAX_BLOCK_WEIGHT - 2000
|
|
320
322
|
# Reducing the weight by 2000 units will prevent 1 large transaction from fitting into the block.
|
|
321
|
-
self.restart_node(0, extra_args=[f"-blockmaxweight={custom_block_weight}"])
|
|
323
|
+
self.restart_node(0, extra_args=["-blockprioritysize=0", f"-datacarriersize={LARGE_VSIZE}", f"-maxscriptsize={LARGE_VSIZE}", f"-blockmaxweight={custom_block_weight}"])
|
|
322
324
|
|
|
323
325
|
self.log.info("Testing the block template with custom -blockmaxweight to include 9 large and 2 normal transactions.")
|
|
324
326
|
self.verify_block_template(
|
|
@@ -328,7 +330,7 @@ class MiningTest(BitcoinTestFramework):
|
|
|
328
330
|
|
|
329
331
|
# Ensure the block weight does not exceed the maximum
|
|
330
332
|
self.log.info(f"Testing that the block weight will never exceed {MAX_BLOCK_WEIGHT - DEFAULT_BLOCK_RESERVED_WEIGHT}.")
|
|
331
|
-
self.restart_node(0, extra_args=[f"-blockmaxweight={MAX_BLOCK_WEIGHT}"])
|
|
333
|
+
self.restart_node(0, extra_args=["-blockprioritysize=0", f"-datacarriersize={LARGE_VSIZE}", f"-maxscriptsize={LARGE_VSIZE}", f"-blockmaxweight={MAX_BLOCK_WEIGHT}"])
|
|
332
334
|
self.log.info("Sending 2 additional normal transactions to fill the mempool to the maximum block weight.")
|
|
333
335
|
self.send_transactions(utxos[LARGE_TXS_COUNT + 2:], NORMAL_FEERATE, NORMAL_VSIZE)
|
|
334
336
|
self.log.info(f"Testing that the mempool's weight matches the maximum block weight: {MAX_BLOCK_WEIGHT}.")
|
|
@@ -342,7 +344,7 @@ class MiningTest(BitcoinTestFramework):
|
|
|
342
344
|
|
|
343
345
|
self.log.info("Test -blockreservedweight startup option.")
|
|
344
346
|
# Lowering the -blockreservedweight by 4000 will allow for two more transactions.
|
|
345
|
-
self.restart_node(0, extra_args=["-blockreservedweight=4000"])
|
|
347
|
+
self.restart_node(0, extra_args=["-blockprioritysize=0", f"-blockmaxweight={MAX_BLOCK_WEIGHT}", f"-datacarriersize={LARGE_VSIZE}", f"-maxscriptsize={LARGE_VSIZE}", "-blockreservedweight=4000"])
|
|
346
348
|
self.verify_block_template(
|
|
347
349
|
expected_tx_count=12,
|
|
348
350
|
expected_weight=MAX_BLOCK_WEIGHT - 4000,
|