From 623b5ab0d0737e59850024bd81e0381a5f7fb31a Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Fri, 2 Dec 2022 13:04:32 +0300 Subject: [PATCH] added version guards to RBH<>WBH GRANDPA finality (and complex) relay --- .../rococo_headers_to_bridge_hub_wococo.rs | 23 +++++++++++++++++-- .../wococo_headers_to_bridge_hub_rococo.rs | 23 +++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/relays/bin-substrate/src/chains/rococo_headers_to_bridge_hub_wococo.rs b/relays/bin-substrate/src/chains/rococo_headers_to_bridge_hub_wococo.rs index 2ec13614a34..2fac858336d 100644 --- a/relays/bin-substrate/src/chains/rococo_headers_to_bridge_hub_wococo.rs +++ b/relays/bin-substrate/src/chains/rococo_headers_to_bridge_hub_wococo.rs @@ -17,8 +17,12 @@ //! Rococo-to-Wococo bridge hubs headers sync entrypoint. use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge}; -use substrate_relay_helper::finality::{ - engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline, + +use async_trait::async_trait; +use relay_substrate_client::{AccountKeyPairOf, Client}; +use substrate_relay_helper::{ + finality::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline}, + TransactionParams, }; /// Description of Rococo -> Wococo finalized headers bridge. @@ -32,12 +36,27 @@ substrate_relay_helper::generate_mocked_submit_finality_proof_call_builder!( relay_bridge_hub_wococo_client::runtime::BridgeGrandpaRococoCall::submit_finality_proof ); +#[async_trait] impl SubstrateFinalitySyncPipeline for RococoFinalityToBridgeHubWococo { type SourceChain = relay_rococo_client::Rococo; type TargetChain = relay_bridge_hub_wococo_client::BridgeHubWococo; type FinalityEngine = GrandpaFinalityEngine; type SubmitFinalityProofCallBuilder = RococoFinalityToBridgeHubWococoCallBuilder; + + async fn start_relay_guards( + target_client: &Client, + _transaction_params: &TransactionParams>, + enable_version_guard: bool, + ) -> relay_substrate_client::Result<()> { + if enable_version_guard { + relay_substrate_client::guard::abort_on_spec_version_change( + target_client.clone(), + target_client.simple_runtime_version().await?.0, + ); + } + Ok(()) + } } /// `Rococo` to BridgeHub `Wococo` bridge definition. diff --git a/relays/bin-substrate/src/chains/wococo_headers_to_bridge_hub_rococo.rs b/relays/bin-substrate/src/chains/wococo_headers_to_bridge_hub_rococo.rs index 30d6af00cd3..6089ae7328c 100644 --- a/relays/bin-substrate/src/chains/wococo_headers_to_bridge_hub_rococo.rs +++ b/relays/bin-substrate/src/chains/wococo_headers_to_bridge_hub_rococo.rs @@ -17,8 +17,12 @@ //! Wococo-to-Rococo bridge hubs headers sync entrypoint. use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge}; -use substrate_relay_helper::finality::{ - engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline, + +use async_trait::async_trait; +use relay_substrate_client::{AccountKeyPairOf, Client}; +use substrate_relay_helper::{ + finality::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline}, + TransactionParams, }; /// Description of Wococo -> Rococo finalized headers bridge. @@ -32,12 +36,27 @@ substrate_relay_helper::generate_mocked_submit_finality_proof_call_builder!( relay_bridge_hub_rococo_client::runtime::BridgeWococoGrandpaCall::submit_finality_proof ); +#[async_trait] impl SubstrateFinalitySyncPipeline for WococoFinalityToBridgeHubRococo { type SourceChain = relay_wococo_client::Wococo; type TargetChain = relay_bridge_hub_rococo_client::BridgeHubRococo; type FinalityEngine = GrandpaFinalityEngine; type SubmitFinalityProofCallBuilder = WococoFinalityToBridgeHubRococoCallBuilder; + + async fn start_relay_guards( + target_client: &Client, + _transaction_params: &TransactionParams>, + enable_version_guard: bool, + ) -> relay_substrate_client::Result<()> { + if enable_version_guard { + relay_substrate_client::guard::abort_on_spec_version_change( + target_client.clone(), + target_client.simple_runtime_version().await?.0, + ); + } + Ok(()) + } } /// `Wococo` to BridgeHub `Rococo` bridge definition.