0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-21 12:22:50 -05:00

init: fail to start when -blockmaxweight exceeds MAX_BLOCK_WEIGHT

This commit is contained in:
ismaelsadeeq 2025-01-09 10:50:53 -05:00
parent 5bb31633cc
commit c8acd4032d
No known key found for this signature in database
GPG key ID: 0E3908F364989888
2 changed files with 14 additions and 0 deletions

View file

@ -1016,6 +1016,13 @@ bool AppInitParameterInteraction(const ArgsManager& args)
}
}
if (args.IsArgSet("-blockmaxweight")) {
const auto max_block_weight = args.GetIntArg("-blockmaxweight", DEFAULT_BLOCK_MAX_WEIGHT);
if (max_block_weight > MAX_BLOCK_WEIGHT) {
return InitError(strprintf(_("Specified -blockmaxweight (%d) exceeds consensus maximum block weight (%d)"), max_block_weight, MAX_BLOCK_WEIGHT));
}
}
nBytesPerSigOp = args.GetIntArg("-bytespersigop", nBytesPerSigOp);
if (!g_wallet_init_interface.ParameterInteraction()) return false;

View file

@ -276,6 +276,13 @@ class MiningTest(BitcoinTestFramework):
expected_weight=MAX_BLOCK_WEIGHT - DEFAULT_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(
extra_args=[f"-blockmaxweight={MAX_BLOCK_WEIGHT + 1}"],
expected_msg=f"Error: Specified -blockmaxweight ({MAX_BLOCK_WEIGHT + 1}) exceeds consensus maximum block weight ({MAX_BLOCK_WEIGHT})",
)
def run_test(self):
node = self.nodes[0]