Remove Woococo related stuff (#2692)

* Remove Woococo related stuff

* More removes

* Compilation

* Added equvocation for Ro/We

* We need chain-westend primitives
This commit is contained in:
Branislav Kontur
2023-11-14 11:32:38 +01:00
committed by Bastian Köcher
parent 7a8c87a450
commit a7d2568df4
37 changed files with 48 additions and 1299 deletions
-2
View File
@@ -35,7 +35,6 @@ relay-bridge-hub-kusama-client = { path = "../client-bridge-hub-kusama" }
relay-bridge-hub-polkadot-client = { path = "../client-bridge-hub-polkadot" }
relay-bridge-hub-rococo-client = { path = "../client-bridge-hub-rococo" }
relay-bridge-hub-westend-client = { path = "../client-bridge-hub-westend" }
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" }
@@ -43,7 +42,6 @@ relay-rococo-client = { path = "../client-rococo" }
relay-substrate-client = { path = "../client-substrate" }
relay-utils = { path = "../utils" }
relay-westend-client = { path = "../client-westend" }
relay-wococo-client = { path = "../client-wococo" }
substrate-relay-helper = { path = "../lib-substrate-relay" }
# Substrate Dependencies
@@ -19,4 +19,3 @@
pub mod kusama_polkadot;
pub mod polkadot_bulletin;
pub mod rococo_westend;
pub mod rococo_wococo;
@@ -1,64 +0,0 @@
// 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/>.
//! BridgeHubRococo-to-BridgeHubWococo messages sync entrypoint.
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
use relay_bridge_hub_rococo_client::BridgeHubRococo;
use relay_bridge_hub_wococo_client::BridgeHubWococo;
use substrate_relay_helper::{messages_lane::SubstrateMessageLane, UtilityPalletBatchCallBuilder};
pub struct BridgeHubRococoToBridgeHubWococoMessagesCliBridge {}
impl CliBridgeBase for BridgeHubRococoToBridgeHubWococoMessagesCliBridge {
type Source = BridgeHubRococo;
type Target = BridgeHubWococo;
}
impl MessagesCliBridge for BridgeHubRococoToBridgeHubWococoMessagesCliBridge {
type MessagesLane = BridgeHubRococoMessagesToBridgeHubWococoMessageLane;
}
substrate_relay_helper::generate_receive_message_proof_call_builder!(
BridgeHubRococoMessagesToBridgeHubWococoMessageLane,
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesProofCallBuilder,
relay_bridge_hub_wococo_client::RuntimeCall::BridgeRococoMessages,
relay_bridge_hub_wococo_client::BridgeMessagesCall::receive_messages_proof
);
substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!(
BridgeHubRococoMessagesToBridgeHubWococoMessageLane,
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesDeliveryProofCallBuilder,
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWococoMessages,
relay_bridge_hub_rococo_client::BridgeMessagesCall::receive_messages_delivery_proof
);
/// Description of BridgeHubRococo -> BridgeHubWococo messages bridge.
#[derive(Clone, Debug)]
pub struct BridgeHubRococoMessagesToBridgeHubWococoMessageLane;
impl SubstrateMessageLane for BridgeHubRococoMessagesToBridgeHubWococoMessageLane {
type SourceChain = BridgeHubRococo;
type TargetChain = BridgeHubWococo;
type ReceiveMessagesProofCallBuilder =
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesProofCallBuilder;
type ReceiveMessagesDeliveryProofCallBuilder =
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesDeliveryProofCallBuilder;
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubRococo>;
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubWococo>;
}
@@ -1,64 +0,0 @@
// 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/>.
//! BridgeHubWococo-to-BridgeHubRococo messages sync entrypoint.
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
use relay_bridge_hub_rococo_client::BridgeHubRococo;
use relay_bridge_hub_wococo_client::BridgeHubWococo;
use substrate_relay_helper::{messages_lane::SubstrateMessageLane, UtilityPalletBatchCallBuilder};
pub struct BridgeHubWococoToBridgeHubRococoMessagesCliBridge {}
impl CliBridgeBase for BridgeHubWococoToBridgeHubRococoMessagesCliBridge {
type Source = BridgeHubWococo;
type Target = BridgeHubRococo;
}
impl MessagesCliBridge for BridgeHubWococoToBridgeHubRococoMessagesCliBridge {
type MessagesLane = BridgeHubWococoMessagesToBridgeHubRococoMessageLane;
}
substrate_relay_helper::generate_receive_message_proof_call_builder!(
BridgeHubWococoMessagesToBridgeHubRococoMessageLane,
BridgeHubWococoMessagesToBridgeHubRococoMessageLaneReceiveMessagesProofCallBuilder,
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWococoMessages,
relay_bridge_hub_rococo_client::BridgeMessagesCall::receive_messages_proof
);
substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!(
BridgeHubWococoMessagesToBridgeHubRococoMessageLane,
BridgeHubWococoMessagesToBridgeHubRococoMessageLaneReceiveMessagesDeliveryProofCallBuilder,
relay_bridge_hub_wococo_client::RuntimeCall::BridgeRococoMessages,
relay_bridge_hub_wococo_client::BridgeMessagesCall::receive_messages_delivery_proof
);
/// Description of BridgeHubWococo -> BridgeHubRococo messages bridge.
#[derive(Clone, Debug)]
pub struct BridgeHubWococoMessagesToBridgeHubRococoMessageLane;
impl SubstrateMessageLane for BridgeHubWococoMessagesToBridgeHubRococoMessageLane {
type SourceChain = BridgeHubWococo;
type TargetChain = BridgeHubRococo;
type ReceiveMessagesProofCallBuilder =
BridgeHubWococoMessagesToBridgeHubRococoMessageLaneReceiveMessagesProofCallBuilder;
type ReceiveMessagesDeliveryProofCallBuilder =
BridgeHubWococoMessagesToBridgeHubRococoMessageLaneReceiveMessagesDeliveryProofCallBuilder;
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubWococo>;
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubRococo>;
}
@@ -1,24 +0,0 @@
// 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 Rococo Bridge Hub and Wococo Bridge Hub.
pub mod bridge_hub_rococo_messages_to_bridge_hub_wococo;
pub mod bridge_hub_wococo_messages_to_bridge_hub_rococo;
pub mod rococo_headers_to_bridge_hub_wococo;
pub mod rococo_parachains_to_bridge_hub_wococo;
pub mod wococo_headers_to_bridge_hub_rococo;
pub mod wococo_parachains_to_bridge_hub_rococo;
@@ -1,80 +0,0 @@
// 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/>.
//! Rococo-to-Wococo bridge hubs headers sync entrypoint.
use crate::cli::bridge::{
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
};
use async_trait::async_trait;
use substrate_relay_helper::{
equivocation::SubstrateEquivocationDetectionPipeline,
finality::SubstrateFinalitySyncPipeline,
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
};
/// Description of Rococo -> Wococo finalized headers bridge.
#[derive(Clone, Debug)]
pub struct RococoFinalityToBridgeHubWococo;
substrate_relay_helper::generate_submit_finality_proof_call_builder!(
RococoFinalityToBridgeHubWococo,
SubmitFinalityProofCallBuilder,
relay_bridge_hub_wococo_client::RuntimeCall::BridgeRococoGrandpa,
relay_bridge_hub_wococo_client::BridgeGrandpaCall::submit_finality_proof
);
substrate_relay_helper::generate_report_equivocation_call_builder!(
RococoFinalityToBridgeHubWococo,
ReportEquivocationCallBuilder,
relay_rococo_client::RuntimeCall::Grandpa,
relay_rococo_client::GrandpaCall::report_equivocation
);
#[async_trait]
impl SubstrateFinalityPipeline for RococoFinalityToBridgeHubWococo {
type SourceChain = relay_rococo_client::Rococo;
type TargetChain = relay_bridge_hub_wococo_client::BridgeHubWococo;
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
}
#[async_trait]
impl SubstrateFinalitySyncPipeline for RococoFinalityToBridgeHubWococo {
type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder;
}
#[async_trait]
impl SubstrateEquivocationDetectionPipeline for RococoFinalityToBridgeHubWococo {
type ReportEquivocationCallBuilder = ReportEquivocationCallBuilder;
}
/// `Rococo` to BridgeHub `Wococo` bridge definition.
pub struct RococoToBridgeHubWococoCliBridge {}
impl CliBridgeBase for RococoToBridgeHubWococoCliBridge {
type Source = relay_rococo_client::Rococo;
type Target = relay_bridge_hub_wococo_client::BridgeHubWococo;
}
impl RelayToRelayHeadersCliBridge for RococoToBridgeHubWococoCliBridge {
type Finality = RococoFinalityToBridgeHubWococo;
}
impl RelayToRelayEquivocationDetectionCliBridge for RococoToBridgeHubWococoCliBridge {
type Equivocation = RococoFinalityToBridgeHubWococo;
}
@@ -1,75 +0,0 @@
// 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/>.
//! Wococo-to-Rococo 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,
};
/// BridgeHub-to-BridgeHub parachain sync description.
#[derive(Clone, Debug)]
pub struct BridgeHubRococoToBridgeHubWococo;
impl SubstrateParachainsPipeline for BridgeHubRococoToBridgeHubWococo {
type SourceParachain = relay_bridge_hub_rococo_client::BridgeHubRococo;
type SourceRelayChain = relay_rococo_client::Rococo;
type TargetChain = relay_bridge_hub_wococo_client::BridgeHubWococo;
type SubmitParachainHeadsCallBuilder = BridgeHubRococoToBridgeHubWococoCallBuilder;
}
pub struct BridgeHubRococoToBridgeHubWococoCallBuilder;
impl SubmitParachainHeadsCallBuilder<BridgeHubRococoToBridgeHubWococo>
for BridgeHubRococoToBridgeHubWococoCallBuilder
{
fn build_submit_parachain_heads_call(
at_relay_block: HeaderIdOf<relay_rococo_client::Rococo>,
parachains: Vec<(ParaId, ParaHash)>,
parachain_heads_proof: ParaHeadsProof,
) -> CallOf<relay_bridge_hub_wococo_client::BridgeHubWococo> {
relay_bridge_hub_wococo_client::RuntimeCall::BridgeRococoParachains(
relay_bridge_hub_wococo_client::BridgeParachainCall::submit_parachain_heads {
at_relay_block: (at_relay_block.0, at_relay_block.1),
parachains,
parachain_heads_proof,
},
)
}
}
/// `BridgeHubParachain` to `BridgeHubParachain` bridge definition.
pub struct BridgeHubRococoToBridgeHubWococoCliBridge {}
impl ParachainToRelayHeadersCliBridge for BridgeHubRococoToBridgeHubWococoCliBridge {
type SourceRelay = relay_rococo_client::Rococo;
type ParachainFinality = BridgeHubRococoToBridgeHubWococo;
type RelayFinality =
crate::bridges::rococo_wococo::rococo_headers_to_bridge_hub_wococo::RococoFinalityToBridgeHubWococo;
}
impl CliBridgeBase for BridgeHubRococoToBridgeHubWococoCliBridge {
type Source = relay_bridge_hub_rococo_client::BridgeHubRococo;
type Target = relay_bridge_hub_wococo_client::BridgeHubWococo;
}
impl MessagesCliBridge for BridgeHubRococoToBridgeHubWococoCliBridge {
type MessagesLane =
crate::bridges::rococo_wococo::bridge_hub_rococo_messages_to_bridge_hub_wococo::BridgeHubRococoMessagesToBridgeHubWococoMessageLane;
}
@@ -1,80 +0,0 @@
// 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/>.
//! Wococo-to-Rococo bridge hubs headers sync entrypoint.
use crate::cli::bridge::{
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
};
use async_trait::async_trait;
use substrate_relay_helper::{
equivocation::SubstrateEquivocationDetectionPipeline,
finality::SubstrateFinalitySyncPipeline,
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
};
/// Description of Wococo -> Rococo finalized headers bridge.
#[derive(Clone, Debug)]
pub struct WococoFinalityToBridgeHubRococo;
substrate_relay_helper::generate_submit_finality_proof_call_builder!(
WococoFinalityToBridgeHubRococo,
SubmitFinalityProofCallBuilder,
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWococoGrandpa,
relay_bridge_hub_rococo_client::BridgeGrandpaCall::submit_finality_proof
);
substrate_relay_helper::generate_report_equivocation_call_builder!(
WococoFinalityToBridgeHubRococo,
ReportEquivocationCallBuilder,
relay_wococo_client::RuntimeCall::Grandpa,
relay_wococo_client::GrandpaCall::report_equivocation
);
#[async_trait]
impl SubstrateFinalityPipeline for WococoFinalityToBridgeHubRococo {
type SourceChain = relay_wococo_client::Wococo;
type TargetChain = relay_bridge_hub_rococo_client::BridgeHubRococo;
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
}
#[async_trait]
impl SubstrateFinalitySyncPipeline for WococoFinalityToBridgeHubRococo {
type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder;
}
#[async_trait]
impl SubstrateEquivocationDetectionPipeline for WococoFinalityToBridgeHubRococo {
type ReportEquivocationCallBuilder = ReportEquivocationCallBuilder;
}
/// `Wococo` to BridgeHub `Rococo` bridge definition.
pub struct WococoToBridgeHubRococoCliBridge {}
impl CliBridgeBase for WococoToBridgeHubRococoCliBridge {
type Source = relay_wococo_client::Wococo;
type Target = relay_bridge_hub_rococo_client::BridgeHubRococo;
}
impl RelayToRelayHeadersCliBridge for WococoToBridgeHubRococoCliBridge {
type Finality = WococoFinalityToBridgeHubRococo;
}
impl RelayToRelayEquivocationDetectionCliBridge for WococoToBridgeHubRococoCliBridge {
type Equivocation = WococoFinalityToBridgeHubRococo;
}
@@ -1,75 +0,0 @@
// 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/>.
//! Rococo-to-Wococo 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,
};
/// BridgeHub-to-BridgeHub parachain sync description.
#[derive(Clone, Debug)]
pub struct BridgeHubWococoToBridgeHubRococo;
impl SubstrateParachainsPipeline for BridgeHubWococoToBridgeHubRococo {
type SourceParachain = relay_bridge_hub_wococo_client::BridgeHubWococo;
type SourceRelayChain = relay_wococo_client::Wococo;
type TargetChain = relay_bridge_hub_rococo_client::BridgeHubRococo;
type SubmitParachainHeadsCallBuilder = BridgeHubWococoToBridgeHubRococoCallBuilder;
}
pub struct BridgeHubWococoToBridgeHubRococoCallBuilder;
impl SubmitParachainHeadsCallBuilder<BridgeHubWococoToBridgeHubRococo>
for BridgeHubWococoToBridgeHubRococoCallBuilder
{
fn build_submit_parachain_heads_call(
at_relay_block: HeaderIdOf<relay_wococo_client::Wococo>,
parachains: Vec<(ParaId, ParaHash)>,
parachain_heads_proof: ParaHeadsProof,
) -> CallOf<relay_bridge_hub_rococo_client::BridgeHubRococo> {
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWococoParachains(
relay_bridge_hub_rococo_client::BridgeParachainCall::submit_parachain_heads {
at_relay_block: (at_relay_block.0, at_relay_block.1),
parachains,
parachain_heads_proof,
},
)
}
}
/// `BridgeHubParachain` to `BridgeHubParachain` bridge definition.
pub struct BridgeHubWococoToBridgeHubRococoCliBridge {}
impl ParachainToRelayHeadersCliBridge for BridgeHubWococoToBridgeHubRococoCliBridge {
type SourceRelay = relay_wococo_client::Wococo;
type ParachainFinality = BridgeHubWococoToBridgeHubRococo;
type RelayFinality =
crate::bridges::rococo_wococo::wococo_headers_to_bridge_hub_rococo::WococoFinalityToBridgeHubRococo;
}
impl CliBridgeBase for BridgeHubWococoToBridgeHubRococoCliBridge {
type Source = relay_bridge_hub_wococo_client::BridgeHubWococo;
type Target = relay_bridge_hub_rococo_client::BridgeHubRococo;
}
impl MessagesCliBridge for BridgeHubWococoToBridgeHubRococoCliBridge {
type MessagesLane =
crate::bridges::rococo_wococo::bridge_hub_wococo_messages_to_bridge_hub_rococo::BridgeHubWococoMessagesToBridgeHubRococoMessageLane;
}
@@ -21,4 +21,3 @@ mod polkadot;
mod polkadot_bulletin;
mod rococo;
mod westend;
mod wococo;
@@ -1,31 +0,0 @@
// 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/>.
//! Wococo + Wococo parachains specification for CLI.
use crate::cli::CliChain;
use relay_bridge_hub_wococo_client::BridgeHubWococo;
use relay_substrate_client::SimpleRuntimeVersion;
use relay_wococo_client::Wococo;
impl CliChain for Wococo {
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
}
impl CliChain for BridgeHubWococo {
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
Some(SimpleRuntimeVersion { spec_version: 9420, transaction_version: 3 });
}
@@ -29,8 +29,6 @@ use substrate_relay_helper::{
#[strum(serialize_all = "kebab_case")]
/// Supported full bridges (headers + messages).
pub enum FullBridge {
BridgeHubRococoToBridgeHubWococo,
BridgeHubWococoToBridgeHubRococo,
BridgeHubRococoToBridgeHubWestend,
BridgeHubWestendToBridgeHubRococo,
BridgeHubKusamaToBridgeHubPolkadot,
@@ -20,9 +20,9 @@ use crate::{
kusama_headers_to_bridge_hub_polkadot::KusamaToBridgeHubPolkadotCliBridge,
polkadot_headers_to_bridge_hub_kusama::PolkadotToBridgeHubKusamaCliBridge,
},
rococo_wococo::{
rococo_headers_to_bridge_hub_wococo::RococoToBridgeHubWococoCliBridge,
wococo_headers_to_bridge_hub_rococo::WococoToBridgeHubRococoCliBridge,
rococo_westend::{
rococo_headers_to_bridge_hub_westend::RococoToBridgeHubWestendCliBridge,
westend_headers_to_bridge_hub_rococo::WestendToBridgeHubRococoCliBridge,
},
},
cli::{bridge::*, chain_schema::*, PrometheusParams},
@@ -53,10 +53,10 @@ pub struct DetectEquivocations {
#[strum(serialize_all = "kebab_case")]
/// Equivocations detection bridge.
pub enum DetectEquivocationsBridge {
RococoToBridgeHubWococo,
WococoToBridgeHubRococo,
KusamaToBridgeHubPolkadot,
PolkadotToBridgeHubKusama,
RococoToBridgeHubWestend,
WestendToBridgeHubRococo,
}
#[async_trait]
@@ -82,23 +82,23 @@ where
}
}
impl EquivocationsDetector for RococoToBridgeHubWococoCliBridge {}
impl EquivocationsDetector for WococoToBridgeHubRococoCliBridge {}
impl EquivocationsDetector for KusamaToBridgeHubPolkadotCliBridge {}
impl EquivocationsDetector for PolkadotToBridgeHubKusamaCliBridge {}
impl EquivocationsDetector for RococoToBridgeHubWestendCliBridge {}
impl EquivocationsDetector for WestendToBridgeHubRococoCliBridge {}
impl DetectEquivocations {
/// Run the command.
pub async fn run(self) -> anyhow::Result<()> {
match self.bridge {
DetectEquivocationsBridge::RococoToBridgeHubWococo =>
RococoToBridgeHubWococoCliBridge::start(self),
DetectEquivocationsBridge::WococoToBridgeHubRococo =>
WococoToBridgeHubRococoCliBridge::start(self),
DetectEquivocationsBridge::KusamaToBridgeHubPolkadot =>
KusamaToBridgeHubPolkadotCliBridge::start(self),
DetectEquivocationsBridge::PolkadotToBridgeHubKusama =>
PolkadotToBridgeHubKusamaCliBridge::start(self),
DetectEquivocationsBridge::RococoToBridgeHubWestend =>
RococoToBridgeHubWestendCliBridge::start(self),
DetectEquivocationsBridge::WestendToBridgeHubRococo =>
WestendToBridgeHubRococoCliBridge::start(self),
}
.await
}
@@ -31,10 +31,6 @@ use crate::{
rococo_headers_to_bridge_hub_westend::RococoToBridgeHubWestendCliBridge,
westend_headers_to_bridge_hub_rococo::WestendToBridgeHubRococoCliBridge,
},
rococo_wococo::{
rococo_headers_to_bridge_hub_wococo::RococoToBridgeHubWococoCliBridge,
wococo_headers_to_bridge_hub_rococo::WococoToBridgeHubRococoCliBridge,
},
},
cli::{bridge::CliBridgeBase, chain_schema::*},
};
@@ -66,8 +62,6 @@ pub struct InitBridge {
#[strum(serialize_all = "kebab_case")]
/// Bridge to initialize.
pub enum InitBridgeName {
RococoToBridgeHubWococo,
WococoToBridgeHubRococo,
KusamaToBridgeHubPolkadot,
PolkadotToBridgeHubKusama,
PolkadotToPolkadotBulletin,
@@ -116,30 +110,6 @@ where
}
}
impl BridgeInitializer for RococoToBridgeHubWococoCliBridge {
type Engine = GrandpaFinalityEngine<Self::Source>;
fn encode_init_bridge(
init_data: <Self::Engine as Engine<Self::Source>>::InitializationData,
) -> <Self::Target as Chain>::Call {
relay_bridge_hub_wococo_client::RuntimeCall::BridgeRococoGrandpa(
relay_bridge_hub_wococo_client::BridgeGrandpaCall::initialize { init_data },
)
}
}
impl BridgeInitializer for WococoToBridgeHubRococoCliBridge {
type Engine = GrandpaFinalityEngine<Self::Source>;
fn encode_init_bridge(
init_data: <Self::Engine as Engine<Self::Source>>::InitializationData,
) -> <Self::Target as Chain>::Call {
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWococoGrandpa(
relay_bridge_hub_rococo_client::BridgeGrandpaCall::initialize { init_data },
)
}
}
impl BridgeInitializer for RococoToBridgeHubWestendCliBridge {
type Engine = GrandpaFinalityEngine<Self::Source>;
@@ -229,10 +199,6 @@ impl InitBridge {
/// Run the command.
pub async fn run(self) -> anyhow::Result<()> {
match self.bridge {
InitBridgeName::RococoToBridgeHubWococo =>
RococoToBridgeHubWococoCliBridge::init_bridge(self),
InitBridgeName::WococoToBridgeHubRococo =>
WococoToBridgeHubRococoCliBridge::init_bridge(self),
InitBridgeName::KusamaToBridgeHubPolkadot =>
KusamaToBridgeHubPolkadotCliBridge::init_bridge(self),
InitBridgeName::PolkadotToBridgeHubKusama =>
@@ -27,10 +27,6 @@ use crate::bridges::{
polkadot_bulletin_headers_to_bridge_hub_polkadot::PolkadotBulletinToBridgeHubPolkadotCliBridge,
polkadot_headers_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge,
},
rococo_wococo::{
rococo_headers_to_bridge_hub_wococo::RococoToBridgeHubWococoCliBridge,
wococo_headers_to_bridge_hub_rococo::WococoToBridgeHubRococoCliBridge,
},
};
use relay_utils::metrics::{GlobalMetrics, StandaloneMetric};
use substrate_relay_helper::finality::SubstrateFinalitySyncPipeline;
@@ -61,8 +57,6 @@ pub struct RelayHeaders {
#[strum(serialize_all = "kebab_case")]
/// Headers relay bridge.
pub enum RelayHeadersBridge {
RococoToBridgeHubWococo,
WococoToBridgeHubRococo,
KusamaToBridgeHubPolkadot,
PolkadotToBridgeHubKusama,
PolkadotToPolkadotBulletin,
@@ -100,8 +94,6 @@ trait HeadersRelayer: RelayToRelayHeadersCliBridge {
}
}
impl HeadersRelayer for RococoToBridgeHubWococoCliBridge {}
impl HeadersRelayer for WococoToBridgeHubRococoCliBridge {}
impl HeadersRelayer for KusamaToBridgeHubPolkadotCliBridge {}
impl HeadersRelayer for PolkadotToBridgeHubKusamaCliBridge {}
impl HeadersRelayer for PolkadotToPolkadotBulletinCliBridge {}
@@ -111,10 +103,6 @@ impl RelayHeaders {
/// Run the command.
pub async fn run(self) -> anyhow::Result<()> {
match self.bridge {
RelayHeadersBridge::RococoToBridgeHubWococo =>
RococoToBridgeHubWococoCliBridge::relay_headers(self),
RelayHeadersBridge::WococoToBridgeHubRococo =>
WococoToBridgeHubRococoCliBridge::relay_headers(self),
RelayHeadersBridge::KusamaToBridgeHubPolkadot =>
KusamaToBridgeHubPolkadotCliBridge::relay_headers(self),
RelayHeadersBridge::PolkadotToBridgeHubKusama =>
@@ -51,10 +51,6 @@ use crate::{
rococo_parachains_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendCliBridge,
westend_parachains_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoCliBridge,
},
rococo_wococo::{
rococo_parachains_to_bridge_hub_wococo::BridgeHubRococoToBridgeHubWococoCliBridge,
wococo_parachains_to_bridge_hub_rococo::BridgeHubWococoToBridgeHubRococoCliBridge,
},
},
cli::{
bridge::{
@@ -196,8 +192,6 @@ where
// All supported chains.
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!(Westend, westend);
declare_chain_cli_schema!(BridgeHubWestend, bridge_hub_westend);
declare_chain_cli_schema!(Kusama, kusama);
@@ -205,8 +199,37 @@ 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!(RococoHeadersToBridgeHubWestend, rococo_headers_to_bridge_hub_westend);
declare_chain_cli_schema!(
RococoParachainsToBridgeHubWestend,
rococo_parachains_to_bridge_hub_westend
);
declare_chain_cli_schema!(WestendHeadersToBridgeHubRococo, westend_headers_to_bridge_hub_rococo);
declare_chain_cli_schema!(
WestendParachainsToBridgeHubRococo,
westend_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
);
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_parachain_to_parachain_bridge_schema!(BridgeHubRococo, Rococo, BridgeHubWococo, Wococo);
declare_parachain_to_parachain_bridge_schema!(BridgeHubRococo, Rococo, BridgeHubWestend, Westend);
declare_parachain_to_parachain_bridge_schema!(BridgeHubKusama, Kusama, BridgeHubPolkadot, Polkadot);
declare_relay_to_parachain_bridge_schema!(PolkadotBulletin, BridgeHubPolkadot, Polkadot);
@@ -376,32 +399,6 @@ where
}
}
/// BridgeHubRococo <> BridgeHubWococo complex relay.
pub struct BridgeHubRococoBridgeHubWococoFull2WayBridge {
base: <Self as Full2WayBridge>::Base,
}
#[async_trait]
impl Full2WayBridge for BridgeHubRococoBridgeHubWococoFull2WayBridge {
type Base = ParachainToParachainBridge<Self::L2R, Self::R2L>;
type Left = relay_bridge_hub_rococo_client::BridgeHubRococo;
type Right = relay_bridge_hub_wococo_client::BridgeHubWococo;
type L2R = BridgeHubRococoToBridgeHubWococoCliBridge;
type R2L = BridgeHubWococoToBridgeHubRococoCliBridge;
fn new(base: Self::Base) -> anyhow::Result<Self> {
Ok(Self { base })
}
fn base(&self) -> &Self::Base {
&self.base
}
fn mut_base(&mut self) -> &mut Self::Base {
&mut self.base
}
}
/// BridgeHubRococo <> BridgeHubWestend complex relay.
pub struct BridgeHubRococoBridgeHubWestendFull2WayBridge {
base: <Self as Full2WayBridge>::Base,
@@ -483,8 +480,6 @@ impl Full2WayBridge for PolkadotBulletinBridgeHubPolkadotFull2WayBridge {
/// Complex headers+messages relay.
#[derive(Debug, PartialEq, StructOpt)]
pub enum RelayHeadersAndMessages {
/// BridgeHubRococo <> BridgeHubWococo relay.
BridgeHubRococoBridgeHubWococo(BridgeHubRococoBridgeHubWococoHeadersAndMessages),
/// BridgeHubKusama <> BridgeHubPolkadot relay.
BridgeHubKusamaBridgeHubPolkadot(BridgeHubKusamaBridgeHubPolkadotHeadersAndMessages),
/// `PolkadotBulletin` <> `BridgeHubPolkadot` relay.
@@ -497,10 +492,6 @@ impl RelayHeadersAndMessages {
/// Run the command.
pub async fn run(self) -> anyhow::Result<()> {
match self {
RelayHeadersAndMessages::BridgeHubRococoBridgeHubWococo(params) =>
BridgeHubRococoBridgeHubWococoFull2WayBridge::new(params.into_bridge().await?)?
.run()
.await,
RelayHeadersAndMessages::BridgeHubRococoBridgeHubWestend(params) =>
BridgeHubRococoBridgeHubWestendFull2WayBridge::new(params.into_bridge().await?)?
.run()
@@ -32,10 +32,6 @@ use crate::bridges::{
bridge_hub_rococo_messages_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendMessagesCliBridge,
bridge_hub_westend_messages_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoMessagesCliBridge,
},
rococo_wococo::{
bridge_hub_rococo_messages_to_bridge_hub_wococo::BridgeHubRococoToBridgeHubWococoMessagesCliBridge,
bridge_hub_wococo_messages_to_bridge_hub_rococo::BridgeHubWococoToBridgeHubRococoMessagesCliBridge,
},
};
use relay_substrate_client::{AccountIdOf, AccountKeyPairOf, BalanceOf, ChainWithTransactions};
use substrate_relay_helper::{messages_lane::MessagesRelayParams, TransactionParams};
@@ -101,8 +97,6 @@ where
}
}
impl MessagesRelayer for BridgeHubRococoToBridgeHubWococoMessagesCliBridge {}
impl MessagesRelayer for BridgeHubWococoToBridgeHubRococoMessagesCliBridge {}
impl MessagesRelayer for BridgeHubRococoToBridgeHubWestendMessagesCliBridge {}
impl MessagesRelayer for BridgeHubWestendToBridgeHubRococoMessagesCliBridge {}
impl MessagesRelayer for BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge {}
@@ -114,10 +108,6 @@ impl RelayMessages {
/// Run the command.
pub async fn run(self) -> anyhow::Result<()> {
match self.bridge {
FullBridge::BridgeHubRococoToBridgeHubWococo =>
BridgeHubRococoToBridgeHubWococoMessagesCliBridge::relay_messages(self),
FullBridge::BridgeHubWococoToBridgeHubRococo =>
BridgeHubWococoToBridgeHubRococoMessagesCliBridge::relay_messages(self),
FullBridge::BridgeHubRococoToBridgeHubWestend =>
BridgeHubRococoToBridgeHubWestendMessagesCliBridge::relay_messages(self),
FullBridge::BridgeHubWestendToBridgeHubRococo =>
@@ -24,10 +24,6 @@ use crate::bridges::{
rococo_parachains_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendCliBridge,
westend_parachains_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoCliBridge,
},
rococo_wococo::{
rococo_parachains_to_bridge_hub_wococo::BridgeHubRococoToBridgeHubWococoCliBridge,
wococo_parachains_to_bridge_hub_rococo::BridgeHubWococoToBridgeHubRococoCliBridge,
},
};
use async_std::sync::Mutex;
use async_trait::async_trait;
@@ -68,8 +64,6 @@ pub struct RelayParachains {
#[derive(Debug, EnumString, EnumVariantNames)]
#[strum(serialize_all = "kebab_case")]
pub enum RelayParachainsBridge {
RococoToBridgeHubWococo,
WococoToBridgeHubRococo,
KusamaToBridgeHubPolkadot,
PolkadotToBridgeHubKusama,
PolkadotToPolkadotBulletin,
@@ -118,8 +112,6 @@ where
}
}
impl ParachainsRelayer for BridgeHubRococoToBridgeHubWococoCliBridge {}
impl ParachainsRelayer for BridgeHubWococoToBridgeHubRococoCliBridge {}
impl ParachainsRelayer for BridgeHubRococoToBridgeHubWestendCliBridge {}
impl ParachainsRelayer for BridgeHubWestendToBridgeHubRococoCliBridge {}
impl ParachainsRelayer for BridgeHubKusamaToBridgeHubPolkadotCliBridge {}
@@ -130,10 +122,6 @@ impl RelayParachains {
/// Run the command.
pub async fn run(self) -> anyhow::Result<()> {
match self.bridge {
RelayParachainsBridge::RococoToBridgeHubWococo =>
BridgeHubRococoToBridgeHubWococoCliBridge::relay_parachains(self),
RelayParachainsBridge::WococoToBridgeHubRococo =>
BridgeHubWococoToBridgeHubRococoCliBridge::relay_parachains(self),
RelayParachainsBridge::RococoToBridgeHubWestend =>
BridgeHubRococoToBridgeHubWestendCliBridge::relay_parachains(self),
RelayParachainsBridge::WestendToBridgeHubRococo =>
@@ -13,13 +13,11 @@ subxt = { version = "0.32.1", default-features = false, features = [] }
# Bridge dependencies
bp-bridge-hub-rococo = { path = "../../primitives/chain-bridge-hub-rococo" }
bp-bridge-hub-wococo = { path = "../../primitives/chain-bridge-hub-wococo" }
bp-header-chain = { path = "../../primitives/header-chain" }
bp-messages = { path = "../../primitives/messages" }
bp-parachains = { path = "../../primitives/parachains" }
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bp-runtime = { path = "../../primitives/runtime" }
bp-wococo = { path = "../../primitives/chain-wococo" }
bridge-runtime-common = { path = "../../bin/runtime-common" }
relay-substrate-client = { path = "../client-substrate" }
@@ -1,34 +0,0 @@
[package]
name = "relay-bridge-hub-wococo-client"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
subxt = { version = "0.32.1", default-features = false, features = [] }
# Bridge dependencies
bp-bridge-hub-rococo = { path = "../../primitives/chain-bridge-hub-rococo" }
bp-bridge-hub-wococo = { path = "../../primitives/chain-bridge-hub-wococo" }
bp-header-chain = { path = "../../primitives/header-chain" }
bp-messages = { path = "../../primitives/messages" }
bp-parachains = { path = "../../primitives/parachains" }
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bp-runtime = { path = "../../primitives/runtime" }
bridge-runtime-common = { path = "../../bin/runtime-common" }
relay-bridge-hub-rococo-client = { path = "../client-bridge-hub-rococo" }
relay-substrate-client = { path = "../client-substrate" }
# Substrate Dependencies
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
[dev-dependencies]
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
@@ -1,169 +0,0 @@
// 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/>.
//! Types used to connect to the BridgeHub-Wococo-Substrate parachain.
use bp_bridge_hub_wococo::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
use bp_messages::MessageNonce;
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
use bp_runtime::ChainId;
use codec::Encode;
use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, UnderlyingChainProvider,
UnsignedTransaction,
};
use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
use std::time::Duration;
pub use codegen_runtime::api::runtime_types;
use relay_bridge_hub_rococo_client::codegen_runtime;
pub type RuntimeCall = runtime_types::bridge_hub_rococo_runtime::RuntimeCall;
pub type BridgeMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call;
pub type BridgeGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call;
pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call;
type UncheckedExtrinsic = bp_bridge_hub_wococo::UncheckedExtrinsic<RuntimeCall, SignedExtension>;
/// Wococo chain definition
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BridgeHubWococo;
impl UnderlyingChainProvider for BridgeHubWococo {
type Chain = bp_bridge_hub_wococo::BridgeHubWococo;
}
impl Chain for BridgeHubWococo {
const ID: ChainId = bp_runtime::BRIDGE_HUB_WOCOCO_CHAIN_ID;
const NAME: &'static str = "BridgeHubWococo";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_bridge_hub_wococo::BEST_FINALIZED_BRIDGE_HUB_WOCOCO_HEADER_METHOD;
const AVERAGE_BLOCK_INTERVAL: Duration = AVERAGE_BLOCK_INTERVAL;
type SignedBlock = bp_bridge_hub_wococo::SignedBlock;
type Call = RuntimeCall;
}
impl ChainWithBalances for BridgeHubWococo {
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
bp_bridge_hub_wococo::AccountInfoStorageMapKeyProvider::final_key(account_id)
}
}
impl ChainWithUtilityPallet for BridgeHubWococo {
type UtilityPallet = MockedRuntimeUtilityPallet<RuntimeCall>;
}
impl ChainWithTransactions for BridgeHubWococo {
type AccountKeyPair = sp_core::sr25519::Pair;
type SignedTransaction = UncheckedExtrinsic;
fn sign_transaction(
param: SignParam<Self>,
unsigned: UnsignedTransaction<Self>,
) -> Result<Self::SignedTransaction, SubstrateError> {
let raw_payload = SignedPayload::new(
unsigned.call,
SignedExtension::from_params(
param.spec_version,
param.transaction_version,
unsigned.era,
param.genesis_hash,
unsigned.nonce,
unsigned.tip,
(((), ()), ((), ())),
),
)?;
let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload));
let signer: sp_runtime::MultiSigner = param.signer.public().into();
let (call, extra, _) = raw_payload.deconstruct();
Ok(UncheckedExtrinsic::new_signed(
call,
signer.into_account().into(),
signature.into(),
extra,
))
}
fn is_signed(tx: &Self::SignedTransaction) -> bool {
tx.signature.is_some()
}
fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
tx.signature
.as_ref()
.map(|(address, _, _)| {
*address == bp_bridge_hub_wococo::Address::Id(signer.public().into())
})
.unwrap_or(false)
}
fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> {
let extra = &tx.signature.as_ref()?.2;
Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip()))
}
}
impl ChainWithMessages for BridgeHubWococo {
const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
bp_bridge_hub_wococo::WITH_BRIDGE_HUB_WOCOCO_MESSAGES_PALLET_NAME;
const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
Some(bp_bridge_hub_wococo::WITH_BRIDGE_HUB_WOCOCO_RELAYERS_PALLET_NAME);
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_bridge_hub_wococo::TO_BRIDGE_HUB_WOCOCO_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_bridge_hub_wococo::FROM_BRIDGE_HUB_WOCOCO_MESSAGE_DETAILS_METHOD;
const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
bp_bridge_hub_wococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
bp_bridge_hub_wococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
}
#[cfg(test)]
mod tests {
use super::*;
use relay_substrate_client::TransactionEra;
type SystemCall = runtime_types::frame_system::pallet::Call;
#[test]
fn parse_transaction_works() {
let unsigned = UnsignedTransaction {
call: RuntimeCall::System(SystemCall::remark { remark: b"Hello world!".to_vec() })
.into(),
nonce: 777,
tip: 888,
era: TransactionEra::immortal(),
};
let signed_transaction = BridgeHubWococo::sign_transaction(
SignParam {
spec_version: 42,
transaction_version: 50000,
genesis_hash: [42u8; 32].into(),
signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(),
},
unsigned.clone(),
)
.unwrap();
let parsed_transaction = BridgeHubWococo::parse_transaction(signed_transaction).unwrap();
assert_eq!(parsed_transaction, unsigned);
}
}
-24
View File
@@ -1,24 +0,0 @@
[package]
name = "relay-wococo-client"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
# Bridge dependencies
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bp-runtime = { path = "../../primitives/runtime" }
bp-wococo = { path = "../../primitives/chain-wococo" }
relay-rococo-client = { path = "../client-rococo" }
relay-substrate-client = { path = "../client-substrate" }
relay-utils = { path = "../utils" }
# Substrate Dependencies
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
-133
View File
@@ -1,133 +0,0 @@
// 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/>.
//! Types used to connect to the Wococo-Substrate chain.
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
use bp_runtime::ChainId;
use bp_wococo::WOCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
use codec::Encode;
use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError,
RelayChain, SignParam, UnderlyingChainProvider, UnsignedTransaction,
};
use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount, MultiAddress};
use sp_session::MembershipProof;
use std::time::Duration;
pub use codegen_runtime::api::runtime_types;
use relay_rococo_client::codegen_runtime;
pub type RuntimeCall = runtime_types::rococo_runtime::RuntimeCall;
pub type GrandpaCall = runtime_types::pallet_grandpa::pallet::Call;
/// Wococo header id.
pub type HeaderId = relay_utils::HeaderId<bp_wococo::Hash, bp_wococo::BlockNumber>;
/// Wococo header type used in headers sync.
pub type SyncHeader = relay_substrate_client::SyncHeader<bp_wococo::Header>;
/// The address format for describing accounts.
pub type Address = MultiAddress<bp_wococo::AccountId, ()>;
/// Wococo chain definition
#[derive(Debug, Clone, Copy)]
pub struct Wococo;
impl UnderlyingChainProvider for Wococo {
type Chain = bp_wococo::Wococo;
}
impl Chain for Wococo {
const ID: ChainId = bp_runtime::WOCOCO_CHAIN_ID;
const NAME: &'static str = "Wococo";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_wococo::BEST_FINALIZED_WOCOCO_HEADER_METHOD;
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6);
type SignedBlock = bp_wococo::SignedBlock;
type Call = RuntimeCall;
}
impl ChainWithGrandpa for Wococo {
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
WOCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
type KeyOwnerProof = MembershipProof;
}
impl ChainWithBalances for Wococo {
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
bp_wococo::AccountInfoStorageMapKeyProvider::final_key(account_id)
}
}
impl RelayChain for Wococo {
const PARAS_PALLET_NAME: &'static str = bp_wococo::PARAS_PALLET_NAME;
}
impl ChainWithTransactions for Wococo {
type AccountKeyPair = sp_core::sr25519::Pair;
type SignedTransaction =
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_wococo::SignedExtension>;
fn sign_transaction(
param: SignParam<Self>,
unsigned: UnsignedTransaction<Self>,
) -> Result<Self::SignedTransaction, SubstrateError> {
let raw_payload = SignedPayload::new(
unsigned.call,
bp_wococo::SignedExtension::from_params(
param.spec_version,
param.transaction_version,
unsigned.era,
param.genesis_hash,
unsigned.nonce,
unsigned.tip,
((), ()),
),
)?;
let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload));
let signer: sp_runtime::MultiSigner = param.signer.public().into();
let (call, extra, _) = raw_payload.deconstruct();
Ok(Self::SignedTransaction::new_signed(
call,
signer.into_account().into(),
signature.into(),
extra,
))
}
fn is_signed(tx: &Self::SignedTransaction) -> bool {
tx.signature.is_some()
}
fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
tx.signature
.as_ref()
.map(|(address, _, _)| *address == Address::Id(signer.public().into()))
.unwrap_or(false)
}
fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> {
let extra = &tx.signature.as_ref()?.2;
Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip()))
}
}
@@ -51,8 +51,7 @@ sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "mas
[dev-dependencies]
bp-rococo = { path = "../../primitives/chain-rococo" }
bp-wococo = { path = "../../primitives/chain-wococo" }
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
relay-rococo-client = { path = "../client-rococo" }
relay-bridge-hub-rococo-client = { path = "../client-bridge-hub-rococo" }
relay-bridge-hub-wococo-client = { path = "../client-bridge-hub-wococo" }
relay-bridge-hub-westend-client = { path = "../client-bridge-hub-westend" }
relay-rococo-client = { path = "../client-rococo" }
@@ -556,7 +556,7 @@ mod tests {
use super::*;
use bp_runtime::Chain as ChainBase;
use relay_bridge_hub_rococo_client::BridgeHubRococo;
use relay_bridge_hub_wococo_client::BridgeHubWococo;
use relay_bridge_hub_westend_client::BridgeHubWestend;
fn message_details_from_rpc(
nonces: RangeInclusive<MessageNonce>,
@@ -644,7 +644,7 @@ mod tests {
msgs_to_refine.push((payload, out_msg_details));
}
let maybe_batches = split_msgs_to_refine::<BridgeHubRococo, BridgeHubWococo>(
let maybe_batches = split_msgs_to_refine::<BridgeHubRococo, BridgeHubWestend>(
Default::default(),
msgs_to_refine,
);