mining: add precious option to IPC block submission#35300
Conversation
Introduce a SubmitBlock() helper in node/miner.cpp that wraps ProcessNewBlock submission and captures validation state through the BlockChecked callback. Route submitSolution through the helper before adding any new IPC method. No behavior change.
Add a submitBlock method to the Mining IPC interface, similar to the submitblock RPC. This accepts a fully assembled block, validates it, and if accepted as new, processes it into chainstate. This is needed for Stratum v2 Job Declarator Server (JDS), where accepted solutions may correspond to jobs not tied to a Bitcoin Core BlockTemplate. JDS receives PushSolution fields and reconstructs full blocks; without an IPC submitBlock method, final submission requires the submitblock RPC. The method returns detailed status (reason/debug strings) matching the checkBlock pattern, giving callers enough information to handle validation failures.
Test the new Mining.submitBlock IPC method: - Invalid block (bad version) returns failure with reason - Valid block (with a real mempool tx) is accepted and propagates - Duplicate block returns failure with "duplicate" reason - Witness commitment without coinbase witness nonce is rejected (bad-witness-nonce-size), confirming no auto-fix behavior - submitBlock then submitSolution: duplicate is accepted (submitSolution returns true for already-known blocks) - submitSolution then submitBlock interaction (duplicate) Build candidate blocks from BlockTemplate data in the existing coinbase and submission test, then exercise checkBlock(), submitSolution(), and submitBlock() against those candidates. submitBlock() uses an isolated IPC node for cases that would otherwise affect the main submitSolution() and checkBlock() assertions.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35300. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. LLM Linter (✨ experimental)Possible places where named args for integral literals may be used (e.g.
Possible places where comparison-specific test macros should replace generic comparisons:
2026-05-16 04:02:34 |
Thread a precious flag through the Mining IPC submitBlock and submitSolution methods so callers can prefer an already-known same-work block, matching preciousblock-style behavior while preserving the default duplicate handling.
Add regtest unit coverage for the Mining interface precious flag, checking default duplicate and inconclusive behavior as well as submitBlock and submitSolution preferring a same-work side block when precious is set.
Extend the IPC mining functional test to exercise the new precious argument for submitBlock and submitSolution, including default same-work side-block behavior and precious reorg behavior.
4573232 to
a02e97d
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
|
Maybe do this after #34672? |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
This PR adds a
preciousflag to the IPC Mining submitBlock and submitSolution methods, as suggested in #34644 (comment). Built on top #34644.With this change, IPC mining clients can submit and prefer a block in one IPC call, instead of submitting it over IPC and then using the
preciousblockRPC separately.By default, same-work side blocks keep the existing behavior:
submitBlockreports duplicate/inconclusive cases as failure with a reason, whilesubmitSolutioncontinues to return true whenProcessNewBlockaccepts or already knows the block.Includes unit and IPC functional coverage for default behavior, precious reorgs, active-tip no-op submissions, and invalid-block rejection.