Skip to main content

zebra_chain/parameters/network/subsidy/constants/
mainnet.rs

1//! Mainnet-specific constants for block subsidies.
2
3use lazy_static::lazy_static;
4
5use crate::parameters::{
6    constants::activation_heights,
7    network::{Amount, Height, NonNegative},
8    subsidy::{
9        constants::POST_NU6_FUNDING_STREAM_NUM_BLOCKS, funding_stream_address_period,
10        nu7_funding_stream_end_height, FundingStreamReceiver, FundingStreamRecipient,
11        FundingStreams,
12    },
13    Network, NetworkUpgrade,
14};
15
16/// The start height of post-NU6 funding streams on Mainnet as described in [ZIP-1015](https://zips.z.cash/zip-1015).
17pub(crate) const POST_NU6_FUNDING_STREAM_START_HEIGHT: u32 = 2_726_400;
18
19/// The one-time lockbox disbursement output addresses and amounts expected in the NU6.1 activation block's
20/// coinbase transaction on Mainnet.
21///
22/// See:
23///
24/// - <https://zips.z.cash/zip-0271#one-timelockboxdisbursement>
25/// - <https://zips.z.cash/zip-0214#mainnet-recipients-for-revision-2>
26pub(crate) const NU6_1_LOCKBOX_DISBURSEMENTS: [(&str, Amount<NonNegative>); 10] = [(
27    "t3ev37Q2uL1sfTsiJQJiWJoFzQpDhmnUwYo",
28    EXPECTED_NU6_1_LOCKBOX_DISBURSEMENTS_TOTAL.div_exact(10),
29); 10];
30
31/// The expected total amount of the one-time lockbox disbursement on Mainnet.
32/// See: <https://zips.z.cash/zip-0271#one-timelockboxdisbursement>.
33pub(crate) const EXPECTED_NU6_1_LOCKBOX_DISBURSEMENTS_TOTAL: Amount<NonNegative> =
34    Amount::new_from_zec(78_750);
35
36/// The post-NU6 funding stream height range on Mainnet
37pub(crate) const POST_NU6_FUNDING_STREAM_START_RANGE: std::ops::Range<Height> =
38    Height(POST_NU6_FUNDING_STREAM_START_HEIGHT)
39        ..Height(POST_NU6_FUNDING_STREAM_START_HEIGHT + POST_NU6_FUNDING_STREAM_NUM_BLOCKS);
40
41/// Number of addresses for each funding stream in the Mainnet.
42/// In the spec ([protocol specification §7.10][7.10]) this is defined as: `fs.addressindex(fs.endheight - 1)`
43/// however we know this value beforehand so we prefer to make it a constant instead.
44///
45/// [7.10]: https://zips.z.cash/protocol/protocol.pdf#fundingstreams
46pub(crate) const FUNDING_STREAMS_NUM_ADDRESSES: usize = 48;
47
48/// List of addresses for the ECC funding stream in the Mainnet.
49pub(crate) const FUNDING_STREAM_ECC_ADDRESSES: [&str; FUNDING_STREAMS_NUM_ADDRESSES] = [
50    "t3LmX1cxWPPPqL4TZHx42HU3U5ghbFjRiif",
51    "t3Toxk1vJQ6UjWQ42tUJz2rV2feUWkpbTDs",
52    "t3ZBdBe4iokmsjdhMuwkxEdqMCFN16YxKe6",
53    "t3ZuaJziLM8xZ32rjDUzVjVtyYdDSz8GLWB",
54    "t3bAtYWa4bi8VrtvqySxnbr5uqcG9czQGTZ",
55    "t3dktADfb5Rmxncpe1HS5BRS5Gcj7MZWYBi",
56    "t3hgskquvKKoCtvxw86yN7q8bzwRxNgUZmc",
57    "t3R1VrLzwcxAZzkX4mX3KGbWpNsgtYtMntj",
58    "t3ff6fhemqPMVujD3AQurxRxTdvS1pPSaa2",
59    "t3cEUQFG3KYnFG6qYhPxSNgGi3HDjUPwC3J",
60    "t3WR9F5U4QvUFqqx9zFmwT6xFqduqRRXnaa",
61    "t3PYc1LWngrdUrJJbHkYPCKvJuvJjcm85Ch",
62    "t3bgkjiUeatWNkhxY3cWyLbTxKksAfk561R",
63    "t3Z5rrR8zahxUpZ8itmCKhMSfxiKjUp5Dk5",
64    "t3PU1j7YW3fJ67jUbkGhSRto8qK2qXCUiW3",
65    "t3S3yaT7EwNLaFZCamfsxxKwamQW2aRGEkh",
66    "t3eutXKJ9tEaPSxZpmowhzKhPfJvmtwTEZK",
67    "t3gbTb7brxLdVVghSPSd3ycGxzHbUpukeDm",
68    "t3UCKW2LrHFqPMQFEbZn6FpjqnhAAbfpMYR",
69    "t3NyHsrnYbqaySoQqEQRyTWkjvM2PLkU7Uu",
70    "t3QEFL6acxuZwiXtW3YvV6njDVGjJ1qeaRo",
71    "t3PdBRr2S1XTDzrV8bnZkXF3SJcrzHWe1wj",
72    "t3ZWyRPpWRo23pKxTLtWsnfEKeq9T4XPxKM",
73    "t3he6QytKCTydhpztykFsSsb9PmBT5JBZLi",
74    "t3VWxWDsLb2TURNEP6tA1ZSeQzUmPKFNxRY",
75    "t3NmWLvZkbciNAipauzsFRMxoZGqmtJksbz",
76    "t3cKr4YxVPvPBG1mCvzaoTTdBNokohsRJ8n",
77    "t3T3smGZn6BoSFXWWXa1RaoQdcyaFjMfuYK",
78    "t3gkDUe9Gm4GGpjMk86TiJZqhztBVMiUSSA",
79    "t3eretuBeBXFHe5jAqeSpUS1cpxVh51fAeb",
80    "t3dN8g9zi2UGJdixGe9txeSxeofLS9t3yFQ",
81    "t3S799pq9sYBFwccRecoTJ3SvQXRHPrHqvx",
82    "t3fhYnv1S5dXwau7GED3c1XErzt4n4vDxmf",
83    "t3cmE3vsBc5xfDJKXXZdpydCPSdZqt6AcNi",
84    "t3h5fPdjJVHaH4HwynYDM5BB3J7uQaoUwKi",
85    "t3Ma35c68BgRX8sdLDJ6WR1PCrKiWHG4Da9",
86    "t3LokMKPL1J8rkJZvVpfuH7dLu6oUWqZKQK",
87    "t3WFFGbEbhJWnASZxVLw2iTJBZfJGGX73mM",
88    "t3L8GLEsUn4QHNaRYcX3EGyXmQ8kjpT1zTa",
89    "t3PgfByBhaBSkH8uq4nYJ9ZBX4NhGCJBVYm",
90    "t3WecsqKDhWXD4JAgBVcnaCC2itzyNZhJrv",
91    "t3ZG9cSfopnsMQupKW5v9sTotjcP5P6RTbn",
92    "t3hC1Ywb5zDwUYYV8LwhvF5rZ6m49jxXSG5",
93    "t3VgMqDL15ZcyQDeqBsBW3W6rzfftrWP2yB",
94    "t3LC94Y6BwLoDtBoK2NuewaEbnko1zvR9rm",
95    "t3cWCUZJR3GtALaTcatrrpNJ3MGbMFVLRwQ",
96    "t3YYF4rPLVxDcF9hHFsXyc5Yq1TFfbojCY6",
97    "t3XHAGxRP2FNfhAjxGjxbrQPYtQQjc3RCQD",
98];
99
100/// Number of founder addresses on Mainnet.
101pub(crate) const NUM_FOUNDER_ADDRESSES: usize = 48;
102
103/// List of founder addresses on Mainnet.
104pub(crate) const FOUNDER_ADDRESS_LIST: [&str; NUM_FOUNDER_ADDRESSES] = [
105    "t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd",
106    "t3cL9AucCajm3HXDhb5jBnJK2vapVoXsop3",
107    "t3fqvkzrrNaMcamkQMwAyHRjfDdM2xQvDTR",
108    "t3TgZ9ZT2CTSK44AnUPi6qeNaHa2eC7pUyF",
109    "t3SpkcPQPfuRYHsP5vz3Pv86PgKo5m9KVmx",
110    "t3Xt4oQMRPagwbpQqkgAViQgtST4VoSWR6S",
111    "t3ayBkZ4w6kKXynwoHZFUSSgXRKtogTXNgb",
112    "t3adJBQuaa21u7NxbR8YMzp3km3TbSZ4MGB",
113    "t3K4aLYagSSBySdrfAGGeUd5H9z5Qvz88t2",
114    "t3RYnsc5nhEvKiva3ZPhfRSk7eyh1CrA6Rk",
115    "t3Ut4KUq2ZSMTPNE67pBU5LqYCi2q36KpXQ",
116    "t3ZnCNAvgu6CSyHm1vWtrx3aiN98dSAGpnD",
117    "t3fB9cB3eSYim64BS9xfwAHQUKLgQQroBDG",
118    "t3cwZfKNNj2vXMAHBQeewm6pXhKFdhk18kD",
119    "t3YcoujXfspWy7rbNUsGKxFEWZqNstGpeG4",
120    "t3bLvCLigc6rbNrUTS5NwkgyVrZcZumTRa4",
121    "t3VvHWa7r3oy67YtU4LZKGCWa2J6eGHvShi",
122    "t3eF9X6X2dSo7MCvTjfZEzwWrVzquxRLNeY",
123    "t3esCNwwmcyc8i9qQfyTbYhTqmYXZ9AwK3X",
124    "t3M4jN7hYE2e27yLsuQPPjuVek81WV3VbBj",
125    "t3gGWxdC67CYNoBbPjNvrrWLAWxPqZLxrVY",
126    "t3LTWeoxeWPbmdkUD3NWBquk4WkazhFBmvU",
127    "t3P5KKX97gXYFSaSjJPiruQEX84yF5z3Tjq",
128    "t3f3T3nCWsEpzmD35VK62JgQfFig74dV8C9",
129    "t3Rqonuzz7afkF7156ZA4vi4iimRSEn41hj",
130    "t3fJZ5jYsyxDtvNrWBeoMbvJaQCj4JJgbgX",
131    "t3Pnbg7XjP7FGPBUuz75H65aczphHgkpoJW",
132    "t3WeKQDxCijL5X7rwFem1MTL9ZwVJkUFhpF",
133    "t3Y9FNi26J7UtAUC4moaETLbMo8KS1Be6ME",
134    "t3aNRLLsL2y8xcjPheZZwFy3Pcv7CsTwBec",
135    "t3gQDEavk5VzAAHK8TrQu2BWDLxEiF1unBm",
136    "t3Rbykhx1TUFrgXrmBYrAJe2STxRKFL7G9r",
137    "t3aaW4aTdP7a8d1VTE1Bod2yhbeggHgMajR",
138    "t3YEiAa6uEjXwFL2v5ztU1fn3yKgzMQqNyo",
139    "t3g1yUUwt2PbmDvMDevTCPWUcbDatL2iQGP",
140    "t3dPWnep6YqGPuY1CecgbeZrY9iUwH8Yd4z",
141    "t3QRZXHDPh2hwU46iQs2776kRuuWfwFp4dV",
142    "t3enhACRxi1ZD7e8ePomVGKn7wp7N9fFJ3r",
143    "t3PkLgT71TnF112nSwBToXsD77yNbx2gJJY",
144    "t3LQtHUDoe7ZhhvddRv4vnaoNAhCr2f4oFN",
145    "t3fNcdBUbycvbCtsD2n9q3LuxG7jVPvFB8L",
146    "t3dKojUU2EMjs28nHV84TvkVEUDu1M1FaEx",
147    "t3aKH6NiWN1ofGd8c19rZiqgYpkJ3n679ME",
148    "t3MEXDF9Wsi63KwpPuQdD6by32Mw2bNTbEa",
149    "t3WDhPfik343yNmPTqtkZAoQZeqA83K7Y3f",
150    "t3PSn5TbMMAEw7Eu36DYctFezRzpX1hzf3M",
151    "t3R3Y5vnBLrEn8L6wFjPjBLnxSUQsKnmFpv",
152    "t3Pcm737EsVkGTbhsu2NekKtJeG92mvYyoN",
153];
154
155/// List of addresses for the Zcash Foundation funding stream in the Mainnet.
156pub(crate) const FUNDING_STREAM_ZF_ADDRESSES: [&str; FUNDING_STREAMS_NUM_ADDRESSES] =
157    ["t3dvVE3SQEi7kqNzwrfNePxZ1d4hUyztBA1"; FUNDING_STREAMS_NUM_ADDRESSES];
158
159/// List of addresses for the Major Grants funding stream in the Mainnet.
160pub(crate) const FUNDING_STREAM_MG_ADDRESSES: [&str; FUNDING_STREAMS_NUM_ADDRESSES] =
161    ["t3XyYW8yBFRuMnfvm5KLGFbEVz25kckZXym"; FUNDING_STREAMS_NUM_ADDRESSES];
162
163/// Number of addresses for each post-NU6 funding stream on Mainnet.
164/// In the spec ([protocol specification §7.10][7.10]) this is defined as: `fs.addressindex(fs.endheight - 1)`
165/// however we know this value beforehand so we prefer to make it a constant instead.
166///
167/// [7.10]: https://zips.z.cash/protocol/protocol.pdf#fundingstreams
168pub(crate) const POST_NU6_FUNDING_STREAMS_NUM_ADDRESSES: usize = 12;
169
170/// List of addresses for the Major Grants post-NU6 funding stream on Mainnet administered by the Financial Privacy Fund (FPF).
171pub(crate) const POST_NU6_FUNDING_STREAM_FPF_ADDRESSES: [&str;
172    POST_NU6_FUNDING_STREAMS_NUM_ADDRESSES] =
173    ["t3cFfPt1Bcvgez9ZbMBFWeZsskxTkPzGCow"; POST_NU6_FUNDING_STREAMS_NUM_ADDRESSES];
174
175/// Number of addresses for each post-NU6.1 funding stream on Mainnet.
176/// In the spec ([protocol specification §7.10][7.10]) this is defined as: `fs.addressindex(fs.endheight - 1)`
177/// however we know this value beforehand so we prefer to make it a constant instead.
178///
179/// [7.10]: https://zips.z.cash/protocol/protocol.pdf#fundingstreams
180pub(crate) const POST_NU6_1_FUNDING_STREAMS_NUM_ADDRESSES: usize = 36;
181
182/// ZIP 2008 rotates only periods following the one containing the last pre-NU7 block.
183fn post_nu6_1_funding_stream_fpf_addresses(
184    network: &Network,
185) -> [&'static str; POST_NU6_1_FUNDING_STREAMS_NUM_ADDRESSES] {
186    let mut addresses =
187        ["t3cFfPt1Bcvgez9ZbMBFWeZsskxTkPzGCow"; POST_NU6_1_FUNDING_STREAMS_NUM_ADDRESSES];
188    if let Some(activation) = NetworkUpgrade::Nu7.activation_height(network) {
189        let last_pre_nu7 = activation
190            .previous()
191            .expect("Mainnet NU7 activates after genesis");
192        let first_rotated = usize::try_from(
193            funding_stream_address_period(last_pre_nu7, network)
194                - funding_stream_address_period(activation_heights::mainnet::NU6_1, network)
195                + 1,
196        )
197        .expect("Mainnet NU7 activates after the revision-2 funding stream starts");
198        // If the stream has already expired, there are no remaining addresses to rotate.
199        if let Some(remaining) = addresses.get_mut(first_rotated..) {
200            remaining.fill("t1MkHnkxVjNpNbCrSs3AJ8J7ZSp6NTYiUcG");
201        }
202    }
203    addresses
204}
205
206lazy_static! {
207    /// The funding streams for Mainnet as described in:
208    /// - [protocol specification §7.10.1][7.10.1]
209    /// - [ZIP-1015](https://zips.z.cash/zip-1015)
210    /// - [ZIP-214#funding-streams](https://zips.z.cash/zip-0214#funding-streams)
211    ///
212    /// [7.10.1]: https://zips.z.cash/protocol/protocol.pdf#zip214fundingstreams
213    pub(crate) static ref FUNDING_STREAMS: Vec<FundingStreams> = vec![
214        FundingStreams {
215            height_range: Height(1_046_400)..Height(2_726_400),
216            recipients: [
217                (
218                    FundingStreamReceiver::Ecc,
219                    FundingStreamRecipient::new(7, FUNDING_STREAM_ECC_ADDRESSES),
220                ),
221                (
222                    FundingStreamReceiver::ZcashFoundation,
223                    FundingStreamRecipient::new(5, FUNDING_STREAM_ZF_ADDRESSES),
224                ),
225                (
226                    FundingStreamReceiver::MajorGrants,
227                    FundingStreamRecipient::new(8, FUNDING_STREAM_MG_ADDRESSES),
228                ),
229            ]
230            .into_iter()
231            .collect(),
232        },
233        FundingStreams {
234            height_range: POST_NU6_FUNDING_STREAM_START_RANGE,
235            recipients: [
236                (
237                    FundingStreamReceiver::Deferred,
238                    FundingStreamRecipient::new::<[&str; 0], &str>(12, []),
239                ),
240                (
241                    FundingStreamReceiver::MajorGrants,
242                    FundingStreamRecipient::new(8, POST_NU6_FUNDING_STREAM_FPF_ADDRESSES),
243                ),
244            ]
245            .into_iter()
246            .collect(),
247        },
248
249        FundingStreams {
250            height_range: activation_heights::mainnet::NU6_1
251                ..nu7_funding_stream_end_height(
252                    Height(4_406_400),
253                    NetworkUpgrade::Nu7.activation_height(&Network::Mainnet),
254                ),
255            recipients: [
256                (
257                    FundingStreamReceiver::Deferred,
258                    FundingStreamRecipient::new::<[&str; 0], &str>(12, []),
259                ),
260                (
261                    FundingStreamReceiver::MajorGrants,
262                    FundingStreamRecipient::new(
263                        8,
264                        post_nu6_1_funding_stream_fpf_addresses(&Network::Mainnet),
265                    ),
266                ),
267            ]
268            .into_iter()
269            .collect(),
270        },
271    ];
272
273}
274
275#[cfg(test)]
276mod tests;