diff --git a/relays/bin-substrate/src/cli/init_bridge.rs b/relays/bin-substrate/src/cli/init_bridge.rs index 7b38d812271..f297a8db6b4 100644 --- a/relays/bin-substrate/src/cli/init_bridge.rs +++ b/relays/bin-substrate/src/cli/init_bridge.rs @@ -19,6 +19,10 @@ use codec::Encode; use crate::{ bridges::{ + kusama_polkadot::{ + kusama_headers_to_bridge_hub_polkadot::KusamaToBridgeHubPolkadotCliBridge, + polkadot_headers_to_bridge_hub_kusama::PolkadotToBridgeHubKusamaCliBridge, + }, rialto_millau::{ millau_headers_to_rialto::MillauToRialtoCliBridge, rialto_headers_to_millau::RialtoToMillauCliBridge, @@ -66,6 +70,8 @@ pub enum InitBridgeName { MillauToRialtoParachain, RococoToBridgeHubWococo, WococoToBridgeHubRococo, + KusamaToBridgeHubPolkadot, + PolkadotToBridgeHubKusama, } #[async_trait] @@ -198,6 +204,34 @@ impl BridgeInitializer for WococoToBridgeHubRococoCliBridge { } } +impl BridgeInitializer for KusamaToBridgeHubPolkadotCliBridge { + type Engine = GrandpaFinalityEngine; + + fn encode_init_bridge( + init_data: >::InitializationData, + ) -> ::Call { + relay_bridge_hub_polkadot_client::runtime::Call::BridgeKusamaGrandpa( + relay_bridge_hub_polkadot_client::runtime::BridgeKusamaGrandpaCall::initialize { + init_data, + }, + ) + } +} + +impl BridgeInitializer for PolkadotToBridgeHubKusamaCliBridge { + type Engine = GrandpaFinalityEngine; + + fn encode_init_bridge( + init_data: >::InitializationData, + ) -> ::Call { + relay_bridge_hub_kusama_client::runtime::Call::BridgePolkadotGrandpa( + relay_bridge_hub_kusama_client::runtime::BridgePolkadotGrandpaCall::initialize { + init_data, + }, + ) + } +} + impl InitBridge { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { @@ -211,6 +245,10 @@ impl InitBridge { RococoToBridgeHubWococoCliBridge::init_bridge(self), InitBridgeName::WococoToBridgeHubRococo => WococoToBridgeHubRococoCliBridge::init_bridge(self), + InitBridgeName::KusamaToBridgeHubPolkadot => + KusamaToBridgeHubPolkadotCliBridge::init_bridge(self), + InitBridgeName::PolkadotToBridgeHubKusama => + PolkadotToBridgeHubKusamaCliBridge::init_bridge(self), } .await } diff --git a/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs b/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs index 5384c8ff9e9..a47283400aa 100644 --- a/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs +++ b/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs @@ -40,6 +40,10 @@ use relay_to_relay::*; use crate::{ bridges::{ + kusama_polkadot::{ + kusama_parachains_to_bridge_hub_polkadot::BridgeHubKusamaToBridgeHubPolkadotCliBridge, + polkadot_parachains_to_bridge_hub_kusama::BridgeHubPolkadotToBridgeHubKusamaCliBridge, + }, rialto_millau::{ millau_headers_to_rialto::MillauToRialtoCliBridge, rialto_headers_to_millau::RialtoToMillauCliBridge, @@ -202,6 +206,10 @@ declare_chain_cli_schema!(Rococo, rococo); declare_chain_cli_schema!(BridgeHubRococo, bridge_hub_rococo); declare_chain_cli_schema!(Wococo, wococo); declare_chain_cli_schema!(BridgeHubWococo, bridge_hub_wococo); +declare_chain_cli_schema!(Kusama, kusama); +declare_chain_cli_schema!(BridgeHubKusama, bridge_hub_kusama); +declare_chain_cli_schema!(Polkadot, polkadot); +declare_chain_cli_schema!(BridgeHubPolkadot, bridge_hub_polkadot); // Means to override signers of different layer transactions. declare_chain_cli_schema!(MillauHeadersToRialto, millau_headers_to_rialto); declare_chain_cli_schema!(MillauHeadersToRialtoParachain, millau_headers_to_rialto_parachain); @@ -217,10 +225,21 @@ declare_chain_cli_schema!( WococoParachainsToBridgeHubRococo, wococo_parachains_to_bridge_hub_rococo ); +declare_chain_cli_schema!(KusamaHeadersToBridgeHubPolkadot, kusama_headers_to_bridge_hub_polkadot); +declare_chain_cli_schema!( + KusamaParachainsToBridgeHubPolkadot, + kusama_parachains_to_bridge_hub_polkadot +); +declare_chain_cli_schema!(PolkadotHeadersToBridgeHubKusama, polkadot_headers_to_bridge_hub_kusama); +declare_chain_cli_schema!( + PolkadotParachainsToBridgeHubKusama, + polkadot_parachains_to_bridge_hub_kusama +); // All supported bridges. declare_relay_to_relay_bridge_schema!(Millau, Rialto); declare_relay_to_parachain_bridge_schema!(Millau, RialtoParachain, Rialto); declare_parachain_to_parachain_bridge_schema!(BridgeHubRococo, Rococo, BridgeHubWococo, Wococo); +declare_parachain_to_parachain_bridge_schema!(BridgeHubKusama, Kusama, BridgeHubPolkadot, Polkadot); /// Base portion of the bidirectional complex relay. /// @@ -463,6 +482,32 @@ impl Full2WayBridge for BridgeHubRococoBridgeHubWococoFull2WayBridge { } } +/// BridgeHubKusama <> BridgeHubPolkadot complex relay. +pub struct BridgeHubKusamaBridgeHubPolkadotFull2WayBridge { + base: ::Base, +} + +#[async_trait] +impl Full2WayBridge for BridgeHubKusamaBridgeHubPolkadotFull2WayBridge { + type Base = ParachainToParachainBridge; + type Left = relay_bridge_hub_kusama_client::BridgeHubKusama; + type Right = relay_bridge_hub_polkadot_client::BridgeHubPolkadot; + type L2R = BridgeHubKusamaToBridgeHubPolkadotCliBridge; + type R2L = BridgeHubPolkadotToBridgeHubKusamaCliBridge; + + fn new(base: Self::Base) -> anyhow::Result { + Ok(Self { base }) + } + + fn base(&self) -> &Self::Base { + &self.base + } + + fn mut_base(&mut self) -> &mut Self::Base { + &mut self.base + } +} + /// Complex headers+messages relay. #[derive(Debug, PartialEq, StructOpt)] pub enum RelayHeadersAndMessages { @@ -472,6 +517,8 @@ pub enum RelayHeadersAndMessages { MillauRialtoParachain(MillauRialtoParachainHeadersAndMessages), /// BridgeHubRococo <> BridgeHubWococo relay. BridgeHubRococoBridgeHubWococo(BridgeHubRococoBridgeHubWococoHeadersAndMessages), + /// BridgeHubKusama <> BridgeHubPolkadot relay. + BridgeHubKusamaBridgeHubPolkadot(BridgeHubKusamaBridgeHubPolkadotHeadersAndMessages), } impl RelayHeadersAndMessages { @@ -488,6 +535,10 @@ impl RelayHeadersAndMessages { BridgeHubRococoBridgeHubWococoFull2WayBridge::new(params.into_bridge().await?)? .run() .await, + RelayHeadersAndMessages::BridgeHubKusamaBridgeHubPolkadot(params) => + BridgeHubKusamaBridgeHubPolkadotFull2WayBridge::new(params.into_bridge().await?)? + .run() + .await, } } }