mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
mining: add TxCollection to bandwidth-efficiently validate external block templates #35671
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!35671
Loading…
Reference in a new issue
No description provided.
Delete branch "2026/03/collect-txs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Stratum v2 spec defines a Job Declarator Server (JDS), whose job it is to approve custom miner templates. Since #34020 it can use
getTransactionsByWitnessID()to request transactions from the node, instead of maintaining its own mempool mirror (see https://github.com/stratum-mining/sv2-apps/pull/911), and then request any missing transactions from the miner.The new
TxCollectioninterface introduced by this PR optimizes this further. We build and validate the block template ourselves now, based on the requested transaction list and our own mempool, so known transactions don't need to cross the IPC boundary. This also fits the draft spec for JDS custom job validation through a Template Provider.The following flow is demonstrated in https://github.com/stratum-mining/sv2-apps/pull/599:
createNewBlock()IPC methodWtxids to the pool's JDSMining::collectTxs()(this PR) with thatWtxidlistCTransactionReffor each matchunknownTxPos()to learn what's missing from the collectionaddMissingTxs()which completes the collectionmakeTemplate()which reconstructs the block and validates it, optionally with the coinbase it intends to use (e.g. to check the reward amount); a node-generated dummy is used otherwise. The JDS needs the check to succeed, may relay the BIP-22 failure reason to the miner.BlockTemplatewhich works as if we generated the template ourselves, but with methods likewaitNext()disabled. The JDS can callsubmitSolution()(the sv2 spec allows for redundant block reconstruction by both the miner node and the JDS).If this sounds very similar to compact block relay: it is! In fact, it would be easy to expand the above methods to take transaction short ids instead of
Wtxid. That may be useful for the p2pool revival project, which needs a way to validate and relay weak blocks as compact blocks. The p2pool client software would need to (trivially) verify the PoW, but could use theTxCollectioninterface to reconstruct and verify the block content. That said, the SRI JDS implementation is much further along and likely to be the first consumer of this.Commits:
BlockAssembler::CreateNewBlock()Potential followups:
addMissingTxs()(optionally) insert favorable transactions into our mempoolTxCollectioncan grab them, instead of needing another round trip)@plebhash it would be very useful to have a (very) rough JDS draft that uses this interface, to see if it actually gets rid of the mirror mempool.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
src/and treat them as errors by hebasto)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.
func(x, /*named_arg=*/0)in C++, andfunc(x, named_arg=0)in Python):src/test/tx_collection_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[0], 0, 1, coinbaseKey, ...)2026-12-01 14:45:03
🚧 At least one of the CI tasks failed.
Task
iwyu: https://github.com/bitcoin/bitcoin/actions/runs/28818181619/job/85462853775LLM reason (✨ experimental): CI failed because IWYU reported/required include fixes (modified files) and intentionally exited non-zero.
Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Concept ACK
This could be collapsed to the response "JDS calls TxCollection::collectTxs() (this PR) with that Wtxid list" to reduce the round trip?
I added an optional
coinbaseargument tomakeTemplate(). Based on my draft JDS implementation https://github.com/stratum-mining/sv2-apps/pull/599 this does appear useful, e.g. for checking the reward amount. We still generate a dummy if no coinbase transaction is provided.@ismaelsadeeq
collectTxs()is the constructor so it needs to return an interface. I don't think it can return both theTxCollectioninterface and the list of missing transactions. But clients can chain requests (not sure if we've fully implemented the on the libmultiprocess side).I can also imagine a (slight) benefit in clients being able to call
unknownTxPos()multiple times, e.g. maybe in a future upgrade we could have the node request missing transactions from peers - not sure how useful that is though.🐙 This pull request conflicts with the target branch and needs rebase.
Rebased after https://github.com/bitcoin/bitcoin/pull/34020:
collectTxs()to@10Capnp pipelining works for any client hitting the RPC socket, regardless of libmultiprocess, because it's a protocol-level feature the server doesn't need to implement. So the client (JDS) just needs to pipeline requests and it will work.
(The caveat only applies to Bitcoin Core's own libmultiprocess generated C++ client code, which currently blocks per call in clientInvoke and doesn't exploit pipelining internally. But since this interface is expected to be consumed by external clients this doens't apply)
In "mining: add TxCollection to bandwidth-efficiently validate external block templates" 9bb89df02fc3dbcb870b36d4a339986089ea40e2
not blocking/design question: would it be worth splitting into two capnp interfaces instead of throwing on methods: an ExternalBlockTemplate with just getBlockHeader/getBlock/getCoinbaseMerklePath/submitSolution and BlockTemplate extends(ExternalBlockTemplate) adding getTxFees/getTxSigops/getCoinbaseTx/waitNext/interruptWait? Then TxCollection::makeTemplate() returns the narrower type and the disallowed methods aren't callable, rather than compiling and throwing on call.
I took the liberty to prototype this here: https://github.com/ViniciusCestarii/bitcoin/compare/9bb89df02fc3dbcb870b36d4a339986089ea40e2...pr-35671-new-interface
In "ipc: add TxCollection scaffold" 19bae00aa17be0964e28529ecc348a94522204af
nit: commit states that it adds CollectedTxs class but there's no CollectedTxs class
In "mining: add TxCollection addMissingTxs" ee1c43e3ceb21fdf38340801221e9fa42c8e6993
AddMissingTxs is order-dependent, a bad entry aborts the loop at that point, so [valid, invalid] keeps valid but [invalid, valid] doesn't. Is this intentional? Correct me if I am wrong but validate-then-apply seems to be a safer approach.
In "mining: add TxCollection addMissingTxs" ee1c43e3ceb21fdf38340801221e9fa42c8e6993
nit: there could be a test case for "unexpected null transaction" when calling addMissingTxs with a null tx
@ViniciusCestarii wrote:
Interesting, so we don't need to change anything in libmultiprocess on the server (node) side?
I'll take your inline comments into account on the next rebase. As I mentioned in the PR description, the code is still a bit rough.
Yes, pipelining is already possible: I have made this client demo that chains calls, including the new interface TxCollection, in a single round trip with only one .wait() at the end.
OBS: Only interface fields (and struct fields that transitively lead to one) can be actually pipelined. (in the example I only pipelined interfaces), any other value like int, bool, enum, text, data, list, etc cannot be pipelined.
compact blocks uses a differential index not primarily for efficiency (though it does save quite a bit when there are many misses) but so that the wire format is safe by construction against an attack that applies the same large transaction over and over again (e.g. if index 5 is some giant txn, you request 5,5,5,5,5,5...) and overflows a buffer or OOMs an implementation explicitly constructs the block and without having to have expensive duplication checks.
@gmaxwell the Mining IPC client1 is expected to run on the same machine, so
unknownTxPos()andaddMissingTxs()are not designed for bandwidth efficiency.We also (currently) more or less trust the IPC client. It needs to deal with any hardening against its clients itself.2
Using absolute positions matches the Stratum v2 spec3, so there's probably no point in hardening it at the node level. But cc @TheBlueMatt as to why it didn't use a differential index?
If we later expand
TxCollectionto support compact blocks, we would probably add newunknownTxDifferentialPos()andaddMissingTxsForCompactBlock()methods. Those should then match the p2p pattern you describe.for
TxCollectionit's the Job Declarator Server: https://github.com/stratum-mining/sv2-apps/tree/main/pool-apps/jd-server ↩︎not having to deal with another network protocol and its DoS risks was one of the motivations for not supporting Stratum v2 p2p messages directly, see discussion that starts at: https://github.com/bitcoin/bitcoin/pull/29432#pullrequestreview-2132699185. That said, over time we could gradually harden the IPC to where the Stratum v2 client can be a very thin wrapper. ↩︎
ProvideMissingTransactions and ProvideMissingTransactions.Success ↩︎
Two interfaces might require a bunch of code duplication on the Rust client side though? Also several disabled methods could be made to work with external templates, if someone actually needs them.
Added.
Fixed commit message.
Rebased after and made consistent with #34672. Addressed @ViniciusCestarii's inline comments https://github.com/bitcoin/bitcoin/pull/35671#pullrequestreview-4655098156. Ready for review.
Used a lambda to avoid
MakeTemplateInternal, reduced intra-commit churn.On the duplication concern:
extends()gives upcasting, so shared logic that only needs the common subset doesn't need duplicating. Where branching is needed, it's because the type system is now correctly rejecting a call that would've thrown at runtime anyway and that's the point of the split, not an added cost.On the disabled methods: if they could be implemented for external templates later, they could just as well be added to the split interfaces later too. The split just removes what's currently unclear to a client consuming the interface (methods that appear callable but are guaranteed to throw).
Just my two cents. I'm fine either way
Concept ACK
Left a few comments.
nit: does the
m_mutexneed to be locked in the constructor? — the object isn't shared until after construction returns, so no concurrent access is possible yet.Should the size of
wtxidsbe checked before the loop (e.g. perhaps using existing constants —MAX_BLOCK_WEIGHT / MIN_TRANSACTION_WEIGHT)?nit: these invariants are guaranteed by the constructor and the
any_ofcheck above — I thinkAssertwould be stronger thanAssumehere to catch future regressions.Added (similar check as in
merkleblock.cpp), along with a test.I added a similar guard to
addMissingTxs(), but for it to be actually useful, we'd need to modify libmultiprocess to enforce things like a maximum param size.Dropped
More importantly
it->secondbelow would crash, soAssertis appropriate. Fixed.Addressed @pablomartin4btc's feedback. This PR grew
interface_ipc_mining.pyto over 1000 lines and the new tests add significant runtime. So I addinterface_ipc_mining_tx_collection.py.🐙 This pull request conflicts with the target branch and needs rebase.
Concept ACK
I do not have much knowledge of compact block relays and would need to look into them further, but this looks like a good improvement.
I did some benchmarking to see how the new interface affects JDS validation. I have not taken a close look at the code yet. I used AI to help put the benchmark code together, then ran and checked the results myself using a local regtest node. Do tell me if i got something wrong here
The benchmark uses
sendrawtransactiononly as a controlled way to insert a transaction into the JDS node’s mempool. It is not part of the normal JDS flow, the timing therefore measures from local transaction submission to JDS approval, not the complete miner to JDS flow.For the same workload of 1 to 20 transactions, i got these results
sendrawtransactionto jds approvalTxCollectionI also tried a 300 sample
TxCollectionrun where the transaction list grew from 1 to 300 transactions:sendrawtransactioncollectTxs()andmakeTemplate()The benchmark creates and signs each transaction before starting the timer. For transactions already in the mempool, timing starts before
sendrawtransactionand stops when the JDS approves the declaration. The missing transaction benchmark measures detecting the missing transaction, supplying it, and validating the completed template.the benchmark harnesses can be found here
Code Review d0c20776abe1ad14073c3328ef8c64434b0f92c7
I initially intended to benchmark this approach against the existing JDS mempool mirror, but I no longer think that is particularly relevant for evaluating the concept, since the main benefit is architectural rather than necessarily a raw speed improvement.
Reusing Bitcoin Core's mempool avoids duplicating transaction storage and continuous mirror synchronization, transfers only transactions the node is missing, and lets external templates be reconstructed and validated using existing validation logic. I plan to continue reviewing the implementation.
left some questions and nits
In commit https://github.com/bitcoin/bitcoin/pull/35671/changes/d0c20776abe1ad14073c3328ef8c64434b0f92c7 mining: restrict externally generated templates
waitNextis disabled for external templates, butinterruptWaitis still allowed? Is there a reason for this?I believe the relationship is that while
waitNextexecutes on a thread,interruptWaitcan be called to stop the wait. For external clients,waitNextwill throw, so even thoughinterruptWaitcan execute, it seems redundant; a call to it would just set the flag to true and wake unrelated waiters unnecessarilyIn commit https://github.com/bitcoin/bitcoin/pull/35671/changes/02ed6eafc42e73cc0637bc3c681ee208487dd2ab ipc: add TxCollection scaffold
nit:
I am a bit confused with the naming here, I initially read
m_collected_txsas a transaction container. I assume the name refers to the transactions held internally inm_transactions, since most operations inspect or update them.But i think this would be better named
m_tx_collection, as this would make it read less as a container and more as an objectIn commit https://github.com/bitcoin/bitcoin/pull/35671/changes/02ed6eafc42e73cc0637bc3c681ee208487dd2ab ipc: add TxCollection scaffold
Supposing a client passes
[A, B, C, A]wtxids. The secondAwould be rejected as the same transaction is requested twice. The current code here would check and recheck this invalid transaction while the mempool is locked.I think the constructor could check for duplicates before locking the mempool? As the duplicate is entirely visible from the input. A possible implementation could be
In commit 02ed6ea ipc: add TxCollection scaffold
Here, the entries are inserted into an
unordered_map, this has internal storage that might need to be reallocated depending on the number of entries.The check above this line helps keep it within the proper limit, but since the collection size is known, we could reserve it before acquiring the mempool lock to avoid the reallocating and rehashing while the mempool is locked
In commit https://github.com/bitcoin/bitcoin/pull/35671/changes/f4d53d163615d09650375317faa617eaaf6a07dc mining: add TxCollection addMissingTxs
The transaction passed here can be much larger than the one rejected by the constructor for
TxCollection. The check here is against the size, but it does not check the weight. So even though it can reject a million tiny transactions, it can accept 16666 large onesThis would be eventually rejected as oversized in
makeTemplatewhenTestBlockValidityis called, but that is a bit too late.A way to track the weight of the transactions currently stored in
m_transactionsand then calculate the weight when adding here could resolve the issueIn commit https://github.com/bitcoin/bitcoin/pull/35671/changes/a4a3db4577a43578951758406c01aa982452f9c5 mining: make TxCollection create a BlockTemplate
nit:
the commit follows the intended flow for creating a template without using
CreateNewBlockbut i do have a concern about the commit structure.In this commit the usual template metadata such as
vTxFees,vTxSigOpsCost,m_coinbase_txare not populated. The next commit addresses this by marking the template as external and causing them to throw. But i think this makes this specific commit a bit incomplete.Perhaps the sixth commit should be introduced before this one? or together in this commit?
In commit a4a3db4 mining: make TxCollection create a BlockTemplate
nit:
It looks like
m_mutexis held longer than necessary here? Could we limit its scope to checking completeness and copying the orderedm_transactionsinto a local vector?The references remain valid after the lock is released, so block construction and
TestBlockValiditywould not need to hold the collection mutex. This would also mirrorCreateNewBlock, which releases the mempool lock after selecting transactions and before final validationThis is a rough implementation of this
In commit 02d8f43959 mining: add coinbase transaction helper
This updates the height since the block being created must have a height one greater than its previous block. The ordinary
createNewBlockalready sets this member, and so does this helper; it is harmless but redundant.Seems it is needed here because in later commits this helper is called directly on a new
BlockAssemblerwithout first callingCreateNewBlock. In that situation, the member might not have been initializedI think a cleaner approach to this helper would be to have it calculate its own height
and then we use in the code
The difference is that changing
nHeightchanges theBlockAssemblerobject even if it is not needer here, while this approach creates a value used only inside this helper. This makes this helper easier to reason about and safer to call independentlyIn commit https://github.com/bitcoin/bitcoin/pull/35671/changes/02d8f439592026975ca6adceb19222adf91976ff mining: add coinbase transaction helper
This method does more than create a basic coinbase transaction, as it also creates the witness commitment.
And since the witness commitment commits to all transactions in the block, adding a transaction after calling this method would make it outdated?
The current documentation here does not mention that all the transactions must be present before calling this so that this does not happen. An improvement could be
In commit https://github.com/bitcoin/bitcoin/pull/35671/changes/e23f21b5cba0883e5d667321ffb0d5f7dabe87f0 mining: add TxCollection unknownTxPos
I think an improvement to this test would be adding a test to verify the mempool snapshot behavior. such that it tests that after the collection is constructed with a transaction in the mempool, if the transaction is removed from the mempool it does not report it as missing.
a rough implementation would look somehting like
I don't think we should take over too much work that
TestBlockValidity()does for us. Duplicating consensus checks could introduce new bugs.Good catch, I probably missed this in a rebase (before I opened the PR).
Done
I'd rather not grow the commit, and reversing them makes it hard to test. Going to leave this alone for now. The commits are bisect-safe.
Taken, and made it a
constmember function.Taken.
Taken
Done
Done, checking duplicates first without a lock now.
Renamed.
Rebased and addressed @enirox001's feedback.
Concept ACK
Ran the new tests and the mining suite, and checked the coinbase commit against its parent.
A question about the reject reasons.
makeTemplate()reports an ancestor prevhash asstale-prevblk, butMining::checkBlock()reports that same case asinconclusive-not-best-prevblk, since it lands inTestBlockValidity(), which uses that reason for any prevhash other than the tip. Nothing in the tree usedstale-prevblkbefore this PR. Themake TxCollection create a BlockTemplatecommit message says this mirrors thegetblocktemplateproposal reasons, but the proposal goes out through that same call, unless I'm misreading it. Was that difference deliberate?nit: for an externally generated template
getCoinbaseTx()throws now, so there is nothing to compare against, and when the client passed a coinbase tomakeTemplate()the one invtx[0]is theirs rather than a dummy. Worth saying which coinbase this returns?nit: the two methods above have
@param[in]and@returns, and this one has neither. The constructor also throws when the list goes pastMAX_BLOCK_WEIGHT / MIN_TRANSACTION_WEIGHT, and that one is left out, whileaddMissingTxs()documents all three of its cases.The amount case is covered, the witness commitment one isn't, and that's the one that pins which transactions the coinbase commits to. I flipped a bit of the commitment and it gives
bad-witness-merkle-match. Would a case next to this one be worth it?🐙 This pull request conflicts with the target branch and needs rebase.
Rebased after #35675. The new
BlockTemplateManagercreates the collection, but it's still owned by the IPC client. I moved it tonode/tx_collection.h.Added unit tests while slightly reducing functional tests.
Also addressed @jeanpablojp's feedback: switched to
inconclusive-not-best-prevblk(https://github.com/bitcoin/bitcoin/pull/35671#pullrequestreview-5125552680), add a check forbad-witness-merkle-match(https://github.com/bitcoin/bitcoin/pull/35671#discussion_r3944180465) and improved docs (other two inline comments).I also ended up combining template creation and the external restrictions, since there was some discussion about the right sequence earlier. To keep the commit manageable, I split it in a different way.
I have a local branch with a fuzzer, but I prefer to leave that to a followup.
Done
Added.
Added such a test.
2 additional verified findings in the Review report.
Earlier concerns neither republished nor resolved: 2 suggestions. See the Run archive linked from the Review report for their assessments.
🟠 Minor · External templates retain reconstruction-time
nBitson submissionOn minimum-difficulty test networks, cross-threshold reconstruction can give
submitSolution()the wrongnBitsand reject a valid redundant submission; no in-tree caller exercises this timing.Location:
src/node/tx_collection.cpp:175(head).🟠 Minor ·
TxCollectionhas no retained-transaction weight budgetA trusted IPC client can accumulate more than a block's weight in one
TxCollectionacrossaddMissingTxs()calls; remote-miner exposure depends on the JDS's own byte budget.Location:
src/node/tx_collection.cpp:99(head).🔵 Suggestion ·
makeTemplate()leaves null-coinbase approval limits undocumentedA successful
makeTemplate()call with a nullcoinbasevalidates the collected transactions with a subsidy-only dummy, not the coinbase the caller intends to mine.Location:
src/interfaces/mining.h:168(head).🔵 Suggestion ·
makeTemplate()omits the signet-verification exceptionmakeTemplate()always usescheck_pow=false, which also skips signet challenge verification, but its API documentation lists only the proof-of-work and merkle-root exceptions.Location:
src/interfaces/mining.h:156(head).🔵 Suggestion ·
collectTxs()leaves the coinbase exclusion and index mapping implicitThe API does not say that
collectTxs()excludes the coinbase or thatunknownTxPos()indices refer to the supplied list rather thanblock.vtx.Location:
src/interfaces/mining.h:286(head).🔵 Suggestion ·
TxCollectiontests lack a script-invalid transactionThe negative
MakeTemplate()cases reject for non-script reasons, so the currentTxCollectionassertions could pass even if script authorization checks were skipped.Location:
src/test/tx_collection_tests.cpp:156(head).Review coverage was incomplete.
Reviewed:
5094a523f089· Review report · Previous reportspermalink
Coming from https://github.com/stratum-mining/sv2-spec/discussions/239, where a Job Declaration Server (JDS) validates an externally built template through a Template Provider (TP). On the Core-IPC side (sv2-tp #137) that maps onto
collectTxs→addMissingTxs→makeTemplate→checkBlock-style validation, and the one value the TP then has to report that this interface doesn't expose is the block's fee total.The node computes it during validation (
nFeesinConnectBlock, needed for thebad-cb-amountcheck), and it is the only party that can: the JDS has the transactions but not the input values.Either of these may work:
BlockTemplate::getTxFees()working on templates returned bymakeTemplate()instead of throwing (per-tx fees are available in the same loop that producesnFees), orfeesfield in thecheckBlockresult (total only), which would also serve users ofcheckBlockon an assembledCBlockbeforeTxCollectionlands.Disclaimer: Fable 5.1 assisted but human reviewed/edited.
@average-gary I might open a separate PR to refactor our mining code so that
BlockTemplate::getTxFees()can work with external templates. Currently fee calculation is done as transactions are added to the template. Or to just add a total fees field.🐙 This pull request conflicts with the target branch and needs rebase.
Rebased after #36469.
I wrote:
#36525 introduces
getTotalFees(), and an internal variable to track that. If it lands first, I'll take advantage of it in this PR, but otherwise I'll leave that a followup.apologies for the late reply @Sjors
I'm a bit confused though:
mempool mirror is going away via
getTransactionsByWitnessIDon v32 (https://github.com/stratum-mining/sv2-apps/pull/911), and my understanding is thatTxCollectionwill only further optimize things (https://github.com/stratum-mining/sv2-apps/issues/609)so I'm confused about this part:
Indeed that comment is stale. I
'llupdated the description to take v32 for granted, and also to reference the draft spec https://github.com/stratum-mining/sv2-spec/discussions/239.So the remaining question is if there's anything missing to implement that draft spec / "further optimize things". Gary already brought up that it's useful to know the total fees.
concept ACK here, and I would highly support aiming to get this merged for v33
#34020 allowed us to move away from a rather suboptimal implementation of SRI's Sv2 Job Declarator Server (JDS) based on a "mempool mirror" for v30/v31 (https://github.com/stratum-mining/sv2-apps/pull/911)
but we didn't foresee that looking the declared transactions up twice, before and after the
ProvideMissingTransactionsround-trip, is prone to races: anything that leaves the mempool in between (e.g. RBF, eviction) is missing on the second lookup, even though the miner was never asked for iton mainnet that hits about ~1% of round-trips on an idle JDS and ~6% on a loaded one (https://github.com/stratum-mining/sv2-apps/issues/975, https://github.com/stratum-mining/sv2-apps/issues/982).
the current workaround is to ask the miner again, a bounded number of times, and every round fetches the whole declared list over IPC again (which is rather inefficient)
a
TxCollectionthat holds the matched transactions across the round-trip removes the race: at most one round-trip per declaration, and known transactions never cross the IPC boundary🐙 This pull request conflicts with the target branch and needs rebase.
Trivial rebase after #36807.
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased after #36451.
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased after:
(per commit CI failure is spurious: https://github.com/bitcoin/bitcoin/actions/runs/46670896379/job/142725496969?pr=35671)
🚧 At least one of the CI tasks failed.
Task
test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/46670896379/job/142725496969LLM reason (✨ experimental): intermittent_network:
apt-get installfailed because Ubuntu package repositories repeatedly returned 503s and connection errors while fetching dependencies.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
Intermittent network issues can occur; re-run CI for now, and report the issue if they keep happening.
A functional or integration test failure may be intermittent or unrelated to this pull request.
If no dedicated issue thread exists, create a new one to track it.
Leave a comment here, if you need help tracking down a confusing failure.
🐙 This pull request conflicts with the target branch and needs rebase.