Skip to content

Commit

Permalink
Always run on-demand headers relay in complex relay (paritytech#975)
Browse files Browse the repository at this point in the history
* always run on-demand headers relay in complex relay

* fix compilation
  • Loading branch information
svyatonik authored and serban300 committed Apr 8, 2024
1 parent c4e53a8 commit b005249
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 281 deletions.
1 change: 0 additions & 1 deletion bridges/relays/bin-substrate/src/cli/relay_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ impl RelayHeaders {
Finality::new(target_client.clone(), target_sign),
source_client,
target_client,
false,
metrics_params,
)
.await
Expand Down
8 changes: 3 additions & 5 deletions bridges/relays/bin-substrate/src/finality_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ use sp_core::Bytes;
use std::{fmt::Debug, marker::PhantomData, time::Duration};

/// Default synchronization loop timeout.
const STALL_TIMEOUT: Duration = Duration::from_secs(120);
pub(crate) const STALL_TIMEOUT: Duration = Duration::from_secs(120);
/// Default limit of recent finality proofs.
///
/// Finality delay of 4096 blocks is unlikely to happen in practice in
/// Substrate+GRANDPA based chains (good to know).
const RECENT_FINALITY_PROOFS_LIMIT: usize = 4096;
pub(crate) const RECENT_FINALITY_PROOFS_LIMIT: usize = 4096;

/// Headers sync pipeline for Substrate <-> Substrate relays.
pub trait SubstrateFinalitySyncPipeline: FinalitySyncPipeline {
Expand Down Expand Up @@ -119,7 +119,6 @@ pub async fn run<SourceChain, TargetChain, P>(
pipeline: P,
source_client: Client<SourceChain>,
target_client: Client<TargetChain>,
is_on_demand_task: bool,
metrics_params: MetricsParams,
) -> anyhow::Result<()>
where
Expand All @@ -142,10 +141,9 @@ where
);

finality_relay::run(
FinalitySource::new(source_client),
FinalitySource::new(source_client, None),
SubstrateFinalityTarget::new(target_client, pipeline),
FinalitySyncParams {
is_on_demand_task,
tick: std::cmp::max(SourceChain::AVERAGE_BLOCK_INTERVAL, TargetChain::AVERAGE_BLOCK_INTERVAL),
recent_finality_proofs_limit: RECENT_FINALITY_PROOFS_LIMIT,
stall_timeout: STALL_TIMEOUT,
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/bin-substrate/src/messages_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ where

async fn require_target_header_on_source(&self, id: TargetHeaderIdOf<P>) {
if let Some(ref target_to_source_headers_relay) = self.target_to_source_headers_relay {
target_to_source_headers_relay.require_finalized_header(id);
target_to_source_headers_relay.require_finalized_header(id).await;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/bin-substrate/src/messages_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ where

async fn require_source_header_on_target(&self, id: SourceHeaderIdOf<P>) {
if let Some(ref source_to_target_headers_relay) = self.source_to_target_headers_relay {
source_to_target_headers_relay.require_finalized_header(id);
source_to_target_headers_relay.require_finalized_header(id).await;
}
}
}
Loading

0 comments on commit b005249

Please sign in to comment.