Skip to content

Commit c8acd40

Browse files
committed
init: fail to start when -blockmaxweight exceeds MAX_BLOCK_WEIGHT
1 parent 5bb3163 commit c8acd40

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/init.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,13 @@ bool AppInitParameterInteraction(const ArgsManager& args)
10161016
}
10171017
}
10181018

1019+
if (args.IsArgSet("-blockmaxweight")) {
1020+
const auto max_block_weight = args.GetIntArg("-blockmaxweight", DEFAULT_BLOCK_MAX_WEIGHT);
1021+
if (max_block_weight > MAX_BLOCK_WEIGHT) {
1022+
return InitError(strprintf(_("Specified -blockmaxweight (%d) exceeds consensus maximum block weight (%d)"), max_block_weight, MAX_BLOCK_WEIGHT));
1023+
}
1024+
}
1025+
10191026
nBytesPerSigOp = args.GetIntArg("-bytespersigop", nBytesPerSigOp);
10201027

10211028
if (!g_wallet_init_interface.ParameterInteraction()) return false;

test/functional/mining_basic.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ def test_block_max_weight(self):
276276
expected_weight=MAX_BLOCK_WEIGHT - DEFAULT_BLOCK_RESERVED_WEIGHT,
277277
)
278278

279+
self.log.info("Test that node will fail to start when user provide invalid -blockmaxweight")
280+
self.stop_node(0)
281+
self.nodes[0].assert_start_raises_init_error(
282+
extra_args=[f"-blockmaxweight={MAX_BLOCK_WEIGHT + 1}"],
283+
expected_msg=f"Error: Specified -blockmaxweight ({MAX_BLOCK_WEIGHT + 1}) exceeds consensus maximum block weight ({MAX_BLOCK_WEIGHT})",
284+
)
285+
279286

280287
def run_test(self):
281288
node = self.nodes[0]

0 commit comments

Comments
 (0)