Skip to main content

zebra_chain/parameters/network/subsidy/
constants.rs

1//! Constants for block subsidies.
2
3pub(crate) mod mainnet;
4pub(crate) mod testnet;
5
6use crate::amount::COIN;
7use crate::block::HeightDiff;
8
9/// The largest block subsidy, used before the first halving.
10///
11/// We use `25 / 2` instead of `12.5`, so that we can calculate the correct value without using floating-point.
12/// This calculation is exact, because COIN is divisible by 2, and the division is done last.
13pub(crate) const MAX_BLOCK_SUBSIDY: u64 = ((25 * COIN) / 2) as u64;
14
15/// Used as a multiplier to get the new halving interval after Blossom.
16///
17/// Calculated as `PRE_BLOSSOM_POW_TARGET_SPACING / POST_BLOSSOM_POW_TARGET_SPACING`
18/// in the Zcash specification.
19pub(crate) const BLOSSOM_POW_TARGET_SPACING_RATIO: u32 = 2;
20
21/// Halving is at about every 4 years, before Blossom block time is 150 seconds.
22///
23/// `(60 * 60 * 24 * 365 * 4) / 150 = 840960`
24pub(crate) const PRE_BLOSSOM_HALVING_INTERVAL: HeightDiff = 840_000;
25
26/// After Blossom the block time is reduced to 75 seconds but halving period should remain around 4 years.
27pub(crate) const POST_BLOSSOM_HALVING_INTERVAL: HeightDiff =
28    PRE_BLOSSOM_HALVING_INTERVAL * (BLOSSOM_POW_TARGET_SPACING_RATIO as HeightDiff);
29
30/// Used as a multiplier to get the new halving interval after NU7.
31///
32/// `NU7PoWTargetSpacingRatio` in [ZIP 218], calculated as
33/// `POST_BLOSSOM_POW_TARGET_SPACING / POST_NU7_POW_TARGET_SPACING`.
34///
35/// [ZIP 218]: https://zips.z.cash/zip-0218
36pub(crate) const NU7_POW_TARGET_SPACING_RATIO: u32 =
37    crate::parameters::NU7_POW_TARGET_SPACING_RATIO;
38
39/// After NU7 the block time is reduced to 25 seconds, so the halving interval is tripled again
40/// to keep the halving period at around 4 years.
41///
42/// `PostNU7HalvingInterval` in [ZIP 218].
43///
44/// [ZIP 218]: https://zips.z.cash/zip-0218
45pub(crate) const POST_NU7_HALVING_INTERVAL: HeightDiff =
46    POST_BLOSSOM_HALVING_INTERVAL * (NU7_POW_TARGET_SPACING_RATIO as HeightDiff);
47
48/// Denominator as described in [protocol specification ยง7.10.1][7.10.1].
49///
50/// [7.10.1]: https://zips.z.cash/protocol/protocol.pdf#zip214fundingstreams
51pub(crate) const FUNDING_STREAM_RECEIVER_DENOMINATOR: u64 = 100;
52
53/// The specification for pre-NU6 funding stream receivers, a URL that links to [ZIP-214].
54///
55/// [ZIP-214]: https://zips.z.cash/zip-0214
56pub(crate) const FUNDING_STREAM_SPECIFICATION: &str = "https://zips.z.cash/zip-0214";
57
58/// The specification for post-NU6 funding stream and lockbox receivers, a URL that links to [ZIP-1015].
59///
60/// [ZIP-1015]: https://zips.z.cash/zip-1015
61pub(crate) const LOCKBOX_SPECIFICATION: &str = "https://zips.z.cash/zip-1015";
62
63/// The number of blocks contained in the post-NU6 funding streams height ranges on Mainnet or Testnet, as specified
64/// in [ZIP-1015](https://zips.z.cash/zip-1015).
65pub(crate) const POST_NU6_FUNDING_STREAM_NUM_BLOCKS: u32 = 420_000;