mining: add reason/debug to submitSolution and unify with submitBlock#34672
Draft
w0xlt wants to merge 5 commits intobitcoin:masterfrom
Draft
mining: add reason/debug to submitSolution and unify with submitBlock#34672w0xlt wants to merge 5 commits intobitcoin:masterfrom
submitSolution and unify with submitBlock#34672w0xlt wants to merge 5 commits intobitcoin:masterfrom
Conversation
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. Unlike the submitblock RPC, this method does NOT auto-add the coinbase witness nonce (via UpdateUncommittedBlockStructures). Since this is a new interface and SegWit has been active for years, callers must provide a fully-formed block including the coinbase witness nonce when a witness commitment is present. 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) The test bootstraps a candidate block with createNewBlock(), mutates and serializes it, then submits it through Mining.submitBlock instead of BlockTemplate.submitSolution. This exercises the complete-block submission path and approximates the Sv2 JDS use case.
Move SubmitBlockStateCatcher and the ProcessNewBlock + validation interface registration logic into a shared ProcessBlock() helper. Both submitSolution and submitBlock now use this common code path. No behavior change.
Add reason and debug output parameters to submitSolution, matching submitBlock. This relays the specific failure reason (e.g. "bad-version(...)", "bad-witness-nonce-size", "duplicate") to callers instead of just a bool. This is a non-breaking capnp schema change: existing clients that only read the bool result field continue to work.
Fold the duplicate/inconclusive/invalid result handling from submitSolution and submitBlock into the ProcessBlock helper, so both methods become simple one-line delegations. No behavior change.
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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 comparison-specific test macros should replace generic comparisons:
2026-02-25 21:41:08 |
This was referenced Feb 26, 2026
Sjors
reviewed
Feb 27, 2026
| getCoinbaseTx @5 (context: Proxy.Context) -> (result: CoinbaseTx); | ||
| getCoinbaseMerklePath @6 (context: Proxy.Context) -> (result: List(Data)); | ||
| submitSolution @7 (context: Proxy.Context, version: UInt32, timestamp: UInt32, nonce: UInt32, coinbase :Data) -> (result: Bool); | ||
| submitSolution @7 (context: Proxy.Context, version: UInt32, timestamp: UInt32, nonce: UInt32, coinbase :Data) -> (reason: Text, debug: Text, result: Bool); |
Member
There was a problem hiding this comment.
For this not to be a breaking change, I suspect the new arguments need to go last?
This was referenced Mar 3, 2026
Contributor
|
🐙 This pull request conflicts with the target branch and needs rebase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Built on top of #34644
Preferred to open a separate PR to keep the other one focused on
submitBlock.This PR:
ProcessBlockhelper that wrapsProcessNewBlockwithSubmitBlockStateCatcherto captureBlockValidationStatereasonanddebugoutput parameters tosubmitSolution, matchingsubmitBlock