chik_sdk_types/
constants.rs1use chik_consensus::consensus_constants::ConsensusConstants;
2use chik_protocol::Bytes32;
3use chik_sha2::Sha256;
4use hex_literal::hex;
5use once_cell::sync::Lazy;
6
7const MAINNET_GENESIS_CHALLENGE: Bytes32 = Bytes32::new(hex!(
8 "ccd5bb71183532bff220ba46c268991a3ff07eb358e8255a65c30a2dce0e5fbb"
9));
10
11const TESTNET11_GENESIS_CHALLENGE: Bytes32 = Bytes32::new(hex!(
12 "37a90eb5185a9c4439a91ddc98bbadce7b4feba060d50116a067de66bf236615"
13));
14
15pub fn default_constants(genesis_challenge: Bytes32, agg_sig_me: Bytes32) -> ConsensusConstants {
19 ConsensusConstants {
20 slot_blocks_target: 32,
21 min_blocks_per_challenge_block: 16,
22 max_sub_slot_blocks: 128,
23 num_sps_sub_slot: 64,
24 sub_slot_iters_starting: 2u64.pow(27),
25 difficulty_constant_factor: 2u128.pow(67),
26 difficulty_starting: 7,
27 difficulty_change_max_factor: 3,
28 sub_epoch_blocks: 384,
29 epoch_blocks: 4608,
30 significant_bits: 8,
31 discriminant_size_bits: 1024,
32 number_zero_bits_plot_filter_v1: 9,
33 number_zero_bits_plot_filter_v2: 9, min_plot_size: 32,
35 max_plot_size: 50,
36 sub_slot_time_target: 600,
37 num_sp_intervals_extra: 3,
38 max_future_time2: 120,
39 number_of_timestamps: 11,
40 genesis_challenge,
41 agg_sig_me_additional_data: agg_sig_me,
42 agg_sig_parent_additional_data: hash(agg_sig_me, 43),
43 agg_sig_puzzle_additional_data: hash(agg_sig_me, 44),
44 agg_sig_amount_additional_data: hash(agg_sig_me, 45),
45 agg_sig_puzzle_amount_additional_data: hash(agg_sig_me, 46),
46 agg_sig_parent_amount_additional_data: hash(agg_sig_me, 47),
47 agg_sig_parent_puzzle_additional_data: hash(agg_sig_me, 48),
48 genesis_pre_farm_pool_puzzle_hash: Bytes32::new(hex!(
49 "d23da14695a188ae5708dd152263c4db883eb27edeb936178d4d988b8f3ce5fc"
50 )),
51 genesis_pre_farm_farmer_puzzle_hash: Bytes32::new(hex!(
52 "3d8765d3a597ec1d99663f6c9816d915b9f68613ac94009884c4addaefcce6af"
53 )),
54 max_vdf_witness_size: 64,
55 mempool_block_buffer: 10,
56 max_coin_amount: u64::MAX,
57 max_block_cost_klvm: 11_000_000_000,
58 cost_per_byte: 12_000,
59 weight_proof_threshold: 2,
60 blocks_cache_size: 4608 + 128 * 4,
61 weight_proof_recent_blocks: 1000,
62 max_block_count_per_requests: 32,
63 max_generator_size: 1_000_000,
64 max_generator_ref_list_size: 512,
65 pool_sub_slot_iters: 37_600_000_000,
66 hard_fork_height: 5_496_000,
67 hard_fork2_height: 0xffff_ffff, plot_filter_128_height: 10_542_000,
69 plot_filter_64_height: 15_592_000,
70 plot_filter_32_height: 20_643_000,
71
72 plot_difficulty_4_height: 0xffff_ffff,
74 plot_difficulty_5_height: 0xffff_ffff,
75 plot_difficulty_6_height: 0xffff_ffff,
76 plot_difficulty_7_height: 0xffff_ffff,
77 plot_difficulty_8_height: 0xffff_ffff,
78 }
79}
80
81pub static MAINNET_CONSTANTS: Lazy<ConsensusConstants> =
84 Lazy::new(|| default_constants(MAINNET_GENESIS_CHALLENGE, MAINNET_GENESIS_CHALLENGE));
85
86pub static TESTNET11_CONSTANTS: Lazy<ConsensusConstants> = Lazy::new(|| ConsensusConstants {
89 sub_slot_iters_starting: 2u64.pow(26),
90 difficulty_constant_factor: 10_052_721_566_054,
91 difficulty_starting: 30,
92 epoch_blocks: 768,
93 min_plot_size: 18,
94 genesis_pre_farm_pool_puzzle_hash: Bytes32::new(hex!(
95 "3ef7c233fc0785f3c0cae5992c1d35e7c955ca37a423571c1607ba392a9d12f7"
96 )),
97 genesis_pre_farm_farmer_puzzle_hash: Bytes32::new(hex!(
98 "08296fc227decd043aee855741444538e4cc9a31772c4d1a9e6242d1e777e42a"
99 )),
100 hard_fork_height: 0,
101 plot_filter_128_height: 6_029_568,
102 plot_filter_64_height: 11_075_328,
103 plot_filter_32_height: 16_121_088,
104 ..default_constants(TESTNET11_GENESIS_CHALLENGE, TESTNET11_GENESIS_CHALLENGE)
105});
106
107fn hash(agg_sig_data: Bytes32, byte: u8) -> Bytes32 {
108 let mut hasher = Sha256::new();
109 hasher.update(agg_sig_data);
110 hasher.update([byte]);
111 hasher.finalize().into()
112}