Skip to content

Commit

Permalink
Expose metrics of on-demand relay chain headers sync from with-parach…
Browse files Browse the repository at this point in the history
…ain complex relays (paritytech#1737)

* expose metrics of on-demand relay chain headers sync from with-parachain complex relays

* spelling

* remove renundant arg
  • Loading branch information
svyatonik authored and serban300 committed Apr 9, 2024
1 parent afdcf46 commit ede29bb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,15 @@ where
self.common.right.client.clone(),
self.left_headers_to_right_transaction_params.clone(),
self.common.shared.only_mandatory_headers,
Some(self.common.metrics_params.clone()),
);
let right_relay_to_left_on_demand_headers =
OnDemandHeadersRelay::<<R2L as ParachainToRelayHeadersCliBridge>::RelayFinality>::new(
self.right_relay.clone(),
self.common.left.client.clone(),
self.right_headers_to_left_transaction_params.clone(),
self.common.shared.only_mandatory_headers,
Some(self.common.metrics_params.clone()),
);

let left_to_right_on_demand_parachains = OnDemandParachainsRelay::<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,15 @@ where
self.common.right.client.clone(),
self.left_headers_to_right_transaction_params.clone(),
self.common.shared.only_mandatory_headers,
None,
);
let right_relay_to_left_on_demand_headers =
OnDemandHeadersRelay::<<R2L as ParachainToRelayHeadersCliBridge>::RelayFinality>::new(
self.right_relay.clone(),
self.common.left.client.clone(),
self.right_headers_to_left_transaction_params.clone(),
self.common.shared.only_mandatory_headers,
Some(self.common.metrics_params.clone()),
);
let right_to_left_on_demand_parachains = OnDemandParachainsRelay::<
<R2L as ParachainToRelayHeadersCliBridge>::ParachainFinality,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,15 @@ where
self.common.right.client.clone(),
self.left_to_right_transaction_params.clone(),
self.common.shared.only_mandatory_headers,
None,
);
let right_to_left_on_demand_headers =
OnDemandHeadersRelay::<<R2L as RelayToRelayHeadersCliBridge>::Finality>::new(
self.common.right.client.clone(),
self.common.left.client.clone(),
self.right_to_left_transaction_params.clone(),
self.common.shared.only_mandatory_headers,
None,
);

Ok((Arc::new(left_to_right_on_demand_headers), Arc::new(right_to_left_on_demand_headers)))
Expand Down
8 changes: 7 additions & 1 deletion bridges/relays/lib-substrate-relay/src/on_demand/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ pub struct OnDemandHeadersRelay<P: SubstrateFinalitySyncPipeline> {

impl<P: SubstrateFinalitySyncPipeline> OnDemandHeadersRelay<P> {
/// Create new on-demand headers relay.
///
/// If `metrics_params` is `Some(_)`, the metrics of the finality relay are registered.
/// Otherwise, all required metrics must be exposed outside of this method.
pub fn new(
source_client: Client<P::SourceChain>,
target_client: Client<P::TargetChain>,
target_transaction_params: TransactionParams<AccountKeyPairOf<P::TargetChain>>,
only_mandatory_headers: bool,
metrics_params: Option<MetricsParams>,
) -> Self
where
AccountIdOf<P::TargetChain>:
Expand All @@ -87,6 +91,7 @@ impl<P: SubstrateFinalitySyncPipeline> OnDemandHeadersRelay<P> {
target_transaction_params,
only_mandatory_headers,
required_header_number,
metrics_params,
)
.await;
});
Expand Down Expand Up @@ -148,6 +153,7 @@ async fn background_task<P: SubstrateFinalitySyncPipeline>(
target_transaction_params: TransactionParams<AccountKeyPairOf<P::TargetChain>>,
only_mandatory_headers: bool,
required_header_number: RequiredHeaderNumberRef<P::SourceChain>,
metrics_params: Option<MetricsParams>,
) where
AccountIdOf<P::TargetChain>: From<<AccountKeyPairOf<P::TargetChain> as sp_core::Pair>::Public>,
{
Expand Down Expand Up @@ -310,7 +316,7 @@ async fn background_task<P: SubstrateFinalitySyncPipeline>(
stall_timeout,
only_mandatory_headers,
},
MetricsParams::disabled(),
metrics_params.clone().unwrap_or_else(|| MetricsParams::disabled()),
futures::future::pending(),
)
.fuse(),
Expand Down

0 comments on commit ede29bb

Please sign in to comment.