init: fail to start when -blockmaxweight exceeds MAX_BLOCK_WEIGHT

This commit is contained in:
ismaelsadeeq 2024-11-30 17:09:45 -05:00
parent b55bb95d8d
commit b096718b88
2 changed files with 14 additions and 0 deletions

View file

@ -1017,6 +1017,13 @@ bool AppInitParameterInteraction(const ArgsManager& args)
} }
} }
if (args.IsArgSet("-blockmaxweight")) {
const auto max_block_weight = args.GetIntArg("-blockmaxweight", MAX_BLOCK_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); nBytesPerSigOp = args.GetIntArg("-bytespersigop", nBytesPerSigOp);
if (!g_wallet_init_interface.ParameterInteraction()) return false; if (!g_wallet_init_interface.ParameterInteraction()) return false;

View file

@ -272,6 +272,13 @@ class MiningTest(BitcoinTestFramework):
expected_weight=MAX_BLOCK_WEIGHT - DEFAULT_COINBASE_TX_WEIGHT, expected_weight=MAX_BLOCK_WEIGHT - DEFAULT_COINBASE_TX_WEIGHT,
) )
self.log.info("Test that node will fail to start when user provide consensus 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): def run_test(self):
node = self.nodes[0] node = self.nodes[0]