mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-04 21:04:58 +02:00
miner: init: add -blockreservedweight startup option
- Prevent setting the value of `-blockreservedweight` below a safety value of 2000.
This commit is contained in:
@@ -28,6 +28,7 @@ from test_framework.messages import (
|
||||
COIN,
|
||||
DEFAULT_BLOCK_RESERVED_WEIGHT,
|
||||
MAX_BLOCK_WEIGHT,
|
||||
MINIMUM_BLOCK_RESERVED_WEIGHT,
|
||||
ser_uint256,
|
||||
WITNESS_SCALE_FACTOR
|
||||
)
|
||||
@@ -276,6 +277,28 @@ class MiningTest(BitcoinTestFramework):
|
||||
expected_weight=MAX_BLOCK_WEIGHT - DEFAULT_BLOCK_RESERVED_WEIGHT,
|
||||
)
|
||||
|
||||
self.log.info("Test -blockreservedweight startup option.")
|
||||
# Lowering the -blockreservedweight by 4000 will allow for two more transactions.
|
||||
self.restart_node(0, extra_args=[f"-datacarriersize={LARGE_VSIZE}", "-blockreservedweight=4000"])
|
||||
self.verify_block_template(
|
||||
expected_tx_count=12,
|
||||
expected_weight=MAX_BLOCK_WEIGHT - 4000,
|
||||
)
|
||||
|
||||
self.log.info("Test that node will fail to start when user provide invalid -blockreservedweight")
|
||||
self.stop_node(0)
|
||||
self.nodes[0].assert_start_raises_init_error(
|
||||
extra_args=[f"-blockreservedweight={MAX_BLOCK_WEIGHT + 1}"],
|
||||
expected_msg=f"Error: Specified -blockreservedweight ({MAX_BLOCK_WEIGHT + 1}) exceeds consensus maximum block weight ({MAX_BLOCK_WEIGHT})",
|
||||
)
|
||||
|
||||
self.log.info(f"Test that node will fail to start when user provide -blockreservedweight below {MINIMUM_BLOCK_RESERVED_WEIGHT}")
|
||||
self.stop_node(0)
|
||||
self.nodes[0].assert_start_raises_init_error(
|
||||
extra_args=[f"-blockreservedweight={MINIMUM_BLOCK_RESERVED_WEIGHT - 1}"],
|
||||
expected_msg=f"Error: Specified -blockreservedweight ({MINIMUM_BLOCK_RESERVED_WEIGHT - 1}) is lower than minimum safety value of ({MINIMUM_BLOCK_RESERVED_WEIGHT})",
|
||||
)
|
||||
|
||||
self.log.info("Test that node will fail to start when user provide invalid -blockmaxweight")
|
||||
self.stop_node(0)
|
||||
self.nodes[0].assert_start_raises_init_error(
|
||||
|
||||
Reference in New Issue
Block a user