-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Description
Since #11100, in init.cpp -blockmaxsize
is translated to -blockmaxweight
with the code:
unsigned int max_size = gArgs.GetArg("-blockmaxsize", 0);
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:
#!/usr/bin/env python3
"""Test limiting maxblocksize"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
class MaxBlockSizeTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.extra_args = [["-blockmaxweight=40000"], ["-blockmaxsize=10000"]]
def run_test(self):
chain_height = self.nodes[0].getblockcount()
assert_equal(chain_height, 200)
self.nodes[0].generate(100)
self.nodes[1].generate(100)
self.nodes[0].generate(100) # unspendable
blk = [None,None]
for n in [0,1]:
vsize = 0
address = self.nodes[n].getnewaddress()
txes = 0
while vsize*4 < 84000:
txid = self.nodes[n].sendtoaddress(address, 0.25)
tx = self.nodes[n].getrawtransaction(txid, 1)
vsize += tx["vsize"]
txes += 1
self.nodes[n].generate(1)
blk[n] = self.nodes[n].getblock(self.nodes[n].getbestblockhash())
self.sync_all()
assert blk[0]["weight"] <= 40000, "blockmaxweight greater than 40000"
assert blk[1]["size"] <= 10000 or blk[1]["weight"] <= 40000, "blockmaxsize is greater than 10000"
if __name__ == '__main__':
MaxBlockSizeTest().main()
Cc @jnewbery (who picked this up via an assertion failure in #11862) @TheBlueMatt (who did the original PR)