-
Notifications
You must be signed in to change notification settings - Fork 38.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 copy-paste ConflictsNo conflicts as of last run. LLM Linter (✨ experimental)Possible places where named args for integral literals may be used (e.g.
2025-12-12 |
|
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. |
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.
Suggested by Sjors Provoost <sjors@sprovoost.nl> in bitcoin#30437 (comment)
| } | ||
| block_template->submitSolution(block.nVersion, block.nTime, block.nNonce, block_template->getCoinbaseTx()); | ||
|
|
||
| if (tip->hash != mining->getTip()->hash) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 1a844b8 bitcoin-mine: Extend example to mine a block: just thought I got lucky on mainnet, but this does not distinguish between actually mining a block and a peer giving ups a new tip :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #30437 (comment)
In 1a844b8 bitcoin-mine: Extend example to mine a block: just thought I got lucky on mainnet, but this does not distinguish between actually mining a block and a peer giving ups a new tip :-)
I guess technically the message didn't say who mined the block. But reworded it to avoid unnecessary excitement
|
re-ACK a2365f1 Since my last review of e1f139b, commits 8bf2269 and b094d38 were absorbed into #33201 which added direct coverage of IPC via a functional test. This also allowed some simplification of I initially wanted to suggest folding this test into |
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.
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.
Suggested by Sjors Provoost <sjors@sprovoost.nl> in bitcoin#30437 (comment)
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.
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.
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated 2cb5e64 -> 057ea0a (pr/mine.34 -> pr/mine.35, compare) just tweaking bitcoin-mine status message
|
|
||
| while (tries_remaining> 0 && block.nNonce < std::numeric_limits<uint32_t>::max() && !CheckProofOfWork(block.GetHash(), block.nBits, consensus_params)) { | ||
| ++block.nNonce; | ||
| --tries_remaining; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #30437 (comment)
+1. I think just having simple code to demonstrate the API with comments pointing out how usage could be more robust is a good middle ground.
src/bitcoin-mine.cpp
Outdated
|
|
||
| // Note: This loop ignores tip changes so the submitSolution call below | ||
| // could fail even if the CheckProofOfWork succeeds! A more realistic miner | ||
| // could avoid this problem by calling call block_template->waitNext() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #30437 (comment)
Thanks, fixed
| } | ||
| block_template->submitSolution(block.nVersion, block.nTime, block.nNonce, block_template->getCoinbaseTx()); | ||
|
|
||
| if (tip->hash != mining->getTip()->hash) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #30437 (comment)
In 1a844b8 bitcoin-mine: Extend example to mine a block: just thought I got lucky on mainnet, but this does not distinguish between actually mining a block and a peer giving ups a new tip :-)
I guess technically the message didn't say who mined the block. But reworded it to avoid unnecessary excitement
|
ACK 057ea0a |
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.
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.
Add
bitcoin-mineexecutable to test connecting to thebitcoin-nodeprocess over a unix socket and callinginterface::Miningmethods.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-nodeprocess 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.