mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 02:08:02 +00:00
Add Rococo<>Westend bridge support/relay (#2647)
* Added Rococo<>Westend primitives * Latest fashion * WIP * Temporary hack for AssetHubWestend to Millau * typo * tool/runtime-codegen tweaks * Rococo<>Westend relay part * zepter * Unify `Parachain` vs `Parachains`
This commit is contained in:
committed by
Bastian Köcher
parent
d4a742a6d9
commit
a3e6ce4f94
@@ -568,7 +568,7 @@ impl pallet_bridge_parachains::Config<WithWestendParachainsInstance> for Runtime
|
||||
type BridgesGrandpaPalletInstance = WestendGrandpaInstance;
|
||||
type ParasPalletName = WestendParasPalletName;
|
||||
type ParaStoredHeaderDataBuilder =
|
||||
SingleParaStoredHeaderDataBuilder<bp_westend::AssetHubWestend>;
|
||||
SingleParaStoredHeaderDataBuilder<bp_bridged_chain::AssetHubWestend>;
|
||||
type HeadsToKeep = ConstU32<1024>;
|
||||
type MaxParaHeadDataSize = MaxWestendParaHeadDataSize;
|
||||
}
|
||||
@@ -974,12 +974,12 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_westend::AssetHubWestendFinalityApi<Block> for Runtime {
|
||||
impl bp_bridged_chain::AssetHubWestendFinalityApi<Block> for Runtime {
|
||||
fn best_finalized() -> Option<HeaderId<bp_westend::Hash, bp_westend::BlockNumber>> {
|
||||
pallet_bridge_parachains::Pallet::<
|
||||
Runtime,
|
||||
WithWestendParachainsInstance,
|
||||
>::best_parachain_head_id::<bp_westend::AssetHubWestend>().unwrap_or(None)
|
||||
>::best_parachain_head_id::<bp_bridged_chain::AssetHubWestend>().unwrap_or(None)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1252,3 +1252,49 @@ mod tests {
|
||||
assert!(core::mem::size_of::<RuntimeCall>() <= MAX_CALL_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO: Note: I know this does not belong here, but I don't want to add it to the
|
||||
/// `chain-asset-hub-westend` or `chain-westend`, because we wont use it for production and I don't
|
||||
/// want to bring this to the bridges subtree now. Anyway, we plan to retire millau/rialto, so this
|
||||
/// hack will disappear with that.
|
||||
pub mod bp_bridged_chain {
|
||||
use bp_messages::Weight;
|
||||
pub use bp_polkadot_core::{
|
||||
AccountId, AccountInfoStorageMapKeyProvider, AccountPublic, Balance, BlockNumber, Hash,
|
||||
Hasher, Hashing, Header, Nonce, Perbill, Signature, SignedBlock, UncheckedExtrinsic,
|
||||
EXTRA_STORAGE_PROOF_SIZE, TX_EXTRA_BYTES,
|
||||
};
|
||||
use bp_runtime::{decl_bridge_finality_runtime_apis, Chain, Parachain};
|
||||
|
||||
/// `AssetHubWestend` parachain definition
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct AssetHubWestend;
|
||||
|
||||
// AssetHubWestend seems to use the same configuration as all Polkadot-like chains, so we'll use
|
||||
// Westend primitives here.
|
||||
impl Chain for AssetHubWestend {
|
||||
type BlockNumber = BlockNumber;
|
||||
type Hash = Hash;
|
||||
type Hasher = Hasher;
|
||||
type Header = Header;
|
||||
|
||||
type AccountId = AccountId;
|
||||
type Balance = Balance;
|
||||
type Nonce = Nonce;
|
||||
type Signature = Signature;
|
||||
|
||||
fn max_extrinsic_size() -> u32 {
|
||||
bp_westend::Westend::max_extrinsic_size()
|
||||
}
|
||||
|
||||
fn max_extrinsic_weight() -> Weight {
|
||||
bp_westend::Westend::max_extrinsic_weight()
|
||||
}
|
||||
}
|
||||
|
||||
impl Parachain for AssetHubWestend {
|
||||
const PARACHAIN_ID: u32 = 1000;
|
||||
}
|
||||
|
||||
decl_bridge_finality_runtime_apis!(AssetHubWestend);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
|
||||
log = { version = "0.4.20", default-features = false }
|
||||
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0", optional = true }
|
||||
|
||||
@@ -335,7 +335,7 @@ impl<T: Config<I>, I: 'static> SendXcm for Pallet<T, I> {
|
||||
// just use exporter to validate destination and insert instructions to pay message fee
|
||||
// at the sibling/child bridge hub
|
||||
//
|
||||
// the cost will include both cost of: (1) to-sibling bridg hub delivery (returned by
|
||||
// the cost will include both cost of: (1) to-sibling bridge hub delivery (returned by
|
||||
// the `Config::ToBridgeHubSender`) and (2) to-bridged bridge hub delivery (returned by
|
||||
// `Self::exporter_for`)
|
||||
ViaBridgeHubExporter::<T, I>::validate(dest, xcm)
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "bit-vec"] }
|
||||
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "bit-vec"] }
|
||||
scale-info = { version = "2.10.0", default-features = false, features = ["bit-vec", "derive"] }
|
||||
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
|
||||
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
|
||||
|
||||
# Substrate Dependencies
|
||||
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
|
||||
@@ -37,6 +37,9 @@ pub enum Call {
|
||||
/// `ToWococoXcmRouter` bridge pallet.
|
||||
#[codec(index = 43)]
|
||||
ToWococoXcmRouter(XcmBridgeHubRouterCall),
|
||||
/// `ToWestendXcmRouter` bridge pallet.
|
||||
#[codec(index = 45)]
|
||||
ToWestendXcmRouter(XcmBridgeHubRouterCall),
|
||||
}
|
||||
|
||||
frame_support::parameter_types! {
|
||||
@@ -44,8 +47,8 @@ frame_support::parameter_types! {
|
||||
pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144);
|
||||
|
||||
/// Base delivery fee to `BridgeHubRococo`.
|
||||
/// (initially was calculated by test `BridgeHubRococo::can_calculate_weight_for_paid_export_message_with_reserve_transfer`)
|
||||
pub const BridgeHubRococoBaseFeeInRocs: u128 = 1214739988;
|
||||
/// (initially was calculated by test `BridgeHubRococo::can_calculate_weight_for_paid_export_message_with_reserve_transfer` + `33%`)
|
||||
pub const BridgeHubRococoBaseFeeInRocs: u128 = 1624803349;
|
||||
}
|
||||
|
||||
/// Identifier of AssetHubRococo in the Rococo relay chain.
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
[package]
|
||||
name = "bp-asset-hub-westend"
|
||||
description = "Primitives of AssetHubWestend parachain runtime."
|
||||
version = "0.1.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
|
||||
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
|
||||
|
||||
# Substrate Dependencies
|
||||
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
|
||||
# Bridge Dependencies
|
||||
bp-xcm-bridge-hub-router = { path = "../xcm-bridge-hub-router", default-features = false }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"bp-xcm-bridge-hub-router/std",
|
||||
"codec/std",
|
||||
"frame-support/std",
|
||||
"scale-info/std",
|
||||
]
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright (C) 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/>.
|
||||
|
||||
//! Module with configuration which reflects AssetHubWestend runtime setup.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;
|
||||
|
||||
/// `AssetHubWestend` Runtime `Call` enum.
|
||||
///
|
||||
/// The enum represents a subset of possible `Call`s we can send to `AssetHubWestend` 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
|
||||
/// `AssetHubWestend` `construct_runtime`, so that we maintain SCALE-compatibility.
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
|
||||
pub enum Call {
|
||||
/// `ToRococoXcmRouter` bridge pallet.
|
||||
#[codec(index = 34)]
|
||||
ToRococoXcmRouter(XcmBridgeHubRouterCall),
|
||||
}
|
||||
|
||||
frame_support::parameter_types! {
|
||||
/// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`.
|
||||
pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144);
|
||||
|
||||
/// Base delivery fee to `BridgeHubWestend`.
|
||||
/// (initially was calculated by test `BridgeHubWestend::can_calculate_weight_for_paid_export_message_with_reserve_transfer` + `33%`)
|
||||
pub const BridgeHubWestendBaseFeeInWocs: u128 = 1624803349;
|
||||
}
|
||||
|
||||
/// Identifier of AssetHubWestend in the Westend relay chain.
|
||||
pub const ASSET_HUB_WESTEND_PARACHAIN_ID: u32 = 1000;
|
||||
@@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
|
||||
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
|
||||
|
||||
# Substrate Dependencies
|
||||
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
|
||||
@@ -44,8 +44,8 @@ frame_support::parameter_types! {
|
||||
pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144);
|
||||
|
||||
/// Base delivery fee to `BridgeHubWococo`.
|
||||
/// (initially was calculated by test `BridgeHubWococo::can_calculate_weight_for_paid_export_message_with_reserve_transfer`)
|
||||
pub const BridgeHubWococoBaseFeeInWocs: u128 = 1214739988;
|
||||
/// (initially was calculated by test `BridgeHubWococo::can_calculate_weight_for_paid_export_message_with_reserve_transfer` + `33%`)
|
||||
pub const BridgeHubWococoBaseFeeInWocs: u128 = 1624803349;
|
||||
}
|
||||
|
||||
/// Identifier of AssetHubWococo in the Wococo relay chain.
|
||||
|
||||
@@ -75,7 +75,10 @@ pub const WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessa
|
||||
pub const WITH_BRIDGE_HUB_ROCOCO_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
|
||||
|
||||
/// Pallet index of `BridgeWococoMessages: pallet_bridge_messages::<Instance1>`.
|
||||
pub const WITH_BRIDGE_WOCOCO_MESSAGES_PALLET_INDEX: u8 = 46;
|
||||
pub const WITH_BRIDGE_ROCOCO_TO_WOCOCO_MESSAGES_PALLET_INDEX: u8 = 46;
|
||||
|
||||
/// Pallet index of `BridgeWestendMessages: pallet_bridge_messages::<Instance3>`.
|
||||
pub const WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX: u8 = 51;
|
||||
|
||||
decl_bridge_finality_runtime_apis!(bridge_hub_rococo);
|
||||
decl_bridge_messages_runtime_apis!(bridge_hub_rococo);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
[package]
|
||||
name = "bp-bridge-hub-westend"
|
||||
description = "Primitives of BridgeHubWestend parachain runtime."
|
||||
version = "0.1.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
|
||||
# Bridge Dependencies
|
||||
|
||||
bp-bridge-hub-cumulus = { path = "../chain-bridge-hub-cumulus", default-features = false }
|
||||
bp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
bp-messages = { path = "../../primitives/messages", default-features = false }
|
||||
|
||||
# Substrate Based Dependencies
|
||||
|
||||
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"bp-bridge-hub-cumulus/std",
|
||||
"bp-messages/std",
|
||||
"bp-runtime/std",
|
||||
"frame-support/std",
|
||||
"sp-api/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
@@ -0,0 +1,75 @@
|
||||
// Copyright (C) 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/>.
|
||||
|
||||
//! Module with configuration which reflects BridgeHubWestend runtime setup
|
||||
//! (AccountId, Headers, Hashes...)
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
pub use bp_bridge_hub_cumulus::*;
|
||||
use bp_messages::*;
|
||||
use bp_runtime::{
|
||||
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain,
|
||||
};
|
||||
use frame_support::dispatch::DispatchClass;
|
||||
use sp_runtime::RuntimeDebug;
|
||||
|
||||
/// BridgeHubWestend parachain.
|
||||
#[derive(RuntimeDebug)]
|
||||
pub struct BridgeHubWestend;
|
||||
|
||||
impl Chain for BridgeHubWestend {
|
||||
type BlockNumber = BlockNumber;
|
||||
type Hash = Hash;
|
||||
type Hasher = Hasher;
|
||||
type Header = Header;
|
||||
|
||||
type AccountId = AccountId;
|
||||
type Balance = Balance;
|
||||
type Nonce = Nonce;
|
||||
type Signature = Signature;
|
||||
|
||||
fn max_extrinsic_size() -> u32 {
|
||||
*BlockLength::get().max.get(DispatchClass::Normal)
|
||||
}
|
||||
|
||||
fn max_extrinsic_weight() -> Weight {
|
||||
BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
.max_extrinsic
|
||||
.unwrap_or(Weight::MAX)
|
||||
}
|
||||
}
|
||||
|
||||
impl Parachain for BridgeHubWestend {
|
||||
const PARACHAIN_ID: u32 = BRIDGE_HUB_WESTEND_PARACHAIN_ID;
|
||||
}
|
||||
|
||||
/// Identifier of BridgeHubWestend in the Westend relay chain.
|
||||
pub const BRIDGE_HUB_WESTEND_PARACHAIN_ID: u32 = 1002;
|
||||
|
||||
/// Name of the With-BridgeHubWestend messages pallet instance that is deployed at bridged chains.
|
||||
pub const WITH_BRIDGE_HUB_WESTEND_MESSAGES_PALLET_NAME: &str = "BridgeWestendMessages";
|
||||
|
||||
/// Name of the With-BridgeHubWestend bridge-relayers pallet instance that is deployed at bridged
|
||||
/// chains.
|
||||
pub const WITH_BRIDGE_HUB_WESTEND_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
|
||||
|
||||
/// Pallet index of `BridgeRococoMessages: pallet_bridge_messages::<Instance1>`.
|
||||
pub const WITH_BRIDGE_WESTEND_TO_ROCOCO_MESSAGES_PALLET_INDEX: u8 = 44;
|
||||
|
||||
decl_bridge_finality_runtime_apis!(bridge_hub_westend);
|
||||
decl_bridge_messages_runtime_apis!(bridge_hub_westend);
|
||||
@@ -69,7 +69,7 @@ pub const WITH_BRIDGE_HUB_WOCOCO_MESSAGES_PALLET_NAME: &str = "BridgeWococoMessa
|
||||
pub const WITH_BRIDGE_HUB_WOCOCO_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
|
||||
|
||||
/// Pallet index of `BridgeRococoMessages: pallet_bridge_messages::<Instance2>`.
|
||||
pub const WITH_BRIDGE_ROCOCO_MESSAGES_PALLET_INDEX: u8 = 45;
|
||||
pub const WITH_BRIDGE_WOCOCO_TO_ROCOCO_MESSAGES_PALLET_INDEX: u8 = 45;
|
||||
|
||||
decl_bridge_finality_runtime_apis!(bridge_hub_wococo);
|
||||
decl_bridge_messages_runtime_apis!(bridge_hub_wococo);
|
||||
|
||||
@@ -16,9 +16,9 @@ bp-runtime = { path = "../runtime", default-features = false }
|
||||
|
||||
# Substrate Based Dependencies
|
||||
|
||||
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||
// Copyright (C) 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
|
||||
@@ -21,9 +21,8 @@
|
||||
pub use bp_polkadot_core::*;
|
||||
|
||||
use bp_header_chain::ChainWithGrandpa;
|
||||
use bp_runtime::{decl_bridge_finality_runtime_apis, Chain, Parachain};
|
||||
use frame_support::weights::Weight;
|
||||
use sp_std::prelude::*;
|
||||
use bp_runtime::{decl_bridge_finality_runtime_apis, Chain};
|
||||
use frame_support::{parameter_types, weights::Weight};
|
||||
|
||||
/// Westend Chain
|
||||
pub struct Westend;
|
||||
@@ -57,53 +56,24 @@ impl ChainWithGrandpa for Westend {
|
||||
const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = AVERAGE_HEADER_SIZE_IN_JUSTIFICATION;
|
||||
}
|
||||
|
||||
/// `AssetHubWestend` parachain definition
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct AssetHubWestend;
|
||||
|
||||
// AssetHubWestend seems to use the same configuration as all Polkadot-like chains, so we'll use
|
||||
// Westend primitives here.
|
||||
impl Chain for AssetHubWestend {
|
||||
type BlockNumber = BlockNumber;
|
||||
type Hash = Hash;
|
||||
type Hasher = Hasher;
|
||||
type Header = Header;
|
||||
|
||||
type AccountId = AccountId;
|
||||
type Balance = Balance;
|
||||
type Nonce = Nonce;
|
||||
type Signature = Signature;
|
||||
|
||||
fn max_extrinsic_size() -> u32 {
|
||||
Westend::max_extrinsic_size()
|
||||
}
|
||||
|
||||
fn max_extrinsic_weight() -> Weight {
|
||||
Westend::max_extrinsic_weight()
|
||||
}
|
||||
parameter_types! {
|
||||
pub const SS58Prefix: u8 = 42;
|
||||
}
|
||||
|
||||
impl Parachain for AssetHubWestend {
|
||||
const PARACHAIN_ID: u32 = ASSET_HUB_WESTEND_PARACHAIN_ID;
|
||||
}
|
||||
// The SignedExtension used by Westend.
|
||||
pub use bp_polkadot_core::CommonSignedExtension as SignedExtension;
|
||||
|
||||
/// Name of the parachains pallet at the Westend runtime.
|
||||
/// Name of the parachains pallet in the Rococo runtime.
|
||||
pub const PARAS_PALLET_NAME: &str = "Paras";
|
||||
|
||||
/// Name of the With-Westend GRANDPA pallet instance that is deployed at bridged chains.
|
||||
pub const WITH_WESTEND_GRANDPA_PALLET_NAME: &str = "BridgeWestendGrandpa";
|
||||
/// Name of the With-Westend parachains bridge pallet instance that is deployed at bridged chains.
|
||||
pub const WITH_WESTEND_BRIDGE_PARAS_PALLET_NAME: &str = "BridgeWestendParachains";
|
||||
|
||||
/// Maximal SCALE-encoded size of parachains headers that are stored at Westend `Paras` pallet.
|
||||
/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Westend
|
||||
/// parachains.
|
||||
///
|
||||
/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some
|
||||
/// reserve.
|
||||
pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128;
|
||||
|
||||
/// Identifier of `AssetHubWestend` parachain at the Westend relay chain.
|
||||
pub const ASSET_HUB_WESTEND_PARACHAIN_ID: u32 = 1000;
|
||||
|
||||
decl_bridge_finality_runtime_apis!(westend, grandpa);
|
||||
|
||||
decl_bridge_finality_runtime_apis!(AssetHubWestend);
|
||||
|
||||
@@ -97,6 +97,9 @@ pub const BRIDGE_HUB_ROCOCO_CHAIN_ID: ChainId = *b"bhro";
|
||||
/// BridgeHubWococo chain id.
|
||||
pub const BRIDGE_HUB_WOCOCO_CHAIN_ID: ChainId = *b"bhwo";
|
||||
|
||||
/// BridgeHubWestend chain id.
|
||||
pub const BRIDGE_HUB_WESTEND_CHAIN_ID: ChainId = *b"bhwd";
|
||||
|
||||
/// BridgeHubKusama chain id.
|
||||
pub const BRIDGE_HUB_KUSAMA_CHAIN_ID: ChainId = *b"bhks";
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ relay-rialto-parachain-client = { path = "../client-rialto-parachain" }
|
||||
relay-bridge-hub-kusama-client = { path = "../client-bridge-hub-kusama" }
|
||||
relay-bridge-hub-polkadot-client = { path = "../client-bridge-hub-polkadot" }
|
||||
relay-bridge-hub-rococo-client = { path = "../client-bridge-hub-rococo" }
|
||||
relay-bridge-hub-westend-client = { path = "../client-bridge-hub-westend" }
|
||||
relay-bridge-hub-wococo-client = { path = "../client-bridge-hub-wococo" }
|
||||
relay-kusama-client = { path = "../client-kusama" }
|
||||
relay-polkadot-client = { path = "../client-polkadot" }
|
||||
|
||||
@@ -20,5 +20,6 @@ pub mod kusama_polkadot;
|
||||
pub mod polkadot_bulletin;
|
||||
pub mod rialto_millau;
|
||||
pub mod rialto_parachain_millau;
|
||||
pub mod rococo_westend;
|
||||
pub mod rococo_wococo;
|
||||
pub mod westend_millau;
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
// 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 crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
|
||||
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
||||
use relay_bridge_hub_westend_client::BridgeHubWestend;
|
||||
use substrate_relay_helper::{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::runtime::Call::BridgeRococoMessages,
|
||||
relay_bridge_hub_westend_client::runtime::BridgeRococoMessagesCall::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>;
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
// 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 crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
|
||||
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
||||
use relay_bridge_hub_westend_client::BridgeHubWestend;
|
||||
use substrate_relay_helper::{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::runtime::Call::BridgeRococoMessages,
|
||||
relay_bridge_hub_westend_client::runtime::BridgeRococoMessagesCall::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>;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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;
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
// Copyright 2022 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity Bridges Common is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Rococo-to-Westend bridge hubs headers sync entrypoint.
|
||||
|
||||
use crate::cli::bridge::{
|
||||
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
|
||||
};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use relay_substrate_client::{AccountKeyPairOf, Client};
|
||||
use substrate_relay_helper::{
|
||||
equivocation::SubstrateEquivocationDetectionPipeline,
|
||||
finality::SubstrateFinalitySyncPipeline,
|
||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
/// Description of Rococo -> Westend finalized headers bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RococoFinalityToBridgeHubWestend;
|
||||
|
||||
substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
||||
RococoFinalityToBridgeHubWestend,
|
||||
SubmitFinalityProofCallBuilder,
|
||||
relay_bridge_hub_westend_client::runtime::Call::BridgeRococoGrandpa,
|
||||
relay_bridge_hub_westend_client::runtime::BridgeRococoGrandpaCall::submit_finality_proof
|
||||
);
|
||||
|
||||
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 fn start_relay_guards(
|
||||
target_client: &Client<Self::TargetChain>,
|
||||
_transaction_params: &TransactionParams<AccountKeyPairOf<Self::TargetChain>>,
|
||||
enable_version_guard: bool,
|
||||
) -> relay_substrate_client::Result<()> {
|
||||
if enable_version_guard {
|
||||
relay_substrate_client::guard::abort_on_spec_version_change(
|
||||
target_client.clone(),
|
||||
target_client.simple_runtime_version().await?.spec_version,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateEquivocationDetectionPipeline for 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
@@ -0,0 +1,75 @@
|
||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity Bridges Common is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Westend-to-Rococo parachains sync entrypoint.
|
||||
|
||||
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge};
|
||||
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
|
||||
use relay_substrate_client::{CallOf, HeaderIdOf};
|
||||
use substrate_relay_helper::parachains::{
|
||||
SubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline,
|
||||
};
|
||||
|
||||
/// BridgeHub-to-BridgeHub parachain sync description.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct 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::runtime::Call::BridgeRococoParachains(
|
||||
relay_bridge_hub_westend_client::runtime::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;
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
// Copyright 2022 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity Bridges Common is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Westend-to-Rococo bridge hubs headers sync entrypoint.
|
||||
|
||||
use crate::cli::bridge::{
|
||||
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
|
||||
};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use relay_substrate_client::{AccountKeyPairOf, Client};
|
||||
use substrate_relay_helper::{
|
||||
equivocation::SubstrateEquivocationDetectionPipeline,
|
||||
finality::SubstrateFinalitySyncPipeline,
|
||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
/// Description of Westend -> Rococo finalized headers bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct WestendFinalityToBridgeHubRococo;
|
||||
|
||||
substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
||||
WestendFinalityToBridgeHubRococo,
|
||||
SubmitFinalityProofCallBuilder,
|
||||
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWestendGrandpa,
|
||||
relay_bridge_hub_rococo_client::BridgeGrandpaCall::submit_finality_proof
|
||||
);
|
||||
|
||||
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 fn start_relay_guards(
|
||||
target_client: &Client<Self::TargetChain>,
|
||||
_transaction_params: &TransactionParams<AccountKeyPairOf<Self::TargetChain>>,
|
||||
enable_version_guard: bool,
|
||||
) -> relay_substrate_client::Result<()> {
|
||||
if enable_version_guard {
|
||||
relay_substrate_client::guard::abort_on_spec_version_change(
|
||||
target_client.clone(),
|
||||
target_client.simple_runtime_version().await?.spec_version,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateEquivocationDetectionPipeline for 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
@@ -0,0 +1,75 @@
|
||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity Bridges Common is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Rococo-to-Westend parachains sync entrypoint.
|
||||
|
||||
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge};
|
||||
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
|
||||
use relay_substrate_client::{CallOf, HeaderIdOf};
|
||||
use substrate_relay_helper::parachains::{
|
||||
SubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline,
|
||||
};
|
||||
|
||||
/// BridgeHub-to-BridgeHub parachain sync description.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct 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
-1
@@ -44,7 +44,7 @@ impl SubmitParachainHeadsCallBuilder<BridgeHubRococoToBridgeHubWococo>
|
||||
parachains: Vec<(ParaId, ParaHash)>,
|
||||
parachain_heads_proof: ParaHeadsProof,
|
||||
) -> CallOf<relay_bridge_hub_wococo_client::BridgeHubWococo> {
|
||||
relay_bridge_hub_wococo_client::RuntimeCall::BridgeRococoParachain(
|
||||
relay_bridge_hub_wococo_client::RuntimeCall::BridgeRococoParachains(
|
||||
relay_bridge_hub_wococo_client::BridgeParachainCall::submit_parachain_heads {
|
||||
at_relay_block: (at_relay_block.0, at_relay_block.1),
|
||||
parachains,
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ impl SubmitParachainHeadsCallBuilder<BridgeHubWococoToBridgeHubRococo>
|
||||
parachains: Vec<(ParaId, ParaHash)>,
|
||||
parachain_heads_proof: ParaHeadsProof,
|
||||
) -> CallOf<relay_bridge_hub_rococo_client::BridgeHubRococo> {
|
||||
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWococoParachain(
|
||||
relay_bridge_hub_rococo_client::RuntimeCall::BridgeWococoParachains(
|
||||
relay_bridge_hub_rococo_client::BridgeParachainCall::submit_parachain_heads {
|
||||
at_relay_block: (at_relay_block.0, at_relay_block.1),
|
||||
parachains,
|
||||
|
||||
+34
-3
@@ -18,7 +18,7 @@
|
||||
|
||||
use crate::cli::bridge::{CliBridgeBase, ParachainToRelayHeadersCliBridge};
|
||||
use relay_millau_client::Millau;
|
||||
use relay_westend_client::{AssetHubWestend, Westend};
|
||||
use relay_westend_client::Westend;
|
||||
use substrate_relay_helper::parachains::{
|
||||
DirectSubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline,
|
||||
};
|
||||
@@ -28,7 +28,7 @@ use substrate_relay_helper::parachains::{
|
||||
pub struct WestendParachainsToMillau;
|
||||
|
||||
impl SubstrateParachainsPipeline for WestendParachainsToMillau {
|
||||
type SourceParachain = AssetHubWestend;
|
||||
type SourceParachain = relay_asset_hub_westend_client::AssetHubWestend;
|
||||
type SourceRelayChain = Westend;
|
||||
type TargetChain = Millau;
|
||||
|
||||
@@ -54,6 +54,37 @@ impl ParachainToRelayHeadersCliBridge for AssetHubWestendToMillauCliBridge {
|
||||
}
|
||||
|
||||
impl CliBridgeBase for AssetHubWestendToMillauCliBridge {
|
||||
type Source = AssetHubWestend;
|
||||
type Source = relay_asset_hub_westend_client::AssetHubWestend;
|
||||
type Target = Millau;
|
||||
}
|
||||
|
||||
/// TODO: Note: I know this does not belong here, but I don't want to add it to the
|
||||
/// `chain-asset-hub-westend` or `chain-westend`, because we wont use it for production and I don't
|
||||
/// want to bring this to the bridges subtree now. Anyway, we plan to retire millau/rialto, so this
|
||||
/// hack will disappear with that.
|
||||
pub mod relay_asset_hub_westend_client {
|
||||
use bp_runtime::{ChainId, UnderlyingChainProvider};
|
||||
use relay_substrate_client::Chain;
|
||||
use std::time::Duration;
|
||||
|
||||
/// `AssetHubWestend` parachain definition
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct AssetHubWestend;
|
||||
|
||||
impl UnderlyingChainProvider for AssetHubWestend {
|
||||
type Chain = millau_runtime::bp_bridged_chain::AssetHubWestend;
|
||||
}
|
||||
|
||||
// Westmint seems to use the same configuration as all Polkadot-like chains, so we'll use
|
||||
// Westend primitives here.
|
||||
impl Chain for AssetHubWestend {
|
||||
const ID: ChainId = bp_runtime::ASSET_HUB_WESTEND_CHAIN_ID;
|
||||
const NAME: &'static str = "Westmint";
|
||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
||||
millau_runtime::bp_bridged_chain::BEST_FINALIZED_ASSETHUBWESTEND_HEADER_METHOD;
|
||||
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6);
|
||||
|
||||
type SignedBlock = bp_polkadot_core::SignedBlock;
|
||||
type Call = ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,3 +65,11 @@ impl CliChain for Millau {
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
||||
Some(SimpleRuntimeVersion::from_runtime_version(&millau_runtime::VERSION));
|
||||
}
|
||||
|
||||
/// TODO: Note: I know this does not belong here, but I don't want to add it to the
|
||||
/// `chain-asset-hub-westend` or `chain-westend`, because we wont use it for production and I don't
|
||||
/// want to bring this to the bridges subtree now. Anyway, we plan to retire millau/rialto, so this
|
||||
/// hack will disappear with that.
|
||||
impl CliChain for crate::bridges::westend_millau::westend_parachains_to_millau::relay_asset_hub_westend_client::AssetHubWestend {
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,15 @@
|
||||
//! Westend chain specification for CLI.
|
||||
|
||||
use crate::cli::CliChain;
|
||||
use relay_bridge_hub_westend_client::BridgeHubWestend;
|
||||
use relay_substrate_client::SimpleRuntimeVersion;
|
||||
use relay_westend_client::{AssetHubWestend, Westend};
|
||||
use relay_westend_client::Westend;
|
||||
|
||||
impl CliChain for Westend {
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
||||
}
|
||||
|
||||
impl CliChain for AssetHubWestend {
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
||||
impl CliChain for BridgeHubWestend {
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
||||
Some(SimpleRuntimeVersion { spec_version: 10000, transaction_version: 3 });
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ pub enum FullBridge {
|
||||
RialtoParachainToMillau,
|
||||
BridgeHubRococoToBridgeHubWococo,
|
||||
BridgeHubWococoToBridgeHubRococo,
|
||||
BridgeHubRococoToBridgeHubWestend,
|
||||
BridgeHubWestendToBridgeHubRococo,
|
||||
BridgeHubKusamaToBridgeHubPolkadot,
|
||||
BridgeHubPolkadotToBridgeHubKusama,
|
||||
PolkadotBulletinToBridgeHubPolkadot,
|
||||
|
||||
@@ -32,6 +32,10 @@ use crate::{
|
||||
rialto_headers_to_millau::RialtoToMillauCliBridge,
|
||||
},
|
||||
rialto_parachain_millau::millau_headers_to_rialto_parachain::MillauToRialtoParachainCliBridge,
|
||||
rococo_westend::{
|
||||
rococo_headers_to_bridge_hub_westend::RococoToBridgeHubWestendCliBridge,
|
||||
westend_headers_to_bridge_hub_rococo::WestendToBridgeHubRococoCliBridge,
|
||||
},
|
||||
rococo_wococo::{
|
||||
rococo_headers_to_bridge_hub_wococo::RococoToBridgeHubWococoCliBridge,
|
||||
wococo_headers_to_bridge_hub_rococo::WococoToBridgeHubRococoCliBridge,
|
||||
@@ -78,6 +82,8 @@ pub enum InitBridgeName {
|
||||
PolkadotToBridgeHubKusama,
|
||||
PolkadotToPolkadotBulletin,
|
||||
PolkadotBulletinToBridgeHubPolkadot,
|
||||
RococoToBridgeHubWestend,
|
||||
WestendToBridgeHubRococo,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@@ -210,6 +216,32 @@ impl BridgeInitializer for WococoToBridgeHubRococoCliBridge {
|
||||
}
|
||||
}
|
||||
|
||||
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::runtime::Call::BridgeRococoGrandpa(
|
||||
relay_bridge_hub_westend_client::runtime::BridgeRococoGrandpaCall::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>;
|
||||
|
||||
@@ -290,6 +322,10 @@ impl InitBridge {
|
||||
PolkadotToPolkadotBulletinCliBridge::init_bridge(self),
|
||||
InitBridgeName::PolkadotBulletinToBridgeHubPolkadot =>
|
||||
PolkadotBulletinToBridgeHubPolkadotCliBridge::init_bridge(self),
|
||||
InitBridgeName::RococoToBridgeHubWestend =>
|
||||
RococoToBridgeHubWestendCliBridge::init_bridge(self),
|
||||
InitBridgeName::WestendToBridgeHubRococo =>
|
||||
WestendToBridgeHubRococoCliBridge::init_bridge(self),
|
||||
}
|
||||
.await
|
||||
}
|
||||
|
||||
@@ -56,6 +56,10 @@ use crate::{
|
||||
millau_headers_to_rialto_parachain::MillauToRialtoParachainCliBridge,
|
||||
rialto_parachains_to_millau::RialtoParachainToMillauCliBridge,
|
||||
},
|
||||
rococo_westend::{
|
||||
rococo_parachains_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendCliBridge,
|
||||
westend_parachains_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoCliBridge,
|
||||
},
|
||||
rococo_wococo::{
|
||||
rococo_parachains_to_bridge_hub_wococo::BridgeHubRococoToBridgeHubWococoCliBridge,
|
||||
wococo_parachains_to_bridge_hub_rococo::BridgeHubWococoToBridgeHubRococoCliBridge,
|
||||
@@ -206,6 +210,8 @@ declare_chain_cli_schema!(Rococo, rococo);
|
||||
declare_chain_cli_schema!(BridgeHubRococo, bridge_hub_rococo);
|
||||
declare_chain_cli_schema!(Wococo, wococo);
|
||||
declare_chain_cli_schema!(BridgeHubWococo, bridge_hub_wococo);
|
||||
declare_chain_cli_schema!(Westend, westend);
|
||||
declare_chain_cli_schema!(BridgeHubWestend, bridge_hub_westend);
|
||||
declare_chain_cli_schema!(Kusama, kusama);
|
||||
declare_chain_cli_schema!(BridgeHubKusama, bridge_hub_kusama);
|
||||
declare_chain_cli_schema!(Polkadot, polkadot);
|
||||
@@ -226,6 +232,16 @@ declare_chain_cli_schema!(
|
||||
WococoParachainsToBridgeHubRococo,
|
||||
wococo_parachains_to_bridge_hub_rococo
|
||||
);
|
||||
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,
|
||||
@@ -249,6 +265,7 @@ declare_chain_cli_schema!(
|
||||
declare_relay_to_relay_bridge_schema!(Millau, Rialto);
|
||||
declare_relay_to_parachain_bridge_schema!(Millau, RialtoParachain, Rialto);
|
||||
declare_parachain_to_parachain_bridge_schema!(BridgeHubRococo, Rococo, BridgeHubWococo, Wococo);
|
||||
declare_parachain_to_parachain_bridge_schema!(BridgeHubRococo, Rococo, BridgeHubWestend, Westend);
|
||||
declare_parachain_to_parachain_bridge_schema!(BridgeHubKusama, Kusama, BridgeHubPolkadot, Polkadot);
|
||||
declare_relay_to_parachain_bridge_schema!(PolkadotBulletin, BridgeHubPolkadot, Polkadot);
|
||||
|
||||
@@ -495,6 +512,32 @@ impl Full2WayBridge for BridgeHubRococoBridgeHubWococoFull2WayBridge {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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,
|
||||
@@ -560,6 +603,8 @@ pub enum RelayHeadersAndMessages {
|
||||
BridgeHubKusamaBridgeHubPolkadot(BridgeHubKusamaBridgeHubPolkadotHeadersAndMessages),
|
||||
/// `PolkadotBulletin` <> `BridgeHubPolkadot` relay.
|
||||
PolkadotBulletinBridgeHubPolkadot(PolkadotBulletinBridgeHubPolkadotHeadersAndMessages),
|
||||
/// BridgeHubRococo <> BridgeHubWestend relay.
|
||||
BridgeHubRococoBridgeHubWestend(BridgeHubRococoBridgeHubWestendHeadersAndMessages),
|
||||
}
|
||||
|
||||
impl RelayHeadersAndMessages {
|
||||
@@ -576,6 +621,10 @@ impl RelayHeadersAndMessages {
|
||||
BridgeHubRococoBridgeHubWococoFull2WayBridge::new(params.into_bridge().await?)?
|
||||
.run()
|
||||
.await,
|
||||
RelayHeadersAndMessages::BridgeHubRococoBridgeHubWestend(params) =>
|
||||
BridgeHubRococoBridgeHubWestendFull2WayBridge::new(params.into_bridge().await?)?
|
||||
.run()
|
||||
.await,
|
||||
RelayHeadersAndMessages::BridgeHubKusamaBridgeHubPolkadot(params) =>
|
||||
BridgeHubKusamaBridgeHubPolkadotFull2WayBridge::new(params.into_bridge().await?)?
|
||||
.run()
|
||||
|
||||
@@ -36,6 +36,10 @@ use crate::bridges::{
|
||||
millau_headers_to_rialto_parachain::MillauToRialtoParachainCliBridge,
|
||||
rialto_parachains_to_millau::RialtoParachainToMillauCliBridge,
|
||||
},
|
||||
rococo_westend::{
|
||||
bridge_hub_rococo_messages_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendMessagesCliBridge,
|
||||
bridge_hub_westend_messages_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoMessagesCliBridge,
|
||||
},
|
||||
rococo_wococo::{
|
||||
bridge_hub_rococo_messages_to_bridge_hub_wococo::BridgeHubRococoToBridgeHubWococoMessagesCliBridge,
|
||||
bridge_hub_wococo_messages_to_bridge_hub_rococo::BridgeHubWococoToBridgeHubRococoMessagesCliBridge,
|
||||
@@ -111,6 +115,8 @@ impl MessagesRelayer for MillauToRialtoParachainCliBridge {}
|
||||
impl MessagesRelayer for RialtoParachainToMillauCliBridge {}
|
||||
impl MessagesRelayer for BridgeHubRococoToBridgeHubWococoMessagesCliBridge {}
|
||||
impl MessagesRelayer for BridgeHubWococoToBridgeHubRococoMessagesCliBridge {}
|
||||
impl MessagesRelayer for BridgeHubRococoToBridgeHubWestendMessagesCliBridge {}
|
||||
impl MessagesRelayer for BridgeHubWestendToBridgeHubRococoMessagesCliBridge {}
|
||||
impl MessagesRelayer for BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge {}
|
||||
impl MessagesRelayer for BridgeHubPolkadotToBridgeHubKusamaMessagesCliBridge {}
|
||||
impl MessagesRelayer for PolkadotBulletinToBridgeHubPolkadotMessagesCliBridge {}
|
||||
@@ -130,6 +136,10 @@ impl RelayMessages {
|
||||
BridgeHubRococoToBridgeHubWococoMessagesCliBridge::relay_messages(self),
|
||||
FullBridge::BridgeHubWococoToBridgeHubRococo =>
|
||||
BridgeHubWococoToBridgeHubRococoMessagesCliBridge::relay_messages(self),
|
||||
FullBridge::BridgeHubRococoToBridgeHubWestend =>
|
||||
BridgeHubRococoToBridgeHubWestendMessagesCliBridge::relay_messages(self),
|
||||
FullBridge::BridgeHubWestendToBridgeHubRococo =>
|
||||
BridgeHubWestendToBridgeHubRococoMessagesCliBridge::relay_messages(self),
|
||||
FullBridge::BridgeHubKusamaToBridgeHubPolkadot =>
|
||||
BridgeHubKusamaToBridgeHubPolkadotMessagesCliBridge::relay_messages(self),
|
||||
FullBridge::BridgeHubPolkadotToBridgeHubKusama =>
|
||||
|
||||
@@ -21,6 +21,10 @@ use crate::bridges::{
|
||||
},
|
||||
polkadot_bulletin::polkadot_parachains_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge,
|
||||
rialto_parachain_millau::rialto_parachains_to_millau::RialtoParachainToMillauCliBridge,
|
||||
rococo_westend::{
|
||||
rococo_parachains_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendCliBridge,
|
||||
westend_parachains_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoCliBridge,
|
||||
},
|
||||
rococo_wococo::{
|
||||
rococo_parachains_to_bridge_hub_wococo::BridgeHubRococoToBridgeHubWococoCliBridge,
|
||||
wococo_parachains_to_bridge_hub_rococo::BridgeHubWococoToBridgeHubRococoCliBridge,
|
||||
@@ -73,6 +77,8 @@ pub enum RelayParachainsBridge {
|
||||
KusamaToBridgeHubPolkadot,
|
||||
PolkadotToBridgeHubKusama,
|
||||
PolkadotToPolkadotBulletin,
|
||||
RococoToBridgeHubWestend,
|
||||
WestendToBridgeHubRococo,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@@ -120,6 +126,8 @@ impl ParachainsRelayer for RialtoParachainToMillauCliBridge {}
|
||||
impl ParachainsRelayer for AssetHubWestendToMillauCliBridge {}
|
||||
impl ParachainsRelayer for BridgeHubRococoToBridgeHubWococoCliBridge {}
|
||||
impl ParachainsRelayer for BridgeHubWococoToBridgeHubRococoCliBridge {}
|
||||
impl ParachainsRelayer for BridgeHubRococoToBridgeHubWestendCliBridge {}
|
||||
impl ParachainsRelayer for BridgeHubWestendToBridgeHubRococoCliBridge {}
|
||||
impl ParachainsRelayer for BridgeHubKusamaToBridgeHubPolkadotCliBridge {}
|
||||
impl ParachainsRelayer for BridgeHubPolkadotToBridgeHubKusamaCliBridge {}
|
||||
impl ParachainsRelayer for PolkadotToPolkadotBulletinCliBridge {}
|
||||
@@ -136,6 +144,10 @@ impl RelayParachains {
|
||||
BridgeHubRococoToBridgeHubWococoCliBridge::relay_parachains(self),
|
||||
RelayParachainsBridge::WococoToBridgeHubRococo =>
|
||||
BridgeHubWococoToBridgeHubRococoCliBridge::relay_parachains(self),
|
||||
RelayParachainsBridge::RococoToBridgeHubWestend =>
|
||||
BridgeHubRococoToBridgeHubWestendCliBridge::relay_parachains(self),
|
||||
RelayParachainsBridge::WestendToBridgeHubRococo =>
|
||||
BridgeHubWestendToBridgeHubRococoCliBridge::relay_parachains(self),
|
||||
RelayParachainsBridge::KusamaToBridgeHubPolkadot =>
|
||||
BridgeHubKusamaToBridgeHubPolkadotCliBridge::relay_parachains(self),
|
||||
RelayParachainsBridge::PolkadotToBridgeHubKusama =>
|
||||
|
||||
@@ -264,16 +264,22 @@ pub mod api {
|
||||
Multisig(runtime_types::pallet_multisig::pallet::Call),
|
||||
#[codec(index = 41)]
|
||||
BridgeWococoGrandpa(runtime_types::pallet_bridge_grandpa::pallet::Call),
|
||||
#[codec(index = 42)]
|
||||
BridgeWococoParachain(runtime_types::pallet_bridge_parachains::pallet::Call),
|
||||
#[codec(index = 46)]
|
||||
BridgeWococoMessages(runtime_types::pallet_bridge_messages::pallet::Call),
|
||||
#[codec(index = 43)]
|
||||
BridgeRococoGrandpa(runtime_types::pallet_bridge_grandpa::pallet::Call),
|
||||
#[codec(index = 48)]
|
||||
BridgeWestendGrandpa(runtime_types::pallet_bridge_grandpa::pallet::Call),
|
||||
#[codec(index = 42)]
|
||||
BridgeWococoParachains(runtime_types::pallet_bridge_parachains::pallet::Call),
|
||||
#[codec(index = 44)]
|
||||
BridgeRococoParachain(runtime_types::pallet_bridge_parachains::pallet::Call),
|
||||
BridgeRococoParachains(runtime_types::pallet_bridge_parachains::pallet::Call),
|
||||
#[codec(index = 49)]
|
||||
BridgeWestendParachains(runtime_types::pallet_bridge_parachains::pallet::Call),
|
||||
#[codec(index = 46)]
|
||||
BridgeWococoMessages(runtime_types::pallet_bridge_messages::pallet::Call),
|
||||
#[codec(index = 45)]
|
||||
BridgeRococoMessages(runtime_types::pallet_bridge_messages::pallet::Call),
|
||||
#[codec(index = 51)]
|
||||
BridgeWestendMessages(runtime_types::pallet_bridge_messages::pallet::Call),
|
||||
#[codec(index = 47)]
|
||||
BridgeRelayers(runtime_types::pallet_bridge_relayers::pallet::Call),
|
||||
}
|
||||
@@ -305,16 +311,22 @@ pub mod api {
|
||||
Multisig(runtime_types::pallet_multisig::pallet::Event),
|
||||
#[codec(index = 41)]
|
||||
BridgeWococoGrandpa(runtime_types::pallet_bridge_grandpa::pallet::Event),
|
||||
#[codec(index = 42)]
|
||||
BridgeWococoParachain(runtime_types::pallet_bridge_parachains::pallet::Event),
|
||||
#[codec(index = 46)]
|
||||
BridgeWococoMessages(runtime_types::pallet_bridge_messages::pallet::Event),
|
||||
#[codec(index = 43)]
|
||||
BridgeRococoGrandpa(runtime_types::pallet_bridge_grandpa::pallet::Event),
|
||||
#[codec(index = 48)]
|
||||
BridgeWestendGrandpa(runtime_types::pallet_bridge_grandpa::pallet::Event),
|
||||
#[codec(index = 42)]
|
||||
BridgeWococoParachains(runtime_types::pallet_bridge_parachains::pallet::Event),
|
||||
#[codec(index = 44)]
|
||||
BridgeRococoParachain(runtime_types::pallet_bridge_parachains::pallet::Event),
|
||||
BridgeRococoParachains(runtime_types::pallet_bridge_parachains::pallet::Event),
|
||||
#[codec(index = 49)]
|
||||
BridgeWestendParachains(runtime_types::pallet_bridge_parachains::pallet::Event),
|
||||
#[codec(index = 46)]
|
||||
BridgeWococoMessages(runtime_types::pallet_bridge_messages::pallet::Event),
|
||||
#[codec(index = 45)]
|
||||
BridgeRococoMessages(runtime_types::pallet_bridge_messages::pallet::Event),
|
||||
#[codec(index = 51)]
|
||||
BridgeWestendMessages(runtime_types::pallet_bridge_messages::pallet::Event),
|
||||
#[codec(index = 47)]
|
||||
BridgeRelayers(runtime_types::pallet_bridge_relayers::pallet::Event),
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
[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"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
||||
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
|
||||
subxt = { version = "0.32.1", default-features = false, features = [] }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
bp-bridge-hub-rococo = { path = "../../primitives/chain-bridge-hub-rococo" }
|
||||
bp-bridge-hub-westend = { path = "../../primitives/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 = "../../primitives/chain-rococo" }
|
||||
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" }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
||||
@@ -0,0 +1,162 @@
|
||||
// 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.
|
||||
|
||||
use bp_bridge_hub_westend::AVERAGE_BLOCK_INTERVAL;
|
||||
use bp_messages::MessageNonce;
|
||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
||||
use bp_runtime::ChainId;
|
||||
use codec::Encode;
|
||||
use relay_substrate_client::{
|
||||
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
|
||||
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, UnderlyingChainProvider,
|
||||
UnsignedTransaction,
|
||||
};
|
||||
use sp_core::{storage::StorageKey, Pair};
|
||||
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
|
||||
use std::time::Duration;
|
||||
|
||||
/// Re-export runtime wrapper
|
||||
pub mod runtime_wrapper;
|
||||
pub use runtime_wrapper as runtime;
|
||||
|
||||
/// 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 ID: ChainId = bp_runtime::BRIDGE_HUB_WESTEND_CHAIN_ID;
|
||||
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 = runtime::Call;
|
||||
}
|
||||
|
||||
impl ChainWithBalances for BridgeHubWestend {
|
||||
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
|
||||
bp_bridge_hub_westend::AccountInfoStorageMapKeyProvider::final_key(account_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl ChainWithUtilityPallet for BridgeHubWestend {
|
||||
type UtilityPallet = MockedRuntimeUtilityPallet<runtime::Call>;
|
||||
}
|
||||
|
||||
impl ChainWithTransactions for BridgeHubWestend {
|
||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
||||
type SignedTransaction = runtime::UncheckedExtrinsic;
|
||||
|
||||
fn sign_transaction(
|
||||
param: SignParam<Self>,
|
||||
unsigned: UnsignedTransaction<Self>,
|
||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::new(
|
||||
unsigned.call,
|
||||
runtime::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(runtime::UncheckedExtrinsic::new_signed(
|
||||
call,
|
||||
signer.into_account().into(),
|
||||
signature.into(),
|
||||
extra,
|
||||
))
|
||||
}
|
||||
|
||||
fn is_signed(tx: &Self::SignedTransaction) -> bool {
|
||||
tx.signature.is_some()
|
||||
}
|
||||
|
||||
fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
|
||||
tx.signature
|
||||
.as_ref()
|
||||
.map(|(address, _, _)| {
|
||||
*address == bp_bridge_hub_westend::Address::Id(signer.public().into())
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> {
|
||||
let extra = &tx.signature.as_ref()?.2;
|
||||
Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ChainWithMessages for BridgeHubWestend {
|
||||
const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
|
||||
bp_bridge_hub_westend::WITH_BRIDGE_HUB_WESTEND_MESSAGES_PALLET_NAME;
|
||||
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;
|
||||
|
||||
const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
|
||||
bp_bridge_hub_westend::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
|
||||
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
|
||||
bp_bridge_hub_westend::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use relay_substrate_client::TransactionEra;
|
||||
|
||||
#[test]
|
||||
fn parse_transaction_works() {
|
||||
let unsigned = UnsignedTransaction {
|
||||
call: runtime::Call::System(runtime::SystemCall::remark(b"Hello world!".to_vec()))
|
||||
.into(),
|
||||
nonce: 777,
|
||||
tip: 888,
|
||||
era: TransactionEra::immortal(),
|
||||
};
|
||||
let signed_transaction = BridgeHubWestend::sign_transaction(
|
||||
SignParam {
|
||||
spec_version: 42,
|
||||
transaction_version: 50000,
|
||||
genesis_hash: [42u8; 32].into(),
|
||||
signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(),
|
||||
},
|
||||
unsigned.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
let parsed_transaction = BridgeHubWestend::parse_transaction(signed_transaction).unwrap();
|
||||
assert_eq!(parsed_transaction, unsigned);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
// 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 BridgeHubWestend 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_westend::SignedExtension;
|
||||
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 BridgeHubWestend extrinsic.
|
||||
pub type UncheckedExtrinsic = bp_bridge_hub_westend::UncheckedExtrinsic<Call, SignedExtension>;
|
||||
|
||||
/// The indirect pallet call used to sync `Rococo` GRANDPA finality to `BHWestend`.
|
||||
pub type BridgeRococoGrandpaCall = BridgeGrandpaCallOf<bp_rococo::Rococo>;
|
||||
/// The indirect pallet call used to sync `BridgeHubRococo` messages to `BridgeHubWestend`.
|
||||
pub type BridgeRococoMessagesCall = BridgeMessagesCallOf<bp_bridge_hub_rococo::BridgeHubRococo>;
|
||||
|
||||
/// `BridgeHubWestend` Runtime `Call` enum.
|
||||
///
|
||||
/// The enum represents a subset of possible `Call`s we can send to `BridgeHubWestend` 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
|
||||
/// `BridgeHubWestend` `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>),
|
||||
|
||||
/// Rococo grandpa bridge pallet.
|
||||
#[codec(index = 42)]
|
||||
BridgeRococoGrandpa(BridgeRococoGrandpaCall),
|
||||
/// Rococo parachains bridge pallet.
|
||||
#[codec(index = 43)]
|
||||
BridgeRococoParachains(BridgeParachainCall),
|
||||
/// Rococo messages bridge pallet.
|
||||
#[codec(index = 44)]
|
||||
BridgeRococoMessages(BridgeRococoMessagesCall),
|
||||
}
|
||||
|
||||
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 = BridgeRococoGrandpaCall::initialize { init_data };
|
||||
let tx = Call::BridgeRococoGrandpa(call);
|
||||
|
||||
// encode call as hex string
|
||||
let hex_encoded_call = format!("0x{:?}", HexDisplay::from(&Encode::encode(&tx)));
|
||||
assert_eq!(hex_encoded_call, "0x2a01ae4a25acf250d72ed02c149ecc7dd3c9ee976d41a2888fc551de8064521dc01d2d0192b965f0656a4e0e5fc0167da2d4b5ee72b3be2c1583c4c1e5236c8c12aa141bd2c0afaab32de0cb8f7f0d89217e37c5ea302c1ffb5a7a83e10d20f12c32874d0000060000000000000000");
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ 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 = "../../primitives/chain-rococo" }
|
||||
bp-runtime = { path = "../../primitives/runtime" }
|
||||
|
||||
bridge-runtime-common = { path = "../../bin/runtime-common" }
|
||||
|
||||
@@ -80,7 +80,7 @@ impl ChainWithBalances for Rococo {
|
||||
|
||||
impl RelayChain for Rococo {
|
||||
const PARAS_PALLET_NAME: &'static str = bp_rococo::PARAS_PALLET_NAME;
|
||||
const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgeRococoParachain";
|
||||
const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgeRococoParachains";
|
||||
}
|
||||
|
||||
impl ChainWithTransactions for Rococo {
|
||||
|
||||
@@ -6,15 +6,23 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
relay-substrate-client = { path = "../client-substrate" }
|
||||
relay-utils = { path = "../utils" }
|
||||
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
|
||||
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
|
||||
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
|
||||
bp-runtime = { path = "../../primitives/runtime" }
|
||||
bp-westend = { path = "../../primitives/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
@@ -16,21 +16,36 @@
|
||||
|
||||
//! Types used to connect to the Westend chain.
|
||||
|
||||
pub mod codegen_runtime;
|
||||
|
||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
||||
use bp_runtime::ChainId;
|
||||
use bp_westend::WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
||||
use codec::Encode;
|
||||
use relay_substrate_client::{
|
||||
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
|
||||
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError,
|
||||
RelayChain, SignParam, UnderlyingChainProvider, UnsignedTransaction,
|
||||
};
|
||||
use sp_core::storage::StorageKey;
|
||||
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;
|
||||
@@ -47,7 +62,7 @@ impl Chain for Westend {
|
||||
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6);
|
||||
|
||||
type SignedBlock = bp_westend::SignedBlock;
|
||||
type Call = ();
|
||||
type Call = RuntimeCall;
|
||||
}
|
||||
|
||||
impl ChainWithGrandpa for Westend {
|
||||
@@ -59,8 +74,7 @@ impl ChainWithGrandpa for Westend {
|
||||
|
||||
impl RelayChain for Westend {
|
||||
const PARAS_PALLET_NAME: &'static str = bp_westend::PARAS_PALLET_NAME;
|
||||
const PARACHAINS_FINALITY_PALLET_NAME: &'static str =
|
||||
bp_westend::WITH_WESTEND_BRIDGE_PARAS_PALLET_NAME;
|
||||
const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgeWestendParachains";
|
||||
}
|
||||
|
||||
impl ChainWithBalances for Westend {
|
||||
@@ -69,23 +83,53 @@ impl ChainWithBalances for Westend {
|
||||
}
|
||||
}
|
||||
|
||||
/// `AssetHubWestend` parachain definition
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct AssetHubWestend;
|
||||
impl ChainWithTransactions for Westend {
|
||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
||||
type SignedTransaction =
|
||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_westend::SignedExtension>;
|
||||
|
||||
impl UnderlyingChainProvider for AssetHubWestend {
|
||||
type Chain = bp_westend::AssetHubWestend;
|
||||
}
|
||||
|
||||
// Westmint seems to use the same configuration as all Polkadot-like chains, so we'll use Westend
|
||||
// primitives here.
|
||||
impl Chain for AssetHubWestend {
|
||||
const ID: ChainId = bp_runtime::ASSET_HUB_WESTEND_CHAIN_ID;
|
||||
const NAME: &'static str = "Westmint";
|
||||
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
|
||||
bp_westend::BEST_FINALIZED_ASSETHUBWESTEND_HEADER_METHOD;
|
||||
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6);
|
||||
|
||||
type SignedBlock = bp_westend::SignedBlock;
|
||||
type Call = ();
|
||||
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,
|
||||
))
|
||||
}
|
||||
|
||||
fn is_signed(tx: &Self::SignedTransaction) -> bool {
|
||||
tx.signature.is_some()
|
||||
}
|
||||
|
||||
fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
|
||||
tx.signature
|
||||
.as_ref()
|
||||
.map(|(address, _, _)| *address == Address::Id(signer.public().into()))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> {
|
||||
let extra = &tx.signature.as_ref()?.2;
|
||||
Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ impl ChainWithBalances for Wococo {
|
||||
|
||||
impl RelayChain for Wococo {
|
||||
const PARAS_PALLET_NAME: &'static str = bp_wococo::PARAS_PALLET_NAME;
|
||||
const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgeWococoParachain";
|
||||
const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgeWococoParachains";
|
||||
}
|
||||
|
||||
impl ChainWithTransactions for Wococo {
|
||||
|
||||
Reference in New Issue
Block a user