Skip to content

Commit

Permalink
[Consensus] Add tracing for proposal receiving (#4160)
Browse files Browse the repository at this point in the history
  • Loading branch information
sitalkedia committed Sep 13, 2022
1 parent 0d36cce commit 23b5f78
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
5 changes: 4 additions & 1 deletion consensus/src/block_storage/tracing.rs
Expand Up @@ -9,7 +9,10 @@ pub struct BlockStage;

impl BlockStage {
pub const SIGNED: &'static str = "signed";
pub const RECEIVED: &'static str = "received";
pub const NETWORK_RECEIVED: &'static str = "network_received";
pub const EPOCH_MANAGER_RECEIVED: &'static str = "epoch_manager_received";
pub const EPOCH_MANAGER_VERIFIED: &'static str = "epoch_manager_verified";
pub const ROUND_MANAGER_RECEIVED: &'static str = "round_manager_received";
pub const SYNCED: &'static str = "synced";
pub const VOTED: &'static str = "voted";
pub const QC_AGGREGATED: &'static str = "qc_aggregated";
Expand Down
14 changes: 14 additions & 0 deletions consensus/src/epoch_manager.rs
@@ -1,6 +1,7 @@
// Copyright (c) Aptos
// SPDX-License-Identifier: Apache-2.0

use crate::block_storage::tracing::{observe_block, BlockStage};
use crate::{
block_storage::BlockStore,
commit_notifier::CommitNotifier,
Expand Down Expand Up @@ -695,6 +696,13 @@ impl EpochManager {
fail_point!("consensus::process::any", |_| {
Err(anyhow::anyhow!("Injected error in process_message"))
});

if let ConsensusMsg::ProposalMsg(proposal) = &consensus_msg {
observe_block(
proposal.proposal().timestamp_usecs(),
BlockStage::EPOCH_MANAGER_RECEIVED,
);
}
// we can't verify signatures from a different epoch
let maybe_unverified_event = self.check_epoch(peer_id, consensus_msg).await?;

Expand Down Expand Up @@ -784,6 +792,12 @@ impl EpochManager {
peer_id: AccountAddress,
event: VerifiedEvent,
) -> anyhow::Result<()> {
if let VerifiedEvent::ProposalMsg(proposal) = &event {
observe_block(
proposal.proposal().timestamp_usecs(),
BlockStage::EPOCH_MANAGER_VERIFIED,
);
}
match event {
buffer_manager_event @ (VerifiedEvent::CommitVote(_)
| VerifiedEvent::CommitDecision(_)) => {
Expand Down
7 changes: 7 additions & 0 deletions consensus/src/network.rs
@@ -1,6 +1,7 @@
// Copyright (c) Aptos
// SPDX-License-Identifier: Apache-2.0

use crate::block_storage::tracing::{observe_block, BlockStage};
use crate::{
counters,
logging::LogEvent,
Expand Down Expand Up @@ -302,6 +303,12 @@ impl NetworkTask {
counters::CONSENSUS_RECEIVED_MSGS
.with_label_values(&[msg.name()])
.inc();
if let ConsensusMsg::ProposalMsg(proposal) = &msg {
observe_block(
proposal.proposal().timestamp_usecs(),
BlockStage::NETWORK_RECEIVED,
);
}
if let Err(e) = self
.consensus_messages_tx
.push((peer_id, discriminant(&msg)), (peer_id, msg))
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/round_manager.rs
Expand Up @@ -297,7 +297,7 @@ impl RoundManager {

observe_block(
proposal_msg.proposal().timestamp_usecs(),
BlockStage::RECEIVED,
BlockStage::ROUND_MANAGER_RECEIVED,
);
info!(
self.new_log(LogEvent::ReceiveProposal)
Expand Down

0 comments on commit 23b5f78

Please sign in to comment.