diff --git a/polkadot/node/core/parachains-inherent/src/lib.rs b/polkadot/node/core/parachains-inherent/src/lib.rs index 87b4f6f247..b15afb8310 100644 --- a/polkadot/node/core/parachains-inherent/src/lib.rs +++ b/polkadot/node/core/parachains-inherent/src/lib.rs @@ -109,9 +109,9 @@ impl ParachainsInherentDataProvider { impl sp_inherents::InherentDataProvider for ParachainsInherentDataProvider { fn provide_inherent_data( &self, - inherent_data: &mut sp_inherents::InherentData, + dst_inherent_data: &mut sp_inherents::InherentData, ) -> Result<(), sp_inherents::Error> { - inherent_data + dst_inherent_data .put_data(polkadot_primitives::v1::PARACHAINS_INHERENT_IDENTIFIER, &self.inherent_data) } diff --git a/polkadot/node/core/provisioner/src/lib.rs b/polkadot/node/core/provisioner/src/lib.rs index 160e1b5d2c..75244fa3fe 100644 --- a/polkadot/node/core/provisioner/src/lib.rs +++ b/polkadot/node/core/provisioner/src/lib.rs @@ -213,6 +213,7 @@ impl ProvisioningJob { self.backed_candidates.clone(), return_senders, sender, + &self.metrics, ) .await { @@ -254,11 +255,12 @@ async fn send_inherent_data( candidate_receipts: Vec, return_senders: Vec>, from_job: &mut impl SubsystemSender, + metrics: &Metrics, ) -> Result<(), Error> { let backed_candidates = collect_backed_candidates(candidate_receipts, relay_parent, from_job).await?; - let disputes = collect_disputes(from_job).await?; + let disputes = collect_disputes(from_job, metrics).await?; let inherent_data = ProvisionerInherentData { bitfields, backed_candidates, disputes }; @@ -324,6 +326,7 @@ async fn collect_backed_candidates( async fn collect_disputes( sender: &mut impl SubsystemSender, + metrics: &metrics::Metrics, ) -> Result { let (tx, rx) = oneshot::channel(); @@ -385,6 +388,10 @@ async fn collect_disputes( .into_iter() .map(|(s, i, sig)| (DisputeStatement::Invalid(s), i, sig)); + metrics.inc_valid_statements_by(valid_statements.len()); + metrics.inc_invalid_statements_by(invalid_statements.len()); + metrics.inc_dispute_statement_sets_by(1); + DisputeStatementSet { candidate_hash, session: session_index, diff --git a/polkadot/node/core/provisioner/src/metrics.rs b/polkadot/node/core/provisioner/src/metrics.rs index b0e3fd7365..082ea11c5a 100644 --- a/polkadot/node/core/provisioner/src/metrics.rs +++ b/polkadot/node/core/provisioner/src/metrics.rs @@ -15,12 +15,19 @@ // along with Polkadot. If not, see . use polkadot_node_subsystem_util::metrics::{self, prometheus}; +use std::convert::TryInto; #[derive(Clone)] struct MetricsInner { inherent_data_requests: prometheus::CounterVec, request_inherent_data: prometheus::Histogram, provisionable_data: prometheus::Histogram, + + /// The dispute_statement.* metrics trak how many disputes/votes the runtime will have to process. It will count + /// all recent statements meaning every dispute from last sessions: 10 min on Rococo, 60 min on Kusama and + /// 4 hours on Polkadot. The metrics are updated only when the node authors block, so values vary across nodes. + dispute_statement_sets_requested: prometheus::Counter, + dispute_statements_requested: prometheus::CounterVec, } /// Provisioner metrics. @@ -50,6 +57,32 @@ impl Metrics { ) -> Option { self.0.as_ref().map(|metrics| metrics.provisionable_data.start_timer()) } + + pub(crate) fn inc_valid_statements_by(&self, votes: usize) { + if let Some(metrics) = &self.0 { + metrics + .dispute_statements_requested + .with_label_values(&["valid"]) + .inc_by(votes.try_into().unwrap_or(0)); + } + } + + pub(crate) fn inc_invalid_statements_by(&self, votes: usize) { + if let Some(metrics) = &self.0 { + metrics + .dispute_statements_requested + .with_label_values(&["invalid"]) + .inc_by(votes.try_into().unwrap_or(0)); + } + } + + pub(crate) fn inc_dispute_statement_sets_by(&self, disputes: usize) { + if let Some(metrics) = &self.0 { + metrics + .dispute_statement_sets_requested + .inc_by(disputes.try_into().unwrap_or(0)); + } + } } impl metrics::Metrics for Metrics { @@ -79,6 +112,23 @@ impl metrics::Metrics for Metrics { ))?, registry, )?, + dispute_statements_requested: prometheus::register( + prometheus::CounterVec::new( + prometheus::Opts::new( + "parachain_inherent_dispute_statements_requested", + "Number of inherent dispute statements requested.", + ), + &["validity"], + )?, + ®istry, + )?, + dispute_statement_sets_requested: prometheus::register( + prometheus::Counter::new( + "parachain_inherent_dispute_statement_sets_requested", + "Number of inherent DisputeStatementSets requested.", + )?, + registry, + )?, }; Ok(Metrics(Some(metrics))) } diff --git a/polkadot/node/service/src/lib.rs b/polkadot/node/service/src/lib.rs index bc7b1f0d29..224d65641a 100644 --- a/polkadot/node/service/src/lib.rs +++ b/polkadot/node/service/src/lib.rs @@ -1015,6 +1015,7 @@ where create_inherent_data_providers: move |parent, ()| { let client_clone = client_clone.clone(); let overseer_handle = overseer_handle.clone(); + async move { let parachain = polkadot_node_core_parachains_inherent::ParachainsInherentDataProvider::create( &*client_clone,