@@ -57,21 +57,22 @@ pub mod consensus {
5757 //
5858
5959 /// Minimal size of the difficulty window. Affects the DA algorithm only at the starting period of a new net
60- pub const MIN_DIFFICULTY_WINDOW_LEN : usize = 2 ;
60+ pub const MIN_DIFFICULTY_WINDOW_LEN : usize = 10 ;
6161
6262 /// **Legacy** difficulty adjustment window size corresponding to ~46 minutes with 1 BPS
6363 pub const LEGACY_DIFFICULTY_WINDOW_SIZE : usize = 2641 ;
6464
6565 /// **New** difficulty window duration expressed in time units (seconds).
6666 /// TODO: KIP-0004: 30,000 (500 minutes)
67- pub const NEW_DIFFICULTY_WINDOW_DURATION : u64 = 2000 ;
67+ pub const NEW_DIFFICULTY_WINDOW_DURATION : u64 = 2641 ;
6868
6969 /// The desired interval between samples of the difficulty window (seconds).
7070 /// TODO: KIP-0004: 30 seconds
71- pub const DIFFICULTY_WINDOW_SAMPLE_INTERVAL : u64 = 2 ;
71+ pub const DIFFICULTY_WINDOW_SAMPLE_INTERVAL : u64 = 4 ;
7272
7373 /// Size of the **sampled** difficulty window (independent of BPS)
74- pub const DIFFICULTY_SAMPLED_WINDOW_SIZE : u64 = NEW_DIFFICULTY_WINDOW_DURATION / DIFFICULTY_WINDOW_SAMPLE_INTERVAL ;
74+ pub const DIFFICULTY_SAMPLED_WINDOW_SIZE : u64 =
75+ ( NEW_DIFFICULTY_WINDOW_DURATION + DIFFICULTY_WINDOW_SAMPLE_INTERVAL - 1 ) / DIFFICULTY_WINDOW_SAMPLE_INTERVAL ;
7576
7677 //
7778 // ~~~~~~~~~~~~~~~~~~~ Finality & Pruning ~~~~~~~~~~~~~~~~~~~
@@ -84,6 +85,14 @@ pub mod consensus {
8485 /// TODO: finalize this value (consider 6-24 hours)
8586 pub const NEW_FINALITY_DURATION : u64 = 43_200 ; // 12 hours
8687
88+ /// Merge depth bound duration (in seconds). For 1 BPS networks this equals the legacy depth
89+ /// bound in block units. For higher BPS networks this should be scaled up.
90+ ///
91+ /// This number should be roughly equal to DAA window duration in order to prevent merging
92+ /// low-difficulty side-chains (up to ~2x over DAA duration is still reasonable since creating
93+ /// a mergeable low-difficulty side-chain within this bound requires a significant hashrate fraction)
94+ pub const MERGE_DEPTH_DURATION : u64 = 3600 ;
95+
8796 /// The value of the pruning proof `M` parameter
8897 pub const PRUNING_PROOF_M : u64 = 1000 ;
8998
@@ -105,6 +114,8 @@ pub mod perf {
105114 use kaspa_hashes:: Hash ;
106115 use std:: mem:: size_of;
107116
117+ use super :: consensus:: NETWORK_DELAY_BOUND ;
118+
108119 /// The default target depth for reachability reindexes.
109120 pub const DEFAULT_REINDEX_DEPTH : u64 = 100 ;
110121
@@ -188,17 +199,15 @@ pub mod perf {
188199 }
189200
190201 pub fn approx_direct_header_parents ( consensus_params : & Params ) -> usize {
191- let avg_delay = 2 ;
192- consensus_params. bps ( ) as usize * avg_delay
202+ consensus_params. bps ( ) as usize * NETWORK_DELAY_BOUND as usize
193203 }
194204
195205 pub fn approx_header_parents ( consensus_params : & Params ) -> usize {
196- approx_direct_header_parents ( consensus_params) * 2 // 2x for multi-levels
206+ approx_direct_header_parents ( consensus_params) * 4 // 4x for multi-levels
197207 }
198208
199209 pub fn approx_mergeset_size ( consensus_params : & Params ) -> usize {
200- let avg_delay = 2 ;
201- consensus_params. bps ( ) as usize * avg_delay
210+ consensus_params. bps ( ) as usize * NETWORK_DELAY_BOUND as usize
202211 }
203212}
204213
0 commit comments