Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiprocess bitcoin #10102

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft

Multiprocess bitcoin #10102

wants to merge 23 commits into from

Conversation

ryanofsky
Copy link
Contributor

@ryanofsky ryanofsky commented Mar 27, 2017

This is a draft PR because it is based on #28921 and #28929. The non-base commits are:


This PR adds an --enable-multiprocess configure option which builds new bitcoin-node, bitcoin-wallet, and bitcoin-gui executables with relevant functionality isolated into different processes. See doc/design/multiprocess.md for usage details and future plans.

The change is implemented by adding a new Init interface that spawns new wallet and node subprocesses that can be controlled over a socketpair by calling Node, Wallet, and ChainClient methods. When running with split processes, you can see the IPC messages going back and forth in -debug=1 output. Followup PR's #19460 and #19461 add -ipcbind and -ipcconnect options that allow more flexibility in how processes are connected.

The IPC protocol used is Cap'n Proto, but this could be swapped out for another protocol. Cap'n Proto types and libraries are only accessed in the src/ipc/capnp/ directory, and not in any public headers or other parts of bitcoin code.

Slides from a presentation describing this change are available on google drive. Demo code used in the presentation was from an older version this PR (tag ipc.21, commits).


This PR is part of the process separation project.

@jonasschnelli
Copy link
Contributor

Oh. Nice.
I expected much more code to achieve this.

Conceptually I think this goes into the right direction, though, I'm not sure if this could end up being only a temporary in-between step that may end up being replaced.
Because, it may be more effective to split the Qt/d part completely and let them communicate over the p2p protocol (SPV and eventually RPC). More effective because it would also allow to run Qt independent from a trusted full node (if not trusted, use mechanism like full block SPV, etc.).

Though, I'm aware that capnp has an RPC layer. But this would introduce another API (RPC / ZMQ / REST and then capnp RPC).

I'm not saying this is the wrong direction, but we should be careful about adding another API.

Three questions:

  • Would the performance be impractical if we would try to use the existing RPC API?
  • Could the capnp approach (or lets say IPC approach) be designed as a (or the) new API ("JSON RPC v2" and replacement for ZMQ)?
  • Does capnp provide a basic form of authentication? Would that even be required?

@ryanofsky
Copy link
Contributor Author

Would the performance be impractical if we would try to use the existing RPC API?

Reason this is currently using capnp is not performance but convenience. Capnp provides a high level API that supports bidirectional, synchronous, and asynchronous calls out of the box and allows me to easily explore implementation choices in bitcoin-qt without having to worry about low level protocol details, write a lot of parameter packing/unpacking boilerplate, and implement things like long polling.

Capnp could definitely be replaced by JSON-RPC, though, and I've gone out of my way to support this by not calling capnp functions or using capnp types or headers anywhere except the ipc/server.cpp and ipc/client.cpp files. No code outside of these two files has to change in order to move to a different protocol.

Could the capnp approach (or lets say IPC approach) be designed as a (or the) new API ("JSON RPC v2" and replacement for ZMQ)?

It could, but I'm going out of my way right now specifically NOT to add yet another bitcoind public API that could add to the JSON-RPC/REST/ZMQ/-blocknotify/-walletnotify confusion. The IPC here doesn't happen over a TCP port or even a unix socket path but over an anonymous socketpair using an inherited file descriptor. (I haven't done a windows implementation yet but similar things are possible there).

I'm trying to make the change completely internal for now and transparent to users. Bitcoin-qt should still be invoked the same way and behave the same way as before, starting its own node and wallet. It just will happen to do this internally now by forking a bitcoind executable rather than calling in-process functions.

This change will not add any new command line or GUI options allowing bitcoin-qt to connect to bitcoinds other than the one it spawns internally. Adding these features and supporting new public APIs might be things we want to do in the future, but they would involve downsides and complications that I'm trying to avoid here.

Does capnp provide a basic form of authentication? Would that even be required?

It's not required here because this change doesn't expose any new socket or endpoint, but it could be supported. Capnp's security model is based on capabilities, so to add authentication, you would just define a factory function that takes credentials as parameters and returns a reference to an object exposing the appropriate functionality.

@gmaxwell
Copy link
Contributor

I'm really uncomfortable with using capn proto, but fine enough for some example testing stuff!

I'm a fan of this general approach (ignoring the use of capn proto) and I think we should have done something like it a long time ago.

@dcousens
Copy link
Contributor

dcousens commented Mar 28, 2017

strong concept ACK, but if is feasible, would prefer usage of the existing RPC instead of capn'proto

@laanwj
Copy link
Member

laanwj commented Mar 29, 2017

Concept ACK, nice.

I'm really uncomfortable with using capn proto, but fine enough for some example testing stuff!

Please, let's not turn this into a discussion of serialization and RPC frameworks. To be honest that's been one of the things that's putting me off of doing work like this. If you want to suggest what framework to use, please make a thorough investigation of what method would be best to use for our specific use case, and propose that, but let's not start throwing random "I'm not comfortable with X" comments.

We already use google protocol buffers in the GUI for payment requests to in a way that would be the straightforward choice. I'm also happy you didn't choose some XML-based abomonation or ASN.1. But anyhow, not here. For this pull it's fine to use whatever RPC mechanism you're comfortable with.

This change will not add any new command line or GUI options allowing bitcoin-qt to connect to bitcoinds other than the one it spawns internally.

I'm also perfectly fine with keeping the scope here to "communication between GUI and bitcoind". This is not the place for introducing another external interface. Might be an option at some point in the future, but for now process isolation is enough motivation.

src/qt/walletmodel.cpp Outdated Show resolved Hide resolved
src/ipc/messages.capnp Outdated Show resolved Hide resolved
src/ipc/client.cpp Outdated Show resolved Hide resolved
src/qt/bitcoin.cpp Outdated Show resolved Hide resolved
src/qt/bitcoin.cpp Outdated Show resolved Hide resolved
src/qt/walletmodel.cpp Outdated Show resolved Hide resolved
src/ipc/server.cpp Outdated Show resolved Hide resolved
Copy link
Contributor Author

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Updated and rebased bf5f8ed -> 0ca73bc (pr/ipc.0 -> pr/ipc.1)

There's a lot of new changes here. More functions and callbacks have been wrapped, and there's now support for asynchronous calls that don't block event threads in the client and server.

At this point it would be very helpful to have code review for the main commit (0ca73bc "Add barebones IPC framework to bitcoin-qt and bitcoind"), because all the real infrastructure is now in place, and the main thing left to do is wrap up more functions and callbacks in IPC calls so the GUI can be functional.

src/qt/bitcoin.cpp Outdated Show resolved Hide resolved
@ryanofsky
Copy link
Contributor Author

ryanofsky commented Apr 7, 2017

Updated and rebased 0ca73bc -> 5e28c2f (pr/ipc.1 -> pr/ipc.3) to avoid a conflict. Main addition is an expanded src/ipc/README.md file.

Again it would be very helpful to have some code review for the main commit (5e28c2f "Add barebones IPC framework to bitcoin-qt and bitcoind"). Giving feedback on the README file would be an easy place to start.

@ryanofsky ryanofsky force-pushed the pr/ipc branch 2 times, most recently from 5e28c2f to dda3756 Compare April 10, 2017 22:00
@ryanofsky
Copy link
Contributor Author

Updated 5e28c2f -> dda3756 (pr/ipc.3 -> pr/ipc.4)

This implements two suggestions from @JeremyRubin:

  • It includes a small commit demonstrating what it looks like to add a single new method to the API:
    dda3756 Add ipc::Node::getNodeCount method. This should help give a clearer picture of the layers involved in implementing an IPC call.

  • Instead of adding Cap'n Proto code and modifying Qt code in a single commit, it includes a new early commit (1407a2b Add ipc::Node and ipc::Wallet interfaces that introduces new src/ipc/interfaces.h and src/ipc/interfaces.cpp files and ports Qt code to use them without any Cap'n Proto stuff. This shows the separation between Qt updates and IPC implementation details better and makes it easier to see how a different IPC system could be substituted in for Cap'n Proto. This commit could even be made into a separate PR.

@ryanofsky
Copy link
Contributor Author

ryanofsky commented Apr 14, 2017

@laanwj pointed out in IRC (https://botbot.me/freenode/bitcoin-core-dev/msg/83983170/) that this change could help make the GUI more responsive by preventing Qt event processing from getting blocked, which currently happens in the monolithic bitcoin-qt when the main GUI thread makes a call to a slow libbitcoin function, or waits a long time for a cs_main or cs_wallet lock.

At the time in IRC, I didn't think this change could directly help gui responsiveness, because although it does move libbitcoin and LOCK calls out of the bitcoin-qt process and into the bitcoind process, it just replaces these calls with blocking IPCs that make the GUI equally unresponsive when they tie up the main GUI thread.

However, this doesn't have to be the case. The place where IPC calls currently block waiting for responses is the return promise.get_future().get(); line in ipc::util::Call::send method here: https://github.com/ryanofsky/bitcoin/blob/pr/ipc.4/src/ipc/util.h#L166

But the std::promise object used in that line could easily be replaced with a Qt-aware promise object that processes GUI events while the promise is blocked. (The Qt-aware promise implementation would check if it is being used on the main GUI thread, and if so use a local Qt event loop substituting
loop.exec() for std::future::get() and loop.quit() for std::promise::set_value().)

This would add more overhead and make the average IPC call a little slower. But it would avoid situations where an unexpectedly slow IPC call ties up the whole gui, so it might be worth doing anyway.

@laanwj
Copy link
Member

laanwj commented Apr 14, 2017

@ryanofsky Yes, integrating the IPC event loop and Qt event loop would help responsiveness.
Though I remember there were some issues in some cases with recursively calling into the Qt event loop (e.g. things need to be reentrant, deleteLater stuff runs earlier than expected, to keep in mind).

@sipa
Copy link
Member

sipa commented Apr 17, 2017

@ryanofsky I'm not familiar with Qt or capnproto, but I don't understand what the move to a different process has to do with making things less blocking. Any changes in architecture that would result in less blocks should equally be possible within the same process.

@sipa
Copy link
Member

sipa commented Apr 17, 2017

This change will not add any new command line or GUI options allowing bitcoin-qt to connect to bitcoinds other than the one it spawns internally. Adding these features and supporting new public APIs might be things we want to do in the future, but they would involve downsides and complications that I'm trying to avoid here.

I don't understand the goal here. On itself, there seems little benefit in separating the GUI and the rest into separate processes if those two processes still depend on each other (this is different from separating the wallet from the node, for example, as there as security considerations there... but for that use case the easiest approach seems to just have a lightweight mode and running two instances).

I think it would be awesome if bitcoin-qt could be started and stopped independently to control a bitcoind process in the background, but if that's not the intent, what is the purpose?

@ryanofsky
Copy link
Contributor Author

Any changes in architecture that would result in less blocks should equally be possible within the same process.

Let's say there are 50 places where bitcoin-qt calls a libbitcoin function. That means there are 50 places to update if you want bitcoin-qt handle to events while the function calls are executing. WIth the IPC framework, there is only one place you have to update instead of 50 places (if you want to do this).

On itself, there seems little benefit in separating the GUI and the rest into separate processes if those two processes still depend on each other.

Ok, so you think the benefits are small, and I think they are more significant.

I think it would be awesome if bitcoin-qt could be started and stopped independently to control a bitcoind process in the background,

This is trivial once bitcoin-qt is controlling bitcoind across a socket. I'm just implementing the socket part first, without introducing new UI features for now.

@sipa
Copy link
Member

sipa commented Apr 17, 2017

I think it would be awesome if bitcoin-qt could be started and stopped independently to control a bitcoind process in the background,

This is trivial once bitcoin-qt is controlling bitcoind across a socket. I'm just implementing the socket part first, without introducing new UI features for now.

Ok, that's what I was missing. It wasn't clear to me that this was a just first step towards a more useful separation.

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Apr 20, 2017
This doesn't crash currently because the method doesn't access any object
members, but this behavior is fragile and incompatible with bitcoin#10102.
knst pushed a commit to knst/dash that referenced this pull request Jan 12, 2024
e2bab2a multiprocess: add multiprocess travis configuration (Russell Yanofsky)
603fd6a depends: add MULTIPROCESS depends option (Russell Yanofsky)
5d1377b build: multiprocess autotools changes (Russell Yanofsky)

Pull request description:

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10).

  ---

  This PR consists of build changes only. It adds an `--enable-multiprocess` autoconf option (off by default and marked experimental), that builds new `bitcoin-node` and `bitcoin-gui` binaries. These currently function the same as existing `bitcoind` and `bitcoin-qt` binaries, but are extended in bitcoin#10102 with IPC features to execute node, wallet, and gui functions in separate processes.

  In addition to adding the `--enable-multiprocess` config flag, it also adds a depends package and autoconf rules to build with the [libmultiprocess](https://github.com/chaincodelabs/libmultiprocess) library, and it adds new travis configuration to exercise the build code and run functional tests with the new binaries.

  The changes in this PR were originally part of bitcoin#10102 but were moved into bitcoin#16367 to be able to develop and review the multiprocess build changes independently of the code changes. bitcoin#16367 was briefly merged and then reverted in bitcoin#18588. Only change since bitcoin#16367 has been dropping the `native_boost.mk` depends package which was pointed out to be no longer necessary in bitcoin#16367 (comment) and bitcoin#18588 (review)

ACKs for top commit:
  practicalswift:
    ACK e2bab2a
  Sjors:
    tACK e2bab2a on macOS 10.15.4
  hebasto:
    ACK e2bab2a, tested on Linux Mint 19.3 (x86_64):

Tree-SHA512: b5a76eab5abf63d9d8b6d628cbdff4cc1888eef15cafa0a5d56369e2f9d02595fed623f4b74b2cf2830c42c05a774f0943e700f9c768a82d9d348cad199e135c
knst pushed a commit to knst/dash that referenced this pull request Jan 13, 2024
e2bab2a multiprocess: add multiprocess travis configuration (Russell Yanofsky)
603fd6a depends: add MULTIPROCESS depends option (Russell Yanofsky)
5d1377b build: multiprocess autotools changes (Russell Yanofsky)

Pull request description:

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10).

  ---

  This PR consists of build changes only. It adds an `--enable-multiprocess` autoconf option (off by default and marked experimental), that builds new `bitcoin-node` and `bitcoin-gui` binaries. These currently function the same as existing `bitcoind` and `bitcoin-qt` binaries, but are extended in bitcoin#10102 with IPC features to execute node, wallet, and gui functions in separate processes.

  In addition to adding the `--enable-multiprocess` config flag, it also adds a depends package and autoconf rules to build with the [libmultiprocess](https://github.com/chaincodelabs/libmultiprocess) library, and it adds new travis configuration to exercise the build code and run functional tests with the new binaries.

  The changes in this PR were originally part of bitcoin#10102 but were moved into bitcoin#16367 to be able to develop and review the multiprocess build changes independently of the code changes. bitcoin#16367 was briefly merged and then reverted in bitcoin#18588. Only change since bitcoin#16367 has been dropping the `native_boost.mk` depends package which was pointed out to be no longer necessary in bitcoin#16367 (comment) and bitcoin#18588 (review)

ACKs for top commit:
  practicalswift:
    ACK e2bab2a
  Sjors:
    tACK e2bab2a on macOS 10.15.4
  hebasto:
    ACK e2bab2a, tested on Linux Mint 19.3 (x86_64):

Tree-SHA512: b5a76eab5abf63d9d8b6d628cbdff4cc1888eef15cafa0a5d56369e2f9d02595fed623f4b74b2cf2830c42c05a774f0943e700f9c768a82d9d348cad199e135c
knst pushed a commit to knst/dash that referenced this pull request Jan 15, 2024
e2bab2a multiprocess: add multiprocess travis configuration (Russell Yanofsky)
603fd6a depends: add MULTIPROCESS depends option (Russell Yanofsky)
5d1377b build: multiprocess autotools changes (Russell Yanofsky)

Pull request description:

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10).

  ---

  This PR consists of build changes only. It adds an `--enable-multiprocess` autoconf option (off by default and marked experimental), that builds new `bitcoin-node` and `bitcoin-gui` binaries. These currently function the same as existing `bitcoind` and `bitcoin-qt` binaries, but are extended in bitcoin#10102 with IPC features to execute node, wallet, and gui functions in separate processes.

  In addition to adding the `--enable-multiprocess` config flag, it also adds a depends package and autoconf rules to build with the [libmultiprocess](https://github.com/chaincodelabs/libmultiprocess) library, and it adds new travis configuration to exercise the build code and run functional tests with the new binaries.

  The changes in this PR were originally part of bitcoin#10102 but were moved into bitcoin#16367 to be able to develop and review the multiprocess build changes independently of the code changes. bitcoin#16367 was briefly merged and then reverted in bitcoin#18588. Only change since bitcoin#16367 has been dropping the `native_boost.mk` depends package which was pointed out to be no longer necessary in bitcoin#16367 (comment) and bitcoin#18588 (review)

ACKs for top commit:
  practicalswift:
    ACK e2bab2a
  Sjors:
    tACK e2bab2a on macOS 10.15.4
  hebasto:
    ACK e2bab2a, tested on Linux Mint 19.3 (x86_64):

Tree-SHA512: b5a76eab5abf63d9d8b6d628cbdff4cc1888eef15cafa0a5d56369e2f9d02595fed623f4b74b2cf2830c42c05a774f0943e700f9c768a82d9d348cad199e135c
knst pushed a commit to knst/dash that referenced this pull request Jan 15, 2024
e2bab2a multiprocess: add multiprocess travis configuration (Russell Yanofsky)
603fd6a depends: add MULTIPROCESS depends option (Russell Yanofsky)
5d1377b build: multiprocess autotools changes (Russell Yanofsky)

Pull request description:

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10).

  ---

  This PR consists of build changes only. It adds an `--enable-multiprocess` autoconf option (off by default and marked experimental), that builds new `bitcoin-node` and `bitcoin-gui` binaries. These currently function the same as existing `bitcoind` and `bitcoin-qt` binaries, but are extended in bitcoin#10102 with IPC features to execute node, wallet, and gui functions in separate processes.

  In addition to adding the `--enable-multiprocess` config flag, it also adds a depends package and autoconf rules to build with the [libmultiprocess](https://github.com/chaincodelabs/libmultiprocess) library, and it adds new travis configuration to exercise the build code and run functional tests with the new binaries.

  The changes in this PR were originally part of bitcoin#10102 but were moved into bitcoin#16367 to be able to develop and review the multiprocess build changes independently of the code changes. bitcoin#16367 was briefly merged and then reverted in bitcoin#18588. Only change since bitcoin#16367 has been dropping the `native_boost.mk` depends package which was pointed out to be no longer necessary in bitcoin#16367 (comment) and bitcoin#18588 (review)

ACKs for top commit:
  practicalswift:
    ACK e2bab2a
  Sjors:
    tACK e2bab2a on macOS 10.15.4
  hebasto:
    ACK e2bab2a, tested on Linux Mint 19.3 (x86_64):

Tree-SHA512: b5a76eab5abf63d9d8b6d628cbdff4cc1888eef15cafa0a5d56369e2f9d02595fed623f4b74b2cf2830c42c05a774f0943e700f9c768a82d9d348cad199e135c
PastaPastaPasta pushed a commit to knst/dash that referenced this pull request Jan 16, 2024
e2bab2a multiprocess: add multiprocess travis configuration (Russell Yanofsky)
603fd6a depends: add MULTIPROCESS depends option (Russell Yanofsky)
5d1377b build: multiprocess autotools changes (Russell Yanofsky)

Pull request description:

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10).

  ---

  This PR consists of build changes only. It adds an `--enable-multiprocess` autoconf option (off by default and marked experimental), that builds new `bitcoin-node` and `bitcoin-gui` binaries. These currently function the same as existing `bitcoind` and `bitcoin-qt` binaries, but are extended in bitcoin#10102 with IPC features to execute node, wallet, and gui functions in separate processes.

  In addition to adding the `--enable-multiprocess` config flag, it also adds a depends package and autoconf rules to build with the [libmultiprocess](https://github.com/chaincodelabs/libmultiprocess) library, and it adds new travis configuration to exercise the build code and run functional tests with the new binaries.

  The changes in this PR were originally part of bitcoin#10102 but were moved into bitcoin#16367 to be able to develop and review the multiprocess build changes independently of the code changes. bitcoin#16367 was briefly merged and then reverted in bitcoin#18588. Only change since bitcoin#16367 has been dropping the `native_boost.mk` depends package which was pointed out to be no longer necessary in bitcoin#16367 (comment) and bitcoin#18588 (review)

ACKs for top commit:
  practicalswift:
    ACK e2bab2a
  Sjors:
    tACK e2bab2a on macOS 10.15.4
  hebasto:
    ACK e2bab2a, tested on Linux Mint 19.3 (x86_64):

Tree-SHA512: b5a76eab5abf63d9d8b6d628cbdff4cc1888eef15cafa0a5d56369e2f9d02595fed623f4b74b2cf2830c42c05a774f0943e700f9c768a82d9d348cad199e135c
@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

achow101 added a commit that referenced this pull request Jan 23, 2024
6acec6b multiprocess: Add type conversion code for UniValue types (Ryan Ofsky)
0cc74fc multiprocess: Add type conversion code for serializable types (Ryan Ofsky)
4aaee23 test: add ipc test to test multiprocess type conversion code (Ryan Ofsky)

Pull request description:

  Add type conversion hooks to allow `UniValue` objects, and objects that have `CDataStream` `Serialize` and `Unserialize` methods to be used as arguments and return values in Cap'nProto interface methods. Also add unit test to verify the hooks are working and data can be round-tripped correctly.

  The non-test code in this PR was previously part of #10102 and has been split off for easier review, but the test code is new.

  ---

  This PR is part of the [process separation project](#28722).

ACKs for top commit:
  achow101:
    ACK 6acec6b
  dergoegge:
    reACK 6acec6b

Tree-SHA512: 5d2cbc5215d488b876d34420adf91205dabf09b736183dcc85aa86255e3804c2bac5bab6792dacd585ef99a1d92cf29c8afb3eb65e4d953abc7ffe41994340c6
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Feb 3, 2024
615965c Move common package version code to init/common (Russell Yanofsky)
5bed2ab Move common logging start code to init/common (Russell Yanofsky)
1fb7fcf Move common logging GetArgs code to init/common (Russell Yanofsky)
90469c1 Move common logging AddArg code to init/common (Russell Yanofsky)
387c4cf Move common sanity check code to init/common (Russell Yanofsky)
a67b548 Move common global init code to init/common (Russell Yanofsky)

Pull request description:

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10).

  ---

  This change is move-only and can be easily reviewed with `--color-moved=dimmed_zebra`. The moves are needed to avoid duplicating common init code between different binaries (`bitcoin-node`, `bitcoin-wallet`, etc) in bitcoin#10102. In bitcoin#10102, each binary has it's own init file (`src/init/bitcoin-node.cpp`, `src/init/bitcoin-wallet.cpp`) so this PR moves the common code to `src/init/common.cpp`.

ACKs for top commit:
  MarcoFalke:
    review ACK 615965c 🖱
  practicalswift:
    cr ACK 615965c: dimmed zebra looks correct

Tree-SHA512: 859e1d86aee17eb50a49d806cf62d30d12f6b15018e41c096da41d7e535a9d2d088481cb340fee59e6c68e512a74b61c7146f2683465f553dc4953bf32f2a7b4
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Feb 5, 2024
615965c Move common package version code to init/common (Russell Yanofsky)
5bed2ab Move common logging start code to init/common (Russell Yanofsky)
1fb7fcf Move common logging GetArgs code to init/common (Russell Yanofsky)
90469c1 Move common logging AddArg code to init/common (Russell Yanofsky)
387c4cf Move common sanity check code to init/common (Russell Yanofsky)
a67b548 Move common global init code to init/common (Russell Yanofsky)

Pull request description:

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10).

  ---

  This change is move-only and can be easily reviewed with `--color-moved=dimmed_zebra`. The moves are needed to avoid duplicating common init code between different binaries (`bitcoin-node`, `bitcoin-wallet`, etc) in bitcoin#10102. In bitcoin#10102, each binary has it's own init file (`src/init/bitcoin-node.cpp`, `src/init/bitcoin-wallet.cpp`) so this PR moves the common code to `src/init/common.cpp`.

ACKs for top commit:
  MarcoFalke:
    review ACK 615965c 🖱
  practicalswift:
    cr ACK 615965c: dimmed zebra looks correct

Tree-SHA512: 859e1d86aee17eb50a49d806cf62d30d12f6b15018e41c096da41d7e535a9d2d088481cb340fee59e6c68e512a74b61c7146f2683465f553dc4953bf32f2a7b4
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Feb 23, 2024
615965c Move common package version code to init/common (Russell Yanofsky)
5bed2ab Move common logging start code to init/common (Russell Yanofsky)
1fb7fcf Move common logging GetArgs code to init/common (Russell Yanofsky)
90469c1 Move common logging AddArg code to init/common (Russell Yanofsky)
387c4cf Move common sanity check code to init/common (Russell Yanofsky)
a67b548 Move common global init code to init/common (Russell Yanofsky)

Pull request description:

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10).

  ---

  This change is move-only and can be easily reviewed with `--color-moved=dimmed_zebra`. The moves are needed to avoid duplicating common init code between different binaries (`bitcoin-node`, `bitcoin-wallet`, etc) in bitcoin#10102. In bitcoin#10102, each binary has it's own init file (`src/init/bitcoin-node.cpp`, `src/init/bitcoin-wallet.cpp`) so this PR moves the common code to `src/init/common.cpp`.

ACKs for top commit:
  MarcoFalke:
    review ACK 615965c 🖱
  practicalswift:
    cr ACK 615965c: dimmed zebra looks correct

Tree-SHA512: 859e1d86aee17eb50a49d806cf62d30d12f6b15018e41c096da41d7e535a9d2d088481cb340fee59e6c68e512a74b61c7146f2683465f553dc4953bf32f2a7b4
@DrahtBot
Copy link
Contributor

⌛ There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@willcl-ark
Copy link
Member

I've been using this in a side-project and noticed some unintended behaviour, which could be my system; if I make distclean (removing the generated files) and then make -j16 the build fails as it can't find the built artefacts. Running plain make works fine every time, and sometimes a low job number works too.

The Makefile appears (to me) to have the dependencies listed correctly, so I'm not entirely sure what's going wrong, but just thought I'd report here in case anyone else had a similar issue. Also, likely not worth actually fixing now before a move to CMake.

vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request May 6, 2024
…NodeContext

493fb47 Make SetupServerArgs callable without NodeContext (Russell Yanofsky)

Pull request description:

  `bitcoin-gui` code needs to call `SetupServerArgs` but will not have a `NodeContext` object if it is communicating with an external `bitcoin-node` process, so this just passes `ArgsManager` directly.

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR bitcoin#10102.

ACKs for top commit:
  MarcoFalke:
    review ACK 493fb47

Tree-SHA512: 94cda4350113237976e32f1935e3602d1e6ea90c29c4434db2094be70dddf4b63702c3094385258bdf1c3e5b52c7d23bbc1f0282bdd4965557eedd5aef9a0fd4
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request May 6, 2024
f47e802 Rearrange fillPSBT arguments (Russell Yanofsky)

Pull request description:

  Move fillPSBT inout argument before output-only arguments. This is a nice thing to do to keep the interface style [consistent](https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). But motivation is to work around a current limitation of the libmultiprocess code generator (which figures out order of inout parameters by looking at input list, but more ideally would use the output list).

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR bitcoin#10102.

ACKs for top commit:
  achow101:
    ACK f47e802
  theStack:
    Code-review ACK f47e802

Tree-SHA512: 1787af3031ff7ed6b519f3b93054d8b257af96a3380a476a6dab0f759329039ecc5d624b785c5c2d14d594fc852dd81c626880c775c691ec9c79b7b3dbcfb257
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request May 6, 2024
…NodeContext

493fb47 Make SetupServerArgs callable without NodeContext (Russell Yanofsky)

Pull request description:

  `bitcoin-gui` code needs to call `SetupServerArgs` but will not have a `NodeContext` object if it is communicating with an external `bitcoin-node` process, so this just passes `ArgsManager` directly.

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR bitcoin#10102.

ACKs for top commit:
  MarcoFalke:
    review ACK 493fb47

Tree-SHA512: 94cda4350113237976e32f1935e3602d1e6ea90c29c4434db2094be70dddf4b63702c3094385258bdf1c3e5b52c7d23bbc1f0282bdd4965557eedd5aef9a0fd4
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request May 6, 2024
f47e802 Rearrange fillPSBT arguments (Russell Yanofsky)

Pull request description:

  Move fillPSBT inout argument before output-only arguments. This is a nice thing to do to keep the interface style [consistent](https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). But motivation is to work around a current limitation of the libmultiprocess code generator (which figures out order of inout parameters by looking at input list, but more ideally would use the output list).

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR bitcoin#10102.

ACKs for top commit:
  achow101:
    ACK f47e802
  theStack:
    Code-review ACK f47e802

Tree-SHA512: 1787af3031ff7ed6b519f3b93054d8b257af96a3380a476a6dab0f759329039ecc5d624b785c5c2d14d594fc852dd81c626880c775c691ec9c79b7b3dbcfb257
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request May 7, 2024
f47e802 Rearrange fillPSBT arguments (Russell Yanofsky)

Pull request description:

  Move fillPSBT inout argument before output-only arguments. This is a nice thing to do to keep the interface style [consistent](https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). But motivation is to work around a current limitation of the libmultiprocess code generator (which figures out order of inout parameters by looking at input list, but more ideally would use the output list).

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR bitcoin#10102.

ACKs for top commit:
  achow101:
    ACK f47e802
  theStack:
    Code-review ACK f47e802

Tree-SHA512: 1787af3031ff7ed6b519f3b93054d8b257af96a3380a476a6dab0f759329039ecc5d624b785c5c2d14d594fc852dd81c626880c775c691ec9c79b7b3dbcfb257
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request May 7, 2024
f47e802 Rearrange fillPSBT arguments (Russell Yanofsky)

Pull request description:

  Move fillPSBT inout argument before output-only arguments. This is a nice thing to do to keep the interface style [consistent](https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). But motivation is to work around a current limitation of the libmultiprocess code generator (which figures out order of inout parameters by looking at input list, but more ideally would use the output list).

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR bitcoin#10102.

ACKs for top commit:
  achow101:
    ACK f47e802
  theStack:
    Code-review ACK f47e802

Tree-SHA512: 1787af3031ff7ed6b519f3b93054d8b257af96a3380a476a6dab0f759329039ecc5d624b785c5c2d14d594fc852dd81c626880c775c691ec9c79b7b3dbcfb257
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request May 16, 2024
f47e802 Rearrange fillPSBT arguments (Russell Yanofsky)

Pull request description:

  Move fillPSBT inout argument before output-only arguments. This is a nice thing to do to keep the interface style [consistent](https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). But motivation is to work around a current limitation of the libmultiprocess code generator (which figures out order of inout parameters by looking at input list, but more ideally would use the output list).

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR bitcoin#10102.

ACKs for top commit:
  achow101:
    ACK f47e802
  theStack:
    Code-review ACK f47e802

Tree-SHA512: 1787af3031ff7ed6b519f3b93054d8b257af96a3380a476a6dab0f759329039ecc5d624b785c5c2d14d594fc852dd81c626880c775c691ec9c79b7b3dbcfb257
PastaPastaPasta pushed a commit to vijaydasmp/dash that referenced this pull request May 19, 2024
f47e802 Rearrange fillPSBT arguments (Russell Yanofsky)

Pull request description:

  Move fillPSBT inout argument before output-only arguments. This is a nice thing to do to keep the interface style [consistent](https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). But motivation is to work around a current limitation of the libmultiprocess code generator (which figures out order of inout parameters by looking at input list, but more ideally would use the output list).

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR bitcoin#10102.

ACKs for top commit:
  achow101:
    ACK f47e802
  theStack:
    Code-review ACK f47e802

Tree-SHA512: 1787af3031ff7ed6b519f3b93054d8b257af96a3380a476a6dab0f759329039ecc5d624b785c5c2d14d594fc852dd81c626880c775c691ec9c79b7b3dbcfb257
@willcl-ark
Copy link
Member

I noticed some other unexpected behaviour when interacting with bitcoin-node from an external process which might be of interest to investigate...

I made a (malformed) call to MakeWalletLoader, not including GlobalArgs, which cause the node to shut down whilst it had an open lock on another (default loaded) wallet. This resulted in preventing this wallet from being re-opened again at next startup.

I wonder whether a malformed call to MakeWalletLoader should shut down the node at all, but if it should, then it seems like (perhaps) we should take care to close opened wallets more carefully?

Log
2024-05-22T13:49:06Z [ipc] {bitcoin-wallet-3127478/bitcoin-wallet-3127478} IPC server post request  #3075 {bitcoin-wallet-3127478/bitcoin-wallet-3127902 (from bitcoin-node-3127476/b-scheduler-3127477)}
2024-05-22T13:49:06Z [ipc] {bitcoin-wallet-3127478/bitcoin-wallet-3127478} IPC server send response #3075 ChainNotifications.transactionAddedToMempool$Results ()
2024-05-22T13:49:06Z [ipc] {bitcoin-node-3127476/b-scheduler-3127477} IPC client recv ChainNotifications.transactionAddedToMempool$Results ()
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server recv request  #201 Init.construct$Params ()
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server send response #201 Init.construct$Results (threadMap = <external capability>)
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server recv request  #202 Init.makeEcho$Params (context = (thread = <external capability>))
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server post request  #202 {bitcoin-node-3127476/b-capnp-loop-3210934 (from )}
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server send response #202 Init.makeEcho$Results (result = <external capability>)
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server recv request  #203 Echo.echo$Params (context = (thread = <external capability>), echo = "Hello, world!")
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server post request  #203 {bitcoin-node-3127476/b-capnp-loop-3210934 (from )}
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server send response #203 Echo.echo$Results (result = "Hello, world!")
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server recv request  #204 Init.makeChain$Params (context = (thread = <external capability>))
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server post request  #204 {bitcoin-node-3127476/b-capnp-loop-3210934 (from )}
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server send response #204 Init.makeChain$Results (result = <external capability>)
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server recv request  #205 Chain.getHeight$Params (context = (thread = <external capability>))
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server post request  #205 {bitcoin-node-3127476/b-capnp-loop-3210934 (from )}
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server send response #205 Chain.getHeight$Results (result = 196713, hasResult = true)
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server recv request  #206 Chain.getSettingsList$Params (context = (thread = <external capability>))
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server post request  #206 {bitcoin-node-3127476/b-capnp-loop-3210934 (from )}
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server send response #206 Chain.getSettingsList$Results (result = [])
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server recv request  #207 Init.makeWalletLoader$Params (context = (thread = <external capability>))
2024-05-22T13:49:15Z [ipc] {bitcoin-node-3127476/b-capnp-loop-3127479} IPC server post request  #207 {bitcoin-node-3127476/b-capnp-loop-3210934 (from )}
bitcoin-node: common/args.cpp:728: void ArgsManager::SetConfigFilePath(fs::path): Assertion `!m_config_path' failed.

Note, I haven't tried to reproduce this, but the above is what I think happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

None yet