forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rococo/Wococo bridge hub relay integration (paritytech#1565)
* [BridgeHub] Added bridge-hub-rococo/wococo clients with bridge-hub-rococo-runtime * [BridgeHub] Add init-bridge stuff for bridge-hub-rococo/wococo * [BridgeHub] Add init-bridge stuff for bridge-hub-rococo/wococo * [BridgeHub] Fixed Call-encoding for init-bridge rococo runtime wrapper * Final index update to runtime calls * [BridgeHub] Add init-bridge stuff for bridge-hub-rococo/wococo (otherside) * Added runtime best_finalized functions + relay-headers init * Renaming and change BridgeHubRococo/Wococo to Rococo/Wococo config * [BridgeHub] Add relay-parachains (Rococo/Wococo) * Missing stuff for adding xcm messaging to BridgeHub * extracted parachain IDs to the primitives * fix compilation * Fixes * Init setup for Rococo->Wococo messaging support * Removed unused AccountId from `trait MessagesBridge` * Removed unused trait SenderOrigin * Small fixes * Cleaning after master-merge * Fixes * Fixes * Fixes * Fixes * Fixes: - align WeightToFee with BridgeHubRococo runtime - MAX_HEADER_SIZE - updated TODOs * Added relay_messages cfg for BridgeHubWococo -> BridgeHubRococo Co-authored-by: Svyatoslav Nikolsky <[email protected]>
- Loading branch information
Showing
34 changed files
with
1,476 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "bp-bridge-hub-rococo" | ||
description = "Primitives of BridgeHubRococo parachain runtime." | ||
version = "0.1.0" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
edition = "2021" | ||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0" | ||
|
||
[dependencies] | ||
smallvec = "1.10.0" | ||
|
||
# Bridge Dependencies | ||
|
||
bp-polkadot-core = { path = "../../primitives/polkadot-core", 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/substrate", branch = "master", default-features = false } | ||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } | ||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } | ||
|
||
# Polkadot Dependencies | ||
polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"bp-polkadot-core/std", | ||
"bp-messages/std", | ||
"bp-runtime/std", | ||
"frame-support/std", | ||
"sp-api/std", | ||
"sp-std/std", | ||
"polkadot-runtime-constants/std", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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/>. | ||
|
||
//! Module with configuration which reflects BridgeHubRococo runtime setup (AccountId, Headers, | ||
//! Hashes...) | ||
|
||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
use bp_messages::*; | ||
pub use bp_polkadot_core::*; | ||
use bp_runtime::{decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis}; | ||
use frame_support::{ | ||
parameter_types, | ||
sp_runtime::{FixedU128, MultiAddress, MultiSigner}, | ||
weights::{ | ||
constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients, | ||
WeightToFeePolynomial, | ||
}, | ||
Parameter, | ||
}; | ||
use sp_std::prelude::*; | ||
|
||
pub type BridgeHubRococo = PolkadotLike; | ||
|
||
/// [`WeightToFee`] should reflect cumulus/bridge-hub-rococo-runtime [`WeightToFee`] | ||
pub struct WeightToFee; | ||
impl WeightToFeePolynomial for WeightToFee { | ||
type Balance = Balance; | ||
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> { | ||
pub const CENTS: Balance = polkadot_runtime_constants::currency::CENTS; | ||
|
||
// in Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: | ||
// in BridgeHub, we map to 1/10 of that, or 1/100 CENT | ||
let p = CENTS; | ||
let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); | ||
smallvec::smallvec![WeightToFeeCoefficient { | ||
degree: 1, | ||
negative: false, | ||
coeff_frac: Perbill::from_rational(p % q, q), | ||
coeff_integer: p / q, | ||
}] | ||
} | ||
} | ||
|
||
/// Public key of the chain account that may be used to verify signatures. | ||
pub type AccountSigner = MultiSigner; | ||
|
||
/// The address format for describing accounts. | ||
pub type Address = MultiAddress<AccountId, ()>; | ||
|
||
/// Identifier of BridgeHubRococo in the Rococo relay chain. | ||
pub const BRIDGE_HUB_ROCOCO_PARACHAIN_ID: u32 = 1013; | ||
|
||
/// Name of the With-BridgeHubRococo messages pallet instance that is deployed at bridged chains. | ||
pub const WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessages"; | ||
|
||
parameter_types! { | ||
pub const SS58Prefix: u16 = 42; | ||
} | ||
|
||
decl_bridge_finality_runtime_apis!(bridge_hub_rococo); | ||
decl_bridge_messages_runtime_apis!(bridge_hub_rococo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[package] | ||
name = "bp-bridge-hub-wococo" | ||
description = "Primitives of BridgeHubWococo parachain runtime." | ||
version = "0.1.0" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
edition = "2021" | ||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0" | ||
|
||
[dependencies] | ||
|
||
# Bridge Dependencies | ||
|
||
bp-bridge-hub-rococo = { path = "../chain-bridge-hub-rococo", 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/substrate", branch = "master", default-features = false } | ||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } | ||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"bp-runtime/std", | ||
"bp-messages/std", | ||
"frame-support/std", | ||
"sp-api/std", | ||
"sp-std/std", | ||
"bp-bridge-hub-rococo/std", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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/>. | ||
|
||
//! Module with configuration which reflects BridgeHubWococo runtime setup | ||
//! (AccountId, Headers, Hashes...) | ||
//! | ||
//! but actually this is just reexported BridgeHubRococo stuff, because they are supposed to be | ||
//! identical, at least uses the same parachain runtime | ||
|
||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
// Re-export only what is really needed | ||
pub use bp_bridge_hub_rococo::{ | ||
account_info_storage_key, AccountId, AccountPublic, AccountSigner, Address, Balance, | ||
BlockNumber, Hash, Hashing, Header, Nonce, SS58Prefix, Signature, SignedBlock, | ||
SignedExtensions, UncheckedExtrinsic, WeightToFee, ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT, | ||
DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT, EXTRA_STORAGE_PROOF_SIZE, | ||
MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, | ||
MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, | ||
PAY_INBOUND_DISPATCH_FEE_WEIGHT, TX_EXTRA_BYTES, | ||
}; | ||
use bp_messages::*; | ||
use bp_runtime::{decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis}; | ||
use frame_support::{sp_runtime::FixedU128, Parameter}; | ||
use sp_std::prelude::*; | ||
|
||
pub type BridgeHubWococo = bp_bridge_hub_rococo::BridgeHubRococo; | ||
|
||
/// Identifier of BridgeHubWococo in the Wococo relay chain. | ||
pub const BRIDGE_HUB_WOCOCO_PARACHAIN_ID: u32 = 1013; | ||
|
||
/// Name of the With-BridgeHubWococo messages pallet instance that is deployed at bridged chains. | ||
pub const WITH_BRIDGE_HUB_WOCOCO_MESSAGES_PALLET_NAME: &str = "BridgeWococoMessages"; | ||
|
||
decl_bridge_finality_runtime_apis!(bridge_hub_wococo); | ||
decl_bridge_messages_runtime_apis!(bridge_hub_wococo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
bridges/relays/bin-substrate/src/chains/bridge_hub_rococo_messages_to_bridge_hub_wococo.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2022 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity Bridges Common. | ||
|
||
// Parity Bridges Common is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity Bridges Common is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! BridgeHubRococo-to-BridgeHubWococo messages sync entrypoint. | ||
|
||
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge}; | ||
use bp_messages::Weight; | ||
use messages_relay::relay_strategy::MixStrategy; | ||
use relay_bridge_hub_rococo_client::BridgeHubRococo; | ||
use relay_bridge_hub_wococo_client::BridgeHubWococo; | ||
use substrate_relay_helper::messages_lane::SubstrateMessageLane; | ||
|
||
pub struct BridgeHubRococoToBridgeHubWococoMessagesCliBridge {} | ||
|
||
impl CliBridgeBase for BridgeHubRococoToBridgeHubWococoMessagesCliBridge { | ||
type Source = BridgeHubRococo; | ||
type Target = BridgeHubWococo; | ||
} | ||
|
||
impl MessagesCliBridge for BridgeHubRococoToBridgeHubWococoMessagesCliBridge { | ||
const ESTIMATE_MESSAGE_FEE_METHOD: &'static str = | ||
"TODO: not needed now, used for send_message and estimate_fee CLI"; | ||
type MessagesLane = BridgeHubRococoMessagesToBridgeHubWococoMessageLane; | ||
} | ||
|
||
substrate_relay_helper::generate_mocked_receive_message_proof_call_builder!( | ||
BridgeHubRococoMessagesToBridgeHubWococoMessageLane, | ||
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesProofCallBuilder, | ||
relay_bridge_hub_wococo_client::runtime::Call::BridgeRococoMessages, | ||
relay_bridge_hub_wococo_client::runtime::BridgeRococoMessagesCall::receive_messages_proof | ||
); | ||
|
||
substrate_relay_helper::generate_mocked_receive_message_delivery_proof_call_builder!( | ||
BridgeHubRococoMessagesToBridgeHubWococoMessageLane, | ||
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesDeliveryProofCallBuilder, | ||
relay_bridge_hub_rococo_client::runtime::Call::BridgeWococoMessages, | ||
relay_bridge_hub_rococo_client::runtime::BridgeWococoMessagesCall::receive_messages_delivery_proof | ||
); | ||
|
||
/// Description of BridgeHubRococo -> BridgeHubWococo messages bridge. | ||
#[derive(Clone, Debug)] | ||
pub struct BridgeHubRococoMessagesToBridgeHubWococoMessageLane; | ||
|
||
impl SubstrateMessageLane for BridgeHubRococoMessagesToBridgeHubWococoMessageLane { | ||
const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None; | ||
const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None; | ||
|
||
const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None; | ||
const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None; | ||
|
||
const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None; | ||
const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None; | ||
|
||
type SourceChain = BridgeHubRococo; | ||
type TargetChain = BridgeHubWococo; | ||
|
||
type ReceiveMessagesProofCallBuilder = | ||
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesProofCallBuilder; | ||
type ReceiveMessagesDeliveryProofCallBuilder = | ||
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesDeliveryProofCallBuilder; | ||
|
||
type TargetToSourceChainConversionRateUpdateBuilder = (); | ||
|
||
type RelayStrategy = MixStrategy; | ||
} |
Oops, something went wrong.