Repository navigation
dgb: NodeRPC serves one request at a time on its one stream - #2369
Merged
Merged
Conversation
The digibyted RPC connection is one beast HTTP stream, used from the stratum IO thread (getblocktemplate, submitblock) and from the HTTP thread (getblockheader for the dashboard), with nothing ordering them: two requests at once could interleave their writes and reads on the socket and take each other's replies. A recursive mutex (m_io_mutex) now covers every use of the stream, the request and the connected flag: Send (the write and the read of one request, and its reconnect), connect and its resolve/connect handlers, reconnect and sync_reconnect. Recursive, because the connect check and a failed request's reconnect send from inside it. Pinned: DgbNodeRpc.TwoThreadsGetTheirOwnRepliesOnOneConnection (rides dgb_coin_node_seam_test): two threads, 200 requests each, on one keep-alive connection to a local JSON-RPC server; every reply is the sender's own. Clean under TSan.
The KAT's server looped back to a blocking accept after the client's connection closed, and closing the acceptor from the test thread does not interrupt it on Linux, so the join hung. It serves one connection and returns when the client closes it. Test only.
…lock; the KAT fails fast - The second thread on the NodeRPC stream is the sharechain compute thread, under the tracker lock, when a share is a block (won_block_dispatch submit_block_hex, then record_found_block's getblockheader). It runs against the IO thread (the stratum submitblock, the GBT tip, the block-verify getblockheader). The comment in rpc.hpp and the KAT header say so; 5531693 named an HTTP thread. - The async_connect handler returns on operation_canceled before it takes m_io_mutex. - KAT DgbNodeRpc.TwoThreadsGetTheirOwnRepliesOnOneConnection: the fake server caches its port and closes the acceptor right after its one accept, so a reconnect is refused at once; the test has a 60 s ctest TIMEOUT. The worker flag that selects getmininginfo is named mininginfo.
frstrtr
added a commit
that referenced
this pull request
Nov 29, 2026
DGB NodeRPC calls to digibyted have a deadline, as BTC's NodeRPC does. Stacked on #2369. - Every request (write and read) runs on a stream that bounds each read_some/write_some by one absolute deadline per call: the socket is in user non-blocking mode and the wait for readiness is poll() with the time left, failing with timed_out once it is spent. A kernel SO_RCVTIMEO does not bound asio's synchronous recv (asio waits in poll(fd, -1) on EAGAIN), so it is not used. - A request that times out closes the stream; the next call reconnects. A request past its deadline is not re-sent. - Send(), close_stream() and the socket setup take #2369's I/O mutex. Tests: a peer that accepts and never answers (the call returns timed_out within the deadline, the stream is closed, the next call reconnects); a peer that answers slowly within the deadline (the call succeeds); concurrent calls with the I/O mutex. All DGB targets 875/875; oracle harness both directions PASS.
frstrtr
added a commit
that referenced
this pull request
Nov 29, 2026
This was referenced Nov 29, 2026
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.
dgb::coin::NodeRPCserves one request at a time on its single digibyted HTTP stream.submit_block_hex, thenrecord_found_block's getblockheader). Unordered, two requests could interleave writes/reads and take each other's replies; on a won block both submitblocks go out within moments of each other.m_io_mutexcovers every use of the stream, the request and the connected flag: Send (write + read of one request, and its reconnect), connect and its resolve/connect handlers, reconnect, sync_reconnect. Recursive because the connect check and a failed request's reconnect send from inside it. A cancelled connect returns before taking the lock.Tests
DgbNodeRpc.TwoThreadsGetTheirOwnRepliesOnOneConnection(indgb_coin_node_seam_test): two threads × 200 requests on one keep-alive connection to a local JSON-RPC server; every reply is the sender's own. TIMEOUT 60; the fake server closes its acceptor after its one accept, so a reconnect fails fast.-fsanitize=thread, run undersetarch -R): pass, 0 reports.tools/ci/check_test_target_allowlist.pyOK.