Quellcode durchsuchen

consensus: removed redundant leaders_spent_coins

aggstam vor 3 Jahren
Ursprung
Commit
9b013fbc5d

+ 0 - 2
src/consensus/proto/protocol_sync_consensus.rs

@@ -79,14 +79,12 @@ impl ProtocolSyncConsensus {
             let unconfirmed_txs = lock.unconfirmed_txs.clone();
             let slot_checkpoints = lock.consensus.slot_checkpoints.clone();
             let leaders_nullifiers = lock.consensus.leaders_nullifiers.clone();
-            let leaders_spent_coins = lock.consensus.leaders_spent_coins.clone();
             let response = ConsensusResponse {
                 offset,
                 proposals,
                 unconfirmed_txs,
                 slot_checkpoints,
                 leaders_nullifiers,
-                leaders_spent_coins,
             };
             if let Err(e) = self.channel.send(response).await {
                 error!("ProtocolSyncConsensus::handle_receive_request() channel send fail: {}", e);

+ 2 - 7
src/consensus/state.rs

@@ -64,8 +64,6 @@ pub struct ConsensusState {
     pub coins_tree: BridgeTree<MerkleNode, MERKLE_DEPTH>,
     /// Seen nullifiers from proposals
     pub leaders_nullifiers: Vec<pallas::Base>,
-    /// Seen spent coins from proposals
-    pub leaders_spent_coins: Vec<(pallas::Base, pallas::Base)>,
     /// Leaders count history
     pub leaders_history: Vec<u64>,
 }
@@ -91,7 +89,6 @@ impl ConsensusState {
             coins: vec![],
             coins_tree: BridgeTree::<MerkleNode, MERKLE_DEPTH>::new(constants::EPOCH_LENGTH * 100),
             leaders_nullifiers: vec![],
-            leaders_spent_coins: vec![],
             leaders_history: vec![0],
         })
     }
@@ -194,10 +191,9 @@ impl ConsensusState {
             self.generate_slot_checkpoint(sigma1.clone(), sigma2.clone());
             return Ok(false)
         }
+
         let eta = self.get_eta();
-        // At start of epoch, relative slot is 0.
         if self.coins.len() == 0 {
-            //TODO:  DRK coin need to be burned, and consensus coin to be minted.
             self.coins = self.create_coins(eta).await?;
         }
         self.epoch = epoch;
@@ -243,6 +239,7 @@ impl ConsensusState {
 
     /// Generate coins for provided sigmas.
     /// NOTE: The strategy here is having a single competing coin per slot.
+    // TODO: DRK coin need to be burned, and consensus coin to be minted.
     async fn create_coins(&mut self, eta: pallas::Base) -> Result<Vec<LeadCoin>> {
         let slot = self.current_slot();
 
@@ -611,8 +608,6 @@ pub struct ConsensusResponse {
     pub slot_checkpoints: Vec<SlotCheckpoint>,
     /// Seen nullifiers from proposals
     pub leaders_nullifiers: Vec<pallas::Base>,
-    /// Seen spent coins from proposals
-    pub leaders_spent_coins: Vec<(pallas::Base, pallas::Base)>,
 }
 
 impl net::Message for ConsensusResponse {

+ 0 - 1
src/consensus/task/consensus_sync.rs

@@ -61,7 +61,6 @@ pub async fn consensus_sync_task(p2p: P2pPtr, state: ValidatorStatePtr) -> Resul
             lock.unconfirmed_txs = response.unconfirmed_txs.clone();
             lock.consensus.slot_checkpoints = response.slot_checkpoints.clone();
             lock.consensus.leaders_nullifiers = response.leaders_nullifiers.clone();
-            lock.consensus.leaders_spent_coins = response.leaders_spent_coins.clone();
 
             break
         }

+ 1 - 2
src/consensus/validator.rs

@@ -496,9 +496,8 @@ impl ValidatorState {
             }
         };
 
-        // Store proposal coin info
+        // Store proposal coin nullifiers
         self.consensus.leaders_nullifiers.push(prop_sn);
-        self.consensus.leaders_spent_coins.push((prop_cm_x, prop_cm_y));
 
         Ok(())
     }