CoinbaseOutputConstraints: coinbase_output_max_additional_sigops is parsed but never applied to the template · Issue #167 · stratum-mining/sv2-tp · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CoinbaseOutputConstraints: coinbase_output_max_additional_sigops is parsed but never applied to the template #167
At f88a306 the Template Provider reads coinbase_output_max_additional_sigops from CoinbaseOutputConstraints but does not use it when it asks the node for a template.
Where
src/sv2/messages.h:216-219 deserializes m_coinbase_output_max_additional_sigops (and falls back to 400 when the field is absent).
src/sv2/connman.cpp:409-431 handles the message. It reads only m_coinbase_output_max_additional_size, checks it against the block weight limit and stores it in client.m_coinbase_tx_outputs_size. The sigops value is not stored.
src/sv2/template_provider.cpp:330-346 builds the BlockCreateOptions for the client. It sets block_reserved_weight from the stored size and nothing else, so coinbase_output_max_additional_sigops stays at its default of 400 (src/sv2/block_options.h:43).
Effect
A client that announces more than 400 additional sigops for its coinbase outputs still gets templates that reserve 400. If the template is close to the block sigops limit and the pool then adds its announced outputs, the block can go over the limit and be invalid. A client that announces fewer than 400 gets no benefit from that either. This needs an unusual payout set (many legacy or bare-multisig outputs) and a sigops-heavy block, so I'd call it low severity, but the field is accepted and then silently ignored.
Suggested fix
Store the value next to m_coinbase_tx_outputs_size and set options.coinbase_output_max_additional_sigops from it in prepare_block_create_options. If the node-side limit can't be honoured, log or reject the constraint, the same way an impossible size is rejected in connman.cpp.
I found no existing issue for this (#47, #99 and #127 are about the size field and about when to send a new template). Filed here as the security policy suggests for an experimental, non-exposed service. It came out of an AI-assisted source review of this commit; nothing was built or run.
Thanks! It appears that this has been broken since the field was introduced in stratum-mining/sv2-spec#86, and even before sv2-tp was a standalone repo.
Activity
Sjors commentedon Nov 24, 2026
Thanks! It appears that this has been broken since the field was introduced in stratum-mining/sv2-spec#86, and even before sv2-tp was a standalone repo.
Fixed in #171.
sv2: reserve the sigops a client announces for its coinbase