-
Notifications
You must be signed in to change notification settings - Fork 38.6k
mining: add getTransactions(ByWitnessID) IPC methods #34020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Add a simple test for both the Txid and Wtxid variants of GetTransaction().
|
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/34020. 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 typos and grammar issues:
2025-12-08 |
|
🚧 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. |
This turned out to be an interesting problem, because in general it's not safe to treat empty Another annoying thing is that if the goal is to be able to serialize So your workaround of interpreting empty Data values as null CTransactionRef is probably the best approach for now. I put together an implementation that should be more robust in b147783 (tag). It limits the workaround to |
ab851fc to
0ce5aba
Compare
|
@ryanofsky thanks, I swapped in your commit (subtree linter is still expected to fail).
One reason I have some confidence in this approach is that the Python functional tests are able to read the result. Although it interprets the empty fields as //! [*] The Cap'n Proto wire format actually does distinguish between null and
//! empty Data values inside Lists, and the C++ API does allow distinguishing
//! between null and empty Data values in other contexts, just not the List
//! context, so this limitation could be removed in the future.If this is fixed one day and we correctly encode null on the wire, it would technically be a breaking API change, but trivial to deal with for clients. E.g. the functional test would check for both b147783 looks good to me, can you make a libmultiprocess PR, and another PR here that bumps the subtree to use it and add the tests? I'll rebase on that. |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
Needs rebase after #34003, but I'll do that after there's a multiprocess PR. |
For Stratum v2 custom job declaration to be bandwidth efficient, the pool can request1 only the transactions that it doesn't know about.
The spec doesn't specify how this is achieved, but one method is to call the
getrawtransactionRPC on each transaction id listed in DeclareMiningJob (or a subset if the pool software maintains a cache). Using RPC is inefficient, made worse by the need to make multiple calls. It also doesn't support queuing by witness id (yet, see #34013).This PR introduces two new IPC methods:
getTransactions(): takes a list ofTxid'sgetTransactionsByWitnessID(): : takes a list ofWtxid'sBoth return a list of serialised transactions. An empty element is returned for transactions that were not found.
The
Txidvariant, just like its RPC counterpart, takes advantage of-txindexif enabled. TheWtxidvariant can't do that unless we add a-witnesstxindex, but at least sv2 has no use for that.The RPC additionally allows providing a
block_hashhint. I haven't implemented that here because I don't have a need or it. It can always be added later.I thought about having a single (or overloaded)
getTransactions()that works with bothTxidandWtxid, but I prefer that clients are intentional about which one they want.A unit and functional test cover the new functionality.
Sv2 probably only needs
getTransactionsByWitnessID(), but it's easy enough to just add both.TODO:
Footnotes
there's two reasons the pool requests these transactions: to approve the template and to broadcast the block if a solution is found (the miner will also broadcast via their template provider). See also https://github.com/stratum-mining/sv2-spec/issues/170 ↩