zebra: Add support for `getblocksubsidy` RPC call
Motivation
Mining pools use the getblocksubsidy
RPC calls.
Mining Pool Usage
s-nomp
calls getblocksubsidy
from this code:
Requirements
https://zcash.github.io/rpc/getblocksubsidy.html
Height argument
- is optional.
- is a number (current zebra functions that have
height
as argument are a string).
Usage
This RPC is called for the next block height to be mined, before that block is created or validated by the node. The expected response is the subsidy amounts. Transaction fees are not included.
This RPC does not need to support founders reward height
s, because all those blocks are mined already.
Design
We need the fixed miner reward and funding stream values for future heights.
Fields:
fundingstreams
: The required amount sent to each funding stream address- the
specification
is a hard-coded value
- the
miner
: the required amount of the miner rewardfoundersreward
:- The required amount sent to a founders rewards address
- always has a fixed value of zero, because the RPC is not called for existing blocks
We can get the funding stream recipient addresses and amounts fromfunding_stream_values()
:
https://github.com/ZcashFoundation/zebra/blob/dc9da24c8b6cee5c05315f0d77bee52613f75fd3/zebra-consensus/src/block/subsidy/funding_streams.rs#L21-L28
We can get the fixed miner reward from zebra_consensus::subsidy
as well.
Error Handling
If the RPC is called for a founders reward block, just return an error.
Testing
- Snapshot the output of the RPC
- Manually compare the
zcashd
andzebrad
RPC output using https://github.com/ZcashFoundation/zebra/blob/main/zebra-utils/zcash-rpc-diff
Follow-Up Work
Testing:
- Test calling the RPC from the mining pool software (in ticket #5934)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (22 by maintainers)
I spoke with Pili and we are going to implement this RPC because some mining pools use it.
It’s difficult to estimate this ticket when there are two very different alternative designs in it.