zebra_chain/parameters/constants.rs
1//! Definitions of Zebra chain constants, including:
2//! - slow start interval,
3//! - slow start shift,
4//! - maximum reorg height
5
6use crate::block::Height;
7
8/// An initial period from Genesis to this Height where the block subsidy is gradually incremented. [What is slow-start mining][slow-mining]
9///
10/// [slow-mining]: https://z.cash/support/faq/#what-is-slow-start-mining
11pub const SLOW_START_INTERVAL: Height = Height(20_000);
12
13/// `SlowStartShift()` as described in [protocol specification ยง7.8][7.8]
14///
15/// [7.8]: https://zips.z.cash/protocol/protocol.pdf#subsidies
16///
17/// This calculation is exact, because `SLOW_START_INTERVAL` is divisible by 2.
18pub const SLOW_START_SHIFT: Height = Height(SLOW_START_INTERVAL.0 / 2);
19
20/// The maximum chain reorganisation height.
21///
22/// This threshold determines the maximum length of the best non-finalized
23/// chain. Once the chain grows past this height, Zebra finalizes its oldest
24/// blocks; deeper reorganisations are outside Zebra's rollback window.
25///
26/// This is a local-only node policy; it is not part of consensus. The window is
27/// sized as a defence-in-depth measure against sustained consensus splits.
28///
29/// ZIP 218 keeps this block count unchanged, so it covers about 20.8 hours before NU7 and
30/// about 6.9 hours of 25-second blocks after it.
31//
32// TODO: change to HeightDiff
33pub const MAX_BLOCK_REORG_HEIGHT: u32 = 1000;
34
35/// Magic numbers used to identify different Zcash networks.
36pub mod magics {
37 use crate::parameters::network::magic::Magic;
38
39 /// The production mainnet.
40 pub const MAINNET: Magic = Magic([0x24, 0xe9, 0x27, 0x64]);
41 /// The testnet.
42 pub const TESTNET: Magic = Magic([0xfa, 0x1a, 0xf9, 0xbf]);
43 /// The regtest, see <https://github.com/zcash/zcash/blob/master/src/chainparams.cpp#L716-L719>
44 pub const REGTEST: Magic = Magic([0xaa, 0xe8, 0x3f, 0x5f]);
45}
46
47/// The block heights at which network upgrades activate.
48pub mod activation_heights {
49 /// Network upgrade activation heights for Testnet.
50 pub mod testnet {
51 use crate::block::Height;
52
53 /// The block height at which `BeforeOverwinter` activates on Testnet.
54 pub const BEFORE_OVERWINTER: Height = Height(1);
55 /// The block height at which `Overwinter` activates on Testnet.
56 pub const OVERWINTER: Height = Height(207_500);
57 /// The block height at which `Sapling` activates on Testnet.
58 pub const SAPLING: Height = Height(280_000);
59 /// The block height at which `Blossom` activates on Testnet.
60 pub const BLOSSOM: Height = Height(584_000);
61 /// The block height at which `Heartwood` activates on Testnet.
62 pub const HEARTWOOD: Height = Height(903_800);
63 /// The block height at which `Canopy` activates on Testnet.
64 pub const CANOPY: Height = Height(1_028_500);
65 /// The block height at which `NU5` activates on Testnet.
66 pub const NU5: Height = Height(1_842_420);
67 /// The block height at which `NU6` activates on Testnet.
68 pub const NU6: Height = Height(2_976_000);
69 /// The block height at which `NU6.1` activates on Testnet.
70 pub const NU6_1: Height = Height(3_536_500);
71 /// The block height at which `NU6.2` activates on Testnet.
72 pub const NU6_2: Height = Height(4_052_000);
73 /// The block height at which `NU6.3` activates on Testnet.
74 pub const NU6_3: Height = Height(4_134_000);
75 /// The block height at which `NU7` activates on Testnet, as specified in ZIP 259.
76 pub const NU7: Height = Height(4_465_026);
77 }
78
79 /// Network upgrade activation heights for Mainnet.
80 pub mod mainnet {
81 use crate::block::Height;
82
83 /// The block height at which `BeforeOverwinter` activates on Mainnet.
84 pub const BEFORE_OVERWINTER: Height = Height(1);
85 /// The block height at which `Overwinter` activates on Mainnet.
86 pub const OVERWINTER: Height = Height(347_500);
87 /// The block height at which `Sapling` activates on Mainnet.
88 pub const SAPLING: Height = Height(419_200);
89 /// The block height at which `Blossom` activates on Mainnet.
90 pub const BLOSSOM: Height = Height(653_600);
91 /// The block height at which `Heartwood` activates on Mainnet.
92 pub const HEARTWOOD: Height = Height(903_000);
93 /// The block height at which `Canopy` activates on Mainnet.
94 pub const CANOPY: Height = Height(1_046_400);
95 /// The block height at which `NU5` activates on Mainnet.
96 pub const NU5: Height = Height(1_687_104);
97 /// The block height at which `NU6` activates on Mainnet.
98 pub const NU6: Height = Height(2_726_400);
99 /// The block height at which `NU6.1` activates on Mainnet.
100 pub const NU6_1: Height = Height(3_146_400);
101 /// The block height at which `NU6.2` activates on Mainnet.
102 pub const NU6_2: Height = Height(3_364_600);
103 /// The block height at which `NU6.3` activates on Mainnet.
104 pub const NU6_3: Height = Height(3_428_143);
105 /// The block height at which `NU7` activates on Mainnet.
106 pub const NU7: Height = Height(3_543_405);
107 }
108}