Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ibalajiarun committed Oct 11, 2024
1 parent f460d05 commit 04a1dc8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 23 deletions.
9 changes: 3 additions & 6 deletions consensus/src/block_storage/block_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,9 @@ impl BlockStore {
self.pending_blocks.clone()
}

pub async fn wait_for_payload(&self, block: &Block) -> anyhow::Result<()> {
tokio::time::timeout(
Duration::from_secs(1),
self.payload_manager.get_transactions(block),
)
.await??;
pub async fn wait_for_payload(&self, block: &Block, deadline: Duration) -> anyhow::Result<()> {
let duration = deadline.saturating_sub(self.time_service.get_current_timestamp());
tokio::time::timeout(duration, self.payload_manager.get_transactions(block)).await??;
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/src/liveness/round_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl RoundState {
NewRoundReason::QCReady
} else {
let prev_round_timeout_reason =
prev_round_timeout_reason.expect("TC must be present for timeout round.");
prev_round_timeout_reason.unwrap_or(RoundTimeoutReason::Unknown);
NewRoundReason::Timeout(prev_round_timeout_reason)
};

Expand Down
6 changes: 2 additions & 4 deletions consensus/src/pending_votes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ impl TwoChainTimeoutVotes {
&mut self.partial_2chain_tc
}

pub(super) fn partial_2chain_tc(&self) -> &TwoChainTimeoutWithPartialSignatures {
&self.partial_2chain_tc
}

fn aggregated_timeout_reason(&self, verifier: &ValidatorVerifier) -> RoundTimeoutReason {
let mut reason_voting_power: HashMap<RoundTimeoutReason, u128> = HashMap::new();
let mut missing_batch_authors: HashMap<usize, u128> = HashMap::new();
Expand All @@ -112,6 +108,8 @@ impl TwoChainTimeoutVotes {
verifier.get_voting_power(author).unwrap_or_default() as u128;
}
RoundTimeoutReason::PayloadUnavailable {
// Since we care only about the variant type, we replace the bitvec
// with a placeholder.
missing_authors: BitVec::with_num_bits(verifier.len() as u16),
}
},
Expand Down
4 changes: 2 additions & 2 deletions consensus/src/quorum_store/batch_proof_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl BatchProofQueue {
}
}

let max_batch_ts_usecs = min_batch_age_usecs
let max_batch_creation_ts_usecs = min_batch_age_usecs
.map(|min_age| aptos_infallible::duration_since_epoch().as_micros() as u64 - min_age);
let mut iters = vec![];
for (_, batches) in self
Expand All @@ -547,7 +547,7 @@ impl BatchProofQueue {

// Ensure that the batch was created at least `min_batch_age_usecs` ago to
// reduce the chance of inline fetches.
if max_batch_ts_usecs
if max_batch_creation_ts_usecs
.is_some_and(|max_create_ts| batch_create_ts_usecs > max_create_ts)
{
return None;
Expand Down
11 changes: 2 additions & 9 deletions consensus/src/quorum_store/tests/proof_manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@ use aptos_consensus_types::{
use aptos_crypto::HashValue;
use aptos_types::{aggregate_signature::AggregateSignature, PeerId};
use futures::channel::oneshot;
use std::{cmp::max, collections::HashSet, time::Duration};
use std::{cmp::max, collections::HashSet};

fn create_proof_manager() -> ProofManager {
let batch_store = batch_store_for_test(5 * 1024 * 1024);
ProofManager::new(
PeerId::random(),
10,
10,
batch_store,
true,
Duration::from_secs(60).as_micros() as u64,
)
ProofManager::new(PeerId::random(), 10, 10, batch_store, true, 1)
}

fn create_proof(author: PeerId, expiration: u64, batch_sequence: u64) -> ProofOfStore {
Expand Down
3 changes: 2 additions & 1 deletion consensus/src/round_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,9 +991,10 @@ impl RoundManager {
.with_label_values(&["missing"])
.inc();
let start_time = Instant::now();
let deadline = self.round_state.current_round_deadline();
let future = async move {
(
block_store.wait_for_payload(&proposal).await,
block_store.wait_for_payload(&proposal, deadline).await,
proposal,
start_time,
)
Expand Down
7 changes: 7 additions & 0 deletions testsuite/generate-format/tests/staged/consensus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,13 @@ RoundTimeoutReason:
Unknown: UNIT
1:
ProposalNotReceived: UNIT
2:
PayloadUnavailable:
STRUCT:
- missing_authors:
TYPENAME: BitVec
3:
NoQC: UNIT
Script:
STRUCT:
- code: BYTES
Expand Down

0 comments on commit 04a1dc8

Please sign in to comment.