mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 09:51:02 +00:00
Move relay clients to separate folder (#2893)
This commit is contained in:
committed by
Bastian Köcher
parent
9b685d5fc9
commit
449ea7b5bb
@@ -1,66 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "substrate-relay"
|
|
||||||
version = "1.2.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2021"
|
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow = "1.0"
|
|
||||||
async-std = "1.9.0"
|
|
||||||
async-trait = "0.1.79"
|
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5" }
|
|
||||||
env_logger = "0.11"
|
|
||||||
futures = "0.3.30"
|
|
||||||
hex = "0.4"
|
|
||||||
log = { workspace = true }
|
|
||||||
num-format = "0.4"
|
|
||||||
num-traits = "0.2"
|
|
||||||
rbtag = "0.3"
|
|
||||||
structopt = "0.3"
|
|
||||||
signal-hook = "0.3.15"
|
|
||||||
signal-hook-async-std = "0.2.2"
|
|
||||||
strum = { version = "0.26.2", features = ["derive"] }
|
|
||||||
|
|
||||||
# Bridge dependencies
|
|
||||||
bp-bridge-hub-polkadot = { path = "../../chains/chain-bridge-hub-polkadot" }
|
|
||||||
bp-bridge-hub-rococo = { path = "../../chains/chain-bridge-hub-rococo" }
|
|
||||||
bp-header-chain = { path = "../../primitives/header-chain" }
|
|
||||||
bp-messages = { path = "../../primitives/messages" }
|
|
||||||
bp-parachains = { path = "../../primitives/parachains" }
|
|
||||||
bp-polkadot-bulletin = { path = "../../chains/chain-polkadot-bulletin" }
|
|
||||||
bp-polkadot = { path = "../../chains/chain-polkadot" }
|
|
||||||
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
|
|
||||||
bp-rococo = { path = "../../chains/chain-rococo" }
|
|
||||||
bp-runtime = { path = "../../primitives/runtime" }
|
|
||||||
bridge-runtime-common = { path = "../../bin/runtime-common" }
|
|
||||||
pallet-bridge-parachains = { path = "../../modules/parachains" }
|
|
||||||
parachains-relay = { path = "../parachains" }
|
|
||||||
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-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" }
|
|
||||||
relay-westend-client = { path = "../client-westend" }
|
|
||||||
substrate-relay-helper = { path = "../lib-substrate-relay" }
|
|
||||||
|
|
||||||
# Substrate Dependencies
|
|
||||||
|
|
||||||
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
bp-test-utils = { path = "../../primitives/test-utils" }
|
|
||||||
hex-literal = "0.4"
|
|
||||||
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
tempfile = "3.10"
|
|
||||||
finality-grandpa = { version = "0.16.2" }
|
|
||||||
-68
@@ -1,68 +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/>.
|
|
||||||
|
|
||||||
//! BridgeHubKusama-to-BridgeHubPolkadot messages sync entrypoint.
|
|
||||||
|
|
||||||
use relay_bridge_hub_kusama_client::BridgeHubKusama;
|
|
||||||
use relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge},
|
|
||||||
messages_lane::SubstrateMessageLane,
|
|
||||||
UtilityPalletBatchCallBuilder,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// BridgeHubKusama-to-BridgeHubPolkadot messages bridge.
|
|
||||||
pub struct BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge {
|
|
||||||
type Source = BridgeHubKusama;
|
|
||||||
type Target = BridgeHubPolkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge {
|
|
||||||
type MessagesLane = BridgeHubKusamaMessagesToBridgeHubPolkadotMessageLane;
|
|
||||||
}
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_proof_call_builder!(
|
|
||||||
BridgeHubKusamaMessagesToBridgeHubPolkadotMessageLane,
|
|
||||||
BridgeHubKusamaMessagesToBridgeHubPolkadotMessageLaneReceiveMessagesProofCallBuilder,
|
|
||||||
relay_bridge_hub_polkadot_client::RuntimeCall::BridgeKusamaMessages,
|
|
||||||
relay_bridge_hub_polkadot_client::BridgeKusamaMessagesCall::receive_messages_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!(
|
|
||||||
BridgeHubKusamaMessagesToBridgeHubPolkadotMessageLane,
|
|
||||||
BridgeHubKusamaMessagesToBridgeHubPolkadotMessageLaneReceiveMessagesDeliveryProofCallBuilder,
|
|
||||||
relay_bridge_hub_kusama_client::RuntimeCall::BridgePolkadotMessages,
|
|
||||||
relay_bridge_hub_kusama_client::BridgeMessagesCall::receive_messages_delivery_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
/// BridgeHubKusama-to-BridgeHubPolkadot messages lane.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct BridgeHubKusamaMessagesToBridgeHubPolkadotMessageLane;
|
|
||||||
|
|
||||||
impl SubstrateMessageLane for BridgeHubKusamaMessagesToBridgeHubPolkadotMessageLane {
|
|
||||||
type SourceChain = BridgeHubKusama;
|
|
||||||
type TargetChain = BridgeHubPolkadot;
|
|
||||||
|
|
||||||
type ReceiveMessagesProofCallBuilder =
|
|
||||||
BridgeHubKusamaMessagesToBridgeHubPolkadotMessageLaneReceiveMessagesProofCallBuilder;
|
|
||||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
|
||||||
BridgeHubKusamaMessagesToBridgeHubPolkadotMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
|
||||||
|
|
||||||
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubKusama>;
|
|
||||||
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubPolkadot>;
|
|
||||||
}
|
|
||||||
-68
@@ -1,68 +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/>.
|
|
||||||
|
|
||||||
//! BridgeHubPolkadot-to-BridgeHubKusama messages sync entrypoint.
|
|
||||||
|
|
||||||
use relay_bridge_hub_kusama_client::BridgeHubKusama;
|
|
||||||
use relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge},
|
|
||||||
messages_lane::SubstrateMessageLane,
|
|
||||||
UtilityPalletBatchCallBuilder,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// BridgeHubPolkadot-to-BridgeHubKusama messages bridge.
|
|
||||||
pub struct BridgeHubPolkadotToBridgeHubKusamaMessagesCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for BridgeHubPolkadotToBridgeHubKusamaMessagesCliBridge {
|
|
||||||
type Source = BridgeHubPolkadot;
|
|
||||||
type Target = BridgeHubKusama;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for BridgeHubPolkadotToBridgeHubKusamaMessagesCliBridge {
|
|
||||||
type MessagesLane = BridgeHubPolkadotMessagesToBridgeHubKusamaMessageLane;
|
|
||||||
}
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_proof_call_builder!(
|
|
||||||
BridgeHubPolkadotMessagesToBridgeHubKusamaMessageLane,
|
|
||||||
BridgeHubPolkadotMessagesToBridgeHubKusamaMessageLaneReceiveMessagesProofCallBuilder,
|
|
||||||
relay_bridge_hub_kusama_client::RuntimeCall::BridgePolkadotMessages,
|
|
||||||
relay_bridge_hub_kusama_client::BridgeMessagesCall::receive_messages_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!(
|
|
||||||
BridgeHubPolkadotMessagesToBridgeHubKusamaMessageLane,
|
|
||||||
BridgeHubPolkadotMessagesToBridgeHubKusamaMessageLaneReceiveMessagesDeliveryProofCallBuilder,
|
|
||||||
relay_bridge_hub_polkadot_client::RuntimeCall::BridgeKusamaMessages,
|
|
||||||
relay_bridge_hub_polkadot_client::BridgeKusamaMessagesCall::receive_messages_delivery_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
/// BridgeHubPolkadot-to-BridgeHubKusama messages lane.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct BridgeHubPolkadotMessagesToBridgeHubKusamaMessageLane;
|
|
||||||
|
|
||||||
impl SubstrateMessageLane for BridgeHubPolkadotMessagesToBridgeHubKusamaMessageLane {
|
|
||||||
type SourceChain = BridgeHubPolkadot;
|
|
||||||
type TargetChain = BridgeHubKusama;
|
|
||||||
|
|
||||||
type ReceiveMessagesProofCallBuilder =
|
|
||||||
BridgeHubPolkadotMessagesToBridgeHubKusamaMessageLaneReceiveMessagesProofCallBuilder;
|
|
||||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
|
||||||
BridgeHubPolkadotMessagesToBridgeHubKusamaMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
|
||||||
|
|
||||||
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubPolkadot>;
|
|
||||||
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubKusama>;
|
|
||||||
}
|
|
||||||
-80
@@ -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/>.
|
|
||||||
|
|
||||||
//! Kusama-to-BridgeHubPolkadot headers sync entrypoint.
|
|
||||||
|
|
||||||
use substrate_relay_helper::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 Kusama -> PolkadotBridgeHub finalized headers bridge.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct KusamaFinalityToBridgeHubPolkadot;
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
|
||||||
KusamaFinalityToBridgeHubPolkadot,
|
|
||||||
SubmitFinalityProofCallBuilder,
|
|
||||||
relay_bridge_hub_polkadot_client::RuntimeCall::BridgeKusamaGrandpa,
|
|
||||||
relay_bridge_hub_polkadot_client::BridgeKusamaGrandpaCall::submit_finality_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_report_equivocation_call_builder!(
|
|
||||||
KusamaFinalityToBridgeHubPolkadot,
|
|
||||||
ReportEquivocationCallBuilder,
|
|
||||||
relay_kusama_client::RuntimeCall::Grandpa,
|
|
||||||
relay_kusama_client::GrandpaCall::report_equivocation
|
|
||||||
);
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalityPipeline for KusamaFinalityToBridgeHubPolkadot {
|
|
||||||
type SourceChain = relay_kusama_client::Kusama;
|
|
||||||
type TargetChain = relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
|
|
||||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalitySyncPipeline for KusamaFinalityToBridgeHubPolkadot {
|
|
||||||
type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateEquivocationDetectionPipeline for KusamaFinalityToBridgeHubPolkadot {
|
|
||||||
type ReportEquivocationCallBuilder = ReportEquivocationCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `Kusama` to BridgeHub `Polkadot` bridge definition.
|
|
||||||
pub struct KusamaToBridgeHubPolkadotCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for KusamaToBridgeHubPolkadotCliBridge {
|
|
||||||
type Source = relay_kusama_client::Kusama;
|
|
||||||
type Target = relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayHeadersCliBridge for KusamaToBridgeHubPolkadotCliBridge {
|
|
||||||
type Finality = KusamaFinalityToBridgeHubPolkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayEquivocationDetectionCliBridge for KusamaToBridgeHubPolkadotCliBridge {
|
|
||||||
type Equivocation = KusamaFinalityToBridgeHubPolkadot;
|
|
||||||
}
|
|
||||||
-75
@@ -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/>.
|
|
||||||
|
|
||||||
//! Kusama-to-BridgeHubPolkadot parachains sync entrypoint.
|
|
||||||
|
|
||||||
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
|
|
||||||
use relay_substrate_client::{CallOf, HeaderIdOf};
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge},
|
|
||||||
parachains::{SubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Kusama-to-BridgeHubPolkadot parachain sync description.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct BridgeHubKusamaToBridgeHubPolkadot;
|
|
||||||
|
|
||||||
impl SubstrateParachainsPipeline for BridgeHubKusamaToBridgeHubPolkadot {
|
|
||||||
type SourceParachain = relay_bridge_hub_kusama_client::BridgeHubKusama;
|
|
||||||
type SourceRelayChain = relay_kusama_client::Kusama;
|
|
||||||
type TargetChain = relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
|
|
||||||
type SubmitParachainHeadsCallBuilder = BridgeHubKusamaToBridgeHubPolkadotCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct BridgeHubKusamaToBridgeHubPolkadotCallBuilder;
|
|
||||||
impl SubmitParachainHeadsCallBuilder<BridgeHubKusamaToBridgeHubPolkadot>
|
|
||||||
for BridgeHubKusamaToBridgeHubPolkadotCallBuilder
|
|
||||||
{
|
|
||||||
fn build_submit_parachain_heads_call(
|
|
||||||
at_relay_block: HeaderIdOf<relay_kusama_client::Kusama>,
|
|
||||||
parachains: Vec<(ParaId, ParaHash)>,
|
|
||||||
parachain_heads_proof: ParaHeadsProof,
|
|
||||||
) -> CallOf<relay_bridge_hub_polkadot_client::BridgeHubPolkadot> {
|
|
||||||
relay_bridge_hub_polkadot_client::RuntimeCall::BridgeKusamaParachains(
|
|
||||||
relay_bridge_hub_polkadot_client::BridgeParachainCall::submit_parachain_heads {
|
|
||||||
at_relay_block: (at_relay_block.0, at_relay_block.1),
|
|
||||||
parachains,
|
|
||||||
parachain_heads_proof,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Kusama-to-BridgeHubPolkadot parachain sync description for the CLI.
|
|
||||||
pub struct BridgeHubKusamaToBridgeHubPolkadotCliBridge {}
|
|
||||||
|
|
||||||
impl ParachainToRelayHeadersCliBridge for BridgeHubKusamaToBridgeHubPolkadotCliBridge {
|
|
||||||
type SourceRelay = relay_kusama_client::Kusama;
|
|
||||||
type ParachainFinality = BridgeHubKusamaToBridgeHubPolkadot;
|
|
||||||
type RelayFinality =
|
|
||||||
crate::bridges::kusama_polkadot::kusama_headers_to_bridge_hub_polkadot::KusamaFinalityToBridgeHubPolkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CliBridgeBase for BridgeHubKusamaToBridgeHubPolkadotCliBridge {
|
|
||||||
type Source = relay_bridge_hub_kusama_client::BridgeHubKusama;
|
|
||||||
type Target = relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for BridgeHubKusamaToBridgeHubPolkadotCliBridge {
|
|
||||||
type MessagesLane =
|
|
||||||
crate::bridges::kusama_polkadot::bridge_hub_kusama_messages_to_bridge_hub_polkadot::BridgeHubKusamaMessagesToBridgeHubPolkadotMessageLane;
|
|
||||||
}
|
|
||||||
@@ -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 Kusama Bridge Hub and Polkadot Bridge Hub.
|
|
||||||
|
|
||||||
pub mod bridge_hub_kusama_messages_to_bridge_hub_polkadot;
|
|
||||||
pub mod bridge_hub_polkadot_messages_to_bridge_hub_kusama;
|
|
||||||
pub mod kusama_headers_to_bridge_hub_polkadot;
|
|
||||||
pub mod kusama_parachains_to_bridge_hub_polkadot;
|
|
||||||
pub mod polkadot_headers_to_bridge_hub_kusama;
|
|
||||||
pub mod polkadot_parachains_to_bridge_hub_kusama;
|
|
||||||
-80
@@ -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/>.
|
|
||||||
|
|
||||||
//! Polkadot-to-KusamaBridgeHub headers sync entrypoint.
|
|
||||||
|
|
||||||
use substrate_relay_helper::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 Polkadot -> KusamaBridgeHub finalized headers bridge.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct PolkadotFinalityToBridgeHubKusama;
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
|
||||||
PolkadotFinalityToBridgeHubKusama,
|
|
||||||
SubmitFinalityProofCallBuilder,
|
|
||||||
relay_bridge_hub_kusama_client::RuntimeCall::BridgePolkadotGrandpa,
|
|
||||||
relay_bridge_hub_kusama_client::BridgeGrandpaCall::submit_finality_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_report_equivocation_call_builder!(
|
|
||||||
PolkadotFinalityToBridgeHubKusama,
|
|
||||||
ReportEquivocationCallBuilder,
|
|
||||||
relay_polkadot_client::RuntimeCall::Grandpa,
|
|
||||||
relay_polkadot_client::GrandpaCall::report_equivocation
|
|
||||||
);
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalityPipeline for PolkadotFinalityToBridgeHubKusama {
|
|
||||||
type SourceChain = relay_polkadot_client::Polkadot;
|
|
||||||
type TargetChain = relay_bridge_hub_kusama_client::BridgeHubKusama;
|
|
||||||
|
|
||||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalitySyncPipeline for PolkadotFinalityToBridgeHubKusama {
|
|
||||||
type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateEquivocationDetectionPipeline for PolkadotFinalityToBridgeHubKusama {
|
|
||||||
type ReportEquivocationCallBuilder = ReportEquivocationCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `Polkadot` to BridgeHub `Kusama` bridge definition.
|
|
||||||
pub struct PolkadotToBridgeHubKusamaCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for PolkadotToBridgeHubKusamaCliBridge {
|
|
||||||
type Source = relay_polkadot_client::Polkadot;
|
|
||||||
type Target = relay_bridge_hub_kusama_client::BridgeHubKusama;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayHeadersCliBridge for PolkadotToBridgeHubKusamaCliBridge {
|
|
||||||
type Finality = PolkadotFinalityToBridgeHubKusama;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayEquivocationDetectionCliBridge for PolkadotToBridgeHubKusamaCliBridge {
|
|
||||||
type Equivocation = PolkadotFinalityToBridgeHubKusama;
|
|
||||||
}
|
|
||||||
-75
@@ -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/>.
|
|
||||||
|
|
||||||
//! Polkadot-to-BridgeHubKusama parachains sync entrypoint.
|
|
||||||
|
|
||||||
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
|
|
||||||
use relay_substrate_client::{CallOf, HeaderIdOf};
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge},
|
|
||||||
parachains::{SubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Polkadot-to-BridgeHubKusama parachain sync description.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct BridgeHubPolkadotToBridgeHubKusama;
|
|
||||||
|
|
||||||
impl SubstrateParachainsPipeline for BridgeHubPolkadotToBridgeHubKusama {
|
|
||||||
type SourceParachain = relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
type SourceRelayChain = relay_polkadot_client::Polkadot;
|
|
||||||
type TargetChain = relay_bridge_hub_kusama_client::BridgeHubKusama;
|
|
||||||
|
|
||||||
type SubmitParachainHeadsCallBuilder = BridgeHubPolkadotToBridgeHubKusamaCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct BridgeHubPolkadotToBridgeHubKusamaCallBuilder;
|
|
||||||
impl SubmitParachainHeadsCallBuilder<BridgeHubPolkadotToBridgeHubKusama>
|
|
||||||
for BridgeHubPolkadotToBridgeHubKusamaCallBuilder
|
|
||||||
{
|
|
||||||
fn build_submit_parachain_heads_call(
|
|
||||||
at_relay_block: HeaderIdOf<relay_polkadot_client::Polkadot>,
|
|
||||||
parachains: Vec<(ParaId, ParaHash)>,
|
|
||||||
parachain_heads_proof: ParaHeadsProof,
|
|
||||||
) -> CallOf<relay_bridge_hub_kusama_client::BridgeHubKusama> {
|
|
||||||
relay_bridge_hub_kusama_client::RuntimeCall::BridgePolkadotParachains(
|
|
||||||
relay_bridge_hub_kusama_client::BridgeParachainCall::submit_parachain_heads {
|
|
||||||
at_relay_block: (at_relay_block.0, at_relay_block.1),
|
|
||||||
parachains,
|
|
||||||
parachain_heads_proof,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Polkadot-to-BridgeHubKusama parachain sync description for the CLI.
|
|
||||||
pub struct BridgeHubPolkadotToBridgeHubKusamaCliBridge {}
|
|
||||||
|
|
||||||
impl ParachainToRelayHeadersCliBridge for BridgeHubPolkadotToBridgeHubKusamaCliBridge {
|
|
||||||
type SourceRelay = relay_polkadot_client::Polkadot;
|
|
||||||
type ParachainFinality = BridgeHubPolkadotToBridgeHubKusama;
|
|
||||||
type RelayFinality =
|
|
||||||
crate::bridges::kusama_polkadot::polkadot_headers_to_bridge_hub_kusama::PolkadotFinalityToBridgeHubKusama;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CliBridgeBase for BridgeHubPolkadotToBridgeHubKusamaCliBridge {
|
|
||||||
type Source = relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
type Target = relay_bridge_hub_kusama_client::BridgeHubKusama;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for BridgeHubPolkadotToBridgeHubKusamaCliBridge {
|
|
||||||
type MessagesLane =
|
|
||||||
crate::bridges::kusama_polkadot::bridge_hub_polkadot_messages_to_bridge_hub_kusama::BridgeHubPolkadotMessagesToBridgeHubKusamaMessageLane;
|
|
||||||
}
|
|
||||||
@@ -1,22 +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 that the relay is able to serve.
|
|
||||||
|
|
||||||
pub mod kusama_polkadot;
|
|
||||||
pub mod polkadot_bulletin;
|
|
||||||
pub mod rococo_bulletin;
|
|
||||||
pub mod rococo_westend;
|
|
||||||
-69
@@ -1,69 +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/>.
|
|
||||||
|
|
||||||
//! BridgeHubPolkadot-to-PolkadotBulletin messages sync entrypoint.
|
|
||||||
|
|
||||||
use relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
use relay_polkadot_bulletin_client::PolkadotBulletin;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge},
|
|
||||||
messages_lane::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::BridgePolkadotMessages,
|
|
||||||
relay_polkadot_bulletin_client::BridgePolkadotMessagesCall::receive_messages_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!(
|
|
||||||
BridgeHubPolkadotMessagesToPolkadotBulletinMessageLane,
|
|
||||||
BridgeHubPolkadotMessagesToPolkadotBulletinMessageLaneReceiveMessagesDeliveryProofCallBuilder,
|
|
||||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/2547 - use BridgePolkadotBulletinMessages
|
|
||||||
relay_bridge_hub_polkadot_client::RuntimeCall::BridgeKusamaMessages,
|
|
||||||
relay_bridge_hub_polkadot_client::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 = ();
|
|
||||||
}
|
|
||||||
@@ -1,23 +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 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;
|
|
||||||
-86
@@ -1,86 +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/>.
|
|
||||||
|
|
||||||
//! PolkadotBulletin-to-BridgeHubPolkadot headers sync entrypoint.
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
equivocation::SubstrateEquivocationDetectionPipeline,
|
|
||||||
finality::SubstrateFinalitySyncPipeline,
|
|
||||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
use substrate_relay_helper::cli::bridge::{
|
|
||||||
CliBridgeBase, MessagesCliBridge, RelayToRelayEquivocationDetectionCliBridge,
|
|
||||||
RelayToRelayHeadersCliBridge,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Description of `PolkadotBulletin` -> `PolkadotBridgeHub` finalized headers bridge.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct PolkadotBulletinFinalityToBridgeHubPolkadot;
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
|
||||||
PolkadotBulletinFinalityToBridgeHubPolkadot,
|
|
||||||
SubmitFinalityProofCallBuilder,
|
|
||||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/2547 - use BridgePolkadotBulletinGrandpa
|
|
||||||
relay_bridge_hub_polkadot_client::RuntimeCall::BridgeKusamaGrandpa,
|
|
||||||
relay_bridge_hub_polkadot_client::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_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;
|
|
||||||
}
|
|
||||||
-69
@@ -1,69 +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/>.
|
|
||||||
|
|
||||||
//! PolkadotBulletin-to-BridgeHubPolkadot messages sync entrypoint.
|
|
||||||
|
|
||||||
use relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
use relay_polkadot_bulletin_client::PolkadotBulletin;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge},
|
|
||||||
messages_lane::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,
|
|
||||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/2547 - use BridgePolkadotBulletinMessages
|
|
||||||
relay_bridge_hub_polkadot_client::RuntimeCall::BridgeKusamaMessages,
|
|
||||||
relay_bridge_hub_polkadot_client::BridgePolkadotBulletinMessagesCall::receive_messages_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!(
|
|
||||||
PolkadotBulletinMessagesToBridgeHubPolkadotMessageLane,
|
|
||||||
PolkadotBulletinMessagesToBridgeHubPolkadotMessageLaneReceiveMessagesDeliveryProofCallBuilder,
|
|
||||||
relay_polkadot_bulletin_client::RuntimeCall::BridgePolkadotMessages,
|
|
||||||
relay_polkadot_bulletin_client::BridgePolkadotMessagesCall::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>;
|
|
||||||
}
|
|
||||||
-80
@@ -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/>.
|
|
||||||
|
|
||||||
//! Polkadot-to-PolkadotBulletin headers sync entrypoint.
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
equivocation::SubstrateEquivocationDetectionPipeline,
|
|
||||||
finality::SubstrateFinalitySyncPipeline,
|
|
||||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
use substrate_relay_helper::cli::bridge::{
|
|
||||||
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// 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_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;
|
|
||||||
}
|
|
||||||
-94
@@ -1,94 +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/>.
|
|
||||||
|
|
||||||
//! Polkadot-to-PolkadotBulletin parachains sync entrypoint.
|
|
||||||
|
|
||||||
use substrate_relay_helper::cli::bridge::{
|
|
||||||
CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge,
|
|
||||||
};
|
|
||||||
|
|
||||||
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
|
|
||||||
use bp_runtime::Chain;
|
|
||||||
use relay_substrate_client::{CallOf, HeaderIdOf};
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
messages_lane::MessagesRelayLimits,
|
|
||||||
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<PolkadotToPolkadotBulletin>
|
|
||||||
for PolkadotToPolkadotBulletinCallBuilder
|
|
||||||
{
|
|
||||||
fn build_submit_parachain_heads_call(
|
|
||||||
at_relay_block: HeaderIdOf<relay_polkadot_client::Polkadot>,
|
|
||||||
parachains: Vec<(ParaId, ParaHash)>,
|
|
||||||
parachain_heads_proof: ParaHeadsProof,
|
|
||||||
) -> CallOf<relay_polkadot_bulletin_client::PolkadotBulletin> {
|
|
||||||
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;
|
|
||||||
|
|
||||||
fn maybe_messages_limits() -> Option<MessagesRelayLimits> {
|
|
||||||
// Polkadot Bulletin chain is missing the `TransactionPayment` runtime API (as well as the
|
|
||||||
// transaction payment pallet itself), so we can't estimate limits using runtime calls.
|
|
||||||
// Let's do it here.
|
|
||||||
//
|
|
||||||
// Folloiung constants are just safe **underestimations**. Normally, we are able to deliver
|
|
||||||
// and dispatch thousands of messages in the same transaction.
|
|
||||||
Some(MessagesRelayLimits {
|
|
||||||
max_messages_in_single_batch: 128,
|
|
||||||
max_messages_weight_in_single_batch:
|
|
||||||
bp_polkadot_bulletin::PolkadotBulletin::max_extrinsic_weight() / 20,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-68
@@ -1,68 +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-RococoBulletin messages sync entrypoint.
|
|
||||||
|
|
||||||
use super::BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
use relay_polkadot_bulletin_client::PolkadotBulletin as RococoBulletin;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge},
|
|
||||||
messages_lane::SubstrateMessageLane,
|
|
||||||
UtilityPalletBatchCallBuilder,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// BridgeHubRococo-to-RococoBulletin messages bridge.
|
|
||||||
pub struct BridgeHubRococoToRococoBulletinMessagesCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for BridgeHubRococoToRococoBulletinMessagesCliBridge {
|
|
||||||
type Source = BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
type Target = RococoBulletin;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for BridgeHubRococoToRococoBulletinMessagesCliBridge {
|
|
||||||
type MessagesLane = BridgeHubRococoMessagesToRococoBulletinMessageLane;
|
|
||||||
}
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_proof_call_builder!(
|
|
||||||
BridgeHubRococoMessagesToRococoBulletinMessageLane,
|
|
||||||
BridgeHubRococoMessagesToRococoBulletinMessageLaneReceiveMessagesProofCallBuilder,
|
|
||||||
relay_polkadot_bulletin_client::RuntimeCall::BridgePolkadotMessages,
|
|
||||||
relay_polkadot_bulletin_client::BridgePolkadotMessagesCall::receive_messages_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!(
|
|
||||||
BridgeHubRococoMessagesToRococoBulletinMessageLane,
|
|
||||||
BridgeHubRococoMessagesToRococoBulletinMessageLaneReceiveMessagesDeliveryProofCallBuilder,
|
|
||||||
relay_bridge_hub_rococo_client::RuntimeCall::BridgePolkadotBulletinMessages,
|
|
||||||
relay_bridge_hub_rococo_client::BridgeBulletinMessagesCall::receive_messages_delivery_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
/// BridgeHubRococo-to-RococoBulletin messages lane.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct BridgeHubRococoMessagesToRococoBulletinMessageLane;
|
|
||||||
|
|
||||||
impl SubstrateMessageLane for BridgeHubRococoMessagesToRococoBulletinMessageLane {
|
|
||||||
type SourceChain = BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
type TargetChain = RococoBulletin;
|
|
||||||
|
|
||||||
type ReceiveMessagesProofCallBuilder =
|
|
||||||
BridgeHubRococoMessagesToRococoBulletinMessageLaneReceiveMessagesProofCallBuilder;
|
|
||||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
|
||||||
BridgeHubRococoMessagesToRococoBulletinMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
|
||||||
|
|
||||||
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubRococoAsBridgeHubPolkadot>;
|
|
||||||
type TargetBatchCallBuilder = ();
|
|
||||||
}
|
|
||||||
@@ -1,237 +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 Bulletin Chain and Rococo Bridge Hub.
|
|
||||||
|
|
||||||
use bp_messages::MessageNonce;
|
|
||||||
use bp_runtime::{
|
|
||||||
AccountIdOf, BalanceOf, BlockNumberOf, ChainId, HashOf, HasherOf, HeaderOf, NonceOf,
|
|
||||||
SignatureOf,
|
|
||||||
};
|
|
||||||
use frame_support::pallet_prelude::Weight;
|
|
||||||
use relay_substrate_client::{
|
|
||||||
ChainWithRuntimeVersion, Error as SubstrateError, SignParam, SimpleRuntimeVersion,
|
|
||||||
UnsignedTransaction,
|
|
||||||
};
|
|
||||||
use sp_core::storage::StorageKey;
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
pub mod bridge_hub_rococo_messages_to_rococo_bulletin;
|
|
||||||
pub mod rococo_bulletin_headers_to_bridge_hub_rococo;
|
|
||||||
pub mod rococo_bulletin_messages_to_bridge_hub_rococo;
|
|
||||||
pub mod rococo_headers_to_rococo_bulletin;
|
|
||||||
pub mod rococo_parachains_to_rococo_bulletin;
|
|
||||||
|
|
||||||
/// Base `Chain` implementation of Rococo, pretending to be Polkadot.
|
|
||||||
pub struct RococoBaseAsPolkadot;
|
|
||||||
|
|
||||||
impl bp_runtime::Chain for RococoBaseAsPolkadot {
|
|
||||||
const ID: ChainId = relay_rococo_client::Rococo::ID;
|
|
||||||
|
|
||||||
type BlockNumber = BlockNumberOf<bp_rococo::Rococo>;
|
|
||||||
type Hash = HashOf<bp_rococo::Rococo>;
|
|
||||||
type Hasher = HasherOf<bp_rococo::Rococo>;
|
|
||||||
type Header = HeaderOf<bp_rococo::Rococo>;
|
|
||||||
|
|
||||||
type AccountId = AccountIdOf<bp_rococo::Rococo>;
|
|
||||||
type Balance = BalanceOf<bp_rococo::Rococo>;
|
|
||||||
type Nonce = NonceOf<bp_rococo::Rococo>;
|
|
||||||
type Signature = SignatureOf<bp_rococo::Rococo>;
|
|
||||||
|
|
||||||
fn max_extrinsic_size() -> u32 {
|
|
||||||
bp_rococo::Rococo::max_extrinsic_size()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn max_extrinsic_weight() -> Weight {
|
|
||||||
bp_rococo::Rococo::max_extrinsic_weight()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl bp_header_chain::ChainWithGrandpa for RococoBaseAsPolkadot {
|
|
||||||
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str =
|
|
||||||
bp_polkadot::Polkadot::WITH_CHAIN_GRANDPA_PALLET_NAME;
|
|
||||||
const MAX_AUTHORITIES_COUNT: u32 = bp_rococo::Rococo::MAX_AUTHORITIES_COUNT;
|
|
||||||
const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 =
|
|
||||||
bp_rococo::Rococo::REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY;
|
|
||||||
const MAX_MANDATORY_HEADER_SIZE: u32 = bp_rococo::Rococo::MAX_MANDATORY_HEADER_SIZE;
|
|
||||||
const AVERAGE_HEADER_SIZE: u32 = bp_rococo::Rococo::AVERAGE_HEADER_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Relay `Chain` implementation of Rococo, pretending to be Polkadot.
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub struct RococoAsPolkadot;
|
|
||||||
|
|
||||||
impl bp_runtime::UnderlyingChainProvider for RococoAsPolkadot {
|
|
||||||
type Chain = RococoBaseAsPolkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl relay_substrate_client::Chain for RococoAsPolkadot {
|
|
||||||
const NAME: &'static str = relay_rococo_client::Rococo::NAME;
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
relay_polkadot_client::Polkadot::BEST_FINALIZED_HEADER_ID_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration = relay_rococo_client::Rococo::AVERAGE_BLOCK_INTERVAL;
|
|
||||||
|
|
||||||
type SignedBlock = <relay_rococo_client::Rococo as relay_substrate_client::Chain>::SignedBlock;
|
|
||||||
type Call = <relay_rococo_client::Rococo as relay_substrate_client::Chain>::Call;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl relay_substrate_client::ChainWithGrandpa for RococoAsPolkadot {
|
|
||||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
|
||||||
relay_polkadot_client::Polkadot::SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
|
||||||
|
|
||||||
type KeyOwnerProof =
|
|
||||||
<relay_rococo_client::Rococo as relay_substrate_client::ChainWithGrandpa>::KeyOwnerProof;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl relay_substrate_client::ChainWithBalances for RococoAsPolkadot {
|
|
||||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
|
||||||
relay_rococo_client::Rococo::account_info_storage_key(account_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl relay_substrate_client::RelayChain for RococoAsPolkadot {
|
|
||||||
const PARAS_PALLET_NAME: &'static str = relay_rococo_client::Rococo::PARAS_PALLET_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl relay_substrate_client::ChainWithTransactions for RococoAsPolkadot {
|
|
||||||
type AccountKeyPair = <relay_rococo_client::Rococo as relay_substrate_client::ChainWithTransactions>::AccountKeyPair;
|
|
||||||
type SignedTransaction = <relay_rococo_client::Rococo as relay_substrate_client::ChainWithTransactions>::SignedTransaction;
|
|
||||||
|
|
||||||
fn sign_transaction(
|
|
||||||
param: SignParam<Self>,
|
|
||||||
unsigned: UnsignedTransaction<Self>,
|
|
||||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
|
||||||
relay_rococo_client::Rococo::sign_transaction(
|
|
||||||
SignParam {
|
|
||||||
spec_version: param.spec_version,
|
|
||||||
transaction_version: param.transaction_version,
|
|
||||||
genesis_hash: param.genesis_hash,
|
|
||||||
signer: param.signer,
|
|
||||||
},
|
|
||||||
unsigned.switch_chain(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for RococoAsPolkadot {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Base `Chain` implementation of Rococo Bridge Hub, pretending to be a Polkadot Bridge Hub.
|
|
||||||
pub struct BaseBridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
|
|
||||||
impl bp_runtime::Chain for BaseBridgeHubRococoAsBridgeHubPolkadot {
|
|
||||||
const ID: ChainId = relay_bridge_hub_rococo_client::BridgeHubRococo::ID;
|
|
||||||
|
|
||||||
type BlockNumber = BlockNumberOf<bp_bridge_hub_rococo::BridgeHubRococo>;
|
|
||||||
type Hash = HashOf<bp_bridge_hub_rococo::BridgeHubRococo>;
|
|
||||||
type Hasher = HasherOf<bp_bridge_hub_rococo::BridgeHubRococo>;
|
|
||||||
type Header = HeaderOf<bp_bridge_hub_rococo::BridgeHubRococo>;
|
|
||||||
|
|
||||||
type AccountId = AccountIdOf<bp_bridge_hub_rococo::BridgeHubRococo>;
|
|
||||||
type Balance = BalanceOf<bp_bridge_hub_rococo::BridgeHubRococo>;
|
|
||||||
type Nonce = NonceOf<bp_bridge_hub_rococo::BridgeHubRococo>;
|
|
||||||
type Signature = SignatureOf<bp_bridge_hub_rococo::BridgeHubRococo>;
|
|
||||||
|
|
||||||
fn max_extrinsic_size() -> u32 {
|
|
||||||
bp_bridge_hub_rococo::BridgeHubRococo::max_extrinsic_size()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn max_extrinsic_weight() -> Weight {
|
|
||||||
bp_bridge_hub_rococo::BridgeHubRococo::max_extrinsic_weight()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl bp_runtime::Parachain for BaseBridgeHubRococoAsBridgeHubPolkadot {
|
|
||||||
const PARACHAIN_ID: u32 = bp_bridge_hub_rococo::BridgeHubRococo::PARACHAIN_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl bp_messages::ChainWithMessages for BaseBridgeHubRococoAsBridgeHubPolkadot {
|
|
||||||
const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
|
|
||||||
relay_bridge_hub_polkadot_client::BridgeHubPolkadot::WITH_CHAIN_MESSAGES_PALLET_NAME;
|
|
||||||
|
|
||||||
const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
|
|
||||||
relay_bridge_hub_rococo_client::BridgeHubRococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
|
|
||||||
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
|
|
||||||
relay_bridge_hub_rococo_client::BridgeHubRococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Relay `Chain` implementation of Rococo Bridge Hub, pretending to be a Polkadot Bridge Hub.
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
pub struct BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
|
|
||||||
impl bp_runtime::UnderlyingChainProvider for BridgeHubRococoAsBridgeHubPolkadot {
|
|
||||||
type Chain = BaseBridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl relay_substrate_client::Chain for BridgeHubRococoAsBridgeHubPolkadot {
|
|
||||||
const NAME: &'static str = relay_bridge_hub_rococo_client::BridgeHubRococo::NAME;
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
relay_bridge_hub_polkadot_client::BridgeHubPolkadot::BEST_FINALIZED_HEADER_ID_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration =
|
|
||||||
relay_bridge_hub_rococo_client::BridgeHubRococo::AVERAGE_BLOCK_INTERVAL;
|
|
||||||
|
|
||||||
type SignedBlock = <relay_bridge_hub_rococo_client::BridgeHubRococo as relay_substrate_client::Chain>::SignedBlock;
|
|
||||||
type Call =
|
|
||||||
<relay_bridge_hub_rococo_client::BridgeHubRococo as relay_substrate_client::Chain>::Call;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl relay_substrate_client::ChainWithBalances for BridgeHubRococoAsBridgeHubPolkadot {
|
|
||||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
|
||||||
relay_bridge_hub_rococo_client::BridgeHubRococo::account_info_storage_key(account_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl relay_substrate_client::ChainWithUtilityPallet for BridgeHubRococoAsBridgeHubPolkadot {
|
|
||||||
type UtilityPallet = relay_substrate_client::MockedRuntimeUtilityPallet<
|
|
||||||
relay_bridge_hub_rococo_client::RuntimeCall,
|
|
||||||
>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl relay_substrate_client::ChainWithTransactions for BridgeHubRococoAsBridgeHubPolkadot {
|
|
||||||
type AccountKeyPair = <relay_bridge_hub_rococo_client::BridgeHubRococo as relay_substrate_client::ChainWithTransactions>::AccountKeyPair;
|
|
||||||
type SignedTransaction = <relay_bridge_hub_rococo_client::BridgeHubRococo as relay_substrate_client::ChainWithTransactions>::SignedTransaction;
|
|
||||||
|
|
||||||
fn sign_transaction(
|
|
||||||
param: SignParam<Self>,
|
|
||||||
unsigned: UnsignedTransaction<Self>,
|
|
||||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
|
||||||
relay_bridge_hub_rococo_client::BridgeHubRococo::sign_transaction(
|
|
||||||
SignParam {
|
|
||||||
spec_version: param.spec_version,
|
|
||||||
transaction_version: param.transaction_version,
|
|
||||||
genesis_hash: param.genesis_hash,
|
|
||||||
signer: param.signer,
|
|
||||||
},
|
|
||||||
unsigned.switch_chain(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl relay_substrate_client::ChainWithMessages for BridgeHubRococoAsBridgeHubPolkadot {
|
|
||||||
const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
|
|
||||||
relay_bridge_hub_polkadot_client::BridgeHubPolkadot::WITH_CHAIN_RELAYERS_PALLET_NAME;
|
|
||||||
|
|
||||||
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
|
||||||
relay_bridge_hub_polkadot_client::BridgeHubPolkadot::TO_CHAIN_MESSAGE_DETAILS_METHOD;
|
|
||||||
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
|
||||||
relay_bridge_hub_polkadot_client::BridgeHubPolkadot::FROM_CHAIN_MESSAGE_DETAILS_METHOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for BridgeHubRococoAsBridgeHubPolkadot {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
|
||||||
Some(SimpleRuntimeVersion { spec_version: 1_003_000, transaction_version: 3 });
|
|
||||||
}
|
|
||||||
-87
@@ -1,87 +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/>.
|
|
||||||
|
|
||||||
//! RococoBulletin-to-BridgeHubRococo headers sync entrypoint.
|
|
||||||
|
|
||||||
use super::BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
equivocation::SubstrateEquivocationDetectionPipeline,
|
|
||||||
finality::SubstrateFinalitySyncPipeline,
|
|
||||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
use substrate_relay_helper::cli::bridge::{
|
|
||||||
CliBridgeBase, MessagesCliBridge, RelayToRelayEquivocationDetectionCliBridge,
|
|
||||||
RelayToRelayHeadersCliBridge,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Description of `RococoBulletin` -> `RococoBridgeHub` finalized headers bridge.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct RococoBulletinFinalityToBridgeHubRococo;
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
|
||||||
RococoBulletinFinalityToBridgeHubRococo,
|
|
||||||
SubmitFinalityProofCallBuilder,
|
|
||||||
relay_bridge_hub_rococo_client::RuntimeCall::BridgePolkadotBulletinGrandpa,
|
|
||||||
relay_bridge_hub_rococo_client::BridgeBulletinGrandpaCall::submit_finality_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_report_equivocation_call_builder!(
|
|
||||||
RococoBulletinFinalityToBridgeHubRococo,
|
|
||||||
ReportEquivocationCallBuilder,
|
|
||||||
relay_polkadot_bulletin_client::RuntimeCall::Grandpa,
|
|
||||||
relay_polkadot_bulletin_client::GrandpaCall::report_equivocation
|
|
||||||
);
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalityPipeline for RococoBulletinFinalityToBridgeHubRococo {
|
|
||||||
type SourceChain = relay_polkadot_bulletin_client::PolkadotBulletin;
|
|
||||||
type TargetChain = BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
|
|
||||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalitySyncPipeline for RococoBulletinFinalityToBridgeHubRococo {
|
|
||||||
type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateEquivocationDetectionPipeline for RococoBulletinFinalityToBridgeHubRococo {
|
|
||||||
type ReportEquivocationCallBuilder = ReportEquivocationCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `RococoBulletin` to BridgeHub `Rococo` bridge definition.
|
|
||||||
pub struct RococoBulletinToBridgeHubRococoCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for RococoBulletinToBridgeHubRococoCliBridge {
|
|
||||||
type Source = relay_polkadot_bulletin_client::PolkadotBulletin;
|
|
||||||
type Target = BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayHeadersCliBridge for RococoBulletinToBridgeHubRococoCliBridge {
|
|
||||||
type Finality = RococoBulletinFinalityToBridgeHubRococo;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayEquivocationDetectionCliBridge for RococoBulletinToBridgeHubRococoCliBridge {
|
|
||||||
type Equivocation = RococoBulletinFinalityToBridgeHubRococo;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for RococoBulletinToBridgeHubRococoCliBridge {
|
|
||||||
type MessagesLane = crate::bridges::rococo_bulletin::rococo_bulletin_messages_to_bridge_hub_rococo::RococoBulletinMessagesToBridgeHubRococoMessageLane;
|
|
||||||
}
|
|
||||||
-68
@@ -1,68 +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/>.
|
|
||||||
|
|
||||||
//! RococoBulletin-to-BridgeHubRococo messages sync entrypoint.
|
|
||||||
|
|
||||||
use super::BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
use relay_polkadot_bulletin_client::PolkadotBulletin as RococoBulletin;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge},
|
|
||||||
messages_lane::SubstrateMessageLane,
|
|
||||||
UtilityPalletBatchCallBuilder,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// RococoBulletin-to-BridgeHubRococo messages bridge.
|
|
||||||
pub struct RococoBulletinToBridgeHubRococoMessagesCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for RococoBulletinToBridgeHubRococoMessagesCliBridge {
|
|
||||||
type Source = RococoBulletin;
|
|
||||||
type Target = BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for RococoBulletinToBridgeHubRococoMessagesCliBridge {
|
|
||||||
type MessagesLane = RococoBulletinMessagesToBridgeHubRococoMessageLane;
|
|
||||||
}
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_proof_call_builder!(
|
|
||||||
RococoBulletinMessagesToBridgeHubRococoMessageLane,
|
|
||||||
RococoBulletinMessagesToBridgeHubRococoMessageLaneReceiveMessagesProofCallBuilder,
|
|
||||||
relay_bridge_hub_rococo_client::RuntimeCall::BridgePolkadotBulletinMessages,
|
|
||||||
relay_bridge_hub_rococo_client::BridgeBulletinMessagesCall::receive_messages_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!(
|
|
||||||
RococoBulletinMessagesToBridgeHubRococoMessageLane,
|
|
||||||
RococoBulletinMessagesToBridgeHubRococoMessageLaneReceiveMessagesDeliveryProofCallBuilder,
|
|
||||||
relay_polkadot_bulletin_client::RuntimeCall::BridgePolkadotMessages,
|
|
||||||
relay_polkadot_bulletin_client::BridgePolkadotMessagesCall::receive_messages_delivery_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
/// RococoBulletin-to-BridgeHubRococo messages lane.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct RococoBulletinMessagesToBridgeHubRococoMessageLane;
|
|
||||||
|
|
||||||
impl SubstrateMessageLane for RococoBulletinMessagesToBridgeHubRococoMessageLane {
|
|
||||||
type SourceChain = RococoBulletin;
|
|
||||||
type TargetChain = BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
|
|
||||||
type ReceiveMessagesProofCallBuilder =
|
|
||||||
RococoBulletinMessagesToBridgeHubRococoMessageLaneReceiveMessagesProofCallBuilder;
|
|
||||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
|
||||||
RococoBulletinMessagesToBridgeHubRococoMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
|
||||||
|
|
||||||
type SourceBatchCallBuilder = ();
|
|
||||||
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubRococoAsBridgeHubPolkadot>;
|
|
||||||
}
|
|
||||||
-82
@@ -1,82 +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-RococoBulletin headers sync entrypoint.
|
|
||||||
|
|
||||||
use super::RococoAsPolkadot;
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
equivocation::SubstrateEquivocationDetectionPipeline,
|
|
||||||
finality::SubstrateFinalitySyncPipeline,
|
|
||||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
use substrate_relay_helper::cli::bridge::{
|
|
||||||
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Description of Rococo -> `RococoBulletin` finalized headers bridge.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct RococoFinalityToRococoBulletin;
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
|
||||||
RococoFinalityToRococoBulletin,
|
|
||||||
SubmitFinalityProofCallBuilder,
|
|
||||||
relay_polkadot_bulletin_client::RuntimeCall::BridgePolkadotGrandpa,
|
|
||||||
relay_polkadot_bulletin_client::BridgePolkadotGrandpaCall::submit_finality_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_report_equivocation_call_builder!(
|
|
||||||
RococoFinalityToRococoBulletin,
|
|
||||||
ReportEquivocationCallBuilder,
|
|
||||||
relay_rococo_client::RuntimeCall::Grandpa,
|
|
||||||
relay_rococo_client::GrandpaCall::report_equivocation
|
|
||||||
);
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalityPipeline for RococoFinalityToRococoBulletin {
|
|
||||||
type SourceChain = RococoAsPolkadot;
|
|
||||||
type TargetChain = relay_polkadot_bulletin_client::PolkadotBulletin;
|
|
||||||
|
|
||||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalitySyncPipeline for RococoFinalityToRococoBulletin {
|
|
||||||
type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateEquivocationDetectionPipeline for RococoFinalityToRococoBulletin {
|
|
||||||
type ReportEquivocationCallBuilder = ReportEquivocationCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `Rococo` to BridgeHub `RococoBulletin` bridge definition.
|
|
||||||
pub struct RococoToRococoBulletinCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for RococoToRococoBulletinCliBridge {
|
|
||||||
type Source = RococoAsPolkadot;
|
|
||||||
type Target = relay_polkadot_bulletin_client::PolkadotBulletin;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayHeadersCliBridge for RococoToRococoBulletinCliBridge {
|
|
||||||
type Finality = RococoFinalityToRococoBulletin;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayEquivocationDetectionCliBridge for RococoToRococoBulletinCliBridge {
|
|
||||||
type Equivocation = RococoFinalityToRococoBulletin;
|
|
||||||
}
|
|
||||||
-91
@@ -1,91 +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-RococoBulletin parachains sync entrypoint.
|
|
||||||
|
|
||||||
use super::{BridgeHubRococoAsBridgeHubPolkadot, RococoAsPolkadot};
|
|
||||||
|
|
||||||
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
|
|
||||||
use bp_runtime::Chain;
|
|
||||||
use relay_substrate_client::{CallOf, HeaderIdOf};
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge},
|
|
||||||
messages_lane::MessagesRelayLimits,
|
|
||||||
parachains::{SubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Rococo-to-RococoBulletin parachain sync description.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct RococoToRococoBulletin;
|
|
||||||
|
|
||||||
impl SubstrateParachainsPipeline for RococoToRococoBulletin {
|
|
||||||
type SourceParachain = BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
type SourceRelayChain = RococoAsPolkadot;
|
|
||||||
type TargetChain = relay_polkadot_bulletin_client::PolkadotBulletin;
|
|
||||||
|
|
||||||
type SubmitParachainHeadsCallBuilder = RococoToRococoBulletinCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct RococoToRococoBulletinCallBuilder;
|
|
||||||
impl SubmitParachainHeadsCallBuilder<RococoToRococoBulletin> for RococoToRococoBulletinCallBuilder {
|
|
||||||
fn build_submit_parachain_heads_call(
|
|
||||||
at_relay_block: HeaderIdOf<relay_rococo_client::Rococo>,
|
|
||||||
parachains: Vec<(ParaId, ParaHash)>,
|
|
||||||
parachain_heads_proof: ParaHeadsProof,
|
|
||||||
) -> CallOf<relay_polkadot_bulletin_client::PolkadotBulletin> {
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Rococo-to-RococoBulletin parachain sync description for the CLI.
|
|
||||||
pub struct RococoToRococoBulletinCliBridge {}
|
|
||||||
|
|
||||||
impl ParachainToRelayHeadersCliBridge for RococoToRococoBulletinCliBridge {
|
|
||||||
type SourceRelay = RococoAsPolkadot;
|
|
||||||
type ParachainFinality = RococoToRococoBulletin;
|
|
||||||
type RelayFinality =
|
|
||||||
crate::bridges::rococo_bulletin::rococo_headers_to_rococo_bulletin::RococoFinalityToRococoBulletin;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CliBridgeBase for RococoToRococoBulletinCliBridge {
|
|
||||||
type Source = BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
type Target = relay_polkadot_bulletin_client::PolkadotBulletin;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for RococoToRococoBulletinCliBridge {
|
|
||||||
type MessagesLane =
|
|
||||||
crate::bridges::rococo_bulletin::bridge_hub_rococo_messages_to_rococo_bulletin::BridgeHubRococoMessagesToRococoBulletinMessageLane;
|
|
||||||
|
|
||||||
fn maybe_messages_limits() -> Option<MessagesRelayLimits> {
|
|
||||||
// Rococo Bulletin chain is missing the `TransactionPayment` runtime API (as well as the
|
|
||||||
// transaction payment pallet itself), so we can't estimate limits using runtime calls.
|
|
||||||
// Let's do it here.
|
|
||||||
//
|
|
||||||
// Folloiung constants are just safe **underestimations**. Normally, we are able to deliver
|
|
||||||
// and dispatch thousands of messages in the same transaction.
|
|
||||||
Some(MessagesRelayLimits {
|
|
||||||
max_messages_in_single_batch: 128,
|
|
||||||
max_messages_weight_in_single_batch:
|
|
||||||
bp_polkadot_bulletin::PolkadotBulletin::max_extrinsic_weight() / 20,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-67
@@ -1,67 +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-BridgeHubWestend messages sync entrypoint.
|
|
||||||
|
|
||||||
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
|
||||||
use relay_bridge_hub_westend_client::BridgeHubWestend;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge},
|
|
||||||
messages_lane::SubstrateMessageLane,
|
|
||||||
UtilityPalletBatchCallBuilder,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct BridgeHubRococoToBridgeHubWestendMessagesCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for BridgeHubRococoToBridgeHubWestendMessagesCliBridge {
|
|
||||||
type Source = BridgeHubRococo;
|
|
||||||
type Target = BridgeHubWestend;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for BridgeHubRococoToBridgeHubWestendMessagesCliBridge {
|
|
||||||
type MessagesLane = BridgeHubRococoMessagesToBridgeHubWestendMessageLane;
|
|
||||||
}
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_proof_call_builder!(
|
|
||||||
BridgeHubRococoMessagesToBridgeHubWestendMessageLane,
|
|
||||||
BridgeHubRococoMessagesToBridgeHubWestendMessageLaneReceiveMessagesProofCallBuilder,
|
|
||||||
relay_bridge_hub_westend_client::RuntimeCall::BridgeRococoMessages,
|
|
||||||
relay_bridge_hub_westend_client::BridgeMessagesCall::receive_messages_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!(
|
|
||||||
BridgeHubRococoMessagesToBridgeHubWestendMessageLane,
|
|
||||||
BridgeHubRococoMessagesToBridgeHubWestendMessageLaneReceiveMessagesDeliveryProofCallBuilder,
|
|
||||||
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWestendMessages,
|
|
||||||
relay_bridge_hub_rococo_client::BridgeMessagesCall::receive_messages_delivery_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Description of BridgeHubRococo -> BridgeHubWestendWestend messages bridge.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct BridgeHubRococoMessagesToBridgeHubWestendMessageLane;
|
|
||||||
|
|
||||||
impl SubstrateMessageLane for BridgeHubRococoMessagesToBridgeHubWestendMessageLane {
|
|
||||||
type SourceChain = BridgeHubRococo;
|
|
||||||
type TargetChain = BridgeHubWestend;
|
|
||||||
|
|
||||||
type ReceiveMessagesProofCallBuilder =
|
|
||||||
BridgeHubRococoMessagesToBridgeHubWestendMessageLaneReceiveMessagesProofCallBuilder;
|
|
||||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
|
||||||
BridgeHubRococoMessagesToBridgeHubWestendMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
|
||||||
|
|
||||||
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubRococo>;
|
|
||||||
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubWestend>;
|
|
||||||
}
|
|
||||||
-67
@@ -1,67 +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/>.
|
|
||||||
|
|
||||||
//! BridgeHubWestend-to-BridgeHubRococo messages sync entrypoint.
|
|
||||||
|
|
||||||
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
|
||||||
use relay_bridge_hub_westend_client::BridgeHubWestend;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge},
|
|
||||||
messages_lane::SubstrateMessageLane,
|
|
||||||
UtilityPalletBatchCallBuilder,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct BridgeHubWestendToBridgeHubRococoMessagesCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for BridgeHubWestendToBridgeHubRococoMessagesCliBridge {
|
|
||||||
type Source = BridgeHubWestend;
|
|
||||||
type Target = BridgeHubRococo;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for BridgeHubWestendToBridgeHubRococoMessagesCliBridge {
|
|
||||||
type MessagesLane = BridgeHubWestendMessagesToBridgeHubRococoMessageLane;
|
|
||||||
}
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_proof_call_builder!(
|
|
||||||
BridgeHubWestendMessagesToBridgeHubRococoMessageLane,
|
|
||||||
BridgeHubWestendMessagesToBridgeHubRococoMessageLaneReceiveMessagesProofCallBuilder,
|
|
||||||
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWestendMessages,
|
|
||||||
relay_bridge_hub_rococo_client::BridgeMessagesCall::receive_messages_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!(
|
|
||||||
BridgeHubWestendMessagesToBridgeHubRococoMessageLane,
|
|
||||||
BridgeHubWestendMessagesToBridgeHubRococoMessageLaneReceiveMessagesDeliveryProofCallBuilder,
|
|
||||||
relay_bridge_hub_westend_client::RuntimeCall::BridgeRococoMessages,
|
|
||||||
relay_bridge_hub_westend_client::BridgeMessagesCall::receive_messages_delivery_proof
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Description of BridgeHubWestend -> BridgeHubRococo messages bridge.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct BridgeHubWestendMessagesToBridgeHubRococoMessageLane;
|
|
||||||
|
|
||||||
impl SubstrateMessageLane for BridgeHubWestendMessagesToBridgeHubRococoMessageLane {
|
|
||||||
type SourceChain = BridgeHubWestend;
|
|
||||||
type TargetChain = BridgeHubRococo;
|
|
||||||
|
|
||||||
type ReceiveMessagesProofCallBuilder =
|
|
||||||
BridgeHubWestendMessagesToBridgeHubRococoMessageLaneReceiveMessagesProofCallBuilder;
|
|
||||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
|
||||||
BridgeHubWestendMessagesToBridgeHubRococoMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
|
||||||
|
|
||||||
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubWestend>;
|
|
||||||
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 Westend Bridge Hub.
|
|
||||||
|
|
||||||
pub mod bridge_hub_rococo_messages_to_bridge_hub_westend;
|
|
||||||
pub mod bridge_hub_westend_messages_to_bridge_hub_rococo;
|
|
||||||
pub mod rococo_headers_to_bridge_hub_westend;
|
|
||||||
pub mod rococo_parachains_to_bridge_hub_westend;
|
|
||||||
pub mod westend_headers_to_bridge_hub_rococo;
|
|
||||||
pub mod westend_parachains_to_bridge_hub_rococo;
|
|
||||||
-80
@@ -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-Westend bridge hubs headers sync entrypoint.
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
equivocation::SubstrateEquivocationDetectionPipeline,
|
|
||||||
finality::SubstrateFinalitySyncPipeline,
|
|
||||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
use substrate_relay_helper::cli::bridge::{
|
|
||||||
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Description of Rococo -> Westend finalized headers bridge.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct RococoFinalityToBridgeHubWestend;
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_submit_finality_proof_ex_call_builder!(
|
|
||||||
RococoFinalityToBridgeHubWestend,
|
|
||||||
SubmitFinalityProofCallBuilder,
|
|
||||||
relay_bridge_hub_westend_client::RuntimeCall::BridgeRococoGrandpa,
|
|
||||||
relay_bridge_hub_westend_client::BridgeGrandpaCall::submit_finality_proof_ex
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_report_equivocation_call_builder!(
|
|
||||||
RococoFinalityToBridgeHubWestend,
|
|
||||||
ReportEquivocationCallBuilder,
|
|
||||||
relay_rococo_client::RuntimeCall::Grandpa,
|
|
||||||
relay_rococo_client::GrandpaCall::report_equivocation
|
|
||||||
);
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalityPipeline for RococoFinalityToBridgeHubWestend {
|
|
||||||
type SourceChain = relay_rococo_client::Rococo;
|
|
||||||
type TargetChain = relay_bridge_hub_westend_client::BridgeHubWestend;
|
|
||||||
|
|
||||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalitySyncPipeline for RococoFinalityToBridgeHubWestend {
|
|
||||||
type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateEquivocationDetectionPipeline for RococoFinalityToBridgeHubWestend {
|
|
||||||
type ReportEquivocationCallBuilder = ReportEquivocationCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `Rococo` to BridgeHub `Westend` bridge definition.
|
|
||||||
pub struct RococoToBridgeHubWestendCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for RococoToBridgeHubWestendCliBridge {
|
|
||||||
type Source = relay_rococo_client::Rococo;
|
|
||||||
type Target = relay_bridge_hub_westend_client::BridgeHubWestend;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayHeadersCliBridge for RococoToBridgeHubWestendCliBridge {
|
|
||||||
type Finality = RococoFinalityToBridgeHubWestend;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayEquivocationDetectionCliBridge for RococoToBridgeHubWestendCliBridge {
|
|
||||||
type Equivocation = RococoFinalityToBridgeHubWestend;
|
|
||||||
}
|
|
||||||
-75
@@ -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/>.
|
|
||||||
|
|
||||||
//! Westend-to-Rococo parachains sync entrypoint.
|
|
||||||
|
|
||||||
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
|
|
||||||
use relay_substrate_client::{CallOf, HeaderIdOf};
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge},
|
|
||||||
parachains::{SubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// BridgeHub-to-BridgeHub parachain sync description.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct BridgeHubRococoToBridgeHubWestend;
|
|
||||||
|
|
||||||
impl SubstrateParachainsPipeline for BridgeHubRococoToBridgeHubWestend {
|
|
||||||
type SourceParachain = relay_bridge_hub_rococo_client::BridgeHubRococo;
|
|
||||||
type SourceRelayChain = relay_rococo_client::Rococo;
|
|
||||||
type TargetChain = relay_bridge_hub_westend_client::BridgeHubWestend;
|
|
||||||
|
|
||||||
type SubmitParachainHeadsCallBuilder = BridgeHubRococoToBridgeHubWestendCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct BridgeHubRococoToBridgeHubWestendCallBuilder;
|
|
||||||
impl SubmitParachainHeadsCallBuilder<BridgeHubRococoToBridgeHubWestend>
|
|
||||||
for BridgeHubRococoToBridgeHubWestendCallBuilder
|
|
||||||
{
|
|
||||||
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_westend_client::BridgeHubWestend> {
|
|
||||||
relay_bridge_hub_westend_client::RuntimeCall::BridgeRococoParachains(
|
|
||||||
relay_bridge_hub_westend_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 BridgeHubRococoToBridgeHubWestendCliBridge {}
|
|
||||||
|
|
||||||
impl ParachainToRelayHeadersCliBridge for BridgeHubRococoToBridgeHubWestendCliBridge {
|
|
||||||
type SourceRelay = relay_rococo_client::Rococo;
|
|
||||||
type ParachainFinality = BridgeHubRococoToBridgeHubWestend;
|
|
||||||
type RelayFinality =
|
|
||||||
crate::bridges::rococo_westend::rococo_headers_to_bridge_hub_westend::RococoFinalityToBridgeHubWestend;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CliBridgeBase for BridgeHubRococoToBridgeHubWestendCliBridge {
|
|
||||||
type Source = relay_bridge_hub_rococo_client::BridgeHubRococo;
|
|
||||||
type Target = relay_bridge_hub_westend_client::BridgeHubWestend;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for BridgeHubRococoToBridgeHubWestendCliBridge {
|
|
||||||
type MessagesLane =
|
|
||||||
crate::bridges::rococo_westend::bridge_hub_rococo_messages_to_bridge_hub_westend::BridgeHubRococoMessagesToBridgeHubWestendMessageLane;
|
|
||||||
}
|
|
||||||
-80
@@ -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/>.
|
|
||||||
|
|
||||||
//! Westend-to-Rococo bridge hubs headers sync entrypoint.
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
equivocation::SubstrateEquivocationDetectionPipeline,
|
|
||||||
finality::SubstrateFinalitySyncPipeline,
|
|
||||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
use substrate_relay_helper::cli::bridge::{
|
|
||||||
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Description of Westend -> Rococo finalized headers bridge.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct WestendFinalityToBridgeHubRococo;
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_submit_finality_proof_ex_call_builder!(
|
|
||||||
WestendFinalityToBridgeHubRococo,
|
|
||||||
SubmitFinalityProofCallBuilder,
|
|
||||||
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWestendGrandpa,
|
|
||||||
relay_bridge_hub_rococo_client::BridgeGrandpaCall::submit_finality_proof_ex
|
|
||||||
);
|
|
||||||
|
|
||||||
substrate_relay_helper::generate_report_equivocation_call_builder!(
|
|
||||||
WestendFinalityToBridgeHubRococo,
|
|
||||||
ReportEquivocationCallBuilder,
|
|
||||||
relay_westend_client::RuntimeCall::Grandpa,
|
|
||||||
relay_westend_client::GrandpaCall::report_equivocation
|
|
||||||
);
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalityPipeline for WestendFinalityToBridgeHubRococo {
|
|
||||||
type SourceChain = relay_westend_client::Westend;
|
|
||||||
type TargetChain = relay_bridge_hub_rococo_client::BridgeHubRococo;
|
|
||||||
|
|
||||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateFinalitySyncPipeline for WestendFinalityToBridgeHubRococo {
|
|
||||||
type SubmitFinalityProofCallBuilder = SubmitFinalityProofCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SubstrateEquivocationDetectionPipeline for WestendFinalityToBridgeHubRococo {
|
|
||||||
type ReportEquivocationCallBuilder = ReportEquivocationCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `Westend` to BridgeHub `Rococo` bridge definition.
|
|
||||||
pub struct WestendToBridgeHubRococoCliBridge {}
|
|
||||||
|
|
||||||
impl CliBridgeBase for WestendToBridgeHubRococoCliBridge {
|
|
||||||
type Source = relay_westend_client::Westend;
|
|
||||||
type Target = relay_bridge_hub_rococo_client::BridgeHubRococo;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayHeadersCliBridge for WestendToBridgeHubRococoCliBridge {
|
|
||||||
type Finality = WestendFinalityToBridgeHubRococo;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayToRelayEquivocationDetectionCliBridge for WestendToBridgeHubRococoCliBridge {
|
|
||||||
type Equivocation = WestendFinalityToBridgeHubRococo;
|
|
||||||
}
|
|
||||||
-75
@@ -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-Westend parachains sync entrypoint.
|
|
||||||
|
|
||||||
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
|
|
||||||
use relay_substrate_client::{CallOf, HeaderIdOf};
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge},
|
|
||||||
parachains::{SubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// BridgeHub-to-BridgeHub parachain sync description.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct BridgeHubWestendToBridgeHubRococo;
|
|
||||||
|
|
||||||
impl SubstrateParachainsPipeline for BridgeHubWestendToBridgeHubRococo {
|
|
||||||
type SourceParachain = relay_bridge_hub_westend_client::BridgeHubWestend;
|
|
||||||
type SourceRelayChain = relay_westend_client::Westend;
|
|
||||||
type TargetChain = relay_bridge_hub_rococo_client::BridgeHubRococo;
|
|
||||||
|
|
||||||
type SubmitParachainHeadsCallBuilder = BridgeHubWestendToBridgeHubRococoCallBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct BridgeHubWestendToBridgeHubRococoCallBuilder;
|
|
||||||
impl SubmitParachainHeadsCallBuilder<BridgeHubWestendToBridgeHubRococo>
|
|
||||||
for BridgeHubWestendToBridgeHubRococoCallBuilder
|
|
||||||
{
|
|
||||||
fn build_submit_parachain_heads_call(
|
|
||||||
at_relay_block: HeaderIdOf<relay_westend_client::Westend>,
|
|
||||||
parachains: Vec<(ParaId, ParaHash)>,
|
|
||||||
parachain_heads_proof: ParaHeadsProof,
|
|
||||||
) -> CallOf<relay_bridge_hub_rococo_client::BridgeHubRococo> {
|
|
||||||
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWestendParachains(
|
|
||||||
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 BridgeHubWestendToBridgeHubRococoCliBridge {}
|
|
||||||
|
|
||||||
impl ParachainToRelayHeadersCliBridge for BridgeHubWestendToBridgeHubRococoCliBridge {
|
|
||||||
type SourceRelay = relay_westend_client::Westend;
|
|
||||||
type ParachainFinality = BridgeHubWestendToBridgeHubRococo;
|
|
||||||
type RelayFinality =
|
|
||||||
crate::bridges::rococo_westend::westend_headers_to_bridge_hub_rococo::WestendFinalityToBridgeHubRococo;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CliBridgeBase for BridgeHubWestendToBridgeHubRococoCliBridge {
|
|
||||||
type Source = relay_bridge_hub_westend_client::BridgeHubWestend;
|
|
||||||
type Target = relay_bridge_hub_rococo_client::BridgeHubRococo;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesCliBridge for BridgeHubWestendToBridgeHubRococoCliBridge {
|
|
||||||
type MessagesLane =
|
|
||||||
crate::bridges::rococo_westend::bridge_hub_westend_messages_to_bridge_hub_rococo::BridgeHubWestendMessagesToBridgeHubRococoMessageLane;
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
// Copyright 2019-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/>.
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use sp_core::Pair;
|
|
||||||
use substrate_relay_helper::cli::chain_schema::TargetSigningParams;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn reads_suri_from_file() {
|
|
||||||
const ALICE: &str = "//Alice";
|
|
||||||
const BOB: &str = "//Bob";
|
|
||||||
const ALICE_PASSWORD: &str = "alice_password";
|
|
||||||
const BOB_PASSWORD: &str = "bob_password";
|
|
||||||
|
|
||||||
let alice: sp_core::sr25519::Pair = Pair::from_string(ALICE, Some(ALICE_PASSWORD)).unwrap();
|
|
||||||
let bob: sp_core::sr25519::Pair = Pair::from_string(BOB, Some(BOB_PASSWORD)).unwrap();
|
|
||||||
let bob_with_alice_password =
|
|
||||||
sp_core::sr25519::Pair::from_string(BOB, Some(ALICE_PASSWORD)).unwrap();
|
|
||||||
|
|
||||||
let temp_dir = tempfile::tempdir().unwrap();
|
|
||||||
let mut suri_file_path = temp_dir.path().to_path_buf();
|
|
||||||
let mut password_file_path = temp_dir.path().to_path_buf();
|
|
||||||
suri_file_path.push("suri");
|
|
||||||
password_file_path.push("password");
|
|
||||||
std::fs::write(&suri_file_path, BOB.as_bytes()).unwrap();
|
|
||||||
std::fs::write(&password_file_path, BOB_PASSWORD.as_bytes()).unwrap();
|
|
||||||
|
|
||||||
// when both seed and password are read from file
|
|
||||||
assert_eq!(
|
|
||||||
TargetSigningParams {
|
|
||||||
target_signer: Some(ALICE.into()),
|
|
||||||
target_signer_password: Some(ALICE_PASSWORD.into()),
|
|
||||||
|
|
||||||
target_signer_file: None,
|
|
||||||
target_signer_password_file: None,
|
|
||||||
|
|
||||||
target_transactions_mortality: None,
|
|
||||||
}
|
|
||||||
.to_keypair::<relay_polkadot_client::Polkadot>()
|
|
||||||
.map(|p| p.public())
|
|
||||||
.map_err(drop),
|
|
||||||
Ok(alice.public()),
|
|
||||||
);
|
|
||||||
|
|
||||||
// when both seed and password are read from file
|
|
||||||
assert_eq!(
|
|
||||||
TargetSigningParams {
|
|
||||||
target_signer: None,
|
|
||||||
target_signer_password: None,
|
|
||||||
|
|
||||||
target_signer_file: Some(suri_file_path.clone()),
|
|
||||||
target_signer_password_file: Some(password_file_path.clone()),
|
|
||||||
|
|
||||||
target_transactions_mortality: None,
|
|
||||||
}
|
|
||||||
.to_keypair::<relay_polkadot_client::Polkadot>()
|
|
||||||
.map(|p| p.public())
|
|
||||||
.map_err(drop),
|
|
||||||
Ok(bob.public()),
|
|
||||||
);
|
|
||||||
|
|
||||||
// when password are is overriden by cli option
|
|
||||||
assert_eq!(
|
|
||||||
TargetSigningParams {
|
|
||||||
target_signer: None,
|
|
||||||
target_signer_password: Some(ALICE_PASSWORD.into()),
|
|
||||||
|
|
||||||
target_signer_file: Some(suri_file_path.clone()),
|
|
||||||
target_signer_password_file: Some(password_file_path.clone()),
|
|
||||||
|
|
||||||
target_transactions_mortality: None,
|
|
||||||
}
|
|
||||||
.to_keypair::<relay_polkadot_client::Polkadot>()
|
|
||||||
.map(|p| p.public())
|
|
||||||
.map_err(drop),
|
|
||||||
Ok(bob_with_alice_password.public()),
|
|
||||||
);
|
|
||||||
|
|
||||||
// when both seed and password are overriden by cli options
|
|
||||||
assert_eq!(
|
|
||||||
TargetSigningParams {
|
|
||||||
target_signer: Some(ALICE.into()),
|
|
||||||
target_signer_password: Some(ALICE_PASSWORD.into()),
|
|
||||||
|
|
||||||
target_signer_file: Some(suri_file_path),
|
|
||||||
target_signer_password_file: Some(password_file_path),
|
|
||||||
|
|
||||||
target_transactions_mortality: None,
|
|
||||||
}
|
|
||||||
.to_keypair::<relay_polkadot_client::Polkadot>()
|
|
||||||
.map(|p| p.public())
|
|
||||||
.map_err(drop),
|
|
||||||
Ok(alice.public()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
// Copyright 2019-2023 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/>.
|
|
||||||
|
|
||||||
use crate::bridges::{
|
|
||||||
kusama_polkadot::{
|
|
||||||
kusama_headers_to_bridge_hub_polkadot::KusamaToBridgeHubPolkadotCliBridge,
|
|
||||||
polkadot_headers_to_bridge_hub_kusama::PolkadotToBridgeHubKusamaCliBridge,
|
|
||||||
},
|
|
||||||
rococo_westend::{
|
|
||||||
rococo_headers_to_bridge_hub_westend::RococoToBridgeHubWestendCliBridge,
|
|
||||||
westend_headers_to_bridge_hub_rococo::WestendToBridgeHubRococoCliBridge,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
use structopt::StructOpt;
|
|
||||||
use strum::{EnumString, VariantNames};
|
|
||||||
|
|
||||||
use substrate_relay_helper::cli::detect_equivocations::{
|
|
||||||
DetectEquivocationsParams, EquivocationsDetector,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Start equivocation detection loop.
|
|
||||||
#[derive(StructOpt)]
|
|
||||||
pub struct DetectEquivocations {
|
|
||||||
#[structopt(possible_values = DetectEquivocationsBridge::VARIANTS, case_insensitive = true)]
|
|
||||||
bridge: DetectEquivocationsBridge,
|
|
||||||
#[structopt(flatten)]
|
|
||||||
params: DetectEquivocationsParams,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, EnumString, VariantNames)]
|
|
||||||
#[strum(serialize_all = "kebab_case")]
|
|
||||||
/// Equivocations detection bridge.
|
|
||||||
pub enum DetectEquivocationsBridge {
|
|
||||||
KusamaToBridgeHubPolkadot,
|
|
||||||
PolkadotToBridgeHubKusama,
|
|
||||||
RococoToBridgeHubWestend,
|
|
||||||
WestendToBridgeHubRococo,
|
|
||||||
}
|
|
||||||
|
|
||||||
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::KusamaToBridgeHubPolkadot =>
|
|
||||||
KusamaToBridgeHubPolkadotCliBridge::start(self.params),
|
|
||||||
DetectEquivocationsBridge::PolkadotToBridgeHubKusama =>
|
|
||||||
PolkadotToBridgeHubKusamaCliBridge::start(self.params),
|
|
||||||
DetectEquivocationsBridge::RococoToBridgeHubWestend =>
|
|
||||||
RococoToBridgeHubWestendCliBridge::start(self.params),
|
|
||||||
DetectEquivocationsBridge::WestendToBridgeHubRococo =>
|
|
||||||
WestendToBridgeHubRococoCliBridge::start(self.params),
|
|
||||||
}
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,199 +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/>.
|
|
||||||
|
|
||||||
use crate::bridges::{
|
|
||||||
kusama_polkadot::{
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
rococo_bulletin::{
|
|
||||||
rococo_bulletin_headers_to_bridge_hub_rococo::RococoBulletinToBridgeHubRococoCliBridge,
|
|
||||||
rococo_headers_to_rococo_bulletin::RococoToRococoBulletinCliBridge,
|
|
||||||
},
|
|
||||||
rococo_westend::{
|
|
||||||
rococo_headers_to_bridge_hub_westend::RococoToBridgeHubWestendCliBridge,
|
|
||||||
westend_headers_to_bridge_hub_rococo::WestendToBridgeHubRococoCliBridge,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use relay_substrate_client::Chain;
|
|
||||||
use structopt::StructOpt;
|
|
||||||
use strum::{EnumString, VariantNames};
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::init_bridge::{BridgeInitializer, InitBridgeParams},
|
|
||||||
finality_base::engine::{Engine, Grandpa as GrandpaFinalityEngine},
|
|
||||||
};
|
|
||||||
|
|
||||||
impl BridgeInitializer for RococoToBridgeHubWestendCliBridge {
|
|
||||||
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_westend_client::RuntimeCall::BridgeRococoGrandpa(
|
|
||||||
relay_bridge_hub_westend_client::BridgeGrandpaCall::initialize { init_data },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BridgeInitializer for WestendToBridgeHubRococoCliBridge {
|
|
||||||
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::BridgeWestendGrandpa(
|
|
||||||
relay_bridge_hub_rococo_client::BridgeGrandpaCall::initialize { init_data },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BridgeInitializer for KusamaToBridgeHubPolkadotCliBridge {
|
|
||||||
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_polkadot_client::RuntimeCall::BridgeKusamaGrandpa(
|
|
||||||
relay_bridge_hub_polkadot_client::BridgeKusamaGrandpaCall::initialize { init_data },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BridgeInitializer for PolkadotToBridgeHubKusamaCliBridge {
|
|
||||||
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_kusama_client::RuntimeCall::BridgePolkadotGrandpa(
|
|
||||||
relay_bridge_hub_kusama_client::BridgeGrandpaCall::initialize { init_data },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BridgeInitializer for PolkadotToPolkadotBulletinCliBridge {
|
|
||||||
type Engine = GrandpaFinalityEngine<Self::Source>;
|
|
||||||
|
|
||||||
fn encode_init_bridge(
|
|
||||||
init_data: <Self::Engine as Engine<Self::Source>>::InitializationData,
|
|
||||||
) -> <Self::Target as Chain>::Call {
|
|
||||||
type RuntimeCall = relay_polkadot_bulletin_client::RuntimeCall;
|
|
||||||
type BridgePolkadotGrandpaCall = relay_polkadot_bulletin_client::BridgePolkadotGrandpaCall;
|
|
||||||
type SudoCall = relay_polkadot_bulletin_client::SudoCall;
|
|
||||||
|
|
||||||
let initialize_call =
|
|
||||||
RuntimeCall::BridgePolkadotGrandpa(BridgePolkadotGrandpaCall::initialize { init_data });
|
|
||||||
|
|
||||||
RuntimeCall::Sudo(SudoCall::sudo { call: Box::new(initialize_call) })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BridgeInitializer for PolkadotBulletinToBridgeHubPolkadotCliBridge {
|
|
||||||
type Engine = GrandpaFinalityEngine<Self::Source>;
|
|
||||||
|
|
||||||
fn encode_init_bridge(
|
|
||||||
init_data: <Self::Engine as Engine<Self::Source>>::InitializationData,
|
|
||||||
) -> <Self::Target as Chain>::Call {
|
|
||||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/2547 - use BridgePolkadotBulletinGrandpa
|
|
||||||
relay_bridge_hub_polkadot_client::RuntimeCall::BridgeKusamaGrandpa(
|
|
||||||
relay_bridge_hub_polkadot_client::BridgePolkadotBulletinGrandpaCall::initialize {
|
|
||||||
init_data,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BridgeInitializer for RococoToRococoBulletinCliBridge {
|
|
||||||
type Engine = GrandpaFinalityEngine<Self::Source>;
|
|
||||||
|
|
||||||
fn encode_init_bridge(
|
|
||||||
init_data: <Self::Engine as Engine<Self::Source>>::InitializationData,
|
|
||||||
) -> <Self::Target as Chain>::Call {
|
|
||||||
type RuntimeCall = relay_polkadot_bulletin_client::RuntimeCall;
|
|
||||||
type BridgePolkadotGrandpaCall = relay_polkadot_bulletin_client::BridgePolkadotGrandpaCall;
|
|
||||||
type SudoCall = relay_polkadot_bulletin_client::SudoCall;
|
|
||||||
|
|
||||||
let initialize_call =
|
|
||||||
RuntimeCall::BridgePolkadotGrandpa(BridgePolkadotGrandpaCall::initialize { init_data });
|
|
||||||
|
|
||||||
RuntimeCall::Sudo(SudoCall::sudo { call: Box::new(initialize_call) })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BridgeInitializer for RococoBulletinToBridgeHubRococoCliBridge {
|
|
||||||
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::BridgePolkadotBulletinGrandpa(
|
|
||||||
relay_bridge_hub_rococo_client::BridgeBulletinGrandpaCall::initialize { init_data },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initialize bridge pallet.
|
|
||||||
#[derive(StructOpt)]
|
|
||||||
pub struct InitBridge {
|
|
||||||
/// A bridge instance to initialize.
|
|
||||||
#[structopt(possible_values = InitBridgeName::VARIANTS, case_insensitive = true)]
|
|
||||||
bridge: InitBridgeName,
|
|
||||||
#[structopt(flatten)]
|
|
||||||
params: InitBridgeParams,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, EnumString, VariantNames)]
|
|
||||||
#[strum(serialize_all = "kebab_case")]
|
|
||||||
/// Bridge to initialize.
|
|
||||||
pub enum InitBridgeName {
|
|
||||||
KusamaToBridgeHubPolkadot,
|
|
||||||
PolkadotToBridgeHubKusama,
|
|
||||||
PolkadotToPolkadotBulletin,
|
|
||||||
PolkadotBulletinToBridgeHubPolkadot,
|
|
||||||
RococoToRococoBulletin,
|
|
||||||
RococoBulletinToBridgeHubRococo,
|
|
||||||
RococoToBridgeHubWestend,
|
|
||||||
WestendToBridgeHubRococo,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl InitBridge {
|
|
||||||
/// Run the command.
|
|
||||||
pub async fn run(self) -> anyhow::Result<()> {
|
|
||||||
match self.bridge {
|
|
||||||
InitBridgeName::KusamaToBridgeHubPolkadot =>
|
|
||||||
KusamaToBridgeHubPolkadotCliBridge::init_bridge(self.params),
|
|
||||||
InitBridgeName::PolkadotToBridgeHubKusama =>
|
|
||||||
PolkadotToBridgeHubKusamaCliBridge::init_bridge(self.params),
|
|
||||||
InitBridgeName::PolkadotToPolkadotBulletin =>
|
|
||||||
PolkadotToPolkadotBulletinCliBridge::init_bridge(self.params),
|
|
||||||
InitBridgeName::PolkadotBulletinToBridgeHubPolkadot =>
|
|
||||||
PolkadotBulletinToBridgeHubPolkadotCliBridge::init_bridge(self.params),
|
|
||||||
InitBridgeName::RococoToRococoBulletin =>
|
|
||||||
RococoToRococoBulletinCliBridge::init_bridge(self.params),
|
|
||||||
InitBridgeName::RococoBulletinToBridgeHubRococo =>
|
|
||||||
RococoBulletinToBridgeHubRococoCliBridge::init_bridge(self.params),
|
|
||||||
InitBridgeName::RococoToBridgeHubWestend =>
|
|
||||||
RococoToBridgeHubWestendCliBridge::init_bridge(self.params),
|
|
||||||
InitBridgeName::WestendToBridgeHubRococo =>
|
|
||||||
WestendToBridgeHubRococoCliBridge::init_bridge(self.params),
|
|
||||||
}
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,131 +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/>.
|
|
||||||
|
|
||||||
//! Deal with CLI args of substrate-to-substrate relay.
|
|
||||||
|
|
||||||
use async_std::prelude::*;
|
|
||||||
use futures::{select, FutureExt};
|
|
||||||
use signal_hook::consts::*;
|
|
||||||
use signal_hook_async_std::Signals;
|
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
mod chain_schema;
|
|
||||||
mod detect_equivocations;
|
|
||||||
mod init_bridge;
|
|
||||||
mod relay_headers;
|
|
||||||
mod relay_headers_and_messages;
|
|
||||||
mod relay_messages;
|
|
||||||
mod relay_parachains;
|
|
||||||
|
|
||||||
/// The target that will be used when publishing logs related to this pallet.
|
|
||||||
pub const LOG_TARGET: &str = "bridge";
|
|
||||||
|
|
||||||
/// Parse relay CLI args.
|
|
||||||
pub fn parse_args() -> Command {
|
|
||||||
Command::from_args()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Substrate-to-Substrate bridge utilities.
|
|
||||||
#[derive(StructOpt)]
|
|
||||||
#[structopt(about = "Substrate-to-Substrate relay")]
|
|
||||||
pub enum Command {
|
|
||||||
/// Initialize on-chain bridge pallet with current header data.
|
|
||||||
///
|
|
||||||
/// Sends initialization transaction to bootstrap the bridge with current finalized block data.
|
|
||||||
InitBridge(init_bridge::InitBridge),
|
|
||||||
/// Start headers relay between two chains.
|
|
||||||
///
|
|
||||||
/// The on-chain bridge component should have been already initialized with
|
|
||||||
/// `init-bridge` sub-command.
|
|
||||||
RelayHeaders(relay_headers::RelayHeaders),
|
|
||||||
/// Relay parachain heads.
|
|
||||||
RelayParachains(relay_parachains::RelayParachains),
|
|
||||||
/// Start messages relay between two chains.
|
|
||||||
///
|
|
||||||
/// Ties up to `Messages` pallets on both chains and starts relaying messages.
|
|
||||||
/// Requires the header relay to be already running.
|
|
||||||
RelayMessages(relay_messages::RelayMessages),
|
|
||||||
/// Start headers and messages relay between two Substrate chains.
|
|
||||||
///
|
|
||||||
/// This high-level relay internally starts four low-level relays: two `RelayHeaders`
|
|
||||||
/// and two `RelayMessages` relays. Headers are only relayed when they are required by
|
|
||||||
/// the message relays - i.e. when there are messages or confirmations that needs to be
|
|
||||||
/// relayed between chains.
|
|
||||||
RelayHeadersAndMessages(Box<relay_headers_and_messages::RelayHeadersAndMessages>),
|
|
||||||
/// Detect and report equivocations.
|
|
||||||
///
|
|
||||||
/// Parses the source chain headers that were synchronized with the target chain looking for
|
|
||||||
/// equivocations. If any equivocation is found, it is reported to the source chain.
|
|
||||||
DetectEquivocations(detect_equivocations::DetectEquivocations),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Command {
|
|
||||||
// Initialize logger depending on the command.
|
|
||||||
fn init_logger(&self) {
|
|
||||||
use relay_utils::initialize::{initialize_logger, initialize_relay};
|
|
||||||
|
|
||||||
match self {
|
|
||||||
Self::InitBridge(_) |
|
|
||||||
Self::RelayHeaders(_) |
|
|
||||||
Self::RelayMessages(_) |
|
|
||||||
Self::RelayHeadersAndMessages(_) => {
|
|
||||||
initialize_relay();
|
|
||||||
},
|
|
||||||
_ => {
|
|
||||||
initialize_logger(false);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Run the command.
|
|
||||||
async fn do_run(self) -> anyhow::Result<()> {
|
|
||||||
match self {
|
|
||||||
Self::InitBridge(arg) => arg.run().await?,
|
|
||||||
Self::RelayHeaders(arg) => arg.run().await?,
|
|
||||||
Self::RelayParachains(arg) => arg.run().await?,
|
|
||||||
Self::RelayMessages(arg) => arg.run().await?,
|
|
||||||
Self::RelayHeadersAndMessages(arg) => arg.run().await?,
|
|
||||||
Self::DetectEquivocations(arg) => arg.run().await?,
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Run the command.
|
|
||||||
pub async fn run(self) {
|
|
||||||
self.init_logger();
|
|
||||||
|
|
||||||
let exit_signals = match Signals::new([SIGINT, SIGTERM]) {
|
|
||||||
Ok(signals) => signals,
|
|
||||||
Err(e) => {
|
|
||||||
log::error!(target: LOG_TARGET, "Could not register exit signals: {}", e);
|
|
||||||
return
|
|
||||||
},
|
|
||||||
};
|
|
||||||
let run = self.do_run().fuse();
|
|
||||||
futures::pin_mut!(exit_signals, run);
|
|
||||||
|
|
||||||
select! {
|
|
||||||
signal = exit_signals.next().fuse() => {
|
|
||||||
log::info!(target: LOG_TARGET, "Received exit signal {:?}", signal);
|
|
||||||
},
|
|
||||||
result = run => {
|
|
||||||
if let Err(e) = result {
|
|
||||||
log::error!(target: LOG_TARGET, "substrate-relay: {}", e);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,85 +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/>.
|
|
||||||
|
|
||||||
use structopt::StructOpt;
|
|
||||||
use strum::{EnumString, VariantNames};
|
|
||||||
|
|
||||||
use crate::bridges::{
|
|
||||||
kusama_polkadot::{
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
rococo_bulletin::{
|
|
||||||
rococo_bulletin_headers_to_bridge_hub_rococo::RococoBulletinToBridgeHubRococoCliBridge,
|
|
||||||
rococo_headers_to_rococo_bulletin::RococoToRococoBulletinCliBridge,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
use substrate_relay_helper::cli::relay_headers::{HeadersRelayer, RelayHeadersParams};
|
|
||||||
|
|
||||||
/// Start headers relayer process.
|
|
||||||
#[derive(StructOpt)]
|
|
||||||
pub struct RelayHeaders {
|
|
||||||
/// A bridge instance to relay headers for.
|
|
||||||
#[structopt(possible_values = RelayHeadersBridge::VARIANTS, case_insensitive = true)]
|
|
||||||
bridge: RelayHeadersBridge,
|
|
||||||
#[structopt(flatten)]
|
|
||||||
params: RelayHeadersParams,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, EnumString, VariantNames)]
|
|
||||||
#[strum(serialize_all = "kebab_case")]
|
|
||||||
/// Headers relay bridge.
|
|
||||||
pub enum RelayHeadersBridge {
|
|
||||||
KusamaToBridgeHubPolkadot,
|
|
||||||
PolkadotToBridgeHubKusama,
|
|
||||||
PolkadotToPolkadotBulletin,
|
|
||||||
PolkadotBulletinToBridgeHubPolkadot,
|
|
||||||
RococoToRococoBulletin,
|
|
||||||
RococoBulletinToBridgeHubRococo,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HeadersRelayer for KusamaToBridgeHubPolkadotCliBridge {}
|
|
||||||
impl HeadersRelayer for PolkadotToBridgeHubKusamaCliBridge {}
|
|
||||||
impl HeadersRelayer for PolkadotToPolkadotBulletinCliBridge {}
|
|
||||||
impl HeadersRelayer for PolkadotBulletinToBridgeHubPolkadotCliBridge {}
|
|
||||||
impl HeadersRelayer for RococoToRococoBulletinCliBridge {}
|
|
||||||
impl HeadersRelayer for RococoBulletinToBridgeHubRococoCliBridge {}
|
|
||||||
|
|
||||||
impl RelayHeaders {
|
|
||||||
/// Run the command.
|
|
||||||
pub async fn run(self) -> anyhow::Result<()> {
|
|
||||||
match self.bridge {
|
|
||||||
RelayHeadersBridge::KusamaToBridgeHubPolkadot =>
|
|
||||||
KusamaToBridgeHubPolkadotCliBridge::relay_headers(self.params),
|
|
||||||
RelayHeadersBridge::PolkadotToBridgeHubKusama =>
|
|
||||||
PolkadotToBridgeHubKusamaCliBridge::relay_headers(self.params),
|
|
||||||
RelayHeadersBridge::PolkadotToPolkadotBulletin =>
|
|
||||||
PolkadotToPolkadotBulletinCliBridge::relay_headers(self.params),
|
|
||||||
RelayHeadersBridge::PolkadotBulletinToBridgeHubPolkadot =>
|
|
||||||
PolkadotBulletinToBridgeHubPolkadotCliBridge::relay_headers(self.params),
|
|
||||||
RelayHeadersBridge::RococoToRococoBulletin =>
|
|
||||||
RococoToRococoBulletinCliBridge::relay_headers(self.params),
|
|
||||||
RelayHeadersBridge::RococoBulletinToBridgeHubRococo =>
|
|
||||||
RococoBulletinToBridgeHubRococoCliBridge::relay_headers(self.params),
|
|
||||||
}
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,377 +0,0 @@
|
|||||||
// Copyright 2019-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/>.
|
|
||||||
|
|
||||||
//! Complex 2-ways headers+messages relays support.
|
|
||||||
//!
|
|
||||||
//! To add new complex relay between `ChainA` and `ChainB`, you must:
|
|
||||||
//!
|
|
||||||
//! 1) ensure that there's a `declare_chain_cli_schema!(...)` for both chains.
|
|
||||||
//! 2) add `declare_chain_to_chain_bridge_schema!(...)` or
|
|
||||||
//! `declare_chain_to_parachain_bridge_schema` for the bridge.
|
|
||||||
//! 3) declare a new struct for the added bridge and implement the `Full2WayBridge` trait for it.
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
use crate::bridges::{
|
|
||||||
kusama_polkadot::{
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
rococo_bulletin::{
|
|
||||||
rococo_bulletin_headers_to_bridge_hub_rococo::RococoBulletinToBridgeHubRococoCliBridge,
|
|
||||||
rococo_parachains_to_rococo_bulletin::RococoToRococoBulletinCliBridge,
|
|
||||||
BridgeHubRococoAsBridgeHubPolkadot,
|
|
||||||
},
|
|
||||||
rococo_westend::{
|
|
||||||
rococo_parachains_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendCliBridge,
|
|
||||||
westend_parachains_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoCliBridge,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use relay_substrate_client::{
|
|
||||||
AccountKeyPairOf, ChainRuntimeVersion, ChainWithRuntimeVersion, ChainWithTransactions,
|
|
||||||
Parachain, SimpleRuntimeVersion,
|
|
||||||
};
|
|
||||||
use substrate_relay_helper::{
|
|
||||||
cli::{
|
|
||||||
bridge::{
|
|
||||||
CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge,
|
|
||||||
RelayToRelayHeadersCliBridge,
|
|
||||||
},
|
|
||||||
chain_schema::*,
|
|
||||||
relay_headers_and_messages::{
|
|
||||||
parachain_to_parachain::ParachainToParachainBridge, relay_to_parachain::*,
|
|
||||||
BridgeEndCommonParams, Full2WayBridge, Full2WayBridgeCommonParams,
|
|
||||||
HeadersAndMessagesSharedParams,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
declare_chain_cli_schema, declare_parachain_to_parachain_bridge_schema,
|
|
||||||
declare_relay_to_parachain_bridge_schema, TransactionParams,
|
|
||||||
};
|
|
||||||
|
|
||||||
// All supported chains.
|
|
||||||
declare_chain_cli_schema!(Rococo, rococo);
|
|
||||||
declare_chain_cli_schema!(BridgeHubRococo, bridge_hub_rococo);
|
|
||||||
declare_chain_cli_schema!(Westend, westend);
|
|
||||||
declare_chain_cli_schema!(BridgeHubWestend, bridge_hub_westend);
|
|
||||||
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);
|
|
||||||
declare_chain_cli_schema!(RococoBulletin, rococo_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!(
|
|
||||||
RococoBulletinHeadersToBridgeHubRococo,
|
|
||||||
rococo_bulletin_headers_to_bridge_hub_rococo
|
|
||||||
);
|
|
||||||
declare_chain_cli_schema!(PolkadotHeadersToPolkadotBulletin, polkadot_headers_to_polkadot_bulletin);
|
|
||||||
declare_chain_cli_schema!(RococoHeadersToRococoBulletin, rococo_headers_to_rococo_bulletin);
|
|
||||||
declare_chain_cli_schema!(
|
|
||||||
PolkadotParachainsToPolkadotBulletin,
|
|
||||||
polkadot_parachains_to_polkadot_bulletin
|
|
||||||
);
|
|
||||||
declare_chain_cli_schema!(RococoParachainsToRococoBulletin, rococo_parachains_to_rococo_bulletin);
|
|
||||||
// All supported bridges.
|
|
||||||
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);
|
|
||||||
declare_relay_to_parachain_bridge_schema!(RococoBulletin, BridgeHubRococo, Rococo);
|
|
||||||
|
|
||||||
/// BridgeHubRococo <> BridgeHubWestend complex relay.
|
|
||||||
pub struct BridgeHubRococoBridgeHubWestendFull2WayBridge {
|
|
||||||
base: <Self as Full2WayBridge>::Base,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Full2WayBridge for BridgeHubRococoBridgeHubWestendFull2WayBridge {
|
|
||||||
type Base = ParachainToParachainBridge<Self::L2R, Self::R2L>;
|
|
||||||
type Left = relay_bridge_hub_rococo_client::BridgeHubRococo;
|
|
||||||
type Right = relay_bridge_hub_westend_client::BridgeHubWestend;
|
|
||||||
type L2R = BridgeHubRococoToBridgeHubWestendCliBridge;
|
|
||||||
type R2L = BridgeHubWestendToBridgeHubRococoCliBridge;
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// BridgeHubKusama <> BridgeHubPolkadot complex relay.
|
|
||||||
pub struct BridgeHubKusamaBridgeHubPolkadotFull2WayBridge {
|
|
||||||
base: <Self as Full2WayBridge>::Base,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Full2WayBridge for BridgeHubKusamaBridgeHubPolkadotFull2WayBridge {
|
|
||||||
type Base = ParachainToParachainBridge<Self::L2R, Self::R2L>;
|
|
||||||
type Left = relay_bridge_hub_kusama_client::BridgeHubKusama;
|
|
||||||
type Right = relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
|
||||||
type L2R = BridgeHubKusamaToBridgeHubPolkadotCliBridge;
|
|
||||||
type R2L = BridgeHubPolkadotToBridgeHubKusamaCliBridge;
|
|
||||||
|
|
||||||
fn new(base: Self::Base) -> anyhow::Result<Self> {
|
|
||||||
Ok(Self { base })
|
|
||||||
}
|
|
||||||
|
|
||||||
fn base(&self) -> &Self::Base {
|
|
||||||
&self.base
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mut_base(&mut self) -> &mut Self::Base {
|
|
||||||
&mut self.base
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `PolkadotBulletin` <> `BridgeHubPolkadot` complex relay.
|
|
||||||
pub struct PolkadotBulletinBridgeHubPolkadotFull2WayBridge {
|
|
||||||
base: <Self as Full2WayBridge>::Base,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Full2WayBridge for PolkadotBulletinBridgeHubPolkadotFull2WayBridge {
|
|
||||||
type Base = RelayToParachainBridge<Self::L2R, Self::R2L>;
|
|
||||||
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<Self> {
|
|
||||||
Ok(Self { base })
|
|
||||||
}
|
|
||||||
|
|
||||||
fn base(&self) -> &Self::Base {
|
|
||||||
&self.base
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mut_base(&mut self) -> &mut Self::Base {
|
|
||||||
&mut self.base
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `RococoBulletin` <> `BridgeHubRococo` complex relay.
|
|
||||||
pub struct RococoBulletinBridgeHubRococoFull2WayBridge {
|
|
||||||
base: <Self as Full2WayBridge>::Base,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Full2WayBridge for RococoBulletinBridgeHubRococoFull2WayBridge {
|
|
||||||
type Base = RelayToParachainBridge<Self::L2R, Self::R2L>;
|
|
||||||
type Left = relay_polkadot_bulletin_client::PolkadotBulletin;
|
|
||||||
type Right = BridgeHubRococoAsBridgeHubPolkadot;
|
|
||||||
type L2R = RococoBulletinToBridgeHubRococoCliBridge;
|
|
||||||
type R2L = RococoToRococoBulletinCliBridge;
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Complex headers+messages relay.
|
|
||||||
#[derive(Debug, PartialEq, StructOpt)]
|
|
||||||
pub enum RelayHeadersAndMessages {
|
|
||||||
/// BridgeHubKusama <> BridgeHubPolkadot relay.
|
|
||||||
BridgeHubKusamaBridgeHubPolkadot(BridgeHubKusamaBridgeHubPolkadotHeadersAndMessages),
|
|
||||||
/// `PolkadotBulletin` <> `BridgeHubPolkadot` relay.
|
|
||||||
PolkadotBulletinBridgeHubPolkadot(PolkadotBulletinBridgeHubPolkadotHeadersAndMessages),
|
|
||||||
/// `RococoBulletin` <> `BridgeHubRococo` relay.
|
|
||||||
RococoBulletinBridgeHubRococo(RococoBulletinBridgeHubRococoHeadersAndMessages),
|
|
||||||
/// BridgeHubRococo <> BridgeHubWestend relay.
|
|
||||||
BridgeHubRococoBridgeHubWestend(BridgeHubRococoBridgeHubWestendHeadersAndMessages),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayHeadersAndMessages {
|
|
||||||
/// Run the command.
|
|
||||||
pub async fn run(self) -> anyhow::Result<()> {
|
|
||||||
match self {
|
|
||||||
RelayHeadersAndMessages::BridgeHubRococoBridgeHubWestend(params) =>
|
|
||||||
BridgeHubRococoBridgeHubWestendFull2WayBridge::new(params.into_bridge().await?)?
|
|
||||||
.run()
|
|
||||||
.await,
|
|
||||||
RelayHeadersAndMessages::BridgeHubKusamaBridgeHubPolkadot(params) =>
|
|
||||||
BridgeHubKusamaBridgeHubPolkadotFull2WayBridge::new(params.into_bridge().await?)?
|
|
||||||
.run()
|
|
||||||
.await,
|
|
||||||
RelayHeadersAndMessages::PolkadotBulletinBridgeHubPolkadot(params) =>
|
|
||||||
PolkadotBulletinBridgeHubPolkadotFull2WayBridge::new(params.into_bridge().await?)?
|
|
||||||
.run()
|
|
||||||
.await,
|
|
||||||
RelayHeadersAndMessages::RococoBulletinBridgeHubRococo(params) =>
|
|
||||||
RococoBulletinBridgeHubRococoFull2WayBridge::new(params.into_bridge().await?)?
|
|
||||||
.run()
|
|
||||||
.await,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use substrate_relay_helper::cli::{HexLaneId, PrometheusParams};
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn should_parse_parachain_to_parachain_options() {
|
|
||||||
// when
|
|
||||||
let res = RelayHeadersAndMessages::from_iter(vec![
|
|
||||||
"relay-headers-and-messages",
|
|
||||||
"bridge-hub-kusama-bridge-hub-polkadot",
|
|
||||||
"--bridge-hub-kusama-host",
|
|
||||||
"bridge-hub-kusama-node-collator1",
|
|
||||||
"--bridge-hub-kusama-port",
|
|
||||||
"9944",
|
|
||||||
"--bridge-hub-kusama-signer",
|
|
||||||
"//Iden",
|
|
||||||
"--bridge-hub-kusama-transactions-mortality",
|
|
||||||
"64",
|
|
||||||
"--kusama-host",
|
|
||||||
"kusama-alice",
|
|
||||||
"--kusama-port",
|
|
||||||
"9944",
|
|
||||||
"--bridge-hub-polkadot-host",
|
|
||||||
"bridge-hub-polkadot-collator1",
|
|
||||||
"--bridge-hub-polkadot-port",
|
|
||||||
"9944",
|
|
||||||
"--bridge-hub-polkadot-signer",
|
|
||||||
"//George",
|
|
||||||
"--bridge-hub-polkadot-transactions-mortality",
|
|
||||||
"64",
|
|
||||||
"--polkadot-host",
|
|
||||||
"polkadot-alice",
|
|
||||||
"--polkadot-port",
|
|
||||||
"9944",
|
|
||||||
"--lane",
|
|
||||||
"00000000",
|
|
||||||
"--prometheus-host",
|
|
||||||
"0.0.0.0",
|
|
||||||
]);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assert_eq!(
|
|
||||||
res,
|
|
||||||
RelayHeadersAndMessages::BridgeHubKusamaBridgeHubPolkadot(
|
|
||||||
BridgeHubKusamaBridgeHubPolkadotHeadersAndMessages {
|
|
||||||
shared: HeadersAndMessagesSharedParams {
|
|
||||||
lane: vec![HexLaneId([0x00, 0x00, 0x00, 0x00])],
|
|
||||||
only_mandatory_headers: false,
|
|
||||||
prometheus_params: PrometheusParams {
|
|
||||||
no_prometheus: false,
|
|
||||||
prometheus_host: "0.0.0.0".into(),
|
|
||||||
prometheus_port: 9616,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
left_relay: KusamaConnectionParams {
|
|
||||||
kusama_host: "kusama-alice".into(),
|
|
||||||
kusama_port: 9944,
|
|
||||||
kusama_secure: false,
|
|
||||||
kusama_runtime_version: KusamaRuntimeVersionParams {
|
|
||||||
kusama_version_mode: RuntimeVersionType::Bundle,
|
|
||||||
kusama_spec_version: None,
|
|
||||||
kusama_transaction_version: None,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
left: BridgeHubKusamaConnectionParams {
|
|
||||||
bridge_hub_kusama_host: "bridge-hub-kusama-node-collator1".into(),
|
|
||||||
bridge_hub_kusama_port: 9944,
|
|
||||||
bridge_hub_kusama_secure: false,
|
|
||||||
bridge_hub_kusama_runtime_version: BridgeHubKusamaRuntimeVersionParams {
|
|
||||||
bridge_hub_kusama_version_mode: RuntimeVersionType::Bundle,
|
|
||||||
bridge_hub_kusama_spec_version: None,
|
|
||||||
bridge_hub_kusama_transaction_version: None,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
left_sign: BridgeHubKusamaSigningParams {
|
|
||||||
bridge_hub_kusama_signer: Some("//Iden".into()),
|
|
||||||
bridge_hub_kusama_signer_password: None,
|
|
||||||
bridge_hub_kusama_signer_file: None,
|
|
||||||
bridge_hub_kusama_signer_password_file: None,
|
|
||||||
bridge_hub_kusama_transactions_mortality: Some(64),
|
|
||||||
},
|
|
||||||
right: BridgeHubPolkadotConnectionParams {
|
|
||||||
bridge_hub_polkadot_host: "bridge-hub-polkadot-collator1".into(),
|
|
||||||
bridge_hub_polkadot_port: 9944,
|
|
||||||
bridge_hub_polkadot_secure: false,
|
|
||||||
bridge_hub_polkadot_runtime_version:
|
|
||||||
BridgeHubPolkadotRuntimeVersionParams {
|
|
||||||
bridge_hub_polkadot_version_mode: RuntimeVersionType::Bundle,
|
|
||||||
bridge_hub_polkadot_spec_version: None,
|
|
||||||
bridge_hub_polkadot_transaction_version: None,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
right_sign: BridgeHubPolkadotSigningParams {
|
|
||||||
bridge_hub_polkadot_signer: Some("//George".into()),
|
|
||||||
bridge_hub_polkadot_signer_password: None,
|
|
||||||
bridge_hub_polkadot_signer_file: None,
|
|
||||||
bridge_hub_polkadot_signer_password_file: None,
|
|
||||||
bridge_hub_polkadot_transactions_mortality: Some(64),
|
|
||||||
},
|
|
||||||
right_relay: PolkadotConnectionParams {
|
|
||||||
polkadot_host: "polkadot-alice".into(),
|
|
||||||
polkadot_port: 9944,
|
|
||||||
polkadot_secure: false,
|
|
||||||
polkadot_runtime_version: PolkadotRuntimeVersionParams {
|
|
||||||
polkadot_version_mode: RuntimeVersionType::Bundle,
|
|
||||||
polkadot_spec_version: None,
|
|
||||||
polkadot_transaction_version: None,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +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/>.
|
|
||||||
|
|
||||||
use structopt::StructOpt;
|
|
||||||
use strum::{EnumString, VariantNames};
|
|
||||||
|
|
||||||
use crate::bridges::{
|
|
||||||
kusama_polkadot::{
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
rococo_bulletin::{
|
|
||||||
bridge_hub_rococo_messages_to_rococo_bulletin::BridgeHubRococoToRococoBulletinMessagesCliBridge,
|
|
||||||
rococo_bulletin_messages_to_bridge_hub_rococo::RococoBulletinToBridgeHubRococoMessagesCliBridge,
|
|
||||||
},
|
|
||||||
rococo_westend::{
|
|
||||||
bridge_hub_rococo_messages_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendMessagesCliBridge,
|
|
||||||
bridge_hub_westend_messages_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoMessagesCliBridge,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use substrate_relay_helper::cli::relay_messages::{MessagesRelayer, RelayMessagesParams};
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, EnumString, VariantNames)]
|
|
||||||
#[strum(serialize_all = "kebab_case")]
|
|
||||||
/// Supported full bridges (headers + messages).
|
|
||||||
pub enum FullBridge {
|
|
||||||
BridgeHubRococoToBridgeHubWestend,
|
|
||||||
BridgeHubWestendToBridgeHubRococo,
|
|
||||||
BridgeHubKusamaToBridgeHubPolkadot,
|
|
||||||
BridgeHubPolkadotToBridgeHubKusama,
|
|
||||||
PolkadotBulletinToBridgeHubPolkadot,
|
|
||||||
BridgeHubPolkadotToPolkadotBulletin,
|
|
||||||
RococoBulletinToBridgeHubRococo,
|
|
||||||
BridgeHubRococoToRococoBulletin,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Start messages relayer process.
|
|
||||||
#[derive(StructOpt)]
|
|
||||||
pub struct RelayMessages {
|
|
||||||
/// A bridge instance to relay messages for.
|
|
||||||
#[structopt(possible_values = FullBridge::VARIANTS, case_insensitive = true)]
|
|
||||||
bridge: FullBridge,
|
|
||||||
#[structopt(flatten)]
|
|
||||||
params: RelayMessagesParams,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessagesRelayer for BridgeHubRococoToBridgeHubWestendMessagesCliBridge {}
|
|
||||||
impl MessagesRelayer for BridgeHubWestendToBridgeHubRococoMessagesCliBridge {}
|
|
||||||
impl MessagesRelayer for BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge {}
|
|
||||||
impl MessagesRelayer for BridgeHubPolkadotToBridgeHubKusamaMessagesCliBridge {}
|
|
||||||
impl MessagesRelayer for PolkadotBulletinToBridgeHubPolkadotMessagesCliBridge {}
|
|
||||||
impl MessagesRelayer for BridgeHubPolkadotToPolkadotBulletinMessagesCliBridge {}
|
|
||||||
impl MessagesRelayer for RococoBulletinToBridgeHubRococoMessagesCliBridge {}
|
|
||||||
impl MessagesRelayer for BridgeHubRococoToRococoBulletinMessagesCliBridge {}
|
|
||||||
|
|
||||||
impl RelayMessages {
|
|
||||||
/// Run the command.
|
|
||||||
pub async fn run(self) -> anyhow::Result<()> {
|
|
||||||
match self.bridge {
|
|
||||||
FullBridge::BridgeHubRococoToBridgeHubWestend =>
|
|
||||||
BridgeHubRococoToBridgeHubWestendMessagesCliBridge::relay_messages(self.params),
|
|
||||||
FullBridge::BridgeHubWestendToBridgeHubRococo =>
|
|
||||||
BridgeHubWestendToBridgeHubRococoMessagesCliBridge::relay_messages(self.params),
|
|
||||||
FullBridge::BridgeHubKusamaToBridgeHubPolkadot =>
|
|
||||||
BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge::relay_messages(self.params),
|
|
||||||
FullBridge::BridgeHubPolkadotToBridgeHubKusama =>
|
|
||||||
BridgeHubPolkadotToBridgeHubKusamaMessagesCliBridge::relay_messages(self.params),
|
|
||||||
FullBridge::PolkadotBulletinToBridgeHubPolkadot =>
|
|
||||||
PolkadotBulletinToBridgeHubPolkadotMessagesCliBridge::relay_messages(self.params),
|
|
||||||
FullBridge::BridgeHubPolkadotToPolkadotBulletin =>
|
|
||||||
BridgeHubPolkadotToPolkadotBulletinMessagesCliBridge::relay_messages(self.params),
|
|
||||||
FullBridge::RococoBulletinToBridgeHubRococo =>
|
|
||||||
RococoBulletinToBridgeHubRococoMessagesCliBridge::relay_messages(self.params),
|
|
||||||
FullBridge::BridgeHubRococoToRococoBulletin =>
|
|
||||||
BridgeHubRococoToRococoBulletinMessagesCliBridge::relay_messages(self.params),
|
|
||||||
}
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,81 +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/>.
|
|
||||||
|
|
||||||
use crate::bridges::{
|
|
||||||
kusama_polkadot::{
|
|
||||||
kusama_parachains_to_bridge_hub_polkadot::BridgeHubKusamaToBridgeHubPolkadotCliBridge,
|
|
||||||
polkadot_parachains_to_bridge_hub_kusama::BridgeHubPolkadotToBridgeHubKusamaCliBridge,
|
|
||||||
},
|
|
||||||
polkadot_bulletin::polkadot_parachains_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge,
|
|
||||||
rococo_bulletin::rococo_parachains_to_rococo_bulletin::RococoToRococoBulletinCliBridge,
|
|
||||||
rococo_westend::{
|
|
||||||
rococo_parachains_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendCliBridge,
|
|
||||||
westend_parachains_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoCliBridge,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use structopt::StructOpt;
|
|
||||||
use strum::{EnumString, VariantNames};
|
|
||||||
use substrate_relay_helper::cli::relay_parachains::{ParachainsRelayer, RelayParachainsParams};
|
|
||||||
|
|
||||||
/// Start parachain heads relayer process.
|
|
||||||
#[derive(StructOpt)]
|
|
||||||
pub struct RelayParachains {
|
|
||||||
/// A bridge instance to relay parachains heads for.
|
|
||||||
#[structopt(possible_values = RelayParachainsBridge::VARIANTS, case_insensitive = true)]
|
|
||||||
bridge: RelayParachainsBridge,
|
|
||||||
#[structopt(flatten)]
|
|
||||||
params: RelayParachainsParams,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Parachain heads relay bridge.
|
|
||||||
#[derive(Debug, EnumString, VariantNames)]
|
|
||||||
#[strum(serialize_all = "kebab_case")]
|
|
||||||
pub enum RelayParachainsBridge {
|
|
||||||
KusamaToBridgeHubPolkadot,
|
|
||||||
PolkadotToBridgeHubKusama,
|
|
||||||
PolkadotToPolkadotBulletin,
|
|
||||||
RococoToRococoBulletin,
|
|
||||||
RococoToBridgeHubWestend,
|
|
||||||
WestendToBridgeHubRococo,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ParachainsRelayer for BridgeHubRococoToBridgeHubWestendCliBridge {}
|
|
||||||
impl ParachainsRelayer for BridgeHubWestendToBridgeHubRococoCliBridge {}
|
|
||||||
impl ParachainsRelayer for BridgeHubKusamaToBridgeHubPolkadotCliBridge {}
|
|
||||||
impl ParachainsRelayer for BridgeHubPolkadotToBridgeHubKusamaCliBridge {}
|
|
||||||
impl ParachainsRelayer for PolkadotToPolkadotBulletinCliBridge {}
|
|
||||||
impl ParachainsRelayer for RococoToRococoBulletinCliBridge {}
|
|
||||||
|
|
||||||
impl RelayParachains {
|
|
||||||
/// Run the command.
|
|
||||||
pub async fn run(self) -> anyhow::Result<()> {
|
|
||||||
match self.bridge {
|
|
||||||
RelayParachainsBridge::RococoToBridgeHubWestend =>
|
|
||||||
BridgeHubRococoToBridgeHubWestendCliBridge::relay_parachains(self.params),
|
|
||||||
RelayParachainsBridge::WestendToBridgeHubRococo =>
|
|
||||||
BridgeHubWestendToBridgeHubRococoCliBridge::relay_parachains(self.params),
|
|
||||||
RelayParachainsBridge::KusamaToBridgeHubPolkadot =>
|
|
||||||
BridgeHubKusamaToBridgeHubPolkadotCliBridge::relay_parachains(self.params),
|
|
||||||
RelayParachainsBridge::PolkadotToBridgeHubKusama =>
|
|
||||||
BridgeHubPolkadotToBridgeHubKusamaCliBridge::relay_parachains(self.params),
|
|
||||||
RelayParachainsBridge::PolkadotToPolkadotBulletin =>
|
|
||||||
PolkadotToPolkadotBulletinCliBridge::relay_parachains(self.params),
|
|
||||||
RelayParachainsBridge::RococoToRococoBulletin =>
|
|
||||||
RococoToRococoBulletinCliBridge::relay_parachains(self.params),
|
|
||||||
}
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +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/>.
|
|
||||||
|
|
||||||
//! Substrate-to-substrate relay entrypoint.
|
|
||||||
|
|
||||||
#![warn(missing_docs)]
|
|
||||||
|
|
||||||
mod bridges;
|
|
||||||
mod cli;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let command = cli::parse_args();
|
|
||||||
let run = command.run();
|
|
||||||
async_std::task::block_on(run);
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "relay-bridge-hub-kusama-client"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2021"
|
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
|
||||||
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }
|
|
||||||
#relay-substrate-client = { path = "../client-substrate" }
|
|
||||||
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
|
|
||||||
|
|
||||||
# Bridge dependencies
|
|
||||||
|
|
||||||
bp-bridge-hub-kusama = { path = "../../chains/chain-bridge-hub-kusama" }
|
|
||||||
bp-header-chain = { path = "../../primitives/header-chain" }
|
|
||||||
bp-messages = { path = "../../primitives/messages" }
|
|
||||||
bp-parachains = { path = "../../primitives/parachains" }
|
|
||||||
bp-polkadot = { path = "../../chains/chain-polkadot" }
|
|
||||||
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
|
|
||||||
bridge-runtime-common = { path = "../../bin/runtime-common" }
|
|
||||||
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" }
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,127 +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-Kusama-Substrate parachain.
|
|
||||||
|
|
||||||
pub mod codegen_runtime;
|
|
||||||
|
|
||||||
use bp_bridge_hub_kusama::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
|
|
||||||
use bp_polkadot::SuffixedCommonSignedExtensionExt;
|
|
||||||
use codec::Encode;
|
|
||||||
use relay_substrate_client::{
|
|
||||||
calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages,
|
|
||||||
ChainWithRuntimeVersion, ChainWithTransactions, ChainWithUtilityPallet,
|
|
||||||
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, SimpleRuntimeVersion,
|
|
||||||
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;
|
|
||||||
|
|
||||||
pub type RuntimeCall = runtime_types::bridge_hub_kusama_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_kusama::UncheckedExtrinsic<RuntimeCall, SignedExtension>;
|
|
||||||
type UtilityCall = runtime_types::pallet_utility::pallet::Call;
|
|
||||||
|
|
||||||
/// Kusama chain definition
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
pub struct BridgeHubKusama;
|
|
||||||
|
|
||||||
impl UnderlyingChainProvider for BridgeHubKusama {
|
|
||||||
type Chain = bp_bridge_hub_kusama::BridgeHubKusama;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Chain for BridgeHubKusama {
|
|
||||||
const NAME: &'static str = "BridgeHubKusama";
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_kusama::BEST_FINALIZED_BRIDGE_HUB_KUSAMA_HEADER_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration = AVERAGE_BLOCK_INTERVAL;
|
|
||||||
|
|
||||||
type SignedBlock = bp_bridge_hub_kusama::SignedBlock;
|
|
||||||
type Call = RuntimeCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithBalances for BridgeHubKusama {
|
|
||||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
|
||||||
bp_bridge_hub_kusama::AccountInfoStorageMapKeyProvider::final_key(account_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<MockUtilityCall<RuntimeCall>> for RuntimeCall {
|
|
||||||
fn from(value: MockUtilityCall<RuntimeCall>) -> RuntimeCall {
|
|
||||||
match value {
|
|
||||||
MockUtilityCall::batch_all(calls) =>
|
|
||||||
RuntimeCall::Utility(UtilityCall::batch_all { calls }),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithUtilityPallet for BridgeHubKusama {
|
|
||||||
type UtilityPallet = MockedRuntimeUtilityPallet<RuntimeCall>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithTransactions for BridgeHubKusama {
|
|
||||||
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,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithMessages for BridgeHubKusama {
|
|
||||||
const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
|
|
||||||
Some(bp_bridge_hub_kusama::WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME);
|
|
||||||
|
|
||||||
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_kusama::TO_BRIDGE_HUB_KUSAMA_MESSAGE_DETAILS_METHOD;
|
|
||||||
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_kusama::FROM_BRIDGE_HUB_KUSAMA_MESSAGE_DETAILS_METHOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for BridgeHubKusama {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
|
||||||
Some(SimpleRuntimeVersion { spec_version: 1_001_000, transaction_version: 4 });
|
|
||||||
}
|
|
||||||
@@ -1,71 +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 that are specific to the BridgeHubKusama runtime.
|
|
||||||
// TODO: regenerate me using `runtime-codegen` tool? (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
|
||||||
|
|
||||||
use codec::{Decode, Encode};
|
|
||||||
use scale_info::TypeInfo;
|
|
||||||
|
|
||||||
pub use bp_bridge_hub_kusama::TransactionExtension;
|
|
||||||
pub use bp_header_chain::BridgeGrandpaCallOf;
|
|
||||||
pub use bp_parachains::BridgeParachainCall;
|
|
||||||
pub use bridge_runtime_common::messages::BridgeMessagesCallOf;
|
|
||||||
pub use relay_substrate_client::calls::{SystemCall, UtilityCall};
|
|
||||||
|
|
||||||
/// Unchecked BridgeHubKusama extrinsic.
|
|
||||||
pub type UncheckedExtrinsic = bp_bridge_hub_kusama::UncheckedExtrinsic<Call, TransactionExtension>;
|
|
||||||
|
|
||||||
// The indirect pallet call used to sync `Polkadot` GRANDPA finality to `BHKusama`.
|
|
||||||
pub type BridgePolkadotGrandpaCall = BridgeGrandpaCallOf<bp_polkadot::Polkadot>;
|
|
||||||
// The indirect pallet call used to sync `BridgeHubPolkadot` messages to `BHKusama`.
|
|
||||||
pub type BridgePolkadotMessagesCall =
|
|
||||||
BridgeMessagesCallOf<bp_bridge_hub_polkadot::BridgeHubPolkadot>;
|
|
||||||
|
|
||||||
/// `BridgeHubKusama` Runtime `Call` enum.
|
|
||||||
///
|
|
||||||
/// The enum represents a subset of possible `Call`s we can send to `BridgeHubKusama` chain.
|
|
||||||
/// Ideally this code would be auto-generated from metadata, because we want to
|
|
||||||
/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s.
|
|
||||||
///
|
|
||||||
/// All entries here (like pretty much in the entire file) must be kept in sync with
|
|
||||||
/// `BridgeHubKusama` `construct_runtime`, so that we maintain SCALE-compatibility.
|
|
||||||
#[allow(clippy::large_enum_variant)]
|
|
||||||
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
|
|
||||||
pub enum Call {
|
|
||||||
#[cfg(test)]
|
|
||||||
#[codec(index = 0)]
|
|
||||||
System(SystemCall),
|
|
||||||
/// Utility pallet.
|
|
||||||
#[codec(index = 40)]
|
|
||||||
Utility(UtilityCall<Call>),
|
|
||||||
|
|
||||||
/// Polkadot bridge pallet.
|
|
||||||
#[codec(index = 51)]
|
|
||||||
BridgePolkadotGrandpa(BridgePolkadotGrandpaCall),
|
|
||||||
/// Polkadot parachain bridge pallet.
|
|
||||||
#[codec(index = 52)]
|
|
||||||
BridgePolkadotParachain(BridgeParachainCall),
|
|
||||||
/// Polkadot messages bridge pallet.
|
|
||||||
#[codec(index = 53)]
|
|
||||||
BridgePolkadotMessages(BridgePolkadotMessagesCall),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<UtilityCall<Call>> for Call {
|
|
||||||
fn from(call: UtilityCall<Call>) -> Call {
|
|
||||||
Call::Utility(call)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "relay-bridge-hub-polkadot-client"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2021"
|
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
|
||||||
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }
|
|
||||||
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
|
|
||||||
|
|
||||||
# Bridge dependencies
|
|
||||||
|
|
||||||
bp-bridge-hub-polkadot = { path = "../../chains/chain-bridge-hub-polkadot" }
|
|
||||||
bp-header-chain = { path = "../../primitives/header-chain" }
|
|
||||||
bp-messages = { path = "../../primitives/messages" }
|
|
||||||
bp-parachains = { path = "../../primitives/parachains" }
|
|
||||||
bp-polkadot = { path = "../../chains/chain-polkadot" }
|
|
||||||
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
|
|
||||||
bp-kusama = { path = "../../chains/chain-kusama" }
|
|
||||||
bp-runtime = { path = "../../primitives/runtime" }
|
|
||||||
bridge-runtime-common = { path = "../../bin/runtime-common" }
|
|
||||||
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" }
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,131 +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-Polkadot-Substrate parachain.
|
|
||||||
|
|
||||||
pub mod codegen_runtime;
|
|
||||||
|
|
||||||
use bp_bridge_hub_polkadot::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
|
|
||||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
|
||||||
use codec::Encode;
|
|
||||||
use relay_substrate_client::{
|
|
||||||
calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages,
|
|
||||||
ChainWithRuntimeVersion, ChainWithTransactions, ChainWithUtilityPallet,
|
|
||||||
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, SimpleRuntimeVersion,
|
|
||||||
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;
|
|
||||||
|
|
||||||
pub type RuntimeCall = runtime_types::bridge_hub_polkadot_runtime::RuntimeCall;
|
|
||||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/2547 - regenerate when ready
|
|
||||||
pub type BridgePolkadotBulletinMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call;
|
|
||||||
pub type BridgeKusamaMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call;
|
|
||||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/2547 - regenerate when ready
|
|
||||||
pub type BridgePolkadotBulletinGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call;
|
|
||||||
pub type BridgeKusamaGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call;
|
|
||||||
pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call;
|
|
||||||
type UncheckedExtrinsic = bp_bridge_hub_polkadot::UncheckedExtrinsic<RuntimeCall, SignedExtension>;
|
|
||||||
type UtilityCall = runtime_types::pallet_utility::pallet::Call;
|
|
||||||
|
|
||||||
/// Polkadot chain definition
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
pub struct BridgeHubPolkadot;
|
|
||||||
|
|
||||||
impl UnderlyingChainProvider for BridgeHubPolkadot {
|
|
||||||
type Chain = bp_bridge_hub_polkadot::BridgeHubPolkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Chain for BridgeHubPolkadot {
|
|
||||||
const NAME: &'static str = "BridgeHubPolkadot";
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_polkadot::BEST_FINALIZED_BRIDGE_HUB_POLKADOT_HEADER_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration = AVERAGE_BLOCK_INTERVAL;
|
|
||||||
|
|
||||||
type SignedBlock = bp_bridge_hub_polkadot::SignedBlock;
|
|
||||||
type Call = RuntimeCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithBalances for BridgeHubPolkadot {
|
|
||||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
|
||||||
bp_bridge_hub_polkadot::AccountInfoStorageMapKeyProvider::final_key(account_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<MockUtilityCall<RuntimeCall>> for RuntimeCall {
|
|
||||||
fn from(value: MockUtilityCall<RuntimeCall>) -> RuntimeCall {
|
|
||||||
match value {
|
|
||||||
MockUtilityCall::batch_all(calls) =>
|
|
||||||
RuntimeCall::Utility(UtilityCall::batch_all { calls }),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithUtilityPallet for BridgeHubPolkadot {
|
|
||||||
type UtilityPallet = MockedRuntimeUtilityPallet<RuntimeCall>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithTransactions for BridgeHubPolkadot {
|
|
||||||
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,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithMessages for BridgeHubPolkadot {
|
|
||||||
const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
|
|
||||||
Some(bp_bridge_hub_polkadot::WITH_BRIDGE_HUB_POLKADOT_RELAYERS_PALLET_NAME);
|
|
||||||
|
|
||||||
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_polkadot::TO_BRIDGE_HUB_POLKADOT_MESSAGE_DETAILS_METHOD;
|
|
||||||
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_polkadot::FROM_BRIDGE_HUB_POLKADOT_MESSAGE_DETAILS_METHOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for BridgeHubPolkadot {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
|
||||||
Some(SimpleRuntimeVersion { spec_version: 1_001_000, transaction_version: 3 });
|
|
||||||
}
|
|
||||||
@@ -1,130 +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 that are specific to the BridgeHubPolkadot runtime.
|
|
||||||
// TODO: regenerate me using `runtime-codegen` tool? (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
|
||||||
|
|
||||||
use codec::{Decode, Encode};
|
|
||||||
use scale_info::TypeInfo;
|
|
||||||
|
|
||||||
pub use bp_bridge_hub_polkadot::TransactionExtension;
|
|
||||||
pub use bp_header_chain::BridgeGrandpaCallOf;
|
|
||||||
pub use bp_parachains::BridgeParachainCall;
|
|
||||||
pub use bridge_runtime_common::messages::BridgeMessagesCallOf;
|
|
||||||
pub use relay_substrate_client::calls::{SystemCall, UtilityCall};
|
|
||||||
|
|
||||||
/// Unchecked BridgeHubPolkadot extrinsic.
|
|
||||||
pub type UncheckedExtrinsic = bp_bridge_hub_polkadot::UncheckedExtrinsic<Call, TransactionExtension>;
|
|
||||||
|
|
||||||
/// The indirect pallet call used to sync `Kusama` GRANDPA finality to `BHPolkadot`.
|
|
||||||
pub type BridgeKusamaGrandpaCall = BridgeGrandpaCallOf<bp_kusama::Kusama>;
|
|
||||||
/// The indirect pallet call used to sync `BridgeHubKusama` messages to `BridgeHubPolkadot`.
|
|
||||||
pub type BridgeKusamaMessagesCall = BridgeMessagesCallOf<bp_bridge_hub_kusama::BridgeHubKusama>;
|
|
||||||
|
|
||||||
/// The indirect pallet call used to sync `PolkadotBulletin` GRANDPA finality to `BHPolkadot`.
|
|
||||||
pub type BridgePolkadotBulletinGrandpaCall =
|
|
||||||
BridgeGrandpaCallOf<bp_polkadot_bulletin::PolkadotBulletin>;
|
|
||||||
/// The indirect pallet call used to sync `PolkadotBulletin` messages to `BridgeHubPolkadot`.
|
|
||||||
pub type BridgePolkadotBulletinMessagesCall =
|
|
||||||
BridgeMessagesCallOf<bp_polkadot_bulletin::PolkadotBulletin>;
|
|
||||||
|
|
||||||
/// `BridgeHubPolkadot` Runtime `Call` enum.
|
|
||||||
///
|
|
||||||
/// The enum represents a subset of possible `Call`s we can send to `BridgeHubPolkadot` chain.
|
|
||||||
/// Ideally this code would be auto-generated from metadata, because we want to
|
|
||||||
/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s.
|
|
||||||
///
|
|
||||||
/// All entries here (like pretty much in the entire file) must be kept in sync with
|
|
||||||
/// `BridgeHubPolkadot` `construct_runtime`, so that we maintain SCALE-compatibility.
|
|
||||||
#[allow(clippy::large_enum_variant)]
|
|
||||||
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
|
|
||||||
pub enum Call {
|
|
||||||
#[cfg(test)]
|
|
||||||
#[codec(index = 0)]
|
|
||||||
System(SystemCall),
|
|
||||||
/// Utility pallet.
|
|
||||||
#[codec(index = 40)]
|
|
||||||
Utility(UtilityCall<Call>),
|
|
||||||
|
|
||||||
/// Kusama grandpa bridge pallet.
|
|
||||||
#[codec(index = 51)]
|
|
||||||
BridgeKusamaGrandpa(BridgeKusamaGrandpaCall),
|
|
||||||
/// Kusama parachains bridge pallet.
|
|
||||||
#[codec(index = 52)]
|
|
||||||
BridgeKusamaParachain(BridgeParachainCall),
|
|
||||||
/// Kusama messages bridge pallet.
|
|
||||||
#[codec(index = 53)]
|
|
||||||
BridgeKusamaMessages(BridgeKusamaMessagesCall),
|
|
||||||
|
|
||||||
/// Polkadot Bulletin grandpa bridge pallet.
|
|
||||||
#[codec(index = 55)]
|
|
||||||
BridgePolkadotBulletinGrandpa(BridgePolkadotBulletinGrandpaCall),
|
|
||||||
/// Polkadot Bulletin messages bridge pallet.
|
|
||||||
#[codec(index = 56)]
|
|
||||||
BridgePolkadotBulletinMessages(BridgePolkadotBulletinMessagesCall),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<UtilityCall<Call>> for Call {
|
|
||||||
fn from(call: UtilityCall<Call>) -> Call {
|
|
||||||
Call::Utility(call)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use bp_runtime::BasicOperatingMode;
|
|
||||||
use sp_consensus_grandpa::AuthorityList;
|
|
||||||
use sp_core::hexdisplay::HexDisplay;
|
|
||||||
use sp_runtime::traits::Header;
|
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
pub type RelayBlockNumber = bp_polkadot_core::BlockNumber;
|
|
||||||
pub type RelayBlockHasher = bp_polkadot_core::Hasher;
|
|
||||||
pub type RelayBlockHeader = sp_runtime::generic::Header<RelayBlockNumber, RelayBlockHasher>;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn encode_decode_calls() {
|
|
||||||
let header = RelayBlockHeader::new(
|
|
||||||
75,
|
|
||||||
bp_polkadot_core::Hash::from_str(
|
|
||||||
"0xd2c0afaab32de0cb8f7f0d89217e37c5ea302c1ffb5a7a83e10d20f12c32874d",
|
|
||||||
)
|
|
||||||
.expect("invalid value"),
|
|
||||||
bp_polkadot_core::Hash::from_str(
|
|
||||||
"0x92b965f0656a4e0e5fc0167da2d4b5ee72b3be2c1583c4c1e5236c8c12aa141b",
|
|
||||||
)
|
|
||||||
.expect("invalid value"),
|
|
||||||
bp_polkadot_core::Hash::from_str(
|
|
||||||
"0xae4a25acf250d72ed02c149ecc7dd3c9ee976d41a2888fc551de8064521dc01d",
|
|
||||||
)
|
|
||||||
.expect("invalid value"),
|
|
||||||
Default::default(),
|
|
||||||
);
|
|
||||||
let init_data = bp_header_chain::InitializationData {
|
|
||||||
header: Box::new(header),
|
|
||||||
authority_list: AuthorityList::default(),
|
|
||||||
set_id: 6,
|
|
||||||
operating_mode: BasicOperatingMode::Normal,
|
|
||||||
};
|
|
||||||
let call = BridgeKusamaGrandpaCall::initialize { init_data };
|
|
||||||
let tx = Call::BridgeKusamaGrandpa(call);
|
|
||||||
|
|
||||||
// encode call as hex string
|
|
||||||
let hex_encoded_call = format!("0x{:?}", HexDisplay::from(&Encode::encode(&tx)));
|
|
||||||
assert_eq!(hex_encoded_call, "0x3301ae4a25acf250d72ed02c149ecc7dd3c9ee976d41a2888fc551de8064521dc01d2d0192b965f0656a4e0e5fc0167da2d4b5ee72b3be2c1583c4c1e5236c8c12aa141bd2c0afaab32de0cb8f7f0d89217e37c5ea302c1ffb5a7a83e10d20f12c32874d0000060000000000000000");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "relay-bridge-hub-rococo-client"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2021"
|
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
|
||||||
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }
|
|
||||||
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
|
|
||||||
|
|
||||||
# Bridge dependencies
|
|
||||||
|
|
||||||
bp-bridge-hub-rococo = { path = "../../chains/chain-bridge-hub-rococo" }
|
|
||||||
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-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" }
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,129 +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-Rococo-Substrate parachain.
|
|
||||||
|
|
||||||
pub mod codegen_runtime;
|
|
||||||
|
|
||||||
use bp_bridge_hub_rococo::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
|
|
||||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
|
||||||
use codec::Encode;
|
|
||||||
use relay_substrate_client::{
|
|
||||||
calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages,
|
|
||||||
ChainWithRuntimeVersion, ChainWithTransactions, ChainWithUtilityPallet,
|
|
||||||
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, SimpleRuntimeVersion,
|
|
||||||
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;
|
|
||||||
|
|
||||||
pub type RuntimeCall = runtime_types::bridge_hub_rococo_runtime::RuntimeCall;
|
|
||||||
pub type BridgeMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call;
|
|
||||||
pub type BridgeBulletinMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call2;
|
|
||||||
pub type BridgeGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call;
|
|
||||||
pub type BridgeBulletinGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call2;
|
|
||||||
pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call;
|
|
||||||
type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic<RuntimeCall, SignedExtension>;
|
|
||||||
type UtilityCall = runtime_types::pallet_utility::pallet::Call;
|
|
||||||
|
|
||||||
/// Rococo chain definition
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
pub struct BridgeHubRococo;
|
|
||||||
|
|
||||||
impl UnderlyingChainProvider for BridgeHubRococo {
|
|
||||||
type Chain = bp_bridge_hub_rococo::BridgeHubRococo;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Chain for BridgeHubRococo {
|
|
||||||
const NAME: &'static str = "BridgeHubRococo";
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_rococo::BEST_FINALIZED_BRIDGE_HUB_ROCOCO_HEADER_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration = AVERAGE_BLOCK_INTERVAL;
|
|
||||||
|
|
||||||
type SignedBlock = bp_bridge_hub_rococo::SignedBlock;
|
|
||||||
type Call = RuntimeCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithBalances for BridgeHubRococo {
|
|
||||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
|
||||||
bp_bridge_hub_rococo::AccountInfoStorageMapKeyProvider::final_key(account_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<MockUtilityCall<RuntimeCall>> for RuntimeCall {
|
|
||||||
fn from(value: MockUtilityCall<RuntimeCall>) -> RuntimeCall {
|
|
||||||
match value {
|
|
||||||
MockUtilityCall::batch_all(calls) =>
|
|
||||||
RuntimeCall::Utility(UtilityCall::batch_all { calls }),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithUtilityPallet for BridgeHubRococo {
|
|
||||||
type UtilityPallet = MockedRuntimeUtilityPallet<RuntimeCall>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithTransactions for BridgeHubRococo {
|
|
||||||
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,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithMessages for BridgeHubRococo {
|
|
||||||
const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
|
|
||||||
Some(bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_RELAYERS_PALLET_NAME);
|
|
||||||
|
|
||||||
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_rococo::TO_BRIDGE_HUB_ROCOCO_MESSAGE_DETAILS_METHOD;
|
|
||||||
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_rococo::FROM_BRIDGE_HUB_ROCOCO_MESSAGE_DETAILS_METHOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for BridgeHubRococo {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
|
||||||
Some(SimpleRuntimeVersion { spec_version: 1_008_000, transaction_version: 4 });
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "relay-bridge-hub-westend-client"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2021"
|
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
|
||||||
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }
|
|
||||||
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
|
|
||||||
|
|
||||||
# Bridge dependencies
|
|
||||||
|
|
||||||
bp-bridge-hub-westend = { path = "../../chains/chain-bridge-hub-westend" }
|
|
||||||
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-rococo = { path = "../../chains/chain-rococo" }
|
|
||||||
|
|
||||||
bridge-runtime-common = { path = "../../bin/runtime-common" }
|
|
||||||
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]
|
|
||||||
bp-runtime = { path = "../../primitives/runtime" }
|
|
||||||
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,127 +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-Westend-Substrate parachain.
|
|
||||||
|
|
||||||
pub mod codegen_runtime;
|
|
||||||
|
|
||||||
use bp_bridge_hub_westend::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
|
|
||||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
|
||||||
use codec::Encode;
|
|
||||||
use relay_substrate_client::{
|
|
||||||
calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages,
|
|
||||||
ChainWithRuntimeVersion, ChainWithTransactions, ChainWithUtilityPallet,
|
|
||||||
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, SimpleRuntimeVersion,
|
|
||||||
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;
|
|
||||||
|
|
||||||
pub type RuntimeCall = runtime_types::bridge_hub_westend_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_westend::UncheckedExtrinsic<RuntimeCall, SignedExtension>;
|
|
||||||
type UtilityCall = runtime_types::pallet_utility::pallet::Call;
|
|
||||||
|
|
||||||
/// Westend chain definition
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
pub struct BridgeHubWestend;
|
|
||||||
|
|
||||||
impl UnderlyingChainProvider for BridgeHubWestend {
|
|
||||||
type Chain = bp_bridge_hub_westend::BridgeHubWestend;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Chain for BridgeHubWestend {
|
|
||||||
const NAME: &'static str = "BridgeHubWestend";
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_westend::BEST_FINALIZED_BRIDGE_HUB_WESTEND_HEADER_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration = AVERAGE_BLOCK_INTERVAL;
|
|
||||||
|
|
||||||
type SignedBlock = bp_bridge_hub_westend::SignedBlock;
|
|
||||||
type Call = RuntimeCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithBalances for BridgeHubWestend {
|
|
||||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
|
||||||
bp_bridge_hub_westend::AccountInfoStorageMapKeyProvider::final_key(account_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<MockUtilityCall<RuntimeCall>> for RuntimeCall {
|
|
||||||
fn from(value: MockUtilityCall<RuntimeCall>) -> RuntimeCall {
|
|
||||||
match value {
|
|
||||||
MockUtilityCall::batch_all(calls) =>
|
|
||||||
RuntimeCall::Utility(UtilityCall::batch_all { calls }),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithUtilityPallet for BridgeHubWestend {
|
|
||||||
type UtilityPallet = MockedRuntimeUtilityPallet<RuntimeCall>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithTransactions for BridgeHubWestend {
|
|
||||||
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,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithMessages for BridgeHubWestend {
|
|
||||||
const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
|
|
||||||
Some(bp_bridge_hub_westend::WITH_BRIDGE_HUB_WESTEND_RELAYERS_PALLET_NAME);
|
|
||||||
|
|
||||||
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_westend::TO_BRIDGE_HUB_WESTEND_MESSAGE_DETAILS_METHOD;
|
|
||||||
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
|
||||||
bp_bridge_hub_westend::FROM_BRIDGE_HUB_WESTEND_MESSAGE_DETAILS_METHOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for BridgeHubWestend {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
|
||||||
Some(SimpleRuntimeVersion { spec_version: 1_008_000, transaction_version: 4 });
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "relay-kusama-client"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2021"
|
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
|
||||||
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }
|
|
||||||
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
|
|
||||||
|
|
||||||
# Bridge dependencies
|
|
||||||
|
|
||||||
bp-kusama = { path = "../../chains/chain-kusama" }
|
|
||||||
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
|
|
||||||
bp-runtime = { path = "../../primitives/runtime" }
|
|
||||||
|
|
||||||
relay-substrate-client = { path = "../client-substrate" }
|
|
||||||
relay-utils = { path = "../utils" }
|
|
||||||
|
|
||||||
# Substrate Dependencies
|
|
||||||
|
|
||||||
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
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" }
|
|
||||||
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,122 +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 Kusama chain.
|
|
||||||
|
|
||||||
pub mod codegen_runtime;
|
|
||||||
|
|
||||||
use bp_kusama::{AccountInfoStorageMapKeyProvider, KUSAMA_SYNCED_HEADERS_GRANDPA_INFO_METHOD};
|
|
||||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
|
||||||
use codec::Encode;
|
|
||||||
use relay_substrate_client::{
|
|
||||||
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithRuntimeVersion, ChainWithTransactions,
|
|
||||||
Error as SubstrateError, RelayChain, SignParam, SimpleRuntimeVersion, 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;
|
|
||||||
|
|
||||||
pub type RuntimeCall = runtime_types::kusama_runtime::RuntimeCall;
|
|
||||||
|
|
||||||
pub type GrandpaCall = runtime_types::pallet_grandpa::pallet::Call;
|
|
||||||
|
|
||||||
/// Kusama header id.
|
|
||||||
pub type HeaderId = relay_utils::HeaderId<bp_kusama::Hash, bp_kusama::BlockNumber>;
|
|
||||||
|
|
||||||
/// Kusama header type used in headers sync.
|
|
||||||
pub type SyncHeader = relay_substrate_client::SyncHeader<bp_kusama::Header>;
|
|
||||||
|
|
||||||
/// The address format for describing accounts.
|
|
||||||
pub type Address = MultiAddress<bp_kusama::AccountId, ()>;
|
|
||||||
|
|
||||||
/// Kusama chain definition
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub struct Kusama;
|
|
||||||
|
|
||||||
impl UnderlyingChainProvider for Kusama {
|
|
||||||
type Chain = bp_kusama::Kusama;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Chain for Kusama {
|
|
||||||
const NAME: &'static str = "Kusama";
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
bp_kusama::BEST_FINALIZED_KUSAMA_HEADER_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6);
|
|
||||||
|
|
||||||
type SignedBlock = bp_kusama::SignedBlock;
|
|
||||||
type Call = RuntimeCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithGrandpa for Kusama {
|
|
||||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
|
||||||
KUSAMA_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
|
||||||
|
|
||||||
type KeyOwnerProof = MembershipProof;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithBalances for Kusama {
|
|
||||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
|
||||||
AccountInfoStorageMapKeyProvider::final_key(account_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayChain for Kusama {
|
|
||||||
const PARAS_PALLET_NAME: &'static str = bp_kusama::PARAS_PALLET_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithTransactions for Kusama {
|
|
||||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
|
||||||
type SignedTransaction =
|
|
||||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_kusama::SignedExtension>;
|
|
||||||
|
|
||||||
fn sign_transaction(
|
|
||||||
param: SignParam<Self>,
|
|
||||||
unsigned: UnsignedTransaction<Self>,
|
|
||||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
|
||||||
let raw_payload = SignedPayload::new(
|
|
||||||
unsigned.call,
|
|
||||||
bp_kusama::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,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for Kusama {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
|
||||||
Some(SimpleRuntimeVersion { spec_version: 1_001_002, transaction_version: 25 });
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "relay-polkadot-bulletin-client"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2021"
|
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
|
||||||
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }
|
|
||||||
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
|
|
||||||
|
|
||||||
# Bridge dependencies
|
|
||||||
|
|
||||||
bp-header-chain = { path = "../../primitives/header-chain" }
|
|
||||||
bp-messages = { path = "../../primitives/messages" }
|
|
||||||
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
|
|
||||||
bp-polkadot-bulletin = { path = "../../chains/chain-polkadot-bulletin" }
|
|
||||||
bp-runtime = { path = "../../primitives/runtime" }
|
|
||||||
bridge-runtime-common = { path = "../../bin/runtime-common" }
|
|
||||||
relay-substrate-client = { path = "../client-substrate" }
|
|
||||||
relay-utils = { path = "../utils" }
|
|
||||||
|
|
||||||
# Substrate Dependencies
|
|
||||||
|
|
||||||
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
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" }
|
|
||||||
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,137 +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 Polkadot Bulletin chain.
|
|
||||||
|
|
||||||
mod codegen_runtime;
|
|
||||||
|
|
||||||
use bp_polkadot_bulletin::POLKADOT_BULLETIN_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
|
||||||
use codec::Encode;
|
|
||||||
use relay_substrate_client::{
|
|
||||||
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, ChainWithRuntimeVersion,
|
|
||||||
ChainWithTransactions, Error as SubstrateError, SignParam, SimpleRuntimeVersion,
|
|
||||||
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;
|
|
||||||
|
|
||||||
/// Call of the Polkadot Bulletin Chain runtime.
|
|
||||||
pub type RuntimeCall = runtime_types::polkadot_bulletin_chain_runtime::RuntimeCall;
|
|
||||||
/// Call of the `Sudo` pallet.
|
|
||||||
pub type SudoCall = runtime_types::pallet_sudo::pallet::Call;
|
|
||||||
/// 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 BridgePolkadotMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call;
|
|
||||||
|
|
||||||
/// Polkadot header id.
|
|
||||||
pub type HeaderId =
|
|
||||||
relay_utils::HeaderId<bp_polkadot_bulletin::Hash, bp_polkadot_bulletin::BlockNumber>;
|
|
||||||
|
|
||||||
/// Polkadot header type used in headers sync.
|
|
||||||
pub type SyncHeader = relay_substrate_client::SyncHeader<bp_polkadot_bulletin::Header>;
|
|
||||||
|
|
||||||
/// The address format for describing accounts.
|
|
||||||
pub type Address = MultiAddress<bp_polkadot_bulletin::AccountId, ()>;
|
|
||||||
|
|
||||||
/// Polkadot chain definition
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub struct PolkadotBulletin;
|
|
||||||
|
|
||||||
impl UnderlyingChainProvider for PolkadotBulletin {
|
|
||||||
type Chain = bp_polkadot_bulletin::PolkadotBulletin;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Chain for PolkadotBulletin {
|
|
||||||
const NAME: &'static str = "PolkadotBulletin";
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
bp_polkadot_bulletin::BEST_FINALIZED_POLKADOT_BULLETIN_HEADER_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6);
|
|
||||||
|
|
||||||
type SignedBlock = bp_polkadot_bulletin::SignedBlock;
|
|
||||||
type Call = RuntimeCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithGrandpa for PolkadotBulletin {
|
|
||||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
|
||||||
POLKADOT_BULLETIN_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
|
||||||
|
|
||||||
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 =
|
|
||||||
bp_polkadot_bulletin::UncheckedExtrinsic<Self::Call, bp_polkadot_bulletin::SignedExtension>;
|
|
||||||
|
|
||||||
fn sign_transaction(
|
|
||||||
param: SignParam<Self>,
|
|
||||||
unsigned: UnsignedTransaction<Self>,
|
|
||||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
|
||||||
let raw_payload = SignedPayload::new(
|
|
||||||
unsigned.call,
|
|
||||||
bp_polkadot_bulletin::SignedExtension::from_params(
|
|
||||||
param.spec_version,
|
|
||||||
param.transaction_version,
|
|
||||||
unsigned.era,
|
|
||||||
param.genesis_hash,
|
|
||||||
unsigned.nonce,
|
|
||||||
),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
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,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for PolkadotBulletin {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
|
||||||
Some(SimpleRuntimeVersion { spec_version: 100, transaction_version: 1 });
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "relay-polkadot-client"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2021"
|
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
|
||||||
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }
|
|
||||||
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
|
|
||||||
|
|
||||||
# Bridge dependencies
|
|
||||||
|
|
||||||
bp-polkadot = { path = "../../chains/chain-polkadot" }
|
|
||||||
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
|
|
||||||
bp-runtime = { path = "../../primitives/runtime" }
|
|
||||||
|
|
||||||
relay-substrate-client = { path = "../client-substrate" }
|
|
||||||
relay-utils = { path = "../utils" }
|
|
||||||
|
|
||||||
# Substrate Dependencies
|
|
||||||
|
|
||||||
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
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" }
|
|
||||||
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,122 +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 Polkadot chain.
|
|
||||||
|
|
||||||
mod codegen_runtime;
|
|
||||||
|
|
||||||
use bp_polkadot::{AccountInfoStorageMapKeyProvider, POLKADOT_SYNCED_HEADERS_GRANDPA_INFO_METHOD};
|
|
||||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
|
||||||
use codec::Encode;
|
|
||||||
use relay_substrate_client::{
|
|
||||||
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithRuntimeVersion, ChainWithTransactions,
|
|
||||||
Error as SubstrateError, RelayChain, SignParam, SimpleRuntimeVersion, 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;
|
|
||||||
|
|
||||||
pub type RuntimeCall = runtime_types::polkadot_runtime::RuntimeCall;
|
|
||||||
|
|
||||||
pub type GrandpaCall = runtime_types::pallet_grandpa::pallet::Call;
|
|
||||||
|
|
||||||
/// Polkadot header id.
|
|
||||||
pub type HeaderId = relay_utils::HeaderId<bp_polkadot::Hash, bp_polkadot::BlockNumber>;
|
|
||||||
|
|
||||||
/// Polkadot header type used in headers sync.
|
|
||||||
pub type SyncHeader = relay_substrate_client::SyncHeader<bp_polkadot::Header>;
|
|
||||||
|
|
||||||
/// The address format for describing accounts.
|
|
||||||
pub type Address = MultiAddress<bp_polkadot::AccountId, ()>;
|
|
||||||
|
|
||||||
/// Polkadot chain definition
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub struct Polkadot;
|
|
||||||
|
|
||||||
impl UnderlyingChainProvider for Polkadot {
|
|
||||||
type Chain = bp_polkadot::Polkadot;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Chain for Polkadot {
|
|
||||||
const NAME: &'static str = "Polkadot";
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
bp_polkadot::BEST_FINALIZED_POLKADOT_HEADER_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6);
|
|
||||||
|
|
||||||
type SignedBlock = bp_polkadot::SignedBlock;
|
|
||||||
type Call = RuntimeCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithGrandpa for Polkadot {
|
|
||||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
|
||||||
POLKADOT_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
|
||||||
|
|
||||||
type KeyOwnerProof = MembershipProof;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithBalances for Polkadot {
|
|
||||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
|
||||||
AccountInfoStorageMapKeyProvider::final_key(account_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayChain for Polkadot {
|
|
||||||
const PARAS_PALLET_NAME: &'static str = bp_polkadot::PARAS_PALLET_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithTransactions for Polkadot {
|
|
||||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
|
||||||
type SignedTransaction =
|
|
||||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_polkadot::SignedExtension>;
|
|
||||||
|
|
||||||
fn sign_transaction(
|
|
||||||
param: SignParam<Self>,
|
|
||||||
unsigned: UnsignedTransaction<Self>,
|
|
||||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
|
||||||
let raw_payload = SignedPayload::new(
|
|
||||||
unsigned.call,
|
|
||||||
bp_polkadot::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,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for Polkadot {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
|
||||||
Some(SimpleRuntimeVersion { spec_version: 1_001_002, transaction_version: 25 });
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "relay-rococo-client"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2021"
|
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
|
||||||
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }
|
|
||||||
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
|
|
||||||
|
|
||||||
# Bridge dependencies
|
|
||||||
|
|
||||||
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
|
|
||||||
bp-rococo = { path = "../../chains/chain-rococo" }
|
|
||||||
|
|
||||||
relay-substrate-client = { path = "../client-substrate" }
|
|
||||||
relay-utils = { path = "../utils" }
|
|
||||||
|
|
||||||
# Substrate Dependencies
|
|
||||||
|
|
||||||
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
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" }
|
|
||||||
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,122 +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 Rococo-Substrate chain.
|
|
||||||
|
|
||||||
pub mod codegen_runtime;
|
|
||||||
|
|
||||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
|
||||||
use bp_rococo::ROCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
|
||||||
use codec::Encode;
|
|
||||||
use relay_substrate_client::{
|
|
||||||
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithRuntimeVersion, ChainWithTransactions,
|
|
||||||
Error as SubstrateError, RelayChain, SignParam, SimpleRuntimeVersion, 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;
|
|
||||||
|
|
||||||
pub type RuntimeCall = runtime_types::rococo_runtime::RuntimeCall;
|
|
||||||
|
|
||||||
pub type GrandpaCall = runtime_types::pallet_grandpa::pallet::Call;
|
|
||||||
|
|
||||||
/// Rococo header id.
|
|
||||||
pub type HeaderId = relay_utils::HeaderId<bp_rococo::Hash, bp_rococo::BlockNumber>;
|
|
||||||
|
|
||||||
/// Rococo header type used in headers sync.
|
|
||||||
pub type SyncHeader = relay_substrate_client::SyncHeader<bp_rococo::Header>;
|
|
||||||
|
|
||||||
/// The address format for describing accounts.
|
|
||||||
pub type Address = MultiAddress<bp_rococo::AccountId, ()>;
|
|
||||||
|
|
||||||
/// Rococo chain definition
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub struct Rococo;
|
|
||||||
|
|
||||||
impl UnderlyingChainProvider for Rococo {
|
|
||||||
type Chain = bp_rococo::Rococo;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Chain for Rococo {
|
|
||||||
const NAME: &'static str = "Rococo";
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
bp_rococo::BEST_FINALIZED_ROCOCO_HEADER_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6);
|
|
||||||
|
|
||||||
type SignedBlock = bp_rococo::SignedBlock;
|
|
||||||
type Call = RuntimeCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithGrandpa for Rococo {
|
|
||||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
|
||||||
ROCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
|
||||||
|
|
||||||
type KeyOwnerProof = MembershipProof;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithBalances for Rococo {
|
|
||||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
|
||||||
bp_rococo::AccountInfoStorageMapKeyProvider::final_key(account_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayChain for Rococo {
|
|
||||||
const PARAS_PALLET_NAME: &'static str = bp_rococo::PARAS_PALLET_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithTransactions for Rococo {
|
|
||||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
|
||||||
type SignedTransaction =
|
|
||||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_rococo::SignedExtension>;
|
|
||||||
|
|
||||||
fn sign_transaction(
|
|
||||||
param: SignParam<Self>,
|
|
||||||
unsigned: UnsignedTransaction<Self>,
|
|
||||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
|
||||||
let raw_payload = SignedPayload::new(
|
|
||||||
unsigned.call,
|
|
||||||
bp_rococo::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,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for Rococo {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
|
||||||
Some(SimpleRuntimeVersion { spec_version: 1_008_000, transaction_version: 24 });
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "relay-westend-client"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2021"
|
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
|
||||||
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }
|
|
||||||
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
|
|
||||||
|
|
||||||
# Bridge dependencies
|
|
||||||
|
|
||||||
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
|
|
||||||
bp-runtime = { path = "../../primitives/runtime" }
|
|
||||||
bp-westend = { path = "../../chains/chain-westend" }
|
|
||||||
|
|
||||||
relay-substrate-client = { path = "../client-substrate" }
|
|
||||||
relay-utils = { path = "../utils" }
|
|
||||||
|
|
||||||
# Substrate Dependencies
|
|
||||||
|
|
||||||
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
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" }
|
|
||||||
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,122 +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 Westend chain.
|
|
||||||
|
|
||||||
pub mod codegen_runtime;
|
|
||||||
|
|
||||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
|
||||||
use bp_westend::WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
|
||||||
use codec::Encode;
|
|
||||||
use relay_substrate_client::{
|
|
||||||
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithRuntimeVersion, ChainWithTransactions,
|
|
||||||
Error as SubstrateError, RelayChain, SignParam, SimpleRuntimeVersion, 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;
|
|
||||||
|
|
||||||
pub type RuntimeCall = runtime_types::westend_runtime::RuntimeCall;
|
|
||||||
|
|
||||||
pub type GrandpaCall = runtime_types::pallet_grandpa::pallet::Call;
|
|
||||||
|
|
||||||
/// Westend header id.
|
|
||||||
pub type HeaderId = relay_utils::HeaderId<bp_westend::Hash, bp_westend::BlockNumber>;
|
|
||||||
|
|
||||||
/// Westend header type used in headers sync.
|
|
||||||
pub type SyncHeader = relay_substrate_client::SyncHeader<bp_westend::Header>;
|
|
||||||
|
|
||||||
/// The address format for describing accounts.
|
|
||||||
pub type Address = MultiAddress<bp_westend::AccountId, ()>;
|
|
||||||
|
|
||||||
/// Westend chain definition
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub struct Westend;
|
|
||||||
|
|
||||||
impl UnderlyingChainProvider for Westend {
|
|
||||||
type Chain = bp_westend::Westend;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Chain for Westend {
|
|
||||||
const NAME: &'static str = "Westend";
|
|
||||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
|
||||||
bp_westend::BEST_FINALIZED_WESTEND_HEADER_METHOD;
|
|
||||||
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6);
|
|
||||||
|
|
||||||
type SignedBlock = bp_westend::SignedBlock;
|
|
||||||
type Call = RuntimeCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithGrandpa for Westend {
|
|
||||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
|
||||||
WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
|
||||||
|
|
||||||
type KeyOwnerProof = MembershipProof;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelayChain for Westend {
|
|
||||||
const PARAS_PALLET_NAME: &'static str = bp_westend::PARAS_PALLET_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithBalances for Westend {
|
|
||||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
|
||||||
bp_westend::AccountInfoStorageMapKeyProvider::final_key(account_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithTransactions for Westend {
|
|
||||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
|
||||||
type SignedTransaction =
|
|
||||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_westend::SignedExtension>;
|
|
||||||
|
|
||||||
fn sign_transaction(
|
|
||||||
param: SignParam<Self>,
|
|
||||||
unsigned: UnsignedTransaction<Self>,
|
|
||||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
|
||||||
let raw_payload = SignedPayload::new(
|
|
||||||
unsigned.call,
|
|
||||||
bp_westend::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,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ChainWithRuntimeVersion for Westend {
|
|
||||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
|
||||||
Some(SimpleRuntimeVersion { spec_version: 1_008_000, transaction_version: 24 });
|
|
||||||
}
|
|
||||||
@@ -58,6 +58,6 @@ sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "mas
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bp-rococo = { path = "../../chains/chain-rococo" }
|
bp-rococo = { path = "../../chains/chain-rococo" }
|
||||||
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
||||||
relay-bridge-hub-rococo-client = { path = "../client-bridge-hub-rococo" }
|
relay-bridge-hub-rococo-client = { path = "../../relay-clients/client-bridge-hub-rococo" }
|
||||||
relay-bridge-hub-westend-client = { path = "../client-bridge-hub-westend" }
|
relay-bridge-hub-westend-client = { path = "../../relay-clients/client-bridge-hub-westend" }
|
||||||
relay-rococo-client = { path = "../client-rococo" }
|
relay-rococo-client = { path = "../../relay-clients/client-rococo" }
|
||||||
|
|||||||
Reference in New Issue
Block a user