blockmaxsize parameter has no effect #12640

issue ajtowns openend this issue on March 7, 2018
  1. ajtowns commented at 9:54 pm on March 7, 2018: member

    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)

  2. MarcoFalke added this to the milestone 0.16.1 on Mar 8, 2018
  3. jnewbery commented at 9:56 pm on March 18, 2018: member

    just removing the option entirely might be better

    Yes - I think it’s best just to remove this option entirely. I don’t know of anyone complaining about this. In #11862 I wrote “Deprecation of blockmaxsize should be swiftly followed by removal in the next release.”, which we’ve now reached.

    It also might be a good idea to add an assert to SoftSetArg() that the leading character is a - to ensure no similar bugs are introduced in future.

  4. laanwj closed this on Mar 26, 2018

  5. laanwj referenced this in commit ec7dbaa37c on Mar 26, 2018
  6. MarcoFalke locked this on Sep 8, 2021


ajtowns jnewbery

Milestone
0.16.1


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me