diff --git a/consensus/src/pipeline/header_processor/pre_pow_validation.rs b/consensus/src/pipeline/header_processor/pre_pow_validation.rs index 45f146f..e20a4df 100644 --- a/consensus/src/pipeline/header_processor/pre_pow_validation.rs +++ b/consensus/src/pipeline/header_processor/pre_pow_validation.rs @@ -50,8 +50,9 @@ impl HeaderProcessor { .calculate_difficulty_bits(ghostdag_data, &daa_window); ctx.mergeset_non_daa = Some(daa_window.mergeset_non_daa); - if header.daa_score <= (self.hf_daa_score + 10) && header.daa_score >= self.hf_daa_score { - // if virtual_state.daa_score < (self.hf_daa_score + 10) || virtual_state.daa_score >= self.hf_daa_score { + if header.daa_score <= (self.hf_daa_score + self.difficulty_window_size as u64) + && header.daa_score >= self.hf_daa_score + { expected_bits = self.genesis.bits; } diff --git a/consensus/src/pipeline/header_processor/processor.rs b/consensus/src/pipeline/header_processor/processor.rs index a9d6e5c..4065003 100644 --- a/consensus/src/pipeline/header_processor/processor.rs +++ b/consensus/src/pipeline/header_processor/processor.rs @@ -127,6 +127,7 @@ pub struct HeaderProcessor { pub(super) skip_proof_of_work: bool, pub(super) max_block_level: BlockLevel, pub(super) hf_daa_score: u64, + pub(super) difficulty_window_size: usize, // DB db: Arc, @@ -217,6 +218,7 @@ impl HeaderProcessor { skip_proof_of_work: params.skip_proof_of_work, max_block_level: params.max_block_level, hf_daa_score: params.hf_daa_score, + difficulty_window_size: params.legacy_difficulty_window_size, } } diff --git a/consensus/src/pipeline/virtual_processor/processor.rs b/consensus/src/pipeline/virtual_processor/processor.rs index 247141c..b4452a4 100644 --- a/consensus/src/pipeline/virtual_processor/processor.rs +++ b/consensus/src/pipeline/virtual_processor/processor.rs @@ -124,6 +124,7 @@ pub struct VirtualStateProcessor { pub(super) mergeset_size_limit: u64, pub(super) pruning_depth: u64, pub(super) hf_daa_score: u64, + pub(super) difficulty_window_size: usize, // Stores pub(super) statuses_store: Arc>, @@ -199,6 +200,7 @@ impl VirtualStateProcessor { mergeset_size_limit: params.mergeset_size_limit, pruning_depth: params.pruning_depth, hf_daa_score: params.hf_daa_score, + difficulty_window_size: params.legacy_difficulty_window_size, db, statuses_store: storage.statuses_store.clone(), @@ -1226,7 +1228,7 @@ impl VirtualStateProcessor { }; // todo: check bits to lower difficulty let mut bits = virtual_state.bits; - if virtual_state.daa_score <= (self.hf_daa_score + 10) + if virtual_state.daa_score <= (self.hf_daa_score + self.difficulty_window_size as u64) && virtual_state.daa_score >= self.hf_daa_score { bits = self.genesis.bits;