The interaction between node startup options like -blockreservedweight and runtime options, especially those passed via IPC, is confusing.
They’re combined in BlockAssembler::Options, which this PR gets rid of in favour of two distinct structs:
BlockCreateOptions: used by interface clients. As before, IPC clients have access to a safe / sane subset, whereas RPC and test code can use all fields.MiningArgs: these are set once during node startup
Both structs have a member for the maximum block height, which is not a problem since they’re different structs. The one on MiningArgs (nBlockMaxWeight) matches -maxblockheight and is left alone. The one on BlockCreateOptions (block_max_weight) is (exclusively) set by ClampOptions.
This all happens in the last commit and requires some preparation to keep things easy to review.
We get rid of BlockAssembler::Options but this is used in many tests. Since large churn is inevitable, we might as well switch all tests, bench and fuzzers over to the Mining interface. The first (non-base) commit does that, dramatically reducing direct use of BlockAssembler. Two exceptions are documented in the commit message. Because test_block_validity wasn’t available via the interface and the block_assemble benchmark needs it, it’s moved from BlockAssembler::Options to BlockCreateOptions (still not exposed via IPC).
We need access to mining related defaults and structs from both the miner and node initialization code. To avoid having to pull in all of BlockAssembler for the latter, the second commit introduces node/mining.h and moves constants and structs there from src/node/types.h (BlockCreateOptions, BlockWaitOptions, BlockCheckOptions) and src/node/miner.h (DEFAULT_PRINT_MODIFIED_FEE).
I considered also moving DEFAULT_BLOCK_MAX_WEIGHT, DEFAULT_BLOCK_RESERVED_WEIGHT, MINIMUM_BLOCK_RESERVED_WEIGHT and DEFAULT_BLOCK_MIN_TX_FEE there from policy.h, since they are distinct from relay policy and not needed by the kernel. But this seems more appropriate for a follow-up and requires additional discussion.
The meat and potatoes of this PR is split between the three last commits for easier review:
- Adds
node/mining_args.{h,cpp}and move the options checking out ofinit.cpp, without adding storage - Add
block_max_weighttoBlockCreateOptionsas explained above - Introduce the
MiningArgsstruct, add it to theNodeContext, expandmining_args.cppto store it, pass it toBlockAssembler, etc.
I kept variable renaming and other formatting changes to a minimum to ease review with --color-moved=dimmed-zebra.
This PR builds on the bug fix in:
Once that is merged, this PR should not change behaviour.