Since #11100, in init.cpp -blockmaxsize
is translated to -blockmaxweight
with the code:
0 unsigned int max_size = gArgs.GetArg("-blockmaxsize", 0);
1 if (gArgs.SoftSetArg("blockmaxweight", strprintf("%d", max_size * WITNESS_SCALE_FACTOR))) {
However SoftSetArg requires the argument to be specified with the leading dash (ie, as SoftSetArg("-blockmaxweight")
) without the dash the value will not be looked up later (because the later lookups specify it with a dash).
Obvious fix is just to add the dash (SoftSetArg("-blockmaxweight", ...)
), but if there haven’t been any complaints, just removing the option entirely might be better, since current behaviour is the same as if the option is just removed.
I believe this applies to master, 0.16 and 0.15 (due to backport via #11592).
Test case to demonstrate:
0#!/usr/bin/env python3
1"""Test limiting maxblocksize"""
2
3from test_framework.test_framework import BitcoinTestFramework
4from test_framework.util import *
5
6class MaxBlockSizeTest(BitcoinTestFramework):
7 def set_test_params(self):
8 self.num_nodes = 2
9 self.extra_args = [["-blockmaxweight=40000"], ["-blockmaxsize=10000"]]
10
11 def run_test(self):
12 chain_height = self.nodes[0].getblockcount()
13 assert_equal(chain_height, 200)
14 self.nodes[0].generate(100)
15 self.nodes[1].generate(100)
16 self.nodes[0].generate(100) # unspendable
17
18 blk = [None,None]
19 for n in [0,1]:
20 vsize = 0
21 address = self.nodes[n].getnewaddress()
22 txes = 0
23 while vsize*4 < 84000:
24 txid = self.nodes[n].sendtoaddress(address, 0.25)
25 tx = self.nodes[n].getrawtransaction(txid, 1)
26 vsize += tx["vsize"]
27 txes += 1
28 self.nodes[n].generate(1)
29 blk[n] = self.nodes[n].getblock(self.nodes[n].getbestblockhash())
30 self.sync_all()
31
32 assert blk[0]["weight"] <= 40000, "blockmaxweight greater than 40000"
33 assert blk[1]["size"] <= 10000 or blk[1]["weight"] <= 40000, "blockmaxsize is greater than 10000"
34
35if __name__ == '__main__':
36 MaxBlockSizeTest().main()
Cc @jnewbery (who picked this up via an assertion failure in #11862) @TheBlueMatt (who did the original PR)