Skip to content

bitcoin_core_sv2 leverages new interruptWait IPC call#177

Merged
GitGab19 merged 5 commits into
stratum-mining:mainfrom
plebhash:2026-01-09-bitcoin-core-v30-2
Jan 16, 2026
Merged

bitcoin_core_sv2 leverages new interruptWait IPC call#177
GitGab19 merged 5 commits into
stratum-mining:mainfrom
plebhash:2026-01-09-bitcoin-core-v30-2

Conversation

@plebhash

Copy link
Copy Markdown
Member

close #81

Comment thread bitcoin-core-sv2/Cargo.toml Outdated
@plebhash plebhash force-pushed the 2026-01-09-bitcoin-core-v30-2 branch from 0d79601 to 73ca3ce Compare January 10, 2026 22:38
@plebhash plebhash changed the title remove temporary workarounds from bitcoin_core_sv2 bitcoin_core_sv2 leverages new interruptWait IPC call Jan 10, 2026
@plebhash

Copy link
Copy Markdown
Member Author

caught a new bug on Bitcoin Core, reported on bitcoin/bitcoin#34250

I assume there's nothing wrong on our side

Comment thread bitcoin-core-sv2/src/monitors.rs Outdated
Comment thread bitcoin-core-sv2/src/monitors.rs Outdated

@Shourya742 Shourya742 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Some suggestions.

Comment thread bitcoin-core-sv2/src/monitors.rs Outdated
Comment thread bitcoin-core-sv2/src/monitors.rs Outdated
@plebhash plebhash force-pushed the 2026-01-09-bitcoin-core-v30-2 branch 3 times, most recently from 0ad1002 to d23da7d Compare January 12, 2026 20:06

@Shourya742 Shourya742 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK

Comment thread bitcoin-core-sv2/src/lib.rs Outdated
@GitGab19

Copy link
Copy Markdown
Member

caught a new bug on Bitcoin Core, reported on bitcoin/bitcoin#34250

I still have to review this PR, but how did you manage this issue?

@plebhash plebhash force-pushed the 2026-01-09-bitcoin-core-v30-2 branch from 449453d to d0e0fa1 Compare January 13, 2026 13:52
@plebhash

Copy link
Copy Markdown
Member Author

caught a new bug on Bitcoin Core, reported on bitcoin/bitcoin#34250

I still have to review this PR, but how did you manage this issue?

the bug there is that Bitcoin Core crashes whenever we disconnect from the UNIX socket while there's a pending waitNext

I naively assumed that now that we're calling interruptWait before disconnecting, it would be safe to disconnect right away

but from the discussions on bitcoin/bitcoin#34250, I learned that the fact that we got a response for interruptWait doesn't mean that waitNext has finished its execution

with d23da7d now we have a global reference to a JoinHandle that encapsulates the lifecycle of waitNext

so I also introduced d0e0fa1 so that we can .await on this JoinHandle before exiting BitcoinCoreSv2::run

that way, we'll never disconnect while waitNext still hasn't returned


ideally this kind of thing should not happen on Bitcoin Core, and there's efforts to fix it under bitcoin/bitcoin#34250

whenever that's fixed, then arguably d0e0fa1 could be potentially reverted

but tbh it also doesn't hurt to leave it there as an extra safeguard

Comment thread bitcoin-core-sv2/src/handlers.rs

@GitGab19 GitGab19 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I ran some tests with v30.2, killing and restarting both Pool and JDC together to stress-test the node, and everything went smoothly.

tACK

@xyephy xyephy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tested with bitcoin v30.2 : it Builds, Connects to IPC socket, Receives templates correctly and Graceful shutdown works .
Minor observation is that: When shutdown happens during the min_interval sleep (not during waitNext), the interruptWait isn't called since the tokio::select! only wraps the waitNext call. This isn't a bug - the sleep will complete and the loop will break on the next iteration via the cancellation token check.

tACK

@lucasbalieiro

Copy link
Copy Markdown
Collaborator

Will the changes here make us compatible with just v30.2+?

If yes, we should update our docs, most of them are instructing v30+:

$ rg v30 >
docker/README.md
18:* A fully synced **Bitcoin Core v30+** node running on **testnet4** (or any network you prefer)

pool-apps/pool/README.md
24:- Bitcoin Core v30+: an officially released Bitcoin Core node running locally, on the same machine, for which a UNIX socket connection will be established

bitcoin-core-sv2/src/lib.rs
9://! `bitcoin_core_sv2` allows for the official Bitcoin Core v30+ distribution (or any compatible

miner-apps/jd-client/README.md
48:- Bitcoin Core v30+: an officially released Bitcoin Core node running locally, on the same machine, for which a UNIX socket connection will be established

integration-tests/lib/template_provider.rs
61:/// Represents a Bitcoin Core v30+ node with IPC enabled.
112:        // Download and setup Bitcoin Core v30 with IPC support
258:/// Represents a template provider using Bitcoin Core v30+ with IPC and standalone sv2-tp.
261:/// 1. Bitcoin Core v30+ (bitcoin-node) with IPC enabled
271:    /// Start a new [`TemplateProvider`] instance with Bitcoin Core v30+ and standalone sv2-tp.

integration-tests/README.md
17:Bitcoin Core v30 binaries are downloaded from https://bitcoincore.org/bin/bitcoin-core-30.0/ and the

@plebhash

plebhash commented Jan 15, 2026

Copy link
Copy Markdown
Member Author

Will the changes here make us compatible with just v30.2+?

v30.1+, which is when interruptWait was introduced... but because of the wallet bug, probably best to stick with v30.2+

If yes, we should update our docs, most of them are instructing v30+:

added a9e1494

@plebhash plebhash force-pushed the 2026-01-09-bitcoin-core-v30-2 branch from d0e0fa1 to a9e1494 Compare January 15, 2026 19:39
@GitGab19 GitGab19 merged commit d1a97e1 into stratum-mining:main Jan 16, 2026
10 checks passed
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.

need to remove temporary workarounds from bitcoin_core_sv2

5 participants