Repository navigation
Conversation
TryATMP sets its promise in the accepted branch only. A rejected tx throws and a tx already in the chain throws, but a tx already in the mempool matches neither branch and reaches promise.get_future().wait() with nothing left to set the promise, parking that RPC thread for the life of the process. -rpcthreads defaults to 4 and HTTP workers run each item synchronously, so four duplicate broadcasts end RPC service on the node. Shutdown hangs after that too, because StopHTTPServer joins every worker. PIVX cherry-picked bitcoin#11117 as 7d05997, which introduced the promise and the wait. bitcoin#11738 fixed the duplicate-broadcast hang that same mechanism creates and was never cherry-picked. This restores that branch. promise.set_value() is called directly rather than through CallFunctionInValidationInterfaceQueue because this branch accepted nothing and so has no validation callback of its own to await. Queueing the wake would hold the duplicate broadcast behind any callback still pending from the tx's original insertion. rpc_rawtransaction.py re-broadcasts a tx still in the mempool and asserts the txid comes back. Without the fix that test fails in 1230s, hitting rpc_timewait at 600s and then failing again because the node cannot be stopped. With it, 37s. The duplicate send uses its own 30s proxy so a regression is cheap to spot. Reported in production 2026-11-09 to 2026-11-14: both PIVX electrum servers froze for about 25h after swap claims were broadcast to each of them, the second copy finding the tx already relayed over P2P. Worked around in ElectrumX bd47967, which probes with getrawtransaction before broadcasting.
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.
Problem
TryATMPsets its promise in the accepted branch only. A rejected tx throws, a tx alreadyin the chain throws, but a tx already in the mempool matches neither branch and falls
through to
promise.get_future().wait()with nothing left to set the promise. That RPCthread is lost for the life of the process.
-rpcthreadsdefaults to 4 (DEFAULT_HTTP_THREADS,httpserver.h:13) and HTTP workers runeach work item synchronously (
httpserver.cpp:118), so four duplicate broadcasts end RPCservice on the node. Shutdown stops working too:
StopHTTPServerjoins every worker(
httpserver.cpp:461-465), so the node needs SIGKILL.The wait sits outside
cs_main, so block validation keeps running. Only RPC is lost.Reachable from two callers,
sendrawtransactionandprotxregistration viarpcevo.cpp:383.Origin
7d0599733acherry-picked bitcoin#11117, which introduced the promise and the wait.bitcoin#11738 fixed the duplicate-broadcast hang that mechanism creates and was never
cherry-picked. This restores that branch.
Why the call is direct
promise.set_value()is called directly rather than throughCallFunctionInValidationInterfaceQueue, matching bitcoin#11738. This branch acceptednothing, so it has no validation callback of its own to await. Queueing the wake would hold
the duplicate broadcast behind any callback still pending from the original insertion
(
TransactionAddedToMempool,validation.cpp:627).Test
rpc_rawtransaction.pyre-broadcasts a tx still in the mempool and asserts the txid comesback.
Without the fix the RPC hits
rpc_timewaitat 600s, then teardown fails again withUnable to stop node. The duplicate send uses its own 30s proxy so a regression costs 30sto spot rather than 600s. Cost: a client timeout does not cancel the server-side handler,
so teardown stays slow under regression.
Production
Reported 2026-11-09 to 2026-11-14. Both PIVX electrum servers froze for about 25h after
swap claims were broadcast to each of them, the second copy finding the tx already relayed
over P2P. Swaps failed. Worked around in ElectrumX by probing
getrawtransactionbeforebroadcasting, which is a workaround and not a fix: any wallet or service that re-sends a
known tx can still wedge a thread.