-
Notifications
You must be signed in to change notification settings - Fork 37.7k
ipc: add bitcoin-mine test program #30437
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
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/30437. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
Thanks. I'll try to get the Mining interface in good shape as well, which this can then be rebased on:
|
🚧 At least one of the CI tasks failed. HintsMake sure to run all tests locally, according to the documentation. The failure may happen due to a number of reasons, for example:
Leave a comment here, if you need help tracking down a confusing failure. |
I'll work on dropping the spawn functionality from this PR next, and just having the
This would simplify the PR by allowing 3 commits to be dropped:
Other things I'd like to do:
|
You won't need that if you include #30440, though maybe it's better to wait until that's merged to avoid too much code churn. |
Yeah definitely some of that should not be needed. Some parts will probably be needed though. For example, the initial version of this PR did not support deserializing |
I'll certainly need |
I opened draft PRs for all interface changes that I think I will need, see updated comment above: #30437 (comment) If you can cherry-pick them all, I'll expand the demo app to simulate all the steps a Template Provider would do. That should reveal any remaining gaps in the interface. |
I wrote:
Once that works the next step for me would be to open an alternative to #29432 which runs the Template Provider in I could then modify the guix build to only produce That way the user can simply install and run a recent Bitcoin Core release in the manner they're familiar with. They would install If later on we can also turn This would be in parallel to the alternative approach of writing With both approaches it will take a while to reach feature parity with #29432 so I'll have to keep maintaining that too (using the same interface, but not as a separate process). |
I simplified PR as suggested so I also added a new commit to make the IPC code compatible with all the interfaces added in #30409, #30356, #30440, and #30443, so this PR is easier to test with those interfaces. I still need to break up the main commit ("Add bitcoin-mine test program") and add unit tests for the new connecting, listening, and serialization code that's introduced. Rebased 3c0a13c -> 4e1a434 ( For reference, the code that was dropped from this PR allowing bitcoin-mine to spawn a bitcoin-node process is in commits:
These changes would probably be useful in another context, but aren't needed for this test program. re: #30437 (comment) I think your ideas for packaging bitcoin-tp make sense. And maybe it would also be good to try to integrate IPC in bitcoind and bitcoin-qt executables instead of separate bitcoin-node and bitcoin-gui executables. Would have to think about how to implement this and what the tradeoffs would be. |
Allows InitError and InitWarning to be used by other executables beside bitcoind and bitcoin-node.
See src/bitcoin-mine.cpp for usage information. Co-authored-by: Sjors Provoost <sjors@sprovoost.nl>
Co-authored-by: Sjors Provoost <sjors@sprovoost.nl>
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Suggested by Sjors Provoost <sjors@sprovoost.nl> in bitcoin#30437 (comment)
Add a MakeBasicInit() function so simpler standalone IPC clients like bitcoin-mine in bitcoin#30437 and bitcoin-cli in bitcoin#32297 that only initiate IPC connections without exposing any IPC interfaces themselves can to avoid needing to implement their own specialized interfaces::Init subclasses.
Expose ENABLE_IPC build option to function tests so new tests for bitcoin-mine in bitcoin#30437 and bitcoin-cli in bitcoin#32297 can test IPC-only features.
Set new `BitcoinTestFramework.binary_paths.bitcoin_bin` property with path to the `bitcoin` wrapper binary. This allows new tests for `bitcoin-mine` in bitcoin#30437 and `bitcoin-cli` in bitcoin#32297 to find the `bitcoin` binary and call `bitcoin -m` to start nodes with IPC support. This way the new tests can run whenever the ENABLE_IPC build option is enabled, instead of only running when the `BITCOIN_CMD` environment variable is set to `bitcoin -m`
Suggested by Sjors Provoost <sjors@sprovoost.nl> in bitcoin#30437 (comment)
Rebased e1f139b -> 1e8a832 ( |
Expose ENABLE_IPC build option to function tests so new tests for bitcoin-mine in bitcoin#30437 and bitcoin-cli in bitcoin#32297 can test IPC-only features.
Set new `BitcoinTestFramework.binary_paths.bitcoin_bin` property with path to the `bitcoin` wrapper binary. This allows new tests for `bitcoin-mine` in bitcoin#30437 and `bitcoin-cli` in bitcoin#32297 to find the `bitcoin` binary and call `bitcoin -m` to start nodes with IPC support. This way the new tests can run whenever the ENABLE_IPC build option is enabled, instead of only running when the `BITCOIN_CMD` environment variable is set to `bitcoin -m`
With this change, tests can specify `self.extra_init = [{ipcbind: True}]` to start a node listening on an IPC socket, instead of needing to choose which node binary to invoke and what `self.extra_args=[["-ipcbind=..."]]` value to pass to it. The eliminates boilerplate code bitcoin#30437 (interface_ipc_mining.py), bitcoin#32297 (interface_ipc_cli.py), and bitcoin#33201 (interface_ipc.py) previously needed in their test setup.
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
Expose ENABLE_IPC build option to function tests so new tests for bitcoin-mine in bitcoin#30437 and bitcoin-cli in bitcoin#32297 can test IPC-only features.
Set new `BitcoinTestFramework.binary_paths.bitcoin_bin` property with path to the `bitcoin` wrapper binary. This allows new tests for `bitcoin-mine` in bitcoin#30437 and `bitcoin-cli` in bitcoin#32297 to find the `bitcoin` binary and call `bitcoin -m` to start nodes with IPC support. This way the new tests can run whenever the ENABLE_IPC build option is enabled, instead of only running when the `BITCOIN_CMD` environment variable is set to `bitcoin -m`
With this change, tests can specify `self.extra_init = [{ipcbind: True}]` to start a node listening on an IPC socket, instead of needing to choose which node binary to invoke and what `self.extra_args=[["-ipcbind=..."]]` value to pass to it. The eliminates boilerplate code bitcoin#30437 (interface_ipc_mining.py), bitcoin#32297 (interface_ipc_cli.py), and bitcoin#33201 (interface_ipc.py) previously needed in their test setup.
Expose ENABLE_IPC build option to function tests so new tests for bitcoin-mine in bitcoin#30437 and bitcoin-cli in bitcoin#32297 can test IPC-only features.
Set new `BitcoinTestFramework.binary_paths.bitcoin_bin` property with path to the `bitcoin` wrapper binary. This allows new tests for `bitcoin-mine` in bitcoin#30437 and `bitcoin-cli` in bitcoin#32297 to find the `bitcoin` binary and call `bitcoin -m` to start nodes with IPC support. This way the new tests can run whenever the ENABLE_IPC build option is enabled, instead of only running when the `BITCOIN_CMD` environment variable is set to `bitcoin -m`
With this change, tests can specify `self.extra_init = [{ipcbind: True}]` to start a node listening on an IPC socket, instead of needing to choose which node binary to invoke and what `self.extra_args=[["-ipcbind=..."]]` value to pass to it. The eliminates boilerplate code bitcoin#30437 (interface_ipc_mining.py), bitcoin#32297 (interface_ipc_cli.py), and bitcoin#33201 (interface_ipc.py) previously needed in their test setup.
…coin` binary test: Provide path to `bitcoin` binary Set new `BitcoinTestFramework.binary_paths.bitcoin_bin` property with path to the `bitcoin` wrapper binary. This allows new tests for `bitcoin-mine` in bitcoin#30437 and `bitcoin-cli` in bitcoin#32297 to find the `bitcoin` binary and call `bitcoin -m` to start nodes with IPC support. This way the new tests can run whenever the ENABLE_IPC build option is enabled, instead of only running when the `BITCOIN_CMD` environment variable is set to `bitcoin -m`
Set new `BitcoinTestFramework.binary_paths.bitcoin_bin` property with path to the `bitcoin` wrapper binary. This allows new tests for `bitcoin-mine` in bitcoin#30437 and `bitcoin-cli` in bitcoin#32297 to find the `bitcoin` binary and call `bitcoin -m` to start nodes with IPC support. This way the new tests can run whenever the ENABLE_IPC build option is enabled, instead of only running when the `BITCOIN_CMD` environment variable is set to `bitcoin -m`
Set new `BitcoinTestFramework.binary_paths.bitcoin_bin` property with path to the `bitcoin` wrapper binary. This allows new tests for `bitcoin-mine` in bitcoin#30437 and `bitcoin-cli` in bitcoin#32297 to find the `bitcoin` binary and call `bitcoin -m` to start nodes with IPC support. This way the new tests can run whenever the ENABLE_IPC build option is enabled, instead of only running when the `BITCOIN_CMD` environment variable is set to `bitcoin -m`
With this change, tests can specify `self.extra_init = [{ipcbind: True}]` to start a node listening on an IPC socket, instead of needing to choose which node binary to invoke and what `self.extra_args=[["-ipcbind=..."]]` value to pass to it. The eliminates boilerplate code bitcoin#30437 (interface_ipc_mining.py), bitcoin#32297 (interface_ipc_cli.py), and bitcoin#33201 (interface_ipc.py) previously needed in their test setup.
test_framework.py:565: error: Need type annotation for "extra_init" |
Add
bitcoin-mine
executable to test connecting to thebitcoin-node
process over a unix socket and callinginterface::Mining
methods.This is useful as discussed in #29432 (comment) to work on getting mining code working in an external process.
This PR initially supported spawning a new
bitcoin-node
process if a connection could not be established with an existing process, but it was dropped to simplify the code. A branch building on this PR and adding that support ispr/mine-detach.
This PR is part of the process separation project.