Skip to content

Conversation

Sjors
Copy link
Member

@Sjors Sjors commented Feb 5, 2025

Have depends make libmultiprocess by default. This PR causes the following behavior changes:

  1. bitcoin-node and bitcoin-gui binaries are included in releases, due to ENABLE_IPC option being switched on by default in depends builds
  2. ENABLE_IPC is also switched on by default in non-depends builds (instructions updated, build: Enable ENABLE_IPC option by default #33190 does this as a standalone PR)
  3. Various changes to CI: switching on ENABLE_IPC on in most configurations and using bitcoin-node binary (bitcoin -m) for functional tests in two of them.
  4. The bitcoin-node and bitcoin-gui are added to Maintenance.cmake (since they're now in the release)

This PR doesn't need to do all of these things at once. However it's is simpler, avoids code churn (especially in CI), and probably less confusing to make all these changes in the same PR.

Windows is not supported yet, so ENABLE_IPC is off by default for it. It can be enabled after #32387.

The initial main use case for IPC is to enable experimental support for the Mining IPC interface. A working example of a Stratum v2 Template Provider client using this interface can be found here: Sjors#48.

See #31756 for discussion of when this should happen. Supersedes #30975.

Wait what, why?

The Stratum v2 spec has been around for a few years now, mostly stable but with ongoing activity to clarify and fix more subtle issues encountered by implementers. Most of the implementation is built in Rust in a project called the Stratum Reference Implementation (SRI).

Braiins added Stratum v2 support to both their (custom) firmware and pool several years ago, though they have fallen behind on recent spec changes (update: it seems they've fixed that). Apparently new hardware is underway that supports Stratum v2 without the need for custom firmware.

DMND pool is Stratum v2 native from the start and employs several of the SRI developers (they haven't fully launched though). The industry is rather secretive, but apparently there is more underway.

What does Bitcoin Core have to do with this? Well, in Stratum v2 jargon we are the Template Provider.

Or at least, the Template Provider role needs us to make block templates. Initially back in 2023 the plan was to have Bitcoin Core implement this role entirely, see #23049. It would speak the sv2 encrypted message protocol. In fact the spec was designed around this assumption, making sure to only use cryptographic primitives already in our codebase.

I took over that effort in late 2023, but during 2024 it became quite clear there was strong resistance to the idea of including all this new code, opening another network ports, etc.

At the same time there was the long running multiprocess / IPC project #10102, and the idea was born to apply that here: instead of including Stratum v2 specific stuff, we offer a general Mining interface via an IPC connection that can e.g. push out fresh block templates as fees rise above a threshold (something not possible and/or very inefficient with getblocktemplate). A client sidecar application then sits between the Stratum v2 world and our node.

Currently there's only one such sidecar application, maintained by me, and reusing the same codebase from the integrated approach. An attempt has been made to connect to our interface from Rust bitcoin-core/libmultiprocess#174, which would pave the way for SRI include the Template Provider role. Plebhash below indicates he's also working on that: #31802 (comment).

So with this new approach in mind, between mid 2024 until spring 2025, I introduced a new Mining interface (#30200 - #31785). At the same time Russ Ryanosky worked on more tight integration of libmultiprocess, including making it a subtree in #31741. See design/multiprocess.md.

Meanwhile I've been maintaining a fork of Bitcoin Core that includes the Template Provider, in the original integrated approach (Sjors#68) as well as an IPC + sidecar variant (Sjors#48). I've been shipping regular releases, mostly after bug fixes or major rebases. The SRI team has been testing both variants, though the "official" instruction on their web page is to stick to integrated version. Bug reports on my repo fork as well as on the SRI repo are evidence of actual testing happening.

But as Pavlenex writes below:

one recurring feedback I kept getting regardless of the size/type of miner is that the need to run a forked version of Bitcoin Core remains a significant barrier to adoption

This PR gets rids of that significant barrier. People can download a "pristine" version of Bitcoin Core and the only change is to start it with bitcoin node -m -ipcconnect=unix instead of the usual bitcoind.

Once that's released, I can dramatically simplify my sidecar codebase (Sjors#48) by removing pretty much all Bitcoin Core code that it doesn't need. My plan is to then make that a separate repository, which should be much easier to contribute to. I can then also make (deterministically built) signed releases, while making it clear that sidecar code has nothing to do with Bitcoin Core. Perhaps later on SRI implements the same and I can stop maintaining that project.

Conceptually the situation will be a lot clearer;

  • today: download forked version of bitcoind (or a forked version of bitcoin-node, plus bitcoin-mine), install SRI stuff
  • tomorrow: download Bitcoin Core v30, install bitcoin-mine and SRI
  • future: download Bitcoin Core v30 and SRI
Guix hashes:
find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
6dbf29baecb1d1593087ef1306ae7c78aa160c8beb04dc016e02549ae2d6d90d  guix-build-ce7d94a492e6/output/aarch64-linux-gnu/SHA256SUMS.part
4b465e5e8f9652c176aa57cfe5c289267c28c3a3c684034a9ce471b529b95275  guix-build-ce7d94a492e6/output/aarch64-linux-gnu/bitcoin-ce7d94a492e6-aarch64-linux-gnu-debug.tar.gz
85bc6fa008b83419d96443d9dcc212b46f0992387fd58fd2dda5da76536ee22c  guix-build-ce7d94a492e6/output/aarch64-linux-gnu/bitcoin-ce7d94a492e6-aarch64-linux-gnu.tar.gz
5ed9ea52a8bd55361d2d9c01fbd1b25ec9970530c2776e6c1959424ba1689f52  guix-build-ce7d94a492e6/output/arm-linux-gnueabihf/SHA256SUMS.part
2e483011fac64462d3aa000b577c3c05c825506032d879e39612e096d7a6c65b  guix-build-ce7d94a492e6/output/arm-linux-gnueabihf/bitcoin-ce7d94a492e6-arm-linux-gnueabihf-debug.tar.gz
7ff1e3ba54944a2be89dd7d68cb91dff6f8950de9d7b521e15dfb746965f81bd  guix-build-ce7d94a492e6/output/arm-linux-gnueabihf/bitcoin-ce7d94a492e6-arm-linux-gnueabihf.tar.gz
abdf89e701b21b8c1238a8cec46aeaa55e0c3a0b88ad718636e89cde9813ca08  guix-build-ce7d94a492e6/output/arm64-apple-darwin/SHA256SUMS.part
fb55cff0296cd5474811fe5cedcf28603628729dd085eeefa007c72582459b33  guix-build-ce7d94a492e6/output/arm64-apple-darwin/bitcoin-ce7d94a492e6-arm64-apple-darwin-codesigning.tar.gz
e9aa566b1e79c467d7987b7c68fa608db788e6ddf89c4d90e524cd47b4faaf86  guix-build-ce7d94a492e6/output/arm64-apple-darwin/bitcoin-ce7d94a492e6-arm64-apple-darwin-unsigned.tar.gz
bb428fc62a1230a55f49fa3b5c7ba8d588e8fed491357f890d5a6724a38b14e9  guix-build-ce7d94a492e6/output/arm64-apple-darwin/bitcoin-ce7d94a492e6-arm64-apple-darwin-unsigned.zip
5ef4b75e94b2c8265fbc588bbb42467a84438af969fddac0ea61ced3e4113345  guix-build-ce7d94a492e6/output/dist-archive/bitcoin-ce7d94a492e6.tar.gz
4f55d56a108c8f312a502cd5dfdf0840b091861a6d502df31caf4636a203697a  guix-build-ce7d94a492e6/output/powerpc64-linux-gnu/SHA256SUMS.part
66c5b1242c60e37098885a00e24efe19baee4afcd2e3d6407207523d8872f055  guix-build-ce7d94a492e6/output/powerpc64-linux-gnu/bitcoin-ce7d94a492e6-powerpc64-linux-gnu-debug.tar.gz
d9dbbee7217544eda26e77158cd82caeaef2b40fb9fc7033323e7ffe64264109  guix-build-ce7d94a492e6/output/powerpc64-linux-gnu/bitcoin-ce7d94a492e6-powerpc64-linux-gnu.tar.gz
d9b808cc5685c819abcebb4ace65f003ebc4bfedf3fca046b34de37994358782  guix-build-ce7d94a492e6/output/riscv64-linux-gnu/SHA256SUMS.part
eeeea470b1cf76515bfae14c779a3ea356d89f719d1fef1a81e8f0d6b04ab747  guix-build-ce7d94a492e6/output/riscv64-linux-gnu/bitcoin-ce7d94a492e6-riscv64-linux-gnu-debug.tar.gz
9993da4eb51618b8bd25ec88cc576496720e5589315e9eba6f3ddab25f9c3e60  guix-build-ce7d94a492e6/output/riscv64-linux-gnu/bitcoin-ce7d94a492e6-riscv64-linux-gnu.tar.gz
1b5a676580e0e79598d182f6ebbb05fb8aee2381edc3c09c042cae2600f448ab  guix-build-ce7d94a492e6/output/x86_64-apple-darwin/SHA256SUMS.part
9152122d95a34d5df75305c6883c87707e7b09033fffd08e264d703ed177ef12  guix-build-ce7d94a492e6/output/x86_64-apple-darwin/bitcoin-ce7d94a492e6-x86_64-apple-darwin-codesigning.tar.gz
2793f75730dbef6bdf12b5ed7135e22ed21178abff2926dee92843837d4ab544  guix-build-ce7d94a492e6/output/x86_64-apple-darwin/bitcoin-ce7d94a492e6-x86_64-apple-darwin-unsigned.tar.gz
e89aafd7e4a330a41f470e8f0a91ea876fad7d19547b404600867413f1a8ccb7  guix-build-ce7d94a492e6/output/x86_64-apple-darwin/bitcoin-ce7d94a492e6-x86_64-apple-darwin-unsigned.zip
955b27f881927a86da3c566357ad8ca68dbe17e9652bde8c482a57ceacba92cb  guix-build-ce7d94a492e6/output/x86_64-linux-gnu/SHA256SUMS.part
fd012be97bdf5c75ac12ddef21526bfdb5e17ecc77cde9c34d832194b0dc3293  guix-build-ce7d94a492e6/output/x86_64-linux-gnu/bitcoin-ce7d94a492e6-x86_64-linux-gnu-debug.tar.gz
0ecf7f80e9049369760d0e27fe6c026391ab25eae0f42336bef43e51a2621726  guix-build-ce7d94a492e6/output/x86_64-linux-gnu/bitcoin-ce7d94a492e6-x86_64-linux-gnu.tar.gz
2e8085f5fecc246d841b0bf6f28ecd0684a6cee49252fc88c1019d7586c7b7a2  guix-build-ce7d94a492e6/output/x86_64-w64-mingw32/SHA256SUMS.part
c60041e8137eda352557254c5f67fb83eeb97ecfec342ee528451bd44ee4523a  guix-build-ce7d94a492e6/output/x86_64-w64-mingw32/bitcoin-ce7d94a492e6-win64-codesigning.tar.gz
b1be6b2f4de1c69c2e0e4de6dd97a4891ae9eb50d89435ef47247b5a187915a9  guix-build-ce7d94a492e6/output/x86_64-w64-mingw32/bitcoin-ce7d94a492e6-win64-debug.zip
bfe143f41a20c537145c7044aca889b28efe19072b0150042a3bd865983b3d7e  guix-build-ce7d94a492e6/output/x86_64-w64-mingw32/bitcoin-ce7d94a492e6-win64-setup-unsigned.exe
94a906b83d84db7b25f7e3cfdce2a2030243f2ee6cc70b1fc088459f0b2f382d  guix-build-ce7d94a492e6/output/x86_64-w64-mingw32/bitcoin-ce7d94a492e6-win64-unsigned.zip

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 5, 2025

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31802.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK ryanofsky, ismaelsadeeq, josibake, janb84, achow101
Concept NACK fanquake
Concept ACK TheCharlatan
Stale ACK vasild, BrandonOdiwuor

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #33201 (Add functional test for IPC interface by sipa)
  • #32989 (ci: Migrate CI to hosted Cirrus Runners by willcl-ark)
  • #32162 (depends: Switch from multilib to platform-specific toolchains by hebasto)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@sipa
Copy link
Member

sipa commented Feb 7, 2025

Some chatter from IRC:

17:21:41 < darosior> It might be confusing to release both a bitcoin-wallet utility and a bitcoin-wallet binary as part of multiprocess?
17:24:08 < darosior> We could rename the utility, but then it would be nice to at least have one deprecation cycle. Given recent momentum i estimate it's possible we might release multiprocess in 
                     30.0, which means if we want to deprecate the bitcoin-wallet utility name we should do it.. now?
17:33:31 < sipa> bitcoin-wallet-util ?
...
23:38:57 < _aj_> darosior: bitcoin-wallet-process, bitcoin-gui-process, etc? it's multi *-process!
03:04:34 < Sjors[m]> darosior: at the moment there is no wallet binary if were to enable multiprocess. That won't happen until #19460.
...
03:05:18 < Sjors[m]> Or maybe already in #10102
...
03:05:50 < Sjors[m]> In any case #31802 only adds bitcoin-node and bitcoin-gui.
...
03:07:19 < Sjors[m]> Though if we want to rename the utility eventually, it's always better to do it early.

@Sjors
Copy link
Member Author

Sjors commented Feb 8, 2025

@sipa I opened #31827

onlinesipahimithu

This comment was marked as spam.

@ryanofsky
Copy link
Contributor

Thanks to all who reviewed, tested, and commented on this. This has been very useful and should lead to a lot of good followups. I think all concerns can be addressed in future PRs even if they have not been addressed here and I think there are clear next steps to address all the issues listed in the review summary

@TheCharlatan
Copy link
Contributor

Post-merge ACK ce7d94a

@Sjors
Copy link
Member Author

Sjors commented Aug 21, 2025

🎉 thanks for all the reviews!

I'll stay on top of followup PR's over the next few weeks.

@maflcko
Copy link
Member

maflcko commented Aug 21, 2025

OSS-Fuzz is now failing, as explained above in #31802 (comment) (with possible fixes).

https://oss-fuzz-build-logs.storage.googleapis.com/log-66a59cf3-d2f6-4bf1-b4e1-0a5ef44fbaaf.txt

...
Step #3 - "compile-afl-address-x86_64": /src/bitcoin-core/depends/work/download/native_capnp-1.2.0/capnproto-cxx-1.2.0.tar.gz.temp: OK
Step #3 - "compile-afl-address-x86_64": Extracting native_capnp...
Step #3 - "compile-afl-address-x86_64": /src/bitcoin-core/depends/sources/capnproto-cxx-1.2.0.tar.gz: OK
Step #3 - "compile-afl-address-x86_64": Preprocessing native_capnp...
Step #3 - "compile-afl-address-x86_64": Configuring native_capnp...
Step #3 - "compile-afl-address-x86_64": -- The CXX compiler identification is GNU 9.4.0
Step #3 - "compile-afl-address-x86_64": -- Detecting CXX compiler ABI info
Step #3 - "compile-afl-address-x86_64": -- Detecting CXX compiler ABI info - failed
Step #3 - "compile-afl-address-x86_64": -- Check for working CXX compiler: /usr/bin/g++
Step #3 - "compile-afl-address-x86_64": -- Check for working CXX compiler: /usr/bin/g++ - broken
Step #3 - "compile-afl-address-x86_64": �[31mCMake Error at /usr/local/share/cmake-3.29/Modules/CMakeTestCXXCompiler.cmake:60 (message):
Step #3 - "compile-afl-address-x86_64":   The C++ compiler
Step #3 - "compile-afl-address-x86_64": 
Step #3 - "compile-afl-address-x86_64":     "/usr/bin/g++"
Step #3 - "compile-afl-address-x86_64": 
Step #3 - "compile-afl-address-x86_64":   is not able to compile a simple test program.
Step #3 - "compile-afl-address-x86_64": 
Step #3 - "compile-afl-address-x86_64":   It fails with the following output:
Step #3 - "compile-afl-address-x86_64": 
Step #3 - "compile-afl-address-x86_64":     Change Dir: '/src/bitcoin-core/depends/work/build/x86_64-pc-linux-gnu/native_capnp/1.2.0-5b53bc4e344/CMakeFiles/CMakeScratch/TryCompile-waMe51'
Step #3 - "compile-afl-address-x86_64":     
Step #3 - "compile-afl-address-x86_64":     Run Build Command(s): /usr/local/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_7afd9/fast
Step #3 - "compile-afl-address-x86_64":     make[1]: Entering directory '/src/bitcoin-core/depends/work/build/x86_64-pc-linux-gnu/native_capnp/1.2.0-5b53bc4e344/CMakeFiles/CMakeScratch/TryCompile-waMe51'
Step #3 - "compile-afl-address-x86_64":     /usr/bin/make  -f CMakeFiles/cmTC_7afd9.dir/build.make CMakeFiles/cmTC_7afd9.dir/build
Step #3 - "compile-afl-address-x86_64":     make[2]: Entering directory '/src/bitcoin-core/depends/work/build/x86_64-pc-linux-gnu/native_capnp/1.2.0-5b53bc4e344/CMakeFiles/CMakeScratch/TryCompile-waMe51'
Step #3 - "compile-afl-address-x86_64":     Building CXX object CMakeFiles/cmTC_7afd9.dir/testCXXCompiler.cxx.o
Step #3 - "compile-afl-address-x86_64":     /usr/bin/g++   -I/src/bitcoin-core/depends/x86_64-pc-linux-gnu/native/include       -pipe -std=c++20  -fPIE -o CMakeFiles/cmTC_7afd9.dir/testCXXCompiler.cxx.o -c /src/bitcoin-core/depends/work/build/x86_64-pc-linux-gnu/native_capnp/1.2.0-5b53bc4e344/CMakeFiles/CMakeScratch/TryCompile-waMe51/testCXXCompiler.cxx
Step #3 - "compile-afl-address-x86_64":     g++: error: unrecognized command line option '-std=c++20'; did you mean '-std=c++2a'?
Step #3 - "compile-afl-address-x86_64":     make[2]: *** [CMakeFiles/cmTC_7afd9.dir/build.make:78: CMakeFiles/cmTC_7afd9.dir/testCXXCompiler.cxx.o] Error 1
Step #3 - "compile-afl-address-x86_64":     make[2]: Leaving directory '/src/bitcoin-core/depends/work/build/x86_64-pc-linux-gnu/native_capnp/1.2.0-5b53bc4e344/CMakeFiles/CMakeScratch/TryCompile-waMe51'
Step #3 - "compile-afl-address-x86_64":     make[1]: *** [Makefile:127: cmTC_7afd9/fast] Error 2
Step #3 - "compile-afl-address-x86_64":     make[1]: Leaving directory '/src/bitcoin-core/depends/work/build/x86_64-pc-linux-gnu/native_capnp/1.2.0-5b53bc4e344/CMakeFiles/CMakeScratch/TryCompile-waMe51'
Step #3 - "compile-afl-address-x86_64":     
Step #3 - "compile-afl-address-x86_64":     
Step #3 - "compile-afl-address-x86_64": 
Step #3 - "compile-afl-address-x86_64":   
Step #3 - "compile-afl-address-x86_64": 
Step #3 - "compile-afl-address-x86_64":   CMake will not be able to correctly generate this project.
Step #3 - "compile-afl-address-x86_64": Call Stack (most recent call first):
Step #3 - "compile-afl-address-x86_64":   CMakeLists.txt:2 (project)
Step #3 - "compile-afl-address-x86_64": 
Step #3 - "compile-afl-address-x86_64": �[0m
Step #3 - "compile-afl-address-x86_64": -- Configuring incomplete, errors occurred!
Step #3 - "compile-afl-address-x86_64": make: *** [funcs.mk:345: /src/bitcoin-core/depends/x86_64-pc-linux-gnu/.native_capnp_stamp_configured] Error 1
Step #3 - "compile-afl-address-x86_64": ********************************************************************************
Step #3 - "compile-afl-address-x86_64": Failed to build.
Step #3 - "compile-afl-address-x86_64": To reproduce, run:
Step #3 - "compile-afl-address-x86_64": python infra/helper.py build_image bitcoin-core
Step #3 - "compile-afl-address-x86_64": python infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 bitcoin-core
Step #3 - "compile-afl-address-x86_64": ********************************************************************************
Finished Step #3 - "compile-afl-address-x86_64"
ERROR
ERROR: build step 3 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1

I am still waiting for the oss-fuzz maintainers to give the ok for google/oss-fuzz#13018, so I guess in the meantime one of the above mentioned workarounds could be used.

@@ -35,6 +35,7 @@ Bitcoin Core requires one of the following compilers.

| Dependency | Releases | Minimum required |
| --- | --- | --- |
| [Cap'n Proto](../depends/packages/capnp.mk) | [link](https://capnproto.org) | [0.7.1](https://capnproto.org/install.html) |
Copy link
Member

Choose a reason for hiding this comment

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

my understanding is that this should refer to the pull introducing the min required, which would be [0.7.1](https://github.com/bitcoin/bitcoin/pull/28907) via bitcoin-core/libmultiprocess@414542f

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in #33233

@Sjors
Copy link
Member Author

Sjors commented Aug 21, 2025

@fanquake @maflcko I opened a PR to temporarily disable IPC build for oss-fuzz, please take a look: google/oss-fuzz#13854

DavidKorczynski pushed a commit to google/oss-fuzz that referenced this pull request Aug 21, 2025
bitcoin/bitcoin#31802 builds libmultiprocess and
enables IPC by default, but my understanding is that this breaks
oss-fuzz. One proposed solution is
#13018.

This PR builds depends with `NO_IPC=1`, which disables the feature, for
now while we work on an actual fix.
fanquake added a commit that referenced this pull request Aug 22, 2025
…inaries for IPC"

de65c86 doc: capnproto instruction for Alpine and Arch (Sjors Provoost)
49d1a1a doc: add capnproto-devel to Fedora build instruction (Sjors Provoost)
eab5518 doc: mark bitcoin-{node,gui} installed in files.md (Sjors Provoost)
2a815d1 doc: link to capnp version bump PR (Sjors Provoost)

Pull request description:

  - have `dependencies.md` link to the PR that updated the capnp version: #31802 (comment)

ACKs for top commit:
  maflcko:
    lgtm ACK de65c86
  janb84:
    re ACK de65c86

Tree-SHA512: 842d7a89ef18a8c597ca05720c41a72e67500bc93430cf2c3b074cb2f4b936f1df58b5b1e99010e1ea5c1f8a9f8875fb9c20398f915feeacecee9b2fed3cb03c
hebasto added a commit to hebasto/bitcoin-core-nightly that referenced this pull request Aug 23, 2025
hebasto added a commit to hebasto/bitcoin-core-nightly that referenced this pull request Aug 23, 2025
hebasto added a commit to hebasto/bitcoin-core-nightly that referenced this pull request Aug 23, 2025
hebasto added a commit to hebasto/bitcoin-core-nightly that referenced this pull request Aug 23, 2025
hebasto added a commit to hebasto/bitcoin-core-nightly that referenced this pull request Aug 23, 2025
hebasto added a commit to hebasto/bitcoin-core-nightly that referenced this pull request Aug 23, 2025
hebasto added a commit to hebasto/bitcoin-core-nightly that referenced this pull request Aug 24, 2025
@Sjors
Copy link
Member Author

Sjors commented Aug 27, 2025

The sidecar Template Provider application now has its own repo: https://github.com/Sjors/sv2-tp (release coming soon)

I suspect that the SRI team will have a Rust alternative soon(tm) as well.

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

Successfully merging this pull request may close these issues.