async fn execute_and_vote(&mut self, proposed_block: Block<T>) -> anyhow::Result<Vote> {
        trace_code_block!("round_manager::execute_and_vote", {"block", proposed_block.id()});
        let executed_block = self
            .block_store
            .execute_and_insert_block(proposed_block)
            .context("Failed to execute_and_insert the block")?;
        // notify mempool about failed txn
        if let Some(payload) = executed_block.payload() {
            let compute_result = executed_block.compute_result();
            if let Err(e) = self.txn_manager.commit_txns(payload, &compute_result).await {
                error!("Failed to notify mempool of rejected txns: {:?}", e);
            }
        }
        let block = executed_block.block();

        // Checking round_state round again, because multiple proposed_block can now race
        // during async block retrieval
        ensure!(
            block.round() == self.round_state.current_round(),
            "Proposal {} rejected because round is incorrect. RoundState: {}, proposed_block: {}",
            block,
            self.round_state.current_round(),
            block.round(),
        );

        // Short circuit if already voted.
        ensure!(
            self.round_state.vote_sent().is_none(),
            "Already vote on this round {}",
            self.round_state.current_round()
        );

        let parent_block = self
            .block_store
            .get_block(executed_block.parent_id())
            .ok_or_else(|| format_err!("Parent block not found in block store"))?;

        self.wait_before_vote_if_needed(block.timestamp_usecs())
            .await?;

        let vote_proposal = VoteProposal::new(
            AccumulatorExtensionProof::<TransactionAccumulatorHasher>::new(
                parent_block.compute_result().frozen_subtree_roots().clone(),
                parent_block.compute_result().num_leaves(),
                executed_block
                    .compute_result()
                    .transaction_info_hashes()
                    .clone(),
            ),
            block.clone(),
            executed_block.compute_result().epoch_state().clone(),
        );

        let vote = self
            .safety_rules
            .construct_and_sign_vote(&vote_proposal)
            .with_context(|| format!("{}Rejected{} {}", Fg(Red), Fg(Reset), block))?;

        let consensus_state = self.safety_rules.consensus_state()?;
        counters::LAST_VOTE_ROUND.set(consensus_state.last_voted_round() as i64);
        self.storage
            .save_vote(&vote)
            .context("Fail to persist last vote")?;

        Ok(vote)
    }
/// The function generates a VoteMsg for a given proposed_block:
/// * first execute the block and add it to the block store
/// * then verify the voting rules
/// * save the updated state to consensus DB
/// * return a VoteMsg with the LedgerInfo to be committed in case the vote gathers QC.
///
/// This function assumes that it might be called from different tasks concurrently.
The function generates a VoteMsg for a given proposed_block:
first execute the block and add it to the block store
then verify the voting rules
save the updated state to consensus DB
return a VoteMsg with the LedgerInfo to be committed in case the vote gathers QC.

This function assumes that it might be called from different tasks concurrently.
The function generates a VoteMsg for a given proposed_block : first execute the block and add it to the block store then verify the voting rules save the updated state to consensus DB return a VoteMsg with the LedgerInfo to be committed in case the vote gathers QC . This function assumes that it might be called from different tasks concurrently .
async fn execute_and_vote(&mut self, proposed_block: Block<T>) -> anyhow::Result<Vote> {
        trace_code_block!("round_manager::execute_and_vote", {"block", proposed_block.id()});
        let executed_block = self
            .block_store
            .execute_and_insert_block(proposed_block)
            .context("Failed to execute_and_insert the block")?;
        // notify mempool about failed txn
        if let Some(payload) = executed_block.payload() {
            let compute_result = executed_block.compute_result();
            if let Err(e) = self.txn_manager.commit_txns(payload, &compute_result).await {
                error!("Failed to notify mempool of rejected txns: {:?}", e);
            }
        }
        let block = executed_block.block();
        // Checking round_state round again, because multiple proposed_block can now race
        // during async block retrieval
        ensure!(
            block.round() == self.round_state.current_round(),
            "Proposal {} rejected because round is incorrect. RoundState: {}, proposed_block: {}",
            block,
            self.round_state.current_round(),
            block.round(),
        );
        // Short circuit if already voted.
        ensure!(
            self.round_state.vote_sent().is_none(),
            "Already vote on this round {}",
            self.round_state.current_round()
        );
        let parent_block = self
            .block_store
            .get_block(executed_block.parent_id())
            .ok_or_else(|| format_err!("Parent block not found in block store"))?;
        self.wait_before_vote_if_needed(block.timestamp_usecs())
            .await?;
        let vote_proposal = VoteProposal::new(
            AccumulatorExtensionProof::<TransactionAccumulatorHasher>::new(
                parent_block.compute_result().frozen_subtree_roots().clone(),
                parent_block.compute_result().num_leaves(),
                executed_block
                    .compute_result()
                    .transaction_info_hashes()
                    .clone(),
            ),
            block.clone(),
            executed_block.compute_result().epoch_state().clone(),
        );
        let vote = self
            .safety_rules
            .construct_and_sign_vote(&vote_proposal)
            .with_context(|| format!("{}Rejected{} {}", Fg(Red), Fg(Reset), block))?;
        let consensus_state = self.safety_rules.consensus_state()?;
        counters::LAST_VOTE_ROUND.set(consensus_state.last_voted_round() as i64);
        self.storage
            .save_vote(&vote)
            .context("Fail to persist last vote")?;
        Ok(vote)
    }
async fn execute_and_vote ( & mut self , proposed_block : Block < T > ) -> anyhow :: Result < Vote > { trace_code_block ! ( " " { " " proposed_block id ( ) } ) ; let executed_block = self . block_store . execute_and_insert_block ( proposed_block ) . context ( " " ) ? ; // notify mempool about failed txn if let Some ( payload ) = executed_block . payload ( ) { let compute_result = executed_block . compute_result ( ) ; if let Err ( e ) = self . txn_manager . commit_txns ( payload , & compute_result ) . await { error ! ( " " e ) ; } } let block = executed_block . block ( ) ; // Checking round_state round again, because multiple proposed_block can now race // during async block retrieval ensure ! ( block round ( ) self round_state current_round ( ) " " block self round_state current_round ( ) block round ( ) ) ; // Short circuit if already voted. ensure ! ( self round_state vote_sent ( ) is_none ( ) " " self round_state current_round ( ) ) ; let parent_block = self . block_store . get_block ( executed_block . parent_id ( ) ) . ok_or_else ( | | format_err ! ( " " ) ) ? ; self . wait_before_vote_if_needed ( block . timestamp_usecs ( ) ) . await ? ; let vote_proposal = VoteProposal :: new ( AccumulatorExtensionProof :: < TransactionAccumulatorHasher > :: new ( parent_block . compute_result ( ) . frozen_subtree_roots ( ) . clone ( ) , parent_block . compute_result ( ) . num_leaves ( ) , executed_block . compute_result ( ) . transaction_info_hashes ( ) . clone ( ) , ) , block . clone ( ) , executed_block . compute_result ( ) . epoch_state ( ) . clone ( ) , ) ; let vote = self . safety_rules . construct_and_sign_vote ( & vote_proposal ) . with_context ( | | format ! ( " " Fg ( Red ) Fg ( Reset ) block ) ) ? ; let consensus_state = self . safety_rules . consensus_state ( ) ? ; counters :: LAST_VOTE_ROUND . set ( consensus_state . last_voted_round ( ) as i64 ) ; self . storage . save_vote ( & vote ) . context ( " " ) ? ; Ok ( vote ) }
The function generates a VoteMsg for a given proposed_block:
 first execute the block and add it to the block store
 then verify the voting rules
 save the updated state to consensus DB
 return a VoteMsg with the LedgerInfo to be committed in case the vote gathers QC.
The function generates a VoteMsg for a given proposed_block : first execute the block and add it to the block store then verify the voting rules save the updated state to consensus DB return a VoteMsg with the LedgerInfo to be committed in case the vote gathers QC .
&mut self
proposed_block
Block<T>
&mut self
proposed_block
Block<T>