Просмотр исходного кода

[consensus] pid integral is integral of #leads

mohab metwally 3 лет назад
Родитель
Сommit
4393d2050c
3 измененных файлов с 10 добавлено и 10 удалено
  1. 5 5
      src/consensus/constants.rs
  2. 4 4
      src/consensus/state.rs
  3. 1 1
      src/consensus/validator.rs

+ 5 - 5
src/consensus/constants.rs

@@ -45,13 +45,13 @@ lazy_static! {
     pub static ref  DT: Float10 =  Float10::from_str_native("0.1").unwrap().with_precision(RADIX_BITS).value();
     pub static ref  DT: Float10 =  Float10::from_str_native("0.1").unwrap().with_precision(RADIX_BITS).value();
     pub static ref  TI: Float10 = FLOAT10_ONE.clone();
     pub static ref  TI: Float10 = FLOAT10_ONE.clone();
     pub static ref  TD: Float10 = FLOAT10_ONE.clone();
     pub static ref  TD: Float10 = FLOAT10_ONE.clone();
-    pub static ref  KP: Float10 = Float10::from_str_native("0.4").unwrap().with_precision(RADIX_BITS).value();
-    pub static ref  KI: Float10 = Float10::from_str_native("0.02").unwrap().with_precision(RADIX_BITS).value();
+    pub static ref  KP: Float10 = Float10::from_str_native("0.2").unwrap().with_precision(RADIX_BITS).value();
+    pub static ref  KI: Float10 = Float10::from_str_native("0.05").unwrap().with_precision(RADIX_BITS).value();
     pub static ref  KD: Float10 = FLOAT10_ONE.clone();
     pub static ref  KD: Float10 = FLOAT10_ONE.clone();
     pub static ref PID_OUT_STEP: Float10  = Float10::from_str_native("0.1").unwrap().with_precision(RADIX_BITS).value();
     pub static ref PID_OUT_STEP: Float10  = Float10::from_str_native("0.1").unwrap().with_precision(RADIX_BITS).value();
-    pub static ref MAX_DER: Float10 = Float10::from_str_native("0.3").unwrap().with_precision(RADIX_BITS).value();
-    pub static ref MIN_DER: Float10 = Float10::from_str_native("-0.3").unwrap().with_precision(RADIX_BITS).value();
-    pub static ref MAX_F: Float10 = Float10::from_str_native("0.95").unwrap().with_precision(RADIX_BITS).value();
+    pub static ref MAX_DER: Float10 = Float10::from_str_native("0.1").unwrap().with_precision(RADIX_BITS).value();
+    pub static ref MIN_DER: Float10 = Float10::from_str_native("-0.1").unwrap().with_precision(RADIX_BITS).value();
+    pub static ref MAX_F: Float10 = Float10::from_str_native("0.8").unwrap().with_precision(RADIX_BITS).value();
     pub static ref MIN_F: Float10 = Float10::from_str_native("0.05").unwrap().with_precision(RADIX_BITS).value();
     pub static ref MIN_F: Float10 = Float10::from_str_native("0.05").unwrap().with_precision(RADIX_BITS).value();
 
 
 }
 }

+ 4 - 4
src/consensus/state.rs

@@ -263,7 +263,8 @@ impl ConsensusState {
         // Temporarily, we compete with zero stake
         // Temporarily, we compete with zero stake
         let coin = LeadCoin::new(
         let coin = LeadCoin::new(
             eta,
             eta,
-            constants::LOTTERY_HEAD_START, // TODO: TESTNET: Why is this constant being used?
+            rand::thread_rng().gen_range(0..1000),
+            //constants::LOTTERY_HEAD_START, // TODO: TESTNET: Why is this constant being used?
             slot,
             slot,
             epoch_secrets.secret_keys[0].inner(),
             epoch_secrets.secret_keys[0].inner(),
             epoch_secrets.merkle_roots[0],
             epoch_secrets.merkle_roots[0],
@@ -382,10 +383,10 @@ impl ConsensusState {
     fn f_int(&self) -> Float10 {
     fn f_int(&self) -> Float10 {
         let mut sum = constants::FLOAT10_ZERO.clone();
         let mut sum = constants::FLOAT10_ZERO.clone();
         let lead_history_len = self.leaders_history.len();
         let lead_history_len = self.leaders_history.len();
-        let history_begin_index = if lead_history_len > 10 { lead_history_len - 10 } else { 0 };
+        let history_begin_index = if lead_history_len > 5 { lead_history_len - 5 } else { 0 };
 
 
         for lf in &self.leaders_history[history_begin_index..] {
         for lf in &self.leaders_history[history_begin_index..] {
-            sum += Self::pid_error(Float10::try_from(lf.clone()).unwrap()).abs();
+            sum += Float10::try_from(lf.clone()).unwrap().abs();
         }
         }
         sum
         sum
     }
     }
@@ -408,7 +409,6 @@ impl ConsensusState {
         if f == constants::FLOAT10_ZERO.clone() {
         if f == constants::FLOAT10_ZERO.clone() {
             return constants::MIN_F.clone()
             return constants::MIN_F.clone()
         }
         }
-        info!("win_inv_prob_with_full_stake(): PID clipped f: {}", f);
         f
         f
     }
     }
 
 

+ 1 - 1
src/consensus/validator.rs

@@ -680,7 +680,7 @@ impl ValidatorState {
         // Removing finalized proposals from chain
         // Removing finalized proposals from chain
         self.consensus.slot_checkpoints.drain(..bound);
         self.consensus.slot_checkpoints.drain(..bound);
 
 
-        info!(
+        debug!(
             "consensus: Adding {} finalized slot checkpoints to canonical chain.",
             "consensus: Adding {} finalized slot checkpoints to canonical chain.",
             finalized_slot_checkpoints.len()
             finalized_slot_checkpoints.len()
         );
         );