When generating a block template through e.g. getblocktemplate RPC, we reserve 4000 weight units and 400 sigops. Pools use this space for their coinbase outputs.
At least one pool patched their Bitcoin Core node to adjust these hardcoded values. They eventually produced an invalid block which exceeded the sigops limit.
The existince of such patches suggests it may be useful to make this value configurable. This PR would make such a change easier. However, the main motivation is that in the Stratum v2 spec requires the pool to communicate the maximum bytes they intend to add to the coinbase outputs.
Specifically the CoinbaseOutputDataSize
message which is part of the Template Distribution Protocol has a field coinbase_output_max_additional_size
.
A proposed change to the spec adds the max additional sigops as well: https://github.com/stratum-mining/sv2-spec/pull/86. Whether that change makes it into the spec is not important though, as adding both to BlockAssembler::Options
makes sense.
The first commit is a test refactor followup for #30335, related to the code that’s changed here, but not required.
The second commit adds coinbase_output_max_additional_size
and coinbase_output_max_additional_sigops
to BlockAssembler::Options
, with their defaults set to the existing hardcoded values.
The third commit introduces util/mining.h
as a place to store these defaults in a place where both the RPC and node interface can access them. I picked libbitcoin_util
instead of libbitcoin_common
to avoid a future dependency of the Stratum v2 Template Provider (#29432) on libbitcoin_common
. The latter goal requires additional changes and is mostly just nice to have (the important bit is not depending on libbitcoin_node
).
The last commit adds the two arguments to the mining interface. By default it uses the originally hardcoded values, and no existing caller overrides these defaults. This changes in #29432.