diff --git a/consensus/consensus-types/src/proof_of_store.rs b/consensus/consensus-types/src/proof_of_store.rs index 3f06a6cf0f2749..09d43afae4bb2a 100644 --- a/consensus/consensus-types/src/proof_of_store.rs +++ b/consensus/consensus-types/src/proof_of_store.rs @@ -363,7 +363,10 @@ impl ProofOfStore { } let result = validator .verify_multi_signatures(&self.info, &self.multi_signature) - .context("Failed to verify ProofOfStore"); + .context(format!( + "Failed to verify ProofOfStore for batch: {:?}", + self.info + )); if result.is_ok() { cache.insert(self.info.clone(), self.multi_signature.clone()); } diff --git a/consensus/src/consensus_observer/network/observer_message.rs b/consensus/src/consensus_observer/network/observer_message.rs index 7b5dc2c7c60c29..ba77d41d69b27c 100644 --- a/consensus/src/consensus_observer/network/observer_message.rs +++ b/consensus/src/consensus_observer/network/observer_message.rs @@ -15,6 +15,10 @@ use aptos_types::{ ledger_info::LedgerInfoWithSignatures, transaction::SignedTransaction, }; +use rayon::{ + iter::{IntoParallelRefIterator, ParallelIterator}, + prelude::*, +}; use serde::{Deserialize, Serialize}; use std::{ fmt::{Display, Formatter}, @@ -36,17 +40,16 @@ impl ConsensusObserverMessage { blocks: Vec>, ordered_proof: LedgerInfoWithSignatures, ) -> ConsensusObserverDirectSend { - ConsensusObserverDirectSend::OrderedBlock(OrderedBlock { - blocks, - ordered_proof, - }) + let ordered_block = OrderedBlock::new(blocks, ordered_proof); + ConsensusObserverDirectSend::OrderedBlock(ordered_block) } /// Creates and returns a new commit decision message using the given commit decision pub fn new_commit_decision_message( commit_proof: LedgerInfoWithSignatures, ) -> ConsensusObserverDirectSend { - ConsensusObserverDirectSend::CommitDecision(CommitDecision { commit_proof }) + let commit_decision = CommitDecision::new(commit_proof); + ConsensusObserverDirectSend::CommitDecision(commit_decision) } /// Creates and returns a new block payload message using the given block, transactions and limit @@ -54,10 +57,8 @@ impl ConsensusObserverMessage { block: BlockInfo, transaction_payload: BlockTransactionPayload, ) -> ConsensusObserverDirectSend { - ConsensusObserverDirectSend::BlockPayload(BlockPayload { - block, - transaction_payload, - }) + let block_payload = BlockPayload::new(block, transaction_payload); + ConsensusObserverDirectSend::BlockPayload(block_payload) } } @@ -721,19 +722,18 @@ impl BlockPayload { // Create a dummy proof cache to verify the proofs let proof_cache = ProofCache::new(1); - // TODO: parallelize the verification of the proof signatures! - - // Verify each of the proof signatures + // Verify each of the proof signatures (in parallel) + let payload_proofs = self.transaction_payload.payload_proofs(); let validator_verifier = &epoch_state.verifier; - for proof_of_store in &self.transaction_payload.payload_proofs() { - if let Err(error) = proof_of_store.verify(validator_verifier, &proof_cache) { - return Err(Error::InvalidMessageError(format!( - "Failed to verify the proof of store for batch: {:?}, Error: {:?}", - proof_of_store.info(), + payload_proofs + .par_iter() + .try_for_each(|proof| proof.verify(validator_verifier, &proof_cache)) + .map_err(|error| { + Error::InvalidMessageError(format!( + "Failed to verify the payload proof signatures! Error: {:?}", error - ))); - } - } + )) + })?; Ok(()) // All proofs are correctly signed } diff --git a/consensus/src/consensus_observer/observer/payload_store.rs b/consensus/src/consensus_observer/observer/payload_store.rs index fc93dd0d7cdae7..5622b5743925a8 100644 --- a/consensus/src/consensus_observer/observer/payload_store.rs +++ b/consensus/src/consensus_observer/observer/payload_store.rs @@ -213,8 +213,7 @@ impl BlockPayloadStore { } /// Verifies the block payload signatures against the given epoch state. - /// If verification is successful, blocks are marked as verified. Each - /// new verified block is + /// If verification is successful, blocks are marked as verified. pub fn verify_payload_signatures(&mut self, epoch_state: &EpochState) -> Vec { // Get the current epoch let current_epoch = epoch_state.epoch;