implement handle_push_solution on jd_server_sv2 + bitcoin_core_sv2#593
implement handle_push_solution on jd_server_sv2 + bitcoin_core_sv2#593plebhash wants to merge 17 commits into
handle_push_solution on jd_server_sv2 + bitcoin_core_sv2#593Conversation
1cc987b to
e394a70
Compare
|
currently, there's no official Bitcoin Core v32 release so this PR is temporarily stubbing ITF to use a binary that's only available locally on my machine once v32 is released I'll fix this PR and CI should be green all integration tests pass locally though, so nothing to worry about |
That seems fine as a first version, but given that new templates may be proposed quite frequently based on fee updates, and that ASIC's may chew on older jobs for a bit, it's a good TODO to try previous templates. Otherwise you completely rely on the JDC/TP to handle the block broadcast for those. (update: I guess it won't fail if only fees changed, so the only concern is stale blocks)
In the https://github.com/2140-dev/bitcoin-capnp-types/blob/master/.github/workflows/ci.yml#L17-L33 And for open pull requests the actual PR branch, e.g. 2140-dev/bitcoin-capnp-types#28
I assume |
that's used for |
Bitcoin Core submitBlock requires a fully assembled block, so JDS must retain non-coinbase transaction bodies from DeclareMiningJob validation. As a prerequisite for upcoming PushSolution handling with v32 IPC support, JdResponse::Success now carries txdata and no longer returns redundant txid_list. JDS derives txids directly from txdata when validating merkle-root/merkle-path consistency for SetCustomMiningJob, without storing an extra txid cache in DeclaredCustomJob. This addresses an earlier design blindspot and does not change v30/v31 validation behavior.
e394a70 to
a40b91b
Compare
Reconstruct a full block at JDS when receiving PushSolution and submit it to Bitcoin Core via submitBlock. Follow the clarified Job Declaration semantics from sv2-spec. Reference: stratum-mining/sv2-spec#188 Reference: stratum-mining/sv2-spec#189 Design choice (KISS): JDS keeps only the latest declared custom job per downstream connection and only attempts PushSolution propagation against that entry. It does not attempt propagation for previously declared jobs.
a40b91b to
4e75fed
Compare
close #441
blocked by:
bitcoin-capnp-typesrelease compatible with v32a few conceptual points worthy of note for reviewers:
JdRequest::PushSolutionmust carryBlockbefore this PR,
JdRequest::PushSolutioncarried aPushSolutionmessagehowever, Bitcoin Core's new
submitBlockcapnproto method needs a full blockBitcoinCoreSv2JDPdoes not have enough context to reconstruct a full block from aPushSolution, so it's JDS's responsability to do thattherefore,
JdRequest::PushSolutionnow carries abitcoin::Blockinstead of aPushSolutionmessageJdResponse::Successmust carrytxdatabefore this PR,
DeclaredCustomJobcarried atxid_list, which was used formerkle_pathvalidation ofSetCustomMiningJobgiven that now it's JDS responsability to reconstruct the full block from a
PushSolution,txid_listis no longer sufficientso
JdResponse::Successnow carriestxdatainstead oftxid_listtxid_listis computed fromtxdataformerkle_pathvalidation ofSetCustomMiningJobPushSolutionmust be handled within isolated Downstream Client contextstratum-mining/sv2-spec#189 established that upon receiving
PushSolution, JDS MUST try to reconstruct the block based on the last acknowledgedDeclareMiningJob, and MAY try to reconstruct based on previous oneswe're doing a KISS approach here, where we only try to propagate a solution for the last acknowledged
DeclareMiningJobthis motivated #590 / #592 as a pre-requisite, because otherwise there would be no way to unambiguously associate a
PushSolutionwith aDeclareMiningJobBitcoin Core's new
submitSolutioncapnp methodBitcoin Core's new
submitSolutioncapnp method is being used atbitcoin_core_sv2::unix_capnp::v32x::job_declaration_protocol::BitcoinCoreSv2JDP::handle_push_solutionwhen compared to the previous implementations,
BitcoinCoreSv2JDPgot a new dedicatedsubmit_block_thread_ipc_clientso that we don't block solution submission with regular mempool monitoring activity