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

consensus: add missing log targets

aggstam 3 лет назад
Родитель
Сommit
a87a9cc57e

+ 3 - 3
src/consensus/leadcoin.rs

@@ -129,7 +129,7 @@ impl LeadCoin {
             .unwrap();
         // Derive the nonce for coin2
         //let coin2_seed = Self::util_derived_rho(coin1_sk_root, seed);
-        //info!("coin2_seed[{}]: {:?}", slot, coin2_seed);
+        //info!(target: "consensus::leadcoin", "coin2_seed[{}]: {:?}", slot, coin2_seed);
         // Create commitment to coin2
         //let coin2_commitment = Self::commitment(
         //pk,
@@ -307,8 +307,8 @@ impl LeadCoin {
             let mut writer = BufWriter::new(f);
             writer.write(&y_t_str.into_bytes()).unwrap();
         }
-        info!("is_leader(): y = {:?}", y);
-        info!("is_leader(): T = {:?}", target);
+        info!(target: "consensus::leadcoin", "is_leader(): y = {:?}", y);
+        info!(target: "consensus::leadcoin", "is_leader(): T = {:?}", target);
 
         y < target
     }

+ 14 - 14
src/consensus/state.rs

@@ -201,7 +201,7 @@ impl ConsensusState {
     fn generate_slot_checkpoint(&mut self, sigma1: pallas::Base, sigma2: pallas::Base) {
         let slot = self.current_slot();
         let eta = self.get_eta();
-        info!("generate_slot_checkpoint: slot: {:?}, eta: {:?}", slot, eta);
+        info!(target: "consensus::state", "generate_slot_checkpoint: slot: {:?}, eta: {:?}", slot, eta);
         let checkpoint = SlotCheckpoint { slot, eta, sigma1, sigma2 };
         self.slot_checkpoints.push(checkpoint);
     }
@@ -255,8 +255,8 @@ impl ConsensusState {
     }
 
     fn calc_sigmas(f: Float10, total_sigma: Float10) -> (pallas::Base, pallas::Base) {
-        info!("sigmas(): f: {}", f);
-        info!("sigmas(): stake: {:}", total_sigma);
+        info!(target: "consensus::state", "sigmas(): f: {}", f);
+        info!(target: "consensus::state", "sigmas(): stake: {:}", total_sigma);
 
         let one = constants::FLOAT10_ONE.clone();
         let neg_one = constants::FLOAT10_NEG_ONE.clone();
@@ -394,7 +394,7 @@ impl ConsensusState {
         }
         self.leaders_history.push(count);
 
-        info!("extend_leaders_history(): Current leaders history: {:?}", self.leaders_history);
+        info!(target: "consensus::state", "extend_leaders_history(): Current leaders history: {:?}", self.leaders_history);
         let mut count_str: String = count.to_string();
         count_str.push_str(",");
         let f = File::options().append(true).open(constants::LEADER_HISTORY_LOG).unwrap();
@@ -425,13 +425,13 @@ impl ConsensusState {
             k1.clone() * err.clone() +
             k2.clone() * self.err_history[err_len - 1].clone() +
             k3.clone() * self.err_history[err_len - 2].clone();
-        info!("pid::f-1: {:}", self.f_history[f_len - 1].clone());
-        info!("pid::err: {:}", err);
-        info!("pid::err-1: {}", self.err_history[err_len - 1].clone());
-        info!("pid::err-2: {}", self.err_history[err_len - 2].clone());
-        info!("pid::k1: {}", k1.clone());
-        info!("pid::k2: {}", k2.clone());
-        info!("pid::k3: {}", k3.clone());
+        info!(target: "consensus::state", "pid::f-1: {:}", self.f_history[f_len - 1].clone());
+        info!(target: "consensus::state", "pid::err: {:}", err);
+        info!(target: "consensus::state", "pid::err-1: {}", self.err_history[err_len - 1].clone());
+        info!(target: "consensus::state", "pid::err-2: {}", self.err_history[err_len - 2].clone());
+        info!(target: "consensus::state", "pid::k1: {}", k1.clone());
+        info!(target: "consensus::state", "pid::k2: {}", k2.clone());
+        info!(target: "consensus::state", "pid::k3: {}", k3.clone());
         self.err_history.push(err.clone());
         ret
     }
@@ -485,9 +485,9 @@ impl ConsensusState {
         let mut highest_stake_idx = 0;
         let total_stake = self.total_stake();
         for (winning_idx, coin) in competing_coins.iter().enumerate() {
-            info!("is_slot_leader: coin stake: {:?}", coin.value);
-            info!("is_slot_leader: total stake: {}", total_stake);
-            info!("is_slot_leader: relative stake: {}", (coin.value as f64) / total_stake as f64);
+            info!(target: "consensus::state", "is_slot_leader: coin stake: {:?}", coin.value);
+            info!(target: "consensus::state", "is_slot_leader: total stake: {}", total_stake);
+            info!(target: "consensus::state", "is_slot_leader: relative stake: {}", (coin.value as f64) / total_stake as f64);
 
             let first_winning = coin.is_leader(
                 sigma1,

+ 2 - 2
src/consensus/task/proposal.rs

@@ -256,8 +256,8 @@ async fn propose_period(
 
     // Node stores the proposal and broadcast to rest nodes
 
-    info!("consensus: Node is the slot leader: Proposed block: {}", proposal);
-    debug!("consensus: Full proposal: {:?}", proposal);
+    info!(target: "consensus::proposal", "consensus: Node is the slot leader: Proposed block: {}", proposal);
+    debug!(target: "consensus::proposal", "consensus: Full proposal: {:?}", proposal);
     match state
         .write()
         .await

+ 3 - 1
src/consensus/validator.rs

@@ -647,7 +647,9 @@ impl ValidatorState {
                 self.consensus.set_leader_history(index_for_history, slot);
                 return Ok((vec![], vec![]))
             }
-            _ => info!("chain_finalization(): Chain {} can be finalized!", fork_index),
+            _ => {
+                info!(target: "consensus::validator", "chain_finalization(): Chain {} can be finalized!", fork_index)
+            }
         }
         if max_length == 0 {
             return Ok((vec![], vec![]))

+ 1 - 1
src/contract/dao/src/dao_client/exec.rs

@@ -164,7 +164,7 @@ impl DaoExecCall {
             Witness::Base(Value::known(user_data)),
         ];
 
-        debug!("proposal_bulla: {:?}", proposal_bulla);
+        debug!(target: "dao", "proposal_bulla: {:?}", proposal_bulla);
         let public_inputs = vec![
             proposal_bulla,
             coin_0,