diff --git a/Cargo.lock b/Cargo.lock index 8f06153198f..de7f8cd3504 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14598,6 +14598,7 @@ dependencies = [ "relay-bridge-hub-wococo-client", "relay-kusama-client", "relay-millau-client", + "relay-polkadot-bulletin-client", "relay-polkadot-client", "relay-rialto-client", "relay-rialto-parachain-client", diff --git a/relays/bin-substrate/Cargo.toml b/relays/bin-substrate/Cargo.toml index 1f74e8dcf9f..aee324d66ee 100644 --- a/relays/bin-substrate/Cargo.toml +++ b/relays/bin-substrate/Cargo.toml @@ -46,6 +46,7 @@ relay-bridge-hub-rococo-client = { path = "../client-bridge-hub-rococo" } relay-bridge-hub-wococo-client = { path = "../client-bridge-hub-wococo" } relay-kusama-client = { path = "../client-kusama" } relay-polkadot-client = { path = "../client-polkadot" } +relay-polkadot-bulletin-client = { path = "../client-polkadot-bulletin" } relay-rococo-client = { path = "../client-rococo" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } diff --git a/relays/bin-substrate/src/bridges/mod.rs b/relays/bin-substrate/src/bridges/mod.rs index 62e69cc0e5f..53fe5e0c192 100644 --- a/relays/bin-substrate/src/bridges/mod.rs +++ b/relays/bin-substrate/src/bridges/mod.rs @@ -17,6 +17,7 @@ //! Declaration of all bridges that the relay is able to serve. pub mod kusama_polkadot; +pub mod polkadot_bulletin; pub mod rialto_millau; pub mod rialto_parachain_millau; pub mod rococo_wococo; diff --git a/relays/bin-substrate/src/bridges/polkadot_bulletin/bridge_hub_polkadot_messages_to_polkadot_bulletin.rs b/relays/bin-substrate/src/bridges/polkadot_bulletin/bridge_hub_polkadot_messages_to_polkadot_bulletin.rs new file mode 100644 index 00000000000..fc83ff63e03 --- /dev/null +++ b/relays/bin-substrate/src/bridges/polkadot_bulletin/bridge_hub_polkadot_messages_to_polkadot_bulletin.rs @@ -0,0 +1,65 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +//! BridgeHubPolkadot-to-PolkadotBulletin messages sync entrypoint. + +use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge}; +use relay_bridge_hub_polkadot_client::BridgeHubPolkadot; +use relay_polkadot_bulletin_client::PolkadotBulletin; +use substrate_relay_helper::{messages::SubstrateMessageLane, UtilityPalletBatchCallBuilder}; + +/// BridgeHubPolkadot-to-PolkadotBulletin messages bridge. +pub struct BridgeHubPolkadotToPolkadotBulletinMessagesCliBridge {} + +impl CliBridgeBase for BridgeHubPolkadotToPolkadotBulletinMessagesCliBridge { + type Source = BridgeHubPolkadot; + type Target = PolkadotBulletin; +} + +impl MessagesCliBridge for BridgeHubPolkadotToPolkadotBulletinMessagesCliBridge { + type MessagesLane = BridgeHubPolkadotMessagesToPolkadotBulletinMessageLane; +} + +substrate_relay_helper::generate_receive_message_proof_call_builder!( + BridgeHubPolkadotMessagesToPolkadotBulletinMessageLane, + BridgeHubPolkadotMessagesToPolkadotBulletinMessageLaneReceiveMessagesProofCallBuilder, + relay_polkadot_bulletin_client::RuntimeCall::BridgePolkadotBridgeHubMessages, + relay_polkadot_bulletin_client::BridgePolkadotBridgeHubMessagesCall::receive_messages_proof +); + +substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!( + BridgeHubPolkadotMessagesToPolkadotBulletinMessageLane, + BridgeHubPolkadotMessagesToPolkadotBulletinMessageLaneReceiveMessagesDeliveryProofCallBuilder, + relay_bridge_hub_polkadot_client::runtime::Call::BridgePolkadotBulletinMessages, + relay_bridge_hub_polkadot_client::runtime::BridgePolkadotBulletinMessagesCall::receive_messages_delivery_proof +); + +/// BridgeHubPolkadot-to-PolkadotBulletin messages lane. +#[derive(Clone, Debug)] +pub struct BridgeHubPolkadotMessagesToPolkadotBulletinMessageLane; + +impl SubstrateMessageLane for BridgeHubPolkadotMessagesToPolkadotBulletinMessageLane { + type SourceChain = BridgeHubPolkadot; + type TargetChain = PolkadotBulletin; + + type ReceiveMessagesProofCallBuilder = + BridgeHubPolkadotMessagesToPolkadotBulletinMessageLaneReceiveMessagesProofCallBuilder; + type ReceiveMessagesDeliveryProofCallBuilder = + BridgeHubPolkadotMessagesToPolkadotBulletinMessageLaneReceiveMessagesDeliveryProofCallBuilder; + + type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder; + type TargetBatchCallBuilder = (); +} diff --git a/relays/bin-substrate/src/bridges/polkadot_bulletin/mod.rs b/relays/bin-substrate/src/bridges/polkadot_bulletin/mod.rs new file mode 100644 index 00000000000..d7c740f601a --- /dev/null +++ b/relays/bin-substrate/src/bridges/polkadot_bulletin/mod.rs @@ -0,0 +1,23 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +//! Declaration of all bridges between Polkadot Bulletin Chain and Polkadot Bridge Hub. + +pub mod bridge_hub_polkadot_messages_to_polkadot_bulletin; +pub mod polkadot_bulletin_headers_to_bridge_hub_polkadot; +pub mod polkadot_bulletin_messages_to_bridge_hub_polkadot; +pub mod polkadot_headers_to_polkadot_bulletin; +pub mod polkadot_parachains_to_polkadot_bulletin; diff --git a/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_bulletin_headers_to_bridge_hub_polkadot.rs b/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_bulletin_headers_to_bridge_hub_polkadot.rs new file mode 100644 index 00000000000..6dddbd273ca --- /dev/null +++ b/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_bulletin_headers_to_bridge_hub_polkadot.rs @@ -0,0 +1,101 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +//! PolkadotBulletin-to-BridgeHubPolkadot headers sync entrypoint. + +use crate::cli::bridge::{ + CliBridgeBase, MessagesCliBridge, RelayToRelayEquivocationDetectionCliBridge, + RelayToRelayHeadersCliBridge, +}; + +use async_trait::async_trait; +use relay_substrate_client::{AccountKeyPairOf, Client}; +use substrate_relay_helper::{ + equivocation::SubstrateEquivocationDetectionPipeline, + finality::SubstrateFinalitySyncPipeline, + finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline}, + TransactionParams, +}; + +/// Description of `PolkadotBulletin` -> `PolkadotBridgeHub` finalized headers bridge. +#[derive(Clone, Debug)] +pub struct PolkadotBulletinFinalityToBridgeHubPolkadot; + +substrate_relay_helper::generate_submit_finality_proof_call_builder!( + PolkadotBulletinFinalityToBridgeHubPolkadot, + SubmitFinalityProofCallBuilder, + relay_bridge_hub_polkadot_client::runtime::Call::BridgePolkadotBulletinGrandpa, + relay_bridge_hub_polkadot_client::runtime::BridgePolkadotBulletinGrandpaCall::submit_finality_proof +); + +substrate_relay_helper::generate_report_equivocation_call_builder!( + PolkadotBulletinFinalityToBridgeHubPolkadot, + ReportEquivocationCallBuilder, + relay_polkadot_bulletin_client::RuntimeCall::Grandpa, + relay_polkadot_bulletin_client::GrandpaCall::report_equivocation +); + +#[async_trait] +impl SubstrateFinalityPipeline for PolkadotBulletinFinalityToBridgeHubPolkadot { + type SourceChain = relay_polkadot_bulletin_client::PolkadotBulletin; + type TargetChain = relay_bridge_hub_polkadot_client::BridgeHubPolkadot; + + type FinalityEngine = GrandpaFinalityEngine; +} + +#[async_trait] +impl SubstrateFinalitySyncPipeline for PolkadotBulletinFinalityToBridgeHubPolkadot { + type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder; + + async fn start_relay_guards( + target_client: &impl 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?.spec_version, + ); + } + Ok(()) + } +} + +#[async_trait] +impl SubstrateEquivocationDetectionPipeline for PolkadotBulletinFinalityToBridgeHubPolkadot { + type ReportEquivocationCallBuilder = ReportEquivocationCallBuilder; +} + +/// `PolkadotBulletin` to BridgeHub `Polkadot` bridge definition. +pub struct PolkadotBulletinToBridgeHubPolkadotCliBridge {} + +impl CliBridgeBase for PolkadotBulletinToBridgeHubPolkadotCliBridge { + type Source = relay_polkadot_bulletin_client::PolkadotBulletin; + type Target = relay_bridge_hub_polkadot_client::BridgeHubPolkadot; +} + +impl RelayToRelayHeadersCliBridge for PolkadotBulletinToBridgeHubPolkadotCliBridge { + type Finality = PolkadotBulletinFinalityToBridgeHubPolkadot; +} + +impl RelayToRelayEquivocationDetectionCliBridge for PolkadotBulletinToBridgeHubPolkadotCliBridge { + type Equivocation = PolkadotBulletinFinalityToBridgeHubPolkadot; +} + +impl MessagesCliBridge for PolkadotBulletinToBridgeHubPolkadotCliBridge { + type MessagesLane = crate::bridges::polkadot_bulletin::polkadot_bulletin_messages_to_bridge_hub_polkadot::PolkadotBulletinMessagesToBridgeHubPolkadotMessageLane; +} diff --git a/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_bulletin_messages_to_bridge_hub_polkadot.rs b/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_bulletin_messages_to_bridge_hub_polkadot.rs new file mode 100644 index 00000000000..9009917eb4f --- /dev/null +++ b/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_bulletin_messages_to_bridge_hub_polkadot.rs @@ -0,0 +1,65 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +//! PolkadotBulletin-to-BridgeHubPolkadot messages sync entrypoint. + +use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge}; +use relay_bridge_hub_polkadot_client::BridgeHubPolkadot; +use relay_polkadot_bulletin_client::PolkadotBulletin; +use substrate_relay_helper::{messages::SubstrateMessageLane, UtilityPalletBatchCallBuilder}; + +/// PolkadotBulletin-to-BridgeHubPolkadot messages bridge. +pub struct PolkadotBulletinToBridgeHubPolkadotMessagesCliBridge {} + +impl CliBridgeBase for PolkadotBulletinToBridgeHubPolkadotMessagesCliBridge { + type Source = PolkadotBulletin; + type Target = BridgeHubPolkadot; +} + +impl MessagesCliBridge for PolkadotBulletinToBridgeHubPolkadotMessagesCliBridge { + type MessagesLane = PolkadotBulletinMessagesToBridgeHubPolkadotMessageLane; +} + +substrate_relay_helper::generate_receive_message_proof_call_builder!( + PolkadotBulletinMessagesToBridgeHubPolkadotMessageLane, + PolkadotBulletinMessagesToBridgeHubPolkadotMessageLaneReceiveMessagesProofCallBuilder, + relay_bridge_hub_polkadot_client::runtime::Call::BridgePolkadotBulletinMessages, + relay_bridge_hub_polkadot_client::runtime::BridgePolkadotBulletinMessagesCall::receive_messages_proof +); + +substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!( + PolkadotBulletinMessagesToBridgeHubPolkadotMessageLane, + PolkadotBulletinMessagesToBridgeHubPolkadotMessageLaneReceiveMessagesDeliveryProofCallBuilder, + relay_polkadot_bulletin_client::RuntimeCall::BridgePolkadotBridgeHubMessages, + relay_polkadot_bulletin_client::BridgePolkadotBridgeHubMessagesCall::receive_messages_delivery_proof +); + +/// PolkadotBulletin-to-BridgeHubPolkadot messages lane. +#[derive(Clone, Debug)] +pub struct PolkadotBulletinMessagesToBridgeHubPolkadotMessageLane; + +impl SubstrateMessageLane for PolkadotBulletinMessagesToBridgeHubPolkadotMessageLane { + type SourceChain = PolkadotBulletin; + type TargetChain = BridgeHubPolkadot; + + type ReceiveMessagesProofCallBuilder = + PolkadotBulletinMessagesToBridgeHubPolkadotMessageLaneReceiveMessagesProofCallBuilder; + type ReceiveMessagesDeliveryProofCallBuilder = + PolkadotBulletinMessagesToBridgeHubPolkadotMessageLaneReceiveMessagesDeliveryProofCallBuilder; + + type SourceBatchCallBuilder = (); + type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder; +} diff --git a/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_headers_to_polkadot_bulletin.rs b/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_headers_to_polkadot_bulletin.rs new file mode 100644 index 00000000000..5af9ce5da7c --- /dev/null +++ b/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_headers_to_polkadot_bulletin.rs @@ -0,0 +1,96 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +//! Polkadot-to-PolkadotBulletin headers sync entrypoint. + +use crate::cli::bridge::{ + CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge, +}; + +use async_trait::async_trait; +use relay_substrate_client::{AccountKeyPairOf, Client}; +use substrate_relay_helper::{ + equivocation::SubstrateEquivocationDetectionPipeline, + finality::SubstrateFinalitySyncPipeline, + finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline}, + TransactionParams, +}; + +/// Description of Polkadot -> `PolkadotBulletin` finalized headers bridge. +#[derive(Clone, Debug)] +pub struct PolkadotFinalityToPolkadotBulletin; + +substrate_relay_helper::generate_submit_finality_proof_call_builder!( + PolkadotFinalityToPolkadotBulletin, + SubmitFinalityProofCallBuilder, + relay_polkadot_bulletin_client::RuntimeCall::BridgePolkadotGrandpa, + relay_polkadot_bulletin_client::BridgePolkadotGrandpaCall::submit_finality_proof +); + +substrate_relay_helper::generate_report_equivocation_call_builder!( + PolkadotFinalityToPolkadotBulletin, + ReportEquivocationCallBuilder, + relay_polkadot_client::RuntimeCall::Grandpa, + relay_polkadot_client::GrandpaCall::report_equivocation +); + +#[async_trait] +impl SubstrateFinalityPipeline for PolkadotFinalityToPolkadotBulletin { + type SourceChain = relay_polkadot_client::Polkadot; + type TargetChain = relay_polkadot_bulletin_client::PolkadotBulletin; + + type FinalityEngine = GrandpaFinalityEngine; +} + +#[async_trait] +impl SubstrateFinalitySyncPipeline for PolkadotFinalityToPolkadotBulletin { + type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder; + + async fn start_relay_guards( + target_client: &impl 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?.spec_version, + ); + } + Ok(()) + } +} + +#[async_trait] +impl SubstrateEquivocationDetectionPipeline for PolkadotFinalityToPolkadotBulletin { + type ReportEquivocationCallBuilder = ReportEquivocationCallBuilder; +} + +/// `Polkadot` to BridgeHub `PolkadotBulletin` bridge definition. +pub struct PolkadotToPolkadotBulletinCliBridge {} + +impl CliBridgeBase for PolkadotToPolkadotBulletinCliBridge { + type Source = relay_polkadot_client::Polkadot; + type Target = relay_polkadot_bulletin_client::PolkadotBulletin; +} + +impl RelayToRelayHeadersCliBridge for PolkadotToPolkadotBulletinCliBridge { + type Finality = PolkadotFinalityToPolkadotBulletin; +} + +impl RelayToRelayEquivocationDetectionCliBridge for PolkadotToPolkadotBulletinCliBridge { + type Equivocation = PolkadotFinalityToPolkadotBulletin; +} diff --git a/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_parachains_to_polkadot_bulletin.rs b/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_parachains_to_polkadot_bulletin.rs new file mode 100644 index 00000000000..74a1cab9a58 --- /dev/null +++ b/relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_parachains_to_polkadot_bulletin.rs @@ -0,0 +1,75 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +//! Polkadot-to-PolkadotBulletin parachains sync entrypoint. + +use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge}; +use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId}; +use relay_substrate_client::{CallOf, HeaderIdOf}; +use substrate_relay_helper::parachains::{ + SubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline, +}; + +/// Polkadot-to-PolkadotBulletin parachain sync description. +#[derive(Clone, Debug)] +pub struct PolkadotToPolkadotBulletin; + +impl SubstrateParachainsPipeline for PolkadotToPolkadotBulletin { + type SourceParachain = relay_bridge_hub_polkadot_client::BridgeHubPolkadot; + type SourceRelayChain = relay_polkadot_client::Polkadot; + type TargetChain = relay_polkadot_bulletin_client::PolkadotBulletin; + + type SubmitParachainHeadsCallBuilder = PolkadotToPolkadotBulletinCallBuilder; +} + +pub struct PolkadotToPolkadotBulletinCallBuilder; +impl SubmitParachainHeadsCallBuilder + for PolkadotToPolkadotBulletinCallBuilder +{ + fn build_submit_parachain_heads_call( + at_relay_block: HeaderIdOf, + parachains: Vec<(ParaId, ParaHash)>, + parachain_heads_proof: ParaHeadsProof, + ) -> CallOf { + relay_polkadot_bulletin_client::RuntimeCall::BridgePolkadotParachains( + relay_polkadot_bulletin_client::BridgePolkadotParachainsCall::submit_parachain_heads { + at_relay_block: (at_relay_block.0, at_relay_block.1), + parachains, + parachain_heads_proof, + }, + ) + } +} + +/// Polkadot-to-PolkadotBulletin parachain sync description for the CLI. +pub struct PolkadotToPolkadotBulletinCliBridge {} + +impl ParachainToRelayHeadersCliBridge for PolkadotToPolkadotBulletinCliBridge { + type SourceRelay = relay_polkadot_client::Polkadot; + type ParachainFinality = PolkadotToPolkadotBulletin; + type RelayFinality = + crate::bridges::polkadot_bulletin::polkadot_headers_to_polkadot_bulletin::PolkadotFinalityToPolkadotBulletin; +} + +impl CliBridgeBase for PolkadotToPolkadotBulletinCliBridge { + type Source = relay_bridge_hub_polkadot_client::BridgeHubPolkadot; + type Target = relay_polkadot_bulletin_client::PolkadotBulletin; +} + +impl MessagesCliBridge for PolkadotToPolkadotBulletinCliBridge { + type MessagesLane = + crate::bridges::polkadot_bulletin::bridge_hub_polkadot_messages_to_polkadot_bulletin::BridgeHubPolkadotMessagesToPolkadotBulletinMessageLane; +} diff --git a/relays/bin-substrate/src/chains/mod.rs b/relays/bin-substrate/src/chains/mod.rs index 8f689af9f44..99057aa5b91 100644 --- a/relays/bin-substrate/src/chains/mod.rs +++ b/relays/bin-substrate/src/chains/mod.rs @@ -19,6 +19,7 @@ mod kusama; mod millau; mod polkadot; +mod polkadot_bulletin; mod rialto; mod rialto_parachain; mod rococo; diff --git a/relays/bin-substrate/src/chains/polkadot_bulletin.rs b/relays/bin-substrate/src/chains/polkadot_bulletin.rs new file mode 100644 index 00000000000..ee7edbd9f42 --- /dev/null +++ b/relays/bin-substrate/src/chains/polkadot_bulletin.rs @@ -0,0 +1,26 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +//! Polkadot + Polkadot parachains specification for CLI. + +use crate::cli::CliChain; +use relay_polkadot_bulletin_client::PolkadotBulletin; +use relay_substrate_client::SimpleRuntimeVersion; + +impl CliChain for PolkadotBulletin { + const RUNTIME_VERSION: Option = + Some(SimpleRuntimeVersion { spec_version: 100, transaction_version: 1 }); +} diff --git a/relays/bin-substrate/src/cli/bridge.rs b/relays/bin-substrate/src/cli/bridge.rs index 88b6fbc5293..6cf2336d961 100644 --- a/relays/bin-substrate/src/cli/bridge.rs +++ b/relays/bin-substrate/src/cli/bridge.rs @@ -35,6 +35,8 @@ pub enum FullBridge { BridgeHubWococoToBridgeHubRococo, BridgeHubKusamaToBridgeHubPolkadot, BridgeHubPolkadotToBridgeHubKusama, + PolkadotBulletinToBridgeHubPolkadot, + BridgeHubPolkadotToPolkadotBulletin, } /// Minimal bridge representation that can be used from the CLI. diff --git a/relays/bin-substrate/src/cli/init_bridge.rs b/relays/bin-substrate/src/cli/init_bridge.rs index 110d5e94f8b..2dea12dba1a 100644 --- a/relays/bin-substrate/src/cli/init_bridge.rs +++ b/relays/bin-substrate/src/cli/init_bridge.rs @@ -23,6 +23,10 @@ use crate::{ kusama_headers_to_bridge_hub_polkadot::KusamaToBridgeHubPolkadotCliBridge, polkadot_headers_to_bridge_hub_kusama::PolkadotToBridgeHubKusamaCliBridge, }, + polkadot_bulletin::{ + polkadot_bulletin_headers_to_bridge_hub_polkadot::PolkadotBulletinToBridgeHubPolkadotCliBridge, + polkadot_headers_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge, + }, rialto_millau::{ millau_headers_to_rialto::MillauToRialtoCliBridge, rialto_headers_to_millau::RialtoToMillauCliBridge, @@ -72,6 +76,8 @@ pub enum InitBridgeName { WococoToBridgeHubRococo, KusamaToBridgeHubPolkadot, PolkadotToBridgeHubKusama, + PolkadotToPolkadotBulletin, + PolkadotBulletinToBridgeHubPolkadot, } #[async_trait] @@ -232,6 +238,32 @@ impl BridgeInitializer for PolkadotToBridgeHubKusamaCliBridge { } } +impl BridgeInitializer for PolkadotToPolkadotBulletinCliBridge { + type Engine = GrandpaFinalityEngine; + + fn encode_init_bridge( + init_data: >::InitializationData, + ) -> ::Call { + relay_polkadot_bulletin_client::RuntimeCall::BridgePolkadotGrandpa( + relay_polkadot_bulletin_client::BridgePolkadotGrandpaCall::initialize { init_data }, + ) + } +} + +impl BridgeInitializer for PolkadotBulletinToBridgeHubPolkadotCliBridge { + type Engine = GrandpaFinalityEngine; + + fn encode_init_bridge( + init_data: >::InitializationData, + ) -> ::Call { + relay_bridge_hub_polkadot_client::runtime::Call::BridgePolkadotBulletinGrandpa( + relay_bridge_hub_polkadot_client::runtime::BridgePolkadotBulletinGrandpaCall::initialize { + init_data, + }, + ) + } +} + impl InitBridge { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { @@ -249,6 +281,10 @@ impl InitBridge { KusamaToBridgeHubPolkadotCliBridge::init_bridge(self), InitBridgeName::PolkadotToBridgeHubKusama => PolkadotToBridgeHubKusamaCliBridge::init_bridge(self), + InitBridgeName::PolkadotToPolkadotBulletin => + PolkadotToPolkadotBulletinCliBridge::init_bridge(self), + InitBridgeName::PolkadotBulletinToBridgeHubPolkadot => + PolkadotBulletinToBridgeHubPolkadotCliBridge::init_bridge(self), } .await } diff --git a/relays/bin-substrate/src/cli/relay_headers.rs b/relays/bin-substrate/src/cli/relay_headers.rs index 5ba7e3bd068..69ab2b4cf11 100644 --- a/relays/bin-substrate/src/cli/relay_headers.rs +++ b/relays/bin-substrate/src/cli/relay_headers.rs @@ -23,6 +23,10 @@ use crate::bridges::{ kusama_headers_to_bridge_hub_polkadot::KusamaToBridgeHubPolkadotCliBridge, polkadot_headers_to_bridge_hub_kusama::PolkadotToBridgeHubKusamaCliBridge, }, + polkadot_bulletin::{ + polkadot_bulletin_headers_to_bridge_hub_polkadot::PolkadotBulletinToBridgeHubPolkadotCliBridge, + polkadot_headers_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge, + }, rialto_millau::{ millau_headers_to_rialto::MillauToRialtoCliBridge, rialto_headers_to_millau::RialtoToMillauCliBridge, @@ -72,6 +76,8 @@ pub enum RelayHeadersBridge { WococoToBridgeHubRococo, KusamaToBridgeHubPolkadot, PolkadotToBridgeHubKusama, + PolkadotToPolkadotBulletin, + PolkadotBulletinToBridgeHubPolkadot, } #[async_trait] @@ -117,6 +123,8 @@ impl HeadersRelayer for RococoToBridgeHubWococoCliBridge {} impl HeadersRelayer for WococoToBridgeHubRococoCliBridge {} impl HeadersRelayer for KusamaToBridgeHubPolkadotCliBridge {} impl HeadersRelayer for PolkadotToBridgeHubKusamaCliBridge {} +impl HeadersRelayer for PolkadotToPolkadotBulletinCliBridge {} +impl HeadersRelayer for PolkadotBulletinToBridgeHubPolkadotCliBridge {} impl RelayHeaders { /// Run the command. @@ -135,6 +143,10 @@ impl RelayHeaders { KusamaToBridgeHubPolkadotCliBridge::relay_headers(self), RelayHeadersBridge::PolkadotToBridgeHubKusama => PolkadotToBridgeHubKusamaCliBridge::relay_headers(self), + RelayHeadersBridge::PolkadotToPolkadotBulletin => + PolkadotToPolkadotBulletinCliBridge::relay_headers(self), + RelayHeadersBridge::PolkadotBulletinToBridgeHubPolkadot => + PolkadotBulletinToBridgeHubPolkadotCliBridge::relay_headers(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 67f5506bc95..821ee969bba 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 @@ -44,6 +44,10 @@ use crate::{ kusama_parachains_to_bridge_hub_polkadot::BridgeHubKusamaToBridgeHubPolkadotCliBridge, polkadot_parachains_to_bridge_hub_kusama::BridgeHubPolkadotToBridgeHubKusamaCliBridge, }, + polkadot_bulletin::{ + polkadot_bulletin_headers_to_bridge_hub_polkadot::PolkadotBulletinToBridgeHubPolkadotCliBridge, + polkadot_parachains_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge, + }, rialto_millau::{ millau_headers_to_rialto::MillauToRialtoCliBridge, rialto_headers_to_millau::RialtoToMillauCliBridge, @@ -202,6 +206,7 @@ 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); +declare_chain_cli_schema!(PolkadotBulletin, polkadot_bulletin); // 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); @@ -227,11 +232,21 @@ declare_chain_cli_schema!( PolkadotParachainsToBridgeHubKusama, polkadot_parachains_to_bridge_hub_kusama ); +declare_chain_cli_schema!( + PolkadotBulletinHeadersToBridgeHubPolkadot, + polkadot_bulletin_headers_to_bridge_hub_polkadot +); +declare_chain_cli_schema!(PolkadotHeadersToPolkadotBulletin, polkadot_headers_to_polkadot_bulletin); +declare_chain_cli_schema!( + PolkadotParachainsToPolkadotBulletin, + polkadot_parachains_to_polkadot_bulletin +); // 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); +declare_relay_to_parachain_bridge_schema!(PolkadotBulletin, BridgeHubPolkadot, Polkadot); /// Base portion of the bidirectional complex relay. /// @@ -504,6 +519,32 @@ impl Full2WayBridge for BridgeHubKusamaBridgeHubPolkadotFull2WayBridge { } } +/// `PolkadotBulletin` <> `BridgeHubPolkadot` complex relay. +pub struct PolkadotBulletinBridgeHubPolkadotFull2WayBridge { + base: ::Base, +} + +#[async_trait] +impl Full2WayBridge for PolkadotBulletinBridgeHubPolkadotFull2WayBridge { + type Base = RelayToParachainBridge; + type Left = relay_polkadot_bulletin_client::PolkadotBulletin; + type Right = relay_bridge_hub_polkadot_client::BridgeHubPolkadot; + type L2R = PolkadotBulletinToBridgeHubPolkadotCliBridge; + type R2L = PolkadotToPolkadotBulletinCliBridge; + + 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 { @@ -515,6 +556,8 @@ pub enum RelayHeadersAndMessages { BridgeHubRococoBridgeHubWococo(BridgeHubRococoBridgeHubWococoHeadersAndMessages), /// BridgeHubKusama <> BridgeHubPolkadot relay. BridgeHubKusamaBridgeHubPolkadot(BridgeHubKusamaBridgeHubPolkadotHeadersAndMessages), + /// `PolkadotBulletin` <> `BridgeHubPolkadot` relay. + PolkadotBulletinBridgeHubPolkadot(PolkadotBulletinBridgeHubPolkadotHeadersAndMessages), } impl RelayHeadersAndMessages { @@ -535,6 +578,10 @@ impl RelayHeadersAndMessages { BridgeHubKusamaBridgeHubPolkadotFull2WayBridge::new(params.into_bridge().await?)? .run() .await, + RelayHeadersAndMessages::PolkadotBulletinBridgeHubPolkadot(params) => + PolkadotBulletinBridgeHubPolkadotFull2WayBridge::new(params.into_bridge().await?)? + .run() + .await, } } } diff --git a/relays/bin-substrate/src/cli/relay_messages.rs b/relays/bin-substrate/src/cli/relay_messages.rs index 3183647e22e..3cdd6364652 100644 --- a/relays/bin-substrate/src/cli/relay_messages.rs +++ b/relays/bin-substrate/src/cli/relay_messages.rs @@ -24,6 +24,10 @@ use crate::bridges::{ bridge_hub_kusama_messages_to_bridge_hub_polkadot::BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge, bridge_hub_polkadot_messages_to_bridge_hub_kusama::BridgeHubPolkadotToBridgeHubKusamaMessagesCliBridge, }, + polkadot_bulletin::{ + bridge_hub_polkadot_messages_to_polkadot_bulletin::BridgeHubPolkadotToPolkadotBulletinMessagesCliBridge, + polkadot_bulletin_messages_to_bridge_hub_polkadot::PolkadotBulletinToBridgeHubPolkadotMessagesCliBridge, + }, rialto_millau::{ millau_headers_to_rialto::MillauToRialtoCliBridge, rialto_headers_to_millau::RialtoToMillauCliBridge, @@ -108,6 +112,8 @@ impl MessagesRelayer for BridgeHubRococoToBridgeHubWococoMessagesCliBridge {} impl MessagesRelayer for BridgeHubWococoToBridgeHubRococoMessagesCliBridge {} impl MessagesRelayer for BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge {} impl MessagesRelayer for BridgeHubPolkadotToBridgeHubKusamaMessagesCliBridge {} +impl MessagesRelayer for PolkadotBulletinToBridgeHubPolkadotMessagesCliBridge {} +impl MessagesRelayer for BridgeHubPolkadotToPolkadotBulletinMessagesCliBridge {} impl RelayMessages { /// Run the command. @@ -127,6 +133,10 @@ impl RelayMessages { BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge::relay_messages(self), FullBridge::BridgeHubPolkadotToBridgeHubKusama => BridgeHubPolkadotToBridgeHubKusamaMessagesCliBridge::relay_messages(self), + FullBridge::PolkadotBulletinToBridgeHubPolkadot => + PolkadotBulletinToBridgeHubPolkadotMessagesCliBridge::relay_messages(self), + FullBridge::BridgeHubPolkadotToPolkadotBulletin => + BridgeHubPolkadotToPolkadotBulletinMessagesCliBridge::relay_messages(self), } .await } diff --git a/relays/bin-substrate/src/cli/relay_parachains.rs b/relays/bin-substrate/src/cli/relay_parachains.rs index 442d852b43c..6e8b94bad05 100644 --- a/relays/bin-substrate/src/cli/relay_parachains.rs +++ b/relays/bin-substrate/src/cli/relay_parachains.rs @@ -19,6 +19,7 @@ use crate::bridges::{ kusama_parachains_to_bridge_hub_polkadot::BridgeHubKusamaToBridgeHubPolkadotCliBridge, polkadot_parachains_to_bridge_hub_kusama::BridgeHubPolkadotToBridgeHubKusamaCliBridge, }, + polkadot_bulletin::polkadot_parachains_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge, rialto_parachain_millau::rialto_parachains_to_millau::RialtoParachainToMillauCliBridge, rococo_wococo::{ rococo_parachains_to_bridge_hub_wococo::BridgeHubRococoToBridgeHubWococoCliBridge, @@ -71,6 +72,7 @@ pub enum RelayParachainsBridge { WococoToBridgeHubRococo, KusamaToBridgeHubPolkadot, PolkadotToBridgeHubKusama, + PolkadotToPolkadotBulletin, } #[async_trait] @@ -120,6 +122,7 @@ impl ParachainsRelayer for BridgeHubRococoToBridgeHubWococoCliBridge {} impl ParachainsRelayer for BridgeHubWococoToBridgeHubRococoCliBridge {} impl ParachainsRelayer for BridgeHubKusamaToBridgeHubPolkadotCliBridge {} impl ParachainsRelayer for BridgeHubPolkadotToBridgeHubKusamaCliBridge {} +impl ParachainsRelayer for PolkadotToPolkadotBulletinCliBridge {} impl RelayParachains { /// Run the command. @@ -137,6 +140,8 @@ impl RelayParachains { BridgeHubKusamaToBridgeHubPolkadotCliBridge::relay_parachains(self), RelayParachainsBridge::PolkadotToBridgeHubKusama => BridgeHubPolkadotToBridgeHubKusamaCliBridge::relay_parachains(self), + RelayParachainsBridge::PolkadotToPolkadotBulletin => + PolkadotToPolkadotBulletinCliBridge::relay_parachains(self), } .await } diff --git a/relays/bin-substrate/src/cli/send_message.rs b/relays/bin-substrate/src/cli/send_message.rs index dbe6cc3cc7b..27c337ca0f1 100644 --- a/relays/bin-substrate/src/cli/send_message.rs +++ b/relays/bin-substrate/src/cli/send_message.rs @@ -110,18 +110,8 @@ impl SendMessage { MillauToRialtoParachainCliBridge::send_message(self), FullBridge::RialtoParachainToMillau => RialtoParachainToMillauCliBridge::send_message(self), - FullBridge::BridgeHubRococoToBridgeHubWococo => unimplemented!( - "Sending message from BridgeHubRococo to BridgeHubWococo is not supported" - ), - FullBridge::BridgeHubWococoToBridgeHubRococo => unimplemented!( - "Sending message from BridgeHubWococo to BridgeHubRococo is not supported" - ), - FullBridge::BridgeHubKusamaToBridgeHubPolkadot => unimplemented!( - "Sending message from BridgeHubKusama to BridgeHubPolkadot is not supported" - ), - FullBridge::BridgeHubPolkadotToBridgeHubKusama => unimplemented!( - "Sending message from BridgeHubPolkadot to BridgeHubKusama is not supported" - ), + // all our (soon to retire_ testnets are above, so if is fine to use `_` + _ => unimplemented!("Sending message from in {:?} is not supported", self.bridge,), } .await } diff --git a/relays/client-polkadot-bulletin/src/codegen_runtime.rs b/relays/client-polkadot-bulletin/src/codegen_runtime.rs index 7377b08c81f..a30662be2df 100644 --- a/relays/client-polkadot-bulletin/src/codegen_runtime.rs +++ b/relays/client-polkadot-bulletin/src/codegen_runtime.rs @@ -205,32 +205,6 @@ pub mod api { #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] pub struct StrippableError; } - pub mod bridge_runtime_common { - use super::runtime_types; - pub mod messages { - use super::runtime_types; - pub mod source { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct FromBridgedChainMessagesDeliveryProof<_0> { - pub bridged_header_hash: _0, - pub storage_proof: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, - pub lane: runtime_types::bp_messages::LaneId, - } - } - pub mod target { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct FromBridgedChainMessagesProof<_0> { - pub bridged_header_hash: _0, - pub storage_proof: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, - pub lane: runtime_types::bp_messages::LaneId, - pub nonces_start: ::core::primitive::u64, - pub nonces_end: ::core::primitive::u64, - } - } - } - } pub mod finality_grandpa { use super::runtime_types; #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] @@ -614,7 +588,29 @@ pub mod api { use super::runtime_types; #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] pub enum Call { - # [codec (index = 0)] set_owner { new_owner : :: core :: option :: Option < :: sp_core :: crypto :: AccountId32 > , } , # [codec (index = 1)] set_operating_mode { operating_mode : runtime_types :: bp_messages :: MessagesOperatingMode , } , # [codec (index = 2)] receive_messages_proof { relayer_id_at_bridged_chain : :: sp_core :: crypto :: AccountId32 , proof : runtime_types :: bridge_runtime_common :: messages :: target :: FromBridgedChainMessagesProof < :: subxt :: utils :: H256 > , messages_count : :: core :: primitive :: u32 , dispatch_weight : :: sp_weights :: Weight , } , # [codec (index = 3)] receive_messages_delivery_proof { proof : runtime_types :: bridge_runtime_common :: messages :: source :: FromBridgedChainMessagesDeliveryProof < :: subxt :: utils :: H256 > , relayers_state : :: bp_messages :: UnrewardedRelayersState , } , } + #[codec(index = 0)] + set_owner { new_owner: ::core::option::Option<::sp_core::crypto::AccountId32> }, + #[codec(index = 1)] + set_operating_mode { + operating_mode: runtime_types::bp_messages::MessagesOperatingMode, + }, + #[codec(index = 2)] + receive_messages_proof { + relayer_id_at_bridged_chain: ::sp_core::crypto::AccountId32, + proof: bp_messages::target_chain::FromBridgedChainMessagesProof< + ::subxt::utils::H256, + >, + messages_count: ::core::primitive::u32, + dispatch_weight: ::sp_weights::Weight, + }, + #[codec(index = 3)] + receive_messages_delivery_proof { + proof: bp_messages::source_chain::FromBridgedChainMessagesDeliveryProof< + ::subxt::utils::H256, + >, + relayers_state: ::bp_messages::UnrewardedRelayersState, + }, + } #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] pub enum Error { # [codec (index = 0)] NotOperatingNormally , # [codec (index = 1)] InactiveOutboundLane , # [codec (index = 2)] MessageDispatchInactive , # [codec (index = 3)] MessageRejectedByChainVerifier (runtime_types :: bp_messages :: VerificationError ,) , # [codec (index = 4)] MessageRejectedByLaneVerifier (runtime_types :: bp_messages :: VerificationError ,) , # [codec (index = 5)] MessageRejectedByPallet (runtime_types :: bp_messages :: VerificationError ,) , # [codec (index = 6)] FailedToWithdrawMessageFee , # [codec (index = 7)] TooManyMessagesInTheProof , # [codec (index = 8)] InvalidMessagesProof , # [codec (index = 9)] InvalidMessagesDeliveryProof , # [codec (index = 10)] InvalidUnrewardedRelayersState , # [codec (index = 11)] InsufficientDispatchWeight , # [codec (index = 12)] MessageIsNotYetSent , # [codec (index = 13)] ReceivalConfirmation (runtime_types :: pallet_bridge_messages :: outbound_lane :: ReceivalConfirmationError ,) , # [codec (index = 14)] BridgeModule (runtime_types :: bp_runtime :: OwnedBridgeModuleError ,) , } diff --git a/relays/client-polkadot-bulletin/src/lib.rs b/relays/client-polkadot-bulletin/src/lib.rs index 0f13c1cace8..de7dc8558df 100644 --- a/relays/client-polkadot-bulletin/src/lib.rs +++ b/relays/client-polkadot-bulletin/src/lib.rs @@ -21,10 +21,10 @@ mod codegen_runtime; use bp_polkadot_bulletin::POLKADOT_BULLETIN_SYNCED_HEADERS_GRANDPA_INFO_METHOD; use codec::Encode; use relay_substrate_client::{ - Chain, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError, SignParam, - UnderlyingChainProvider, UnsignedTransaction, + Chain, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, ChainWithTransactions, + Error as SubstrateError, SignParam, UnderlyingChainProvider, UnsignedTransaction, }; -use sp_core::Pair; +use sp_core::{storage::StorageKey, Pair}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount, MultiAddress}; use sp_session::MembershipProof; use std::time::Duration; @@ -33,6 +33,14 @@ pub use codegen_runtime::api::runtime_types; /// Call of the Polkadot Bulletin Chain runtime. pub type RuntimeCall = runtime_types::polkadot_bulletin_chain_runtime::RuntimeCall; +/// Call of the GRANDPA pallet. +pub type GrandpaCall = runtime_types::pallet_grandpa::pallet::Call; +/// Call of the with-PolkadotBridgeHub bridge GRANDPA pallet. +pub type BridgePolkadotGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call; +/// Call of the with-PolkadotBridgeHub bridge parachains pallet. +pub type BridgePolkadotParachainsCall = runtime_types::pallet_bridge_parachains::pallet::Call; +/// Call of the with-PolkadotBridgeHub bridge messages pallet. +pub type BridgePolkadotBridgeHubMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call; /// Polkadot header id. pub type HeaderId = @@ -59,7 +67,7 @@ impl Chain for PolkadotBulletin { const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6); type SignedBlock = bp_polkadot_bulletin::SignedBlock; - type Call = (); // TODO: RuntimeCall; + type Call = RuntimeCall; } impl ChainWithGrandpa for PolkadotBulletin { @@ -69,6 +77,24 @@ impl ChainWithGrandpa for PolkadotBulletin { type KeyOwnerProof = MembershipProof; } +impl ChainWithMessages for PolkadotBulletin { + // this is not critical (some metrics will be missing from the storage), but probably it needs + // to be changed when we'll polish the bridge configuration + const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = None; + + const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = + bp_polkadot_bulletin::TO_POLKADOT_BULLETIN_MESSAGE_DETAILS_METHOD; + const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = + bp_polkadot_bulletin::FROM_POLKADOT_BULLETIN_MESSAGE_DETAILS_METHOD; +} + +impl ChainWithBalances for PolkadotBulletin { + fn account_info_storage_key(_account_id: &Self::AccountId) -> StorageKey { + // no balances at this chain + StorageKey(vec![]) + } +} + impl ChainWithTransactions for PolkadotBulletin { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = diff --git a/relays/client-substrate/src/guard.rs b/relays/client-substrate/src/guard.rs index dc65ea143c3..8a51c56384f 100644 --- a/relays/client-substrate/src/guard.rs +++ b/relays/client-substrate/src/guard.rs @@ -17,7 +17,7 @@ //! Pallet provides a set of guard functions that are running in background threads //! and are aborting process if some condition fails. -use crate::{error::Error, Chain, ChainWithBalances, Client}; +use crate::{error::Error, Chain, Client}; use async_trait::async_trait; use sp_version::RuntimeVersion; @@ -28,7 +28,7 @@ use std::{ /// Guards environment. #[async_trait] -pub trait Environment: Send + Sync + 'static { +pub trait Environment: Send + Sync + 'static { /// Error type. type Error: Display + Send + Sync + 'static; @@ -52,7 +52,7 @@ pub trait Environment: Send + Sync + 'static { } /// Abort when runtime spec version is different from specified. -pub fn abort_on_spec_version_change( +pub fn abort_on_spec_version_change( mut env: impl Environment, expected_spec_version: u32, ) { @@ -98,7 +98,7 @@ fn conditions_check_delay() -> Duration { } #[async_trait] -impl> Environment for Clnt { +impl> Environment for Clnt { type Error = Error; async fn runtime_version(&mut self) -> Result {