net: dedicated tip-accept thread for tip connect - #313
Merged
Conversation
added 2 commits
September 2, 2026 09:50
P2P reconstruct and RPC generate/submitblock were calling confirm_wire_run_preverified on tokio-rt-worker (connect_lock, TLS uring, ibd-confirm-head join). That can park every runtime worker, including signalfd. A process-wide tip-accept OS thread (queue depth 8) owns connect. Peer sessions await a oneshot. Scripts still publish via start_for_each_owned onto rbtc-scripts-* steal. Not the IBD body-queue pipeline.
Peer sessions reconstruct only. connect_lock / confirm_wire_run_preverified run on tip-accept. Scripts stay on rbtc-scripts-* steal.
added 5 commits
September 2, 2026 10:09
tokio mpsc/oneshot blocking_send/recv panic inside a current-thread runtime, which is how most #[tokio::test] peer tests generate and accept. Drop of an aborted peer future then left a job running against a freed ChainHub (SIGSEGV). Job queue is std sync_channel. Async wait is a waker + condvar so cancellation still joins without parking a tokio blocking primitive.
CI failed this assign test with issued=[] after tip-accept started owning ensure_genesis. Assert the hub tip is 0 before densify so a missed genesis hop fails loudly.
Parallel assign tests mutate RBITCOIN_BLOCK_QUEUE_BYTES. Without the shared lock, over-free-floor densify sees a tiny assign-stop, clamps to fetched_hi, and issues nothing. Tip-accept serializes genesis so the race showed up on CI.
Public accept/generate/rewind methods hop onto tip-accept unconditionally. Nested work calls inner methods so the lane never re-enters. Removed the on-thread / block_in_place forks that still ran confirm on the caller.
is_tokio_runtime_worker was production code gated to silence unused after connect_at started asserting the tip-accept thread name. Tests inline the worker-name check.
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.
Story
P2P/RPC tip connect never runs on a tokio worker. Confirm stays lookup → load →
rbtc-scripts-*steal → write +ibd-confirm-headdrain, one block at a time (or a short queued run). Same per-block work as IBD — without the IBD body-queue / densify / lookup-wave machine.Mainnet freeze (~6h after IBD): all
tokio-rt-workers + main in userspace futex; SIGINT/tip:perfdead. Tip follow was callingaccept_received_block→connect_at→confirm_wire_run_preverifiedon the peer task.What
tip-acceptOS thread (lazyOnceLock, queue depth 8).ChainHub::{accept_block,accept_branch,accept_received_block,generate_to_script,invalidate,reconsider,precious,rewind,ensure_genesis}hop onto that thread (re-entrant / inline if already there).handle_peer_frameawaitsaccept_received_block_async(oneshot). Other tokio workers stay free, includingsignalfd.connect_atdebug_asserts it is not ontokio-rt-worker.confirm_scripts_phase→start_for_each_owned→rbtc-scripts-*. No new interpreter path. Queue-depth script/write overlap skipped this PR (connect_lockvs reorg).Tests
generate_to_script/accept_received_block_asyncfrom a spawned multi-thread worker (debug_assert pin).rbtc-scripts-*.Non-goals