forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 11
WIP: speculative templates #54
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
This commit adds the simplest stratum v2 message. The remaining messages are introduced in later commits. Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
This allows us to subclass Transport.
Implemented starting from a copy of V2Transport and the V2TransportTester, modifying it to fit Stratum v2 and Noise Protocol requirements. Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com> Co-Authored-By: Fi3
Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
…lass This allows reusing them in other mocked implementations. Also move the implementation (method definitions) to `test/util/net.cpp` to make the header `test/util/net.h` easier to follow.
…o it And also allows gradually providing the data to be returned by `Recv()` and sending and receiving net messages (`CNetMessage`).
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
Co-authored-by: Christopher Coverdale <chris.coverdale24@gmail.com>
The template provider will listen for a Job Declarator client. It can establish a connection and detect various protocol errors. Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com> Co-Authored-By: Fi3
An external program that uses the Mining interface may need quick access to some information in the block template, while it can wait a bit longer for the full raw transaction data. This would be the case for a Stratum v2 Template Provider which needs to send a NewTemplate message (which doesn't include transactions) as quickly as possible.
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
4f58e3f
to
9442af5
Compare
9dc6622
to
72b8f59
Compare
8cf7578
to
a1c1bd9
Compare
fe7af33
to
a79388a
Compare
d0d447d
to
737c02e
Compare
6cf485f
to
b4eb739
Compare
746f691
to
93348c2
Compare
5dc7c03
to
a5b230a
Compare
Closing this for now |
Sjors
pushed a commit
that referenced
this pull request
Aug 12, 2025
efb8ea04e4 Merge bitcoin-core/crc32c-subtree#8: Sync to upstream 4a7a05c48d Merge remote-tracking branch 'google/main' into bitcoin-fork 21fc8ef304 Fix typo (#59) 89f69843a1 Fix misspelled "Proccess" in comment 02e65f4fd3 Bump deps (#56) b9d6e825a1 Fix Windows CI build. (#54) bbbb93ab5d Switch CI to GitHub Actions (#55) d46cd17d70 Add clangd cache directory to .gitignore. git-subtree-dir: src/crc32c git-subtree-split: efb8ea04e4a5b6a18dc4bc1908fd1cb2dcefb585
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After reading @0xB10C's blog post on mining pool behaviour during forks, I felt motivated to implement Stratum v2's future block template functionality.
Well, this is just a very rough sketch which doesn't compile.
There's two relevant protocol messages (for the Template Provider in bitcoin#29432):
Whenever the tip updates, the current working implementation first sends a
NewTemplate
message withfuture_template
set totrue
, immediately followed bySetNewPrevHash
for the new tip.This PR tries to improve upon that for two different scenarios:
So prepare for either out, after we've send out the current work as described above, we send two additional templates. Both have
future_template = true
and both build for the block on top of the last template. The first is empty, the second has all the transactions that didn't fit in the original block.Especially this last bit will require an overhaul of
BlockAssembler::CreateNewBlock
, but it would be a nice selling point for stratum v2.So now the following things can happen:
We receive a block via p2p, this means we didn't* win. The Template Provider needs to look though the template cache and send the connected client(s) a
SetNewPrevHash
message referring to the match.We receive a block via
SubmitSolution
. That means we found the block. The message handling code already finds the matching template. All we need to do is reply to the client with aNewPrevHash
message.For both (1) and (2) we then proceed as normal, creating and sending a template with non-empty block.
* =
actually it's possible that the Job Declarator server reconstructed the block and broadcast it for us, so I need to add detection for this case (maybe by comparing the coinbase merkle path).