-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add relays that will be used in Polkadot Bulletin <> Polkadot.BH brid…
…ge (#2556) * added Polkadot.BH <> Polkadot Bulletin chain relays * uncommented ED stuff * complex PolkadotBulletin <> Polkadot.BH relay * removed TODO * spelling
- Loading branch information
Showing
21 changed files
with
626 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...strate/src/bridges/polkadot_bulletin/bridge_hub_polkadot_messages_to_polkadot_bulletin.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
|
||
//! 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<BridgeHubPolkadot>; | ||
type TargetBatchCallBuilder = (); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
|
||
//! 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; |
101 changes: 101 additions & 0 deletions
101
...bstrate/src/bridges/polkadot_bulletin/polkadot_bulletin_headers_to_bridge_hub_polkadot.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
|
||
//! 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<Self::SourceChain>; | ||
} | ||
|
||
#[async_trait] | ||
impl SubstrateFinalitySyncPipeline for PolkadotBulletinFinalityToBridgeHubPolkadot { | ||
type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder; | ||
|
||
async fn start_relay_guards( | ||
target_client: &impl Client<Self::TargetChain>, | ||
_transaction_params: &TransactionParams<AccountKeyPairOf<Self::TargetChain>>, | ||
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; | ||
} |
65 changes: 65 additions & 0 deletions
65
...strate/src/bridges/polkadot_bulletin/polkadot_bulletin_messages_to_bridge_hub_polkadot.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
|
||
//! 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<BridgeHubPolkadot>; | ||
} |
96 changes: 96 additions & 0 deletions
96
relays/bin-substrate/src/bridges/polkadot_bulletin/polkadot_headers_to_polkadot_bulletin.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
|
||
//! 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<Self::SourceChain>; | ||
} | ||
|
||
#[async_trait] | ||
impl SubstrateFinalitySyncPipeline for PolkadotFinalityToPolkadotBulletin { | ||
type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder; | ||
|
||
async fn start_relay_guards( | ||
target_client: &impl Client<Self::TargetChain>, | ||
_transaction_params: &TransactionParams<AccountKeyPairOf<Self::TargetChain>>, | ||
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; | ||
} |
Oops, something went wrong.