Skip to content

ipc: Fail-stop the node when Bitcoin IPC queue overflows#436

Open
pradhyum6144 wants to merge 1 commit into
braidpool:devfrom
pradhyum6144:fix/issue-318-bitcoin-queue-fail-stop
Open

ipc: Fail-stop the node when Bitcoin IPC queue overflows#436
pradhyum6144 wants to merge 1 commit into
braidpool:devfrom
pradhyum6144:fix/issue-318-bitcoin-queue-fail-stop

Conversation

@pradhyum6144

Copy link
Copy Markdown

Issue : #318

Changes

The existing panic! in PriorityRequestQueue::enqueue never halted the node: it runs inside tokio::task::spawn_local, where panics are caught by Tokio and only surface via JoinHandle::await. The processor task died silently while callers blocked on oneshot channels, leaving the node alive but unable to satisfy the consensus-critical IPC required by docs/braidpool_spec.md.

Replace the silent panic with std::process::abort() on Normal/High/Critical overflow so operators see the failure. Low-priority overflow stays a soft drop (warn + continue) since it is non-consensus.

Updates

  • ipc/client.rs
    • New EnqueueOutcome enum returned by enqueue, matched by the processor task: Low → warn + drop, Normal/High/Critical → error + std::process::abort().
    • is_overloaded() now checks all four priority queues.
    • 7 new unit tests covering each outcome and priority ordering.

@pradhyum6144 pradhyum6144 marked this pull request as draft April 15, 2026 10:10
@pradhyum6144

Copy link
Copy Markdown
Author

Flagging before review: #318 has two asks, this PR only covers one.

Covered (requirement 1- "halt + noisy logs"): Normal/High/Critical overflow now emits error! + std::process::abort(). Note: the previous panic! never actually halted the node it ran inside tokio::task::spawn_local, so Tokio caught it and the processor task died silently while callers blocked on oneshot channels. abort() bypasses that.

Not covered (requirement 2 - "ensure this can never happen"): Scoped out; I believe it's blocked on #283 (cmempoold split) + p2p rate limiting.

Direction question: @krishi-agrawal suggested unbounding Critical + High queues so overflow is unreachable - a different philosophy than this PR (bounded + fail-stop). Happy to pivot:

(a) Land as-is, track (2) against #283.
(b) Also unbound Critical + High here, keep abort() as safety net on Normal/Low.
(c) Unbound Critical + High, drop abort() entirely (krishi's proposal).
Which would you prefer?

@pradhyum6144 pradhyum6144 marked this pull request as ready for review April 15, 2026 10:19

@zaidmstrr zaidmstrr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK db6e8f8

I don't like the idea of introducing EnqueueOutcome enum this is making code complex without adding much meaning, even though the test verifies overflow detection but not the abort response, so you end up testing the enum shape rather than the behaviour. Although your concern about the abort() is correct. The cleaner and simpler approach here is to use abort() inside enqueue() and don't treat low priority requests differently than critical and high. Because if a queue is full on low priority, then still that means the Bitcoin node is unresponsive.

pradhyum6144 added a commit to pradhyum6144/braidpool that referenced this pull request Apr 15, 2026
Drop the EnqueueOutcome enum and inline std::process::abort() inside
PriorityRequestQueue::enqueue. A full queue at any priority (including
Low) means bitcoind is unresponsive, so fail-stop uniformly.

Addresses zaidmstrr's review on braidpool#436.

@zaidmstrr zaidmstrr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on the things I suggested previously. This now looks way better than before, but there are some more suggestions below you can look at.

Comment thread node/src/ipc/client.rs
BitcoinRequest::SubmitSolution { priority, .. } => *priority,
};

let result = match priority {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this piece of code is not the intended fix for this issue. I suggest just introducing a simple abort() and leaving the old code unchanged.

…#318)

panic!() inside tokio::task::spawn_local is silently swallowed by the
Tokio runtime and never surfaces to operators. Replace with
std::process::abort() which bypasses unwinding and SIGABRTs the
process unconditionally, making the failure visible.

All existing queue-management logic is unchanged.
@pradhyum6144 pradhyum6144 force-pushed the fix/issue-318-bitcoin-queue-fail-stop branch from 1aa9694 to 7c86eab Compare April 17, 2026 16:51
Comment thread node/src/ipc/client.rs
if self.critical_queue.len() >= self.max_queue_sizes.critical {
error!("BITCOIN IPC QUEUE FULL - CRITICAL QUEUE EXCEEDED LIMIT");
panic!("FATAL: Cannot communicate with Bitcoin Core. Queue is full.");
error!("FATAL: Bitcoin IPC critical queue full - aborting to prevent consensus desync. See issue #318.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to change the previous logs please leave them as they are. And sign your commits.

Comment thread node/src/ipc/client.rs
if self.normal_queue.len() >= self.max_queue_sizes.normal {
error!("BITCOIN IPC QUEUE FULL - NORMAL PRIORITY QUEUE EXCEEDED LIMIT");
panic!("FATAL: Cannot communicate with Bitcoin Core. Queue is full.");
error!("FATAL: Bitcoin IPC normal queue full - aborting to prevent consensus desync. See issue #318.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the issue number listed in running logs not required and imo we can revert to previous log messages only .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants