Skip to content

Commit 4e6435b

Browse files
committed
[qs] introduce BatchInfoExt for Proofs and Signed infos
1 parent b48e5ee commit 4e6435b

21 files changed

+353
-140
lines changed

consensus/consensus-types/src/common.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use crate::{
66
payload::{OptBatches, OptQuorumStorePayload, PayloadExecutionLimit, TxnAndGasLimits},
7-
proof_of_store::{BatchInfo, ProofCache, ProofOfStore},
7+
proof_of_store::{BatchInfo, BatchInfoExt, ProofCache, ProofOfStore, TBatchInfo},
88
};
99
use anyhow::ensure;
1010
use aptos_crypto::{
@@ -518,13 +518,13 @@ impl Payload {
518518
fn verify_with_cache(
519519
proofs: &[ProofOfStore<BatchInfo>],
520520
validator: &ValidatorVerifier,
521-
proof_cache: &ProofCache<BatchInfo>,
521+
proof_cache: &ProofCache,
522522
) -> anyhow::Result<()> {
523523
let unverified: Vec<_> = proofs
524524
.iter()
525525
.filter(|proof| {
526526
proof_cache
527-
.get(proof.info())
527+
.get(&BatchInfoExt::from(proof.info().clone()))
528528
.is_none_or(|cached_proof| cached_proof != *proof.multi_signature())
529529
})
530530
.collect();
@@ -571,7 +571,7 @@ impl Payload {
571571
pub fn verify(
572572
&self,
573573
verifier: &ValidatorVerifier,
574-
proof_cache: &ProofCache<BatchInfo>,
574+
proof_cache: &ProofCache,
575575
quorum_store_enabled: bool,
576576
) -> anyhow::Result<()> {
577577
match (quorum_store_enabled, self) {
@@ -741,7 +741,7 @@ impl BatchPayload {
741741
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq)]
742742
pub enum PayloadFilter {
743743
DirectMempool(Vec<TransactionSummary>),
744-
InQuorumStore(HashSet<BatchInfo>),
744+
InQuorumStore(HashSet<BatchInfoExt>),
745745
Empty,
746746
}
747747

@@ -772,35 +772,35 @@ impl From<&Vec<&Payload>> for PayloadFilter {
772772
match payload {
773773
Payload::InQuorumStore(proof_with_status) => {
774774
for proof in &proof_with_status.proofs {
775-
exclude_batches.insert(proof.info().clone());
775+
exclude_batches.insert(proof.info().clone().into());
776776
}
777777
},
778778
Payload::InQuorumStoreWithLimit(proof_with_status) => {
779779
for proof in &proof_with_status.proof_with_data.proofs {
780-
exclude_batches.insert(proof.info().clone());
780+
exclude_batches.insert(proof.info().clone().into());
781781
}
782782
},
783783
Payload::QuorumStoreInlineHybrid(inline_batches, proof_with_data, _)
784784
| Payload::QuorumStoreInlineHybridV2(inline_batches, proof_with_data, _) => {
785785
for proof in &proof_with_data.proofs {
786-
exclude_batches.insert(proof.info().clone());
786+
exclude_batches.insert(proof.info().clone().into());
787787
}
788788
for (batch_info, _) in inline_batches {
789-
exclude_batches.insert(batch_info.clone());
789+
exclude_batches.insert(batch_info.clone().into());
790790
}
791791
},
792792
Payload::DirectMempool(_) => {
793793
error!("DirectMempool payload in InQuorumStore filter");
794794
},
795795
Payload::OptQuorumStore(opt_qs_payload) => {
796796
for batch in opt_qs_payload.inline_batches().iter() {
797-
exclude_batches.insert(batch.info().clone());
797+
exclude_batches.insert(batch.info().clone().into());
798798
}
799799
for batch_info in &opt_qs_payload.opt_batches().batch_summary {
800-
exclude_batches.insert(batch_info.clone());
800+
exclude_batches.insert(batch_info.clone().into());
801801
}
802802
for proof in &opt_qs_payload.proof_with_data().batch_summary {
803-
exclude_batches.insert(proof.info().clone());
803+
exclude_batches.insert(proof.info().clone().into());
804804
}
805805
},
806806
}

consensus/consensus-types/src/opt_proposal_msg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl OptProposalMsg {
101101
&self,
102102
sender: Author,
103103
validator: &ValidatorVerifier,
104-
proof_cache: &ProofCache<BatchInfo>,
104+
proof_cache: &ProofCache,
105105
quorum_store_enabled: bool,
106106
) -> Result<()> {
107107
ensure!(

consensus/consensus-types/src/payload.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Aptos Foundation
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use crate::proof_of_store::{BatchInfo, ProofOfStore};
4+
use crate::proof_of_store::{BatchInfo, BatchInfoExt, ProofOfStore};
55
use anyhow::ensure;
66
use aptos_types::{transaction::SignedTransaction, PeerId};
77
use core::fmt;
@@ -15,6 +15,10 @@ pub type OptBatches = BatchPointer<BatchInfo>;
1515

1616
pub type ProofBatches = BatchPointer<ProofOfStore<BatchInfo>>;
1717

18+
pub type OptBatchesExt = BatchPointer<BatchInfoExt>;
19+
20+
pub type ProofBatchesExt = BatchPointer<BatchInfoExt>;
21+
1822
pub trait TDataInfo {
1923
fn num_txns(&self) -> u64;
2024

@@ -290,7 +294,7 @@ pub struct OptQuorumStorePayloadV1 {
290294
}
291295

292296
impl OptQuorumStorePayloadV1 {
293-
pub fn get_all_batch_infos(self) -> Vec<BatchInfo> {
297+
pub fn get_all_batch_infos(self) -> Vec<BatchInfoExt> {
294298
let Self {
295299
inline_batches,
296300
opt_batches,
@@ -303,6 +307,7 @@ impl OptQuorumStorePayloadV1 {
303307
.map(|batch| batch.batch_info)
304308
.chain(opt_batches)
305309
.chain(proofs.into_iter().map(|proof| proof.info().clone()))
310+
.map(|info| info.into())
306311
.collect()
307312
}
308313

0 commit comments

Comments
 (0)