Skip to content

Commit

Permalink
feat(ecdsa): CON-1197 Add metrics for delivered quadruples and comple…
Browse files Browse the repository at this point in the history
…ted ECDSA contexts
  • Loading branch information
eichhorl committed Jan 16, 2024
1 parent e61d4c4 commit dec4b88
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 21 deletions.
46 changes: 26 additions & 20 deletions rs/execution_environment/src/execution_environment.rs
Expand Up @@ -542,26 +542,32 @@ impl ExecutionEnvironment {
&args.key_id,
) {
Err(err) => Some((Err(err), msg.take_cycles())),
Ok(_) => self
.sign_with_ecdsa(
(**request).clone(),
args.message_hash,
args.derivation_path
.get()
.clone()
.into_iter()
.map(|x| x.into_vec())
.collect(),
args.key_id,
registry_settings.max_ecdsa_queue_size,
&mut state,
rng,
registry_settings.subnet_size,
)
.map_or_else(
|err| Some((Err(err), msg.take_cycles())),
|()| None,
),
Ok(_) => match self.sign_with_ecdsa(
(**request).clone(),
args.message_hash,
args.derivation_path
.get()
.clone()
.into_iter()
.map(|x| x.into_vec())
.collect(),
args.key_id,
registry_settings.max_ecdsa_queue_size,
&mut state,
rng,
registry_settings.subnet_size,
) {
Err(err) => Some((Err(err), msg.take_cycles())),
Ok(()) => {
self.metrics.observe_message_with_label(
&request.method_name,
since.elapsed().as_secs_f64(),
SUBMITTED_OUTCOME_LABEL.into(),
SUCCESS_STATUS_LABEL.into(),
);
None
}
},
}
}
}
Expand Down
17 changes: 16 additions & 1 deletion rs/execution_environment/src/scheduler/scheduler_metrics.rs
Expand Up @@ -6,7 +6,9 @@ use ic_metrics::{
};
use ic_replicated_state::canister_state::system_state::CyclesUseCase;
use ic_types::nominal_cycles::NominalCycles;
use prometheus::{Gauge, GaugeVec, Histogram, IntCounter, IntCounterVec, IntGauge, IntGaugeVec};
use prometheus::{
Gauge, GaugeVec, Histogram, HistogramVec, IntCounter, IntCounterVec, IntGauge, IntGaugeVec,
};

use crate::metrics::{
cycles_histogram, dts_pause_or_abort_histogram, duration_histogram, instructions_histogram,
Expand Down Expand Up @@ -105,6 +107,8 @@ pub(super) struct SchedulerMetrics {
pub(super) canister_aborted_install_code: Histogram,
pub(super) inducted_messages: IntCounterVec,
pub(super) ecdsa_signature_agreements: IntGauge,
pub(super) ecdsa_delivered_quadruples: HistogramVec,
pub(super) ecdsa_completed_contexts: IntCounterVec,
// TODO(EXC-1466): Remove metric once all calls have `call_id` present.
pub(super) stop_canister_calls_without_call_id: IntGauge,
}
Expand Down Expand Up @@ -219,6 +223,17 @@ impl SchedulerMetrics {
"replicated_state_ecdsa_signature_agreements_total",
"Total number of ECDSA signature agreements created",
),
ecdsa_delivered_quadruples: metrics_registry.histogram_vec(
"execution_ecdsa_delivered_quadruples",
"Number of ECDSA quadruples delivered to execution by key ID",
vec![0.0, 1.0, 2.0, 5.0, 10.0, 15.0, 20.0],
&["key_id"],
),
ecdsa_completed_contexts: metrics_registry.int_counter_vec(
"execution_completed_sign_with_ecdsa_contexts_total",
"Total number of completed sign with ECDSA contexts by key ID",
&["key_id"],
),
input_queue_messages: metrics_registry.int_gauge_vec(
"execution_input_queue_messages",
"Count of messages currently enqueued in input queues, by message kind.",
Expand Down
8 changes: 8 additions & 0 deletions rs/execution_environment/src/scheduler/tecdsa.rs
Expand Up @@ -34,12 +34,20 @@ pub(crate) fn update_sign_with_ecdsa_contexts(
let mut nonce = [0u8; 32];
csprng.fill_bytes(&mut nonce);
context.nonce = Some(nonce);
metrics
.ecdsa_completed_contexts
.with_label_values(&[&context.key_id.to_string()])
.inc();
}
}

// Match up to the maximum number of contexts per key ID to delivered quadruples.
let max_ongoing_signatures = registry_settings.quadruples_to_create_in_advance as usize;
for (key_id, quadruple_ids) in ecdsa_quadruple_ids {
metrics
.ecdsa_delivered_quadruples
.with_label_values(&[&key_id.to_string()])
.observe(quadruple_ids.len() as f64);
match_quadruples_by_key_id(
key_id,
quadruple_ids,
Expand Down

0 comments on commit dec4b88

Please sign in to comment.