-
Notifications
You must be signed in to change notification settings - Fork 107
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
feat(rpc): Implement the getblocksubsidy
RPC
#6032
Conversation
The floating-point values are the same as Here is a test of the default height:
And for a future block height:
And for a height beyond the funding streams:
(This far future response is likely to get changed in a future network upgrade. But it doesn't crash or do anything wrong.) |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6032 +/- ##
==========================================
- Coverage 78.22% 78.15% -0.07%
==========================================
Files 312 312
Lines 39036 39439 +403
==========================================
+ Hits 30536 30824 +288
- Misses 8500 8615 +115 |
…quires JSON numbers
455620f
to
7bb583c
Compare
eca49f2
to
e07747c
Compare
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.
I think it looks really good, i also think we could try harder to make the valueZat
field match but i understand it could not worth the effort.
It's a number field, so we need to use I'll see how hard it is if I get time, but I think it might be a low priority, because this code works and contains the same values. (Only the formatting is different.) |
Co-authored-by: Alfredo Garcia <[email protected]>
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.
thanks for the changes.
Motivation
Some mining pools use
getblocksubsidy
to generate their own coinbase transactions.Closes #5302
Specifications
The specification is here:
https://zcash.github.io/rpc/getblocksubsidy.html
And the
zcashd
implementation of the RPC is:https://github.com/zcash/zcash/blob/20996b4eb771efde6bcb57d5aa8749a5705cd493/src/rpc/mining.cpp#L999-L1054
Complex Code or Requirements
This RPC uses the state tip as the default height, but otherwise it is very simple - it just calls the existing subsidy and funding stream calculation functions directly.
Solution
Implement the
getblocksubsidy
RPC:zcashd
We will never be able to match
zcashd
's format exactly, because they manually format their ZEC values, but we useserde_json
, which requiresf64
values and formats them itself.Related changes:
Testing
zcashd
andzebrad
RPC output using https://github.com/ZcashFoundation/zebra/blob/main/zebra-utils/zcash-rpc-diff (see the first comment)Review
This is ready for review, feel free to be very critical, there are parts of it that I don't like either!
Reviewer Checklist
Follow-Up Work
Testing: