Browse Source

fix validation

mohab metwally 3 years ago
parent
commit
571fad54ae
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/consensus/validator.rs

+ 12 - 1
src/consensus/validator.rs

@@ -475,13 +475,18 @@ impl ValidatorState {
         info!(target: "consensus::validator", "receive_proposal(): Leader proof verified successfully!");
         info!(target: "consensus::validator", "receive_proposal(): Leader proof verified successfully!");
 
 
         // Validate proposal public value against coin creation slot checkpoint
         // Validate proposal public value against coin creation slot checkpoint
+        /*
         let checkpoint = self.consensus.get_slot_checkpoint(lf.coin_slot)?;
         let checkpoint = self.consensus.get_slot_checkpoint(lf.coin_slot)?;
         if checkpoint.eta != lf.coin_eta {
         if checkpoint.eta != lf.coin_eta {
             return Err(Error::ProposalDifferentCoinEtaError)
             return Err(Error::ProposalDifferentCoinEtaError)
         }
         }
-        let (mu_y, mu_rho) = LeadCoin::election_seeds_u64(checkpoint.eta, checkpoint.slot);
+        */
+        // TODO: fix
+        let (mu_y, mu_rho) = LeadCoin::election_seeds_u64(self.consensus.get_eta(),
+                                                          self.consensus.current_slot());
         // y
         // y
         let prop_mu_y = lf.public_inputs[constants::PI_MU_Y_INDEX];
         let prop_mu_y = lf.public_inputs[constants::PI_MU_Y_INDEX];
+
         if mu_y != prop_mu_y {
         if mu_y != prop_mu_y {
             error!(
             error!(
                 target: "consensus::validator",
                 target: "consensus::validator",
@@ -490,8 +495,10 @@ impl ValidatorState {
             );
             );
             return Err(Error::ProposalPublicValuesMismatched)
             return Err(Error::ProposalPublicValuesMismatched)
         }
         }
+
         // rho
         // rho
         let prop_mu_rho = lf.public_inputs[constants::PI_MU_RHO_INDEX];
         let prop_mu_rho = lf.public_inputs[constants::PI_MU_RHO_INDEX];
+
         if mu_rho != prop_mu_rho {
         if mu_rho != prop_mu_rho {
             error!(
             error!(
                 target: "consensus::validator",
                 target: "consensus::validator",
@@ -501,6 +508,7 @@ impl ValidatorState {
             return Err(Error::ProposalPublicValuesMismatched)
             return Err(Error::ProposalPublicValuesMismatched)
         }
         }
 
 
+
         // Validate proposal coin sigmas against current slot checkpoint
         // Validate proposal coin sigmas against current slot checkpoint
         let checkpoint = self.consensus.get_slot_checkpoint(current)?;
         let checkpoint = self.consensus.get_slot_checkpoint(current)?;
         // sigma1
         // sigma1
@@ -673,6 +681,9 @@ impl ValidatorState {
             _ => info!("chain_finalization(): Chain {} can be finalized!", fork_index),
             _ => info!("chain_finalization(): Chain {} can be finalized!", fork_index),
 
 
         }
         }
+        if max_length==0 {
+            return Ok((vec![], vec![]))
+        }
 
 
         // Starting finalization
         // Starting finalization
         let mut fork = self.consensus.forks[fork_index as usize].clone();
         let mut fork = self.consensus.forks[fork_index as usize].clone();