mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 21:01:02 +00:00
Adds Snowbridge to Rococo runtime (#2522)
# Description Adds Snowbridge to the Rococo bridge hub runtime. Includes config changes required in Rococo asset hub. --------- Co-authored-by: Alistair Singh <alistair.singh7@gmail.com> Co-authored-by: ron <yrong1997@gmail.com> Co-authored-by: Vincent Geddes <vincent.geddes@hey.com> Co-authored-by: claravanstaden <Cats 4 life!>
This commit is contained in:
@@ -78,10 +78,13 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default-
|
||||
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
|
||||
parachain-info = { package = "staging-parachain-info", path = "../../../pallets/parachain-info", default-features = false }
|
||||
parachains-common = { path = "../../../common", default-features = false }
|
||||
assets-common = { path = "../../assets/common", default-features = false }
|
||||
snowbridge-rococo-common = { path = "../../../../../bridges/snowbridge/parachain/runtime/rococo-common", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"assets-common/std",
|
||||
"codec/std",
|
||||
"cumulus-pallet-aura-ext/std",
|
||||
"cumulus-pallet-dmp-queue/std",
|
||||
@@ -118,6 +121,7 @@ std = [
|
||||
"polkadot-primitives/std",
|
||||
"polkadot-runtime-common/std",
|
||||
"scale-info/std",
|
||||
"snowbridge-rococo-common/std",
|
||||
"sp-api/std",
|
||||
"sp-block-builder/std",
|
||||
"sp-consensus-aura/std",
|
||||
@@ -138,6 +142,7 @@ std = [
|
||||
]
|
||||
|
||||
runtime-benchmarks = [
|
||||
"assets-common/runtime-benchmarks",
|
||||
"cumulus-pallet-dmp-queue/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
||||
@@ -161,6 +166,7 @@ runtime-benchmarks = [
|
||||
"polkadot-parachain-primitives/runtime-benchmarks",
|
||||
"polkadot-primitives/runtime-benchmarks",
|
||||
"polkadot-runtime-common/runtime-benchmarks",
|
||||
"snowbridge-rococo-common/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"xcm-executor/runtime-benchmarks",
|
||||
|
||||
@@ -32,6 +32,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
mod weights;
|
||||
pub mod xcm_config;
|
||||
|
||||
use assets_common::MultiLocationForAssetId;
|
||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
||||
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
|
||||
use frame_support::{
|
||||
@@ -458,6 +459,41 @@ impl pallet_assets::Config<pallet_assets::Instance1> for Runtime {
|
||||
type BenchmarkHelper = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// we just reuse the same deposits
|
||||
pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get();
|
||||
pub const ForeignAssetsAssetAccountDeposit: Balance = AssetAccountDeposit::get();
|
||||
pub const ForeignAssetsApprovalDeposit: Balance = ApprovalDeposit::get();
|
||||
pub const ForeignAssetsAssetsStringLimit: u32 = AssetsStringLimit::get();
|
||||
pub const ForeignAssetsMetadataDepositBase: Balance = MetadataDepositBase::get();
|
||||
pub const ForeignAssetsMetadataDepositPerByte: Balance = MetadataDepositPerByte::get();
|
||||
}
|
||||
|
||||
/// Another pallet assets instance to store foreign assets from bridgehub.
|
||||
pub type ForeignAssetsInstance = pallet_assets::Instance2;
|
||||
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Balance = Balance;
|
||||
type AssetId = MultiLocationForAssetId;
|
||||
type AssetIdParameter = MultiLocationForAssetId;
|
||||
type Currency = Balances;
|
||||
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
|
||||
type ForceOrigin = EnsureRoot<AccountId>;
|
||||
type AssetDeposit = ForeignAssetsAssetDeposit;
|
||||
type MetadataDepositBase = ForeignAssetsMetadataDepositBase;
|
||||
type MetadataDepositPerByte = ForeignAssetsMetadataDepositPerByte;
|
||||
type ApprovalDeposit = ForeignAssetsApprovalDeposit;
|
||||
type StringLimit = ForeignAssetsAssetsStringLimit;
|
||||
type Freezer = ();
|
||||
type Extra = ();
|
||||
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
|
||||
type CallbackHandle = ();
|
||||
type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit;
|
||||
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = xcm_config::XcmBenchmarkHelper;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
|
||||
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
|
||||
@@ -626,6 +662,7 @@ construct_runtime!(
|
||||
|
||||
// The main stage.
|
||||
Assets: pallet_assets::<Instance1>::{Pallet, Call, Storage, Event<T>} = 50,
|
||||
ForeignAssets: pallet_assets::<Instance2>::{Pallet, Call, Storage, Event<T>} = 51,
|
||||
|
||||
Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>} = 255,
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
//! soon.
|
||||
use super::{
|
||||
AccountId, AllPalletsWithSystem, AssetId as AssetIdPalletAssets, Assets, Balance, Balances,
|
||||
ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
|
||||
WeightToFee, XcmpQueue,
|
||||
ForeignAssets, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent,
|
||||
RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
};
|
||||
use core::marker::PhantomData;
|
||||
use frame_support::{
|
||||
@@ -42,18 +42,19 @@ use pallet_assets::Instance1;
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use polkadot_runtime_common::impls::ToAuthor;
|
||||
use snowbridge_rococo_common::EthereumNetwork;
|
||||
use sp_runtime::traits::Zero;
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteId, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin,
|
||||
FixedWeightBounds, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, ParentAsSuperuser,
|
||||
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||
ConvertedConcreteId, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry,
|
||||
EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset,
|
||||
NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, StartsWith, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||
};
|
||||
use xcm_executor::{traits::JustTry, XcmExecutor};
|
||||
|
||||
@@ -125,8 +126,28 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
CheckingAccount,
|
||||
>;
|
||||
|
||||
/// `AssetId/Balance` converter for `TrustBackedAssets`
|
||||
pub type ForeignAssetsConvertedConcreteId =
|
||||
assets_common::ForeignAssetsConvertedConcreteId<StartsWith<RelayLocation>, Balance>;
|
||||
|
||||
/// Means for transacting foreign assets from different global consensus.
|
||||
pub type ForeignFungiblesTransactor = FungiblesAdapter<
|
||||
// Use this fungibles implementation:
|
||||
ForeignAssets,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
ForeignAssetsConvertedConcreteId,
|
||||
// Convert an XCM MultiLocation into a local account id:
|
||||
LocationToAccountId,
|
||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||
AccountId,
|
||||
// We dont need to check teleports here.
|
||||
NoChecking,
|
||||
// The account to use for tracking teleports.
|
||||
CheckingAccount,
|
||||
>;
|
||||
|
||||
/// Means for transacting assets on this chain.
|
||||
pub type AssetTransactors = (CurrencyTransactor, FungiblesTransactor);
|
||||
pub type AssetTransactors = (CurrencyTransactor, ForeignFungiblesTransactor, FungiblesTransactor);
|
||||
|
||||
/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
|
||||
/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
|
||||
@@ -202,16 +223,22 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
pub type AccountIdOf<R> = <R as frame_system::Config>::AccountId;
|
||||
|
||||
/// Asset filter that allows all assets from a certain location matching asset id.
|
||||
pub struct AssetsFrom<T>(PhantomData<T>);
|
||||
impl<T: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation> for AssetsFrom<T> {
|
||||
pub struct AssetPrefixFrom<Prefix, Origin>(PhantomData<(Prefix, Origin)>);
|
||||
impl<Prefix, Origin> ContainsPair<MultiAsset, MultiLocation> for AssetPrefixFrom<Prefix, Origin>
|
||||
where
|
||||
Prefix: Get<MultiLocation>,
|
||||
Origin: Get<MultiLocation>,
|
||||
{
|
||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
||||
let loc = T::get();
|
||||
let loc = Origin::get();
|
||||
&loc == origin &&
|
||||
matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) }
|
||||
if asset_loc.starts_with(&loc))
|
||||
if asset_loc.starts_with(&Prefix::get()))
|
||||
}
|
||||
}
|
||||
|
||||
type AssetsFrom<T> = AssetPrefixFrom<T, T>;
|
||||
|
||||
/// Asset filter that allows native/relay asset if coming from a certain location.
|
||||
pub struct NativeAssetFrom<T>(PhantomData<T>);
|
||||
impl<T: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation> for NativeAssetFrom<T> {
|
||||
@@ -267,6 +294,7 @@ parameter_types! {
|
||||
0,
|
||||
X2(PalletInstance(50), GeneralIndex(TELEPORTABLE_ASSET_ID.into()))
|
||||
);
|
||||
pub EthereumLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(EthereumNetwork::get())));
|
||||
}
|
||||
|
||||
/// Accepts asset with ID `AssetLocation` and is coming from `Origin` chain.
|
||||
@@ -280,8 +308,12 @@ impl<AssetLocation: Get<MultiLocation>, Origin: Get<MultiLocation>>
|
||||
}
|
||||
}
|
||||
|
||||
pub type Reserves =
|
||||
(NativeAsset, AssetsFrom<SystemAssetHubLocation>, NativeAssetFrom<SystemAssetHubLocation>);
|
||||
pub type Reserves = (
|
||||
NativeAsset,
|
||||
AssetsFrom<SystemAssetHubLocation>,
|
||||
NativeAssetFrom<SystemAssetHubLocation>,
|
||||
AssetPrefixFrom<EthereumLocation, SystemAssetHubLocation>,
|
||||
);
|
||||
pub type TrustedTeleporters =
|
||||
(AssetFromChain<LocalTeleportableToAssetHub, SystemAssetHubLocation>,);
|
||||
|
||||
@@ -362,3 +394,12 @@ impl cumulus_pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||
}
|
||||
|
||||
/// Simple conversion of `u32` into an `AssetId` for use in benchmarking.
|
||||
pub struct XcmBenchmarkHelper;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pallet_assets::BenchmarkHelper<MultiLocation> for XcmBenchmarkHelper {
|
||||
fn create_asset_id_parameter(id: u32) -> MultiLocation {
|
||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user