mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 16:21:02 +00:00
cumulus: add asset-hub-rococo runtime based on asset-hub-kusama and add asset-bridging support to it (#1215)
This commit adds Rococo Asset Hub dedicated runtime so we can test new features here, before merging them in Kusama Asset Hub. Also adds one such feature: asset transfer over bridge (Rococo AssetHub <> Wococo AssetHub) - clone `asset-hub-kusama-runtime` -> `asset-hub-rococo-runtime` - make it use Rococo primitives, names, assets, constants, etc - add asset-transfer-over-bridge support to Rococo AssetHub <> Wococo AssetHub Fixes #1128 --------- Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
This commit is contained in:
@@ -14,6 +14,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! # Bridge Hub Rococo Runtime
|
||||
//!
|
||||
//! This runtime is also used for Bridge Hub Wococo. But we dont want to create another exact copy
|
||||
//! of Bridge Hub Rococo, so we injected some tweaks backed by `RuntimeFlavor` and `pub storage
|
||||
//! Flavor: RuntimeFlavor`. (For example this is needed for successful asset transfer between Asset
|
||||
//! Hub Rococo and Asset Hub Wococo, where we need to have correct `xcm_config::UniversalLocation`
|
||||
//! with correct `GlobalConsensus`.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
|
||||
#![recursion_limit = "256"]
|
||||
@@ -27,6 +35,7 @@ pub mod bridge_hub_wococo_config;
|
||||
mod weights;
|
||||
pub mod xcm_config;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||
@@ -92,6 +101,15 @@ use parachains_common::{
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
/// Enum for handling differences in the runtime configuration for BridgeHubRococo vs
|
||||
/// BridgeHubWococo.
|
||||
#[derive(Default, Eq, PartialEq, Debug, Clone, Copy, Decode, Encode)]
|
||||
pub enum RuntimeFlavor {
|
||||
#[default]
|
||||
Rococo,
|
||||
Wococo,
|
||||
}
|
||||
|
||||
/// The address format for describing accounts.
|
||||
pub type Address = MultiAddress<AccountId, ()>;
|
||||
|
||||
@@ -473,7 +491,7 @@ parameter_types! {
|
||||
pub const RelayerStakeReserveId: [u8; 8] = *b"brdgrlrs";
|
||||
}
|
||||
|
||||
/// Add parachain bridge pallet to track Wococo bridge hub parachain
|
||||
/// Add parachain bridge pallet to track Wococo BridgeHub parachain
|
||||
pub type BridgeParachainWococoInstance = pallet_bridge_parachains::Instance1;
|
||||
impl pallet_bridge_parachains::Config<BridgeParachainWococoInstance> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
@@ -486,7 +504,7 @@ impl pallet_bridge_parachains::Config<BridgeParachainWococoInstance> for Runtime
|
||||
type MaxParaHeadDataSize = MaxWococoParaHeadDataSize;
|
||||
}
|
||||
|
||||
/// Add parachain bridge pallet to track Rococo bridge hub parachain
|
||||
/// Add parachain bridge pallet to track Rococo BridgeHub parachain
|
||||
pub type BridgeParachainRococoInstance = pallet_bridge_parachains::Instance2;
|
||||
impl pallet_bridge_parachains::Config<BridgeParachainRococoInstance> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
@@ -528,9 +546,15 @@ impl pallet_bridge_messages::Config<WithBridgeHubWococoMessagesInstance> for Run
|
||||
>;
|
||||
|
||||
type SourceHeaderChain = SourceHeaderChainAdapter<WithBridgeHubWococoMessageBridge>;
|
||||
type MessageDispatch =
|
||||
XcmBlobMessageDispatch<OnBridgeHubRococoBlobDispatcher, Self::WeightInfo, ()>;
|
||||
type OnMessagesDelivered = ();
|
||||
type MessageDispatch = XcmBlobMessageDispatch<
|
||||
OnBridgeHubRococoBlobDispatcher,
|
||||
Self::WeightInfo,
|
||||
cumulus_pallet_xcmp_queue::bridging::OutXcmpChannelStatusProvider<
|
||||
bridge_hub_rococo_config::AssetHubRococoParaId,
|
||||
Runtime,
|
||||
>,
|
||||
>;
|
||||
type OnMessagesDelivered = bridge_hub_rococo_config::OnMessagesDelivered;
|
||||
}
|
||||
|
||||
/// Add XCM messages support for BridgeHubWococo to support Wococo->Rococo XCM messages
|
||||
@@ -562,9 +586,15 @@ impl pallet_bridge_messages::Config<WithBridgeHubRococoMessagesInstance> for Run
|
||||
>;
|
||||
|
||||
type SourceHeaderChain = SourceHeaderChainAdapter<WithBridgeHubRococoMessageBridge>;
|
||||
type MessageDispatch =
|
||||
XcmBlobMessageDispatch<OnBridgeHubWococoBlobDispatcher, Self::WeightInfo, ()>;
|
||||
type OnMessagesDelivered = ();
|
||||
type MessageDispatch = XcmBlobMessageDispatch<
|
||||
OnBridgeHubWococoBlobDispatcher,
|
||||
Self::WeightInfo,
|
||||
cumulus_pallet_xcmp_queue::bridging::OutXcmpChannelStatusProvider<
|
||||
bridge_hub_wococo_config::AssetHubWococoParaId,
|
||||
Runtime,
|
||||
>,
|
||||
>;
|
||||
type OnMessagesDelivered = bridge_hub_wococo_config::OnMessagesDelivered;
|
||||
}
|
||||
|
||||
/// Allows collect and claim rewards for relayers
|
||||
@@ -617,16 +647,16 @@ construct_runtime!(
|
||||
Utility: pallet_utility::{Pallet, Call, Event} = 40,
|
||||
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 36,
|
||||
|
||||
// Rococo and Wococo Bridge Hubs are sharing the runtime, so this runtime has two sets of
|
||||
// Rococo and Wococo BridgeHubs are sharing the runtime, so this runtime has two sets of
|
||||
// bridge pallets. Both are deployed at both runtimes, but only one set is actually used
|
||||
// at particular runtime.
|
||||
|
||||
// With-Wococo bridge modules that are active (used) at Rococo Bridge Hub runtime.
|
||||
// With-Wococo bridge modules that are active (used) at Rococo BridgeHub runtime.
|
||||
BridgeWococoGrandpa: pallet_bridge_grandpa::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 41,
|
||||
BridgeWococoParachain: pallet_bridge_parachains::<Instance1>::{Pallet, Call, Storage, Event<T>} = 42,
|
||||
BridgeWococoMessages: pallet_bridge_messages::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 46,
|
||||
|
||||
// With-Rococo bridge modules that are active (used) at Wococo Bridge Hub runtime.
|
||||
// With-Rococo bridge modules that are active (used) at Wococo BridgeHub runtime.
|
||||
BridgeRococoGrandpa: pallet_bridge_grandpa::<Instance2>::{Pallet, Call, Storage, Event<T>, Config<T>} = 43,
|
||||
BridgeRococoParachain: pallet_bridge_parachains::<Instance2>::{Pallet, Call, Storage, Event<T>} = 44,
|
||||
BridgeRococoMessages: pallet_bridge_messages::<Instance2>::{Pallet, Call, Storage, Event<T>, Config<T>} = 45,
|
||||
@@ -982,19 +1012,19 @@ impl_runtime_apis! {
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_config::RelayLocation;
|
||||
use xcm_config::TokenLocation;
|
||||
|
||||
impl pallet_xcm_benchmarks::Config for Runtime {
|
||||
type XcmConfig = xcm_config::XcmConfig;
|
||||
type AccountIdConverter = xcm_config::LocationToAccountId;
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(RelayLocation::get())
|
||||
Ok(TokenLocation::get())
|
||||
}
|
||||
fn worst_case_holding(_depositable_count: u32) -> MultiAssets {
|
||||
// just concrete assets according to relay chain.
|
||||
let assets: Vec<MultiAsset> = vec![
|
||||
MultiAsset {
|
||||
id: Concrete(RelayLocation::get()),
|
||||
id: Concrete(TokenLocation::get()),
|
||||
fun: Fungible(1_000_000 * UNITS),
|
||||
}
|
||||
];
|
||||
@@ -1004,8 +1034,8 @@ impl_runtime_apis! {
|
||||
|
||||
parameter_types! {
|
||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
||||
RelayLocation::get(),
|
||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(RelayLocation::get()) },
|
||||
TokenLocation::get(),
|
||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(TokenLocation::get()) },
|
||||
));
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
|
||||
@@ -1020,7 +1050,7 @@ impl_runtime_apis! {
|
||||
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
id: Concrete(RelayLocation::get()),
|
||||
id: Concrete(TokenLocation::get()),
|
||||
fun: Fungible(UNITS),
|
||||
}
|
||||
}
|
||||
@@ -1042,16 +1072,16 @@ impl_runtime_apis! {
|
||||
}
|
||||
|
||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
||||
Ok((RelayLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||
Ok((TokenLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||
}
|
||||
|
||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(RelayLocation::get())
|
||||
Ok(TokenLocation::get())
|
||||
}
|
||||
|
||||
fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> {
|
||||
let origin = RelayLocation::get();
|
||||
let assets: MultiAssets = (Concrete(RelayLocation::get()), 1_000 * UNITS).into();
|
||||
let origin = TokenLocation::get();
|
||||
let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into();
|
||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
||||
Ok((origin, ticket, assets))
|
||||
}
|
||||
@@ -1062,7 +1092,7 @@ impl_runtime_apis! {
|
||||
|
||||
fn export_message_origin_and_destination(
|
||||
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
|
||||
Ok((RelayLocation::get(), NetworkId::Wococo, X1(Parachain(100))))
|
||||
Ok((TokenLocation::get(), NetworkId::Wococo, X1(Parachain(100))))
|
||||
}
|
||||
|
||||
fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> {
|
||||
|
||||
Reference in New Issue
Block a user