Skip to content

Commit

Permalink
Add relays that will be used in Polkadot Bulletin <> Polkadot.BH brid…
Browse files Browse the repository at this point in the history
…ge (#2556)

* added Polkadot.BH <> Polkadot Bulletin chain relays

* uncommented ED stuff

* complex PolkadotBulletin <> Polkadot.BH relay

* removed TODO

* spelling
  • Loading branch information
svyatonik authored Sep 12, 2023
1 parent 12e272e commit 39e780b
Show file tree
Hide file tree
Showing 21 changed files with 626 additions and 47 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions relays/bin-substrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions relays/bin-substrate/src/bridges/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
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 = ();
}
23 changes: 23 additions & 0 deletions relays/bin-substrate/src/bridges/polkadot_bulletin/mod.rs
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;
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;
}
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>;
}
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;
}
Loading

0 comments on commit 39e780b

Please sign in to comment.