Refactor `DEFAULT_MAX_GENERATED_BLOCK_SIZE` into chain-specific defaults
Summary
We would like to be able to provide chain-specific default mined block sizes. This will allow us to fine-tune the defaults that BCHN ships with to be specific to each chain. Motivation: What is a good default for ScaleNet or RegTest doesn't necessarily work as a global default for MainNet.
This commit removes the global constant DEFAULT_MAX_GENERATED_BLOCK_SIZE
since its existence now could potentially be a source of confusion and
bugs. The default mined block size now is a chain-specific setting that
lives in Consensus::Params
and is set-up in chainparams.cpp
for each
of the 5 chains we support.
Moreover, the Config
object manages the user setting as specified in
config file or CLI. Two new methods were added to the Config
object to
get/set the GeneratedMaxBlockSize
.
As such, we got rid of checking the gArgs
object for -blockmaxsize
during critical paths, since that is just wasted CPU cycles (the object
must re-parse the string arg each time!).
init.cpp
is responsible for setting up Config
to respect the
chain-specific defaults, as well as for reading in the user-specified
setting -blockmaxsize
.
Unit tests were updated, as was miner.cpp
to use the new config value
(rather than read gArgs
each time).
Invariants are enforced within the Config
object on
SetMaxGeneratedBlckSize
, (as was already being done with
with ExcessiveBlockSize
).
Also in this commit: Fixed the -hh
help to show chain-specific
-excessiveblocksize
and -blockmaxsize
.
Test Plan
ninja check check-functional
- Verify
bitcoind -hh
has correct chain-specific defaults in the help text (for both-blockmaxsize
and-excessiveblocksize
).