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// TODO: change to HeightDiff
30pub const MAX_BLOCK_REORG_HEIGHT: u32 = 1000;
31
32/// Magic numbers used to identify different Zcash networks.
33pub mod magics {
34 use crate::parameters::network::magic::Magic;
35
36 /// The production mainnet.
37 pub const MAINNET: Magic = Magic([0x24, 0xe9, 0x27, 0x64]);
38 /// The testnet.
39 pub const TESTNET: Magic = Magic([0xfa, 0x1a, 0xf9, 0xbf]);
40 /// The regtest, see <https://github.com/zcash/zcash/blob/master/src/chainparams.cpp#L716-L719>
41 pub const REGTEST: Magic = Magic([0xaa, 0xe8, 0x3f, 0x5f]);
42}
43
44/// The block heights at which network upgrades activate.
45pub mod activation_heights {
46 /// Network upgrade activation heights for Testnet.
47 pub mod testnet {
48 use crate::block::Height;
49
50 /// The block height at which `BeforeOverwinter` activates on Testnet.
51 pub const BEFORE_OVERWINTER: Height = Height(1);
52 /// The block height at which `Overwinter` activates on Testnet.
53 pub const OVERWINTER: Height = Height(207_500);
54 /// The block height at which `Sapling` activates on Testnet.
55 pub const SAPLING: Height = Height(280_000);
56 /// The block height at which `Blossom` activates on Testnet.
57 pub const BLOSSOM: Height = Height(584_000);
58 /// The block height at which `Heartwood` activates on Testnet.
59 pub const HEARTWOOD: Height = Height(903_800);
60 /// The block height at which `Canopy` activates on Testnet.
61 pub const CANOPY: Height = Height(1_028_500);
62 /// The block height at which `NU5` activates on Testnet.
63 pub const NU5: Height = Height(1_842_420);
64 /// The block height at which `NU6` activates on Testnet.
65 pub const NU6: Height = Height(2_976_000);
66 /// The block height at which `NU6.1` activates on Testnet.
67 pub const NU6_1: Height = Height(3_536_500);
68 /// The block height at which `NU6.2` activates on Testnet.
69 pub const NU6_2: Height = Height(4_052_000);
70 /// The block height at which `NU6.3` activates on Testnet.
71 pub const NU6_3: Height = Height(4_134_000);
72 }
73
74 /// Network upgrade activation heights for Mainnet.
75 pub mod mainnet {
76 use crate::block::Height;
77
78 /// The block height at which `BeforeOverwinter` activates on Mainnet.
79 pub const BEFORE_OVERWINTER: Height = Height(1);
80 /// The block height at which `Overwinter` activates on Mainnet.
81 pub const OVERWINTER: Height = Height(347_500);
82 /// The block height at which `Sapling` activates on Mainnet.
83 pub const SAPLING: Height = Height(419_200);
84 /// The block height at which `Blossom` activates on Mainnet.
85 pub const BLOSSOM: Height = Height(653_600);
86 /// The block height at which `Heartwood` activates on Mainnet.
87 pub const HEARTWOOD: Height = Height(903_000);
88 /// The block height at which `Canopy` activates on Mainnet.
89 pub const CANOPY: Height = Height(1_046_400);
90 /// The block height at which `NU5` activates on Mainnet.
91 pub const NU5: Height = Height(1_687_104);
92 /// The block height at which `NU6` activates on Mainnet.
93 pub const NU6: Height = Height(2_726_400);
94 /// The block height at which `NU6.1` activates on Mainnet.
95 pub const NU6_1: Height = Height(3_146_400);
96 /// The block height at which `NU6.2` activates on Mainnet.
97 pub const NU6_2: Height = Height(3_364_600);
98 /// The block height at which `NU6.3` activates on Mainnet.
99 pub const NU6_3: Height = Height(3_428_143);
100 }
101}