Skip to content

Commit

Permalink
vtxn proposal metrics (#12164)
Browse files Browse the repository at this point in the history
  • Loading branch information
zjma committed Feb 29, 2024
1 parent 4078c51 commit 42872bf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
18 changes: 18 additions & 0 deletions consensus/src/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,3 +905,21 @@ pub static EPOCH_MANAGER_ISSUES_DETAILS: Lazy<IntCounterVec> = Lazy::new(|| {
)
.unwrap()
});

pub static PROPOSED_VTXN_COUNT: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
"aptos_proposed_vtxn_count",
"Number of validator transactions proposed",
&["proposer"]
)
.unwrap()
});

pub static PROPOSED_VTXN_BYTES: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
"aptos_proposed_vtxn_bytes",
"The total size in bytes of validator transactions proposed",
&["proposer"]
)
.unwrap()
});
24 changes: 22 additions & 2 deletions consensus/src/round_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{
BlockReader, BlockRetriever, BlockStore,
},
counters,
counters::{PROPOSED_VTXN_BYTES, PROPOSED_VTXN_COUNT},
error::{error_kind, VerifyError},
liveness::{
proposal_generator::ProposalGenerator,
Expand Down Expand Up @@ -678,16 +679,35 @@ impl RoundManager {
(count_acc + 1, size_acc + txn.size_in_bytes())
})
});

let num_validator_txns = num_validator_txns as u64;
let validator_txns_total_bytes = validator_txns_total_bytes as u64;
let vtxn_count_limit = self.vtxn_config.per_block_limit_txn_count();
let vtxn_bytes_limit = self.vtxn_config.per_block_limit_total_bytes();
let author_hex = author.to_hex();
PROPOSED_VTXN_COUNT
.with_label_values(&[&author_hex])
.inc_by(num_validator_txns);
PROPOSED_VTXN_BYTES
.with_label_values(&[&author_hex])
.inc_by(validator_txns_total_bytes);
info!(
vtxn_count_limit = vtxn_count_limit,
vtxn_count_proposed = num_validator_txns,
vtxn_bytes_limit = vtxn_bytes_limit,
vtxn_bytes_proposed = validator_txns_total_bytes,
proposer = author_hex,
"Summarizing proposed validator txns."
);

ensure!(
num_validator_txns <= self.vtxn_config.per_block_limit_txn_count(),
num_validator_txns <= vtxn_count_limit,
"process_proposal failed with per-block vtxn count limit exceeded: limit={}, actual={}",
self.vtxn_config.per_block_limit_txn_count(),
num_validator_txns
);
ensure!(
validator_txns_total_bytes <= self.vtxn_config.per_block_limit_total_bytes(),
validator_txns_total_bytes <= vtxn_bytes_limit,
"process_proposal failed with per-block vtxn bytes limit exceeded: limit={}, actual={}",
self.vtxn_config.per_block_limit_total_bytes(),
validator_txns_total_bytes
Expand Down

0 comments on commit 42872bf

Please sign in to comment.