Newer
Older
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Testnet for Asset Hub Polkadot.
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "256"]
// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
mod weights;
local_and_foreign_assets::{LocalFromLeft, TargetFromLeft},
AssetIdForTrustBackedAssetsConvert,
};
use codec::{Decode, Encode, MaxEncodedLen};
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
construct_runtime, derive_impl,
genesis_builder_helper::{build_state, get_preset},
ord_parameter_types, parameter_types,
fungible, fungibles,
tokens::{imbalance::ResolveAssetTo, nonfungibles_v2::Inspect},
AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, Equals,
InstanceFilter, TransformOrigin,
weights::{ConstantMultiplier, Weight},
Bastian Köcher
committed
};
use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot, EnsureSigned, EnsureSignedBy,
use pallet_asset_conversion_tx_payment::AssetConversionAdapter;
Liam Aharon
committed
use pallet_nfts::{DestroyWitness, PalletFeatures};
Branislav Kontur
committed
use pallet_xcm::EnsureXcm;
impls::DealWithFees, message_queue::*, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
BlockNumber, CollectionId, Hash, Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
NORMAL_DISPATCH_RATIO,
Bastian Köcher
committed
};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, Saturating, Verify},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Perbill, Permill, RuntimeDebug,
};
use sp_std::prelude::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use testnet_parachains_constants::westend::{consensus::*, currency::*, fee::WeightToFee, time::*};
ForeignAssetsConvertedConcreteId, PoolAssetsConvertedConcreteId,
TrustBackedAssetsConvertedConcreteId, TrustBackedAssetsPalletLocationV3, WestendLocation,
WestendLocationV3, XcmOriginToTransactDispatchOrigin,
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
use assets_common::{foreign_creators::ForeignCreators, matching::FromSiblingParachain};
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
// We exclude `Assets` since it's the name of a pallet
use xcm::latest::prelude::AssetId;
#[cfg(feature = "runtime-benchmarks")]
use xcm::latest::prelude::{
Asset, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, NetworkId,
NonFungible, Parent, ParentThen, Response, XCM_VERSION,
};
use crate::xcm_config::ForeignCreatorsSovereignAccountOf;
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
impl_opaque_keys! {
pub struct SessionKeys {
pub aura: Aura,
}
}
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
// Note: "westmint" is the legacy name for this chain. It has been renamed to
// "asset-hub-westend". Many wallets/tools depend on the `spec_name`, so it remains "westmint"
// for the time being. Wallets/tools should update to treat "asset-hub-westend" equally.
spec_name: create_runtime_str!("westmint"),
impl_name: create_runtime_str!("westmint"),
authoring_version: 1,
spec_version: 1_010_000,
};
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
}
parameter_types! {
pub const Version: RuntimeVersion = VERSION;
pub RuntimeBlockLength: BlockLength =
BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
.base_block(BlockExecutionWeight::get())
.for_class(DispatchClass::all(), |weights| {
weights.base_extrinsic = ExtrinsicBaseWeight::get();
})
.for_class(DispatchClass::Normal, |weights| {
weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
})
.for_class(DispatchClass::Operational, |weights| {
weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
// Operational transactions have some extra reserved space, so that they
// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
weights.reserved = Some(
MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
);
})
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
.build_or_panic();
pub const SS58Prefix: u8 = 42;
}
// Configure FRAME pallets to include in runtime.
#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
impl frame_system::Config for Runtime {
type BlockWeights = RuntimeBlockWeights;
type BlockLength = RuntimeBlockLength;
type AccountId = AccountId;
type Block = Block;
type BlockHashCount = BlockHashCount;
type DbWeight = RocksDbWeight;
type Version = Version;
type AccountData = pallet_balances::AccountData<Balance>;
type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
type SS58Prefix = SS58Prefix;
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
impl pallet_timestamp::Config for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = u64;
type OnTimestampSet = Aura;
type MinimumPeriod = ConstU64<0>;
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
}
impl pallet_authorship::Config for Runtime {
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
type EventHandler = (CollatorSelection,);
}
parameter_types! {
pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
}
impl pallet_balances::Config for Runtime {
Branislav Kontur
committed
type MaxLocks = ConstU32<50>;
/// The type for recording an account's balance.
type Balance = Balance;
/// The ubiquitous event type.
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
Branislav Kontur
committed
type MaxReserves = ConstU32<50>;
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<0>;
}
parameter_types! {
/// Relay Chain `TransactionByteFee` / 10
pub const TransactionByteFee: Balance = MILLICENTS;
}
impl pallet_transaction_payment::Config for Runtime {
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
Branislav Kontur
committed
type OperationalFeeMultiplier = ConstU8<5>;
pub const AssetDeposit: Balance = UNITS / 10; // 1 / 10 WND deposit to create asset
pub const AssetAccountDeposit: Balance = deposit(1, 16);
pub const ApprovalDeposit: Balance = EXISTENTIAL_DEPOSIT;
pub const AssetsStringLimit: u32 = 50;
/// Key = 32 bytes, Value = 36 bytes (32+1+1+1+1)
// https://github.com/paritytech/substrate/blob/069917b/frame/assets/src/lib.rs#L257L271
pub const MetadataDepositBase: Balance = deposit(1, 68);
pub const MetadataDepositPerByte: Balance = deposit(0, 1);
}
pub type AssetsForceOrigin = EnsureRoot<AccountId>;
// Called "Trust Backed" assets because these are generally registered by some account, and users of
// the asset assume it has some claimed backing. The pallet is called `Assets` in
// `construct_runtime` to avoid breaking changes on storage reads.
pub type TrustBackedAssetsInstance = pallet_assets::Instance1;
type TrustBackedAssetsCall = pallet_assets::Call<Runtime, TrustBackedAssetsInstance>;
impl pallet_assets::Config<TrustBackedAssetsInstance> for Runtime {
type AssetId = AssetIdForTrustBackedAssets;
type AssetIdParameter = codec::Compact<AssetIdForTrustBackedAssets>;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = AssetsForceOrigin;
type AssetDeposit = AssetDeposit;
type MetadataDepositBase = MetadataDepositBase;
type MetadataDepositPerByte = MetadataDepositPerByte;
type ApprovalDeposit = ApprovalDeposit;
type StringLimit = AssetsStringLimit;
type WeightInfo = weights::pallet_assets_local::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = ConstU32<1000>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}
parameter_types! {
pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon");
pub const LiquidityWithdrawalFee: Permill = Permill::from_percent(0);
}
ord_parameter_types! {
pub const AssetConversionOrigin: sp_runtime::AccountId32 =
AccountIdConversion::<sp_runtime::AccountId32>::into_account_truncating(&AssetConversionPalletId::get());
}
pub type PoolAssetsInstance = pallet_assets::Instance3;
impl pallet_assets::Config<PoolAssetsInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type RemoveItemsLimit = ConstU32<1000>;
type AssetId = u32;
type AssetIdParameter = u32;
type Currency = Balances;
type CreateOrigin =
AsEnsureOriginWithArg<EnsureSignedBy<AssetConversionOrigin, sp_runtime::AccountId32>>;
type ForceOrigin = AssetsForceOrigin;
type AssetDeposit = ConstU128<0>;
type AssetAccountDeposit = ConstU128<0>;
type MetadataDepositBase = ConstU128<0>;
type MetadataDepositPerByte = ConstU128<0>;
type ApprovalDeposit = ConstU128<0>;
type StringLimit = ConstU32<50>;
type Freezer = ();
type Extra = ();
type WeightInfo = weights::pallet_assets_pool::WeightInfo<Runtime>;
type CallbackHandle = ();
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
/// Union fungibles implementation for `Assets` and `ForeignAssets`.
pub type LocalAndForeignAssets = fungibles::UnionOf<
Assets,
ForeignAssets,
LocalFromLeft<
AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocationV3, xcm::v3::Location>,
AssetIdForTrustBackedAssets,
>,
AccountId,
>;
/// Union fungibles implementation for [`LocalAndForeignAssets`] and `Balances`.
pub type NativeAndAssets = fungible::UnionOf<
Balances,
LocalAndForeignAssets,
TargetFromLeft<WestendLocationV3, xcm::v3::Location>,
xcm::v3::Location,
AccountId,
>;
Muharem Ismailov
committed
pub type PoolIdToAccountId = pallet_asset_conversion::AccountIdConverter<
AssetConversionPalletId,
(xcm::v3::Location, xcm::v3::Location),
>;
impl pallet_asset_conversion::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type HigherPrecisionBalance = sp_core::U256;
type Assets = NativeAndAssets;
type PoolId = (Self::AssetKind, Self::AssetKind);
Muharem Ismailov
committed
type PoolLocator = pallet_asset_conversion::WithFirstAsset<
WestendLocationV3,
AccountId,
Self::AssetKind,
PoolIdToAccountId,
>;
type PoolAssets = PoolAssets;
type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam
type PoolSetupFeeTarget = ResolveAssetTo<AssetConversionOrigin, Self::Assets>;
type LiquidityWithdrawalFee = LiquidityWithdrawalFee;
type LPFee = ConstU32<3>;
type PalletId = AssetConversionPalletId;
type MaxSwapPathLength = ConstU32<3>;
type MintMinLiquidity = ConstU128<100>;
type WeightInfo = weights::pallet_asset_conversion::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = assets_common::benchmarks::AssetPairFactory<
parachain_info::Pallet<Runtime>,
xcm_config::TrustBackedAssetsPalletIndex,
xcm::v3::Location,
>;
Muharem Ismailov
committed
impl pallet_asset_conversion_ops::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<
<Runtime as pallet_asset_conversion::Config>::PoolId,
>;
type AssetsRefund = <Runtime as pallet_asset_conversion::Config>::Assets;
type PoolAssetsRefund = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
type PoolAssetsTeam = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
type DepositAsset = Balances;
type WeightInfo = weights::pallet_asset_conversion_ops::WeightInfo<Runtime>;
}
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();
}
/// Assets managed by some foreign location. Note: we do not declare a `ForeignAssetsCall` type, as
/// this type is used in proxy definitions. We assume that a foreign location would not want to set
/// an individual, local account as a proxy for the issuance of their assets. This issuance should
/// be managed by the foreign location's governance.
pub type ForeignAssetsInstance = pallet_assets::Instance2;
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type AssetId = xcm::v3::Location;
type AssetIdParameter = xcm::v3::Location;
type Currency = Balances;
type CreateOrigin = ForeignCreators<
FromSiblingParachain<parachain_info::Pallet<Runtime>, xcm::v3::Location>,
ForeignCreatorsSovereignAccountOf,
AccountId,
>;
type ForceOrigin = AssetsForceOrigin;
type AssetDeposit = ForeignAssetsAssetDeposit;
type MetadataDepositBase = ForeignAssetsMetadataDepositBase;
type MetadataDepositPerByte = ForeignAssetsMetadataDepositPerByte;
type ApprovalDeposit = ForeignAssetsApprovalDeposit;
type StringLimit = ForeignAssetsAssetsStringLimit;
type Freezer = ();
type Extra = ();
type WeightInfo = weights::pallet_assets_foreign::WeightInfo<Runtime>;
type CallbackHandle = ();
type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = xcm_config::XcmBenchmarkHelper;
}
parameter_types! {
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
pub const DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u32 = 100;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
}
impl pallet_utility::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
}
parameter_types! {
// One storage item; key size 32, value size 8; .
pub const ProxyDepositBase: Balance = deposit(1, 40);
// Additional storage item size of 33 bytes.
pub const ProxyDepositFactor: Balance = deposit(0, 33);
pub const MaxProxies: u16 = 32;
// One storage item; key size 32, value size 16
pub const AnnouncementDepositBase: Balance = deposit(1, 48);
pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
pub const MaxPending: u16 = 32;
}
/// The type used to represent the kinds of proxying allowed.
Bastian Köcher
committed
#[derive(
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
RuntimeDebug,
MaxEncodedLen,
Bastian Köcher
committed
)]
pub enum ProxyType {
/// Fully permissioned proxy. Can execute any call on behalf of _proxied_.
Any,
/// Can execute any call that does not transfer funds or assets.
NonTransfer,
/// Proxy with the ability to reject time-delay proxy announcements.
CancelProxy,
/// Assets proxy. Can execute any call from `assets`, **including asset transfers**.
Assets,
/// Owner proxy. Can execute calls related to asset ownership.
AssetOwner,
/// Asset manager. Can execute calls related to asset management.
AssetManager,
/// Collator selection proxy. Can execute calls related to collator selection mechanism.
Collator,
}
impl Default for ProxyType {
fn default() -> Self {
Self::Any
}
}
impl InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &RuntimeCall) -> bool {
ProxyType::NonTransfer => !matches!(
c,
RuntimeCall::Balances { .. } |
RuntimeCall::Assets { .. } |
RuntimeCall::NftFractionalization { .. } |
Bastian Köcher
committed
ProxyType::CancelProxy => matches!(
c,
RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Assets { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. }
Bastian Köcher
committed
ProxyType::AssetOwner => matches!(
c,
RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
Bastian Köcher
committed
ProxyType::AssetManager => matches!(
c,
RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) |
RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
Bastian Köcher
committed
),
ProxyType::Collator => matches!(
c,
RuntimeCall::CollatorSelection { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
(ProxyType::Assets, ProxyType::AssetOwner) => true,
(ProxyType::Assets, ProxyType::AssetManager) => true,
(ProxyType::NonTransfer, ProxyType::Collator) => true,
_ => false,
}
}
}
impl pallet_proxy::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type ProxyType = ProxyType;
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = MaxProxies;
type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
type MaxPending = MaxPending;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}
parameter_types! {
pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
}
impl cumulus_pallet_parachain_system::Config for Runtime {
type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
type OnSystemEvent = ();
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type OutboundXcmpMessageSource = XcmpQueue;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHook;
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
UNINCLUDED_SEGMENT_CAPACITY,
>;
parameter_types! {
pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
}
impl pallet_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
cumulus_primitives_core::AggregateMessageOrigin,
>;
#[cfg(not(feature = "runtime-benchmarks"))]
type MessageProcessor = xcm_builder::ProcessXcmMessage<
AggregateMessageOrigin,
xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
RuntimeCall,
>;
type Size = u32;
// The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin:
type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
type HeapSize = sp_core::ConstU32<{ 64 * 1024 }>;
type MaxStale = sp_core::ConstU32<8>;
type ServiceWeight = MessageQueueServiceWeight;
type IdleMaxServiceWeight = MessageQueueServiceWeight;
impl cumulus_pallet_aura_ext::Config for Runtime {}
parameter_types! {
/// The asset ID for the asset that we use to pay for message delivery fees.
pub FeeAssetId: AssetId = AssetId(xcm_config::WestendLocation::get());
/// The base fee for the message delivery fees.
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
}
pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
FeeAssetId,
BaseDeliveryFee,
TransactionByteFee,
XcmpQueue,
>;
type VersionWrapper = PolkadotXcm;
// Enqueue XCMP messages from siblings for later processing.
type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
type MaxInboundSuspended = sp_core::ConstU32<1_000>;
type ControllerOrigin = EnsureRoot<AccountId>;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
parameter_types! {
pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
}
parameter_types! {
pub const Period: u32 = 6 * HOURS;
pub const Offset: u32 = 0;
}
impl pallet_session::Config for Runtime {
type ValidatorId = <Self as frame_system::Config>::AccountId;
// we don't have stash and controller, thus we don't need the convert as well.
type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type SessionManager = CollatorSelection;
Branislav Kontur
committed
// Essentially just Aura, but let's be pedantic.
type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys;
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
}
impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
Branislav Kontur
committed
type MaxAuthorities = ConstU32<100_000>;
type AllowMultipleBlocksPerSlot = ConstBool<true>;
type SlotDuration = ConstU64<SLOT_DURATION>;
}
parameter_types! {
pub const PotId: PalletId = PalletId(*b"PotStake");
pub const SessionLength: BlockNumber = 6 * HOURS;
}
pub type CollatorSelectionUpdateOrigin = EnsureRoot<AccountId>;
type UpdateOrigin = CollatorSelectionUpdateOrigin;
type MaxCandidates = ConstU32<100>;
type MinEligibleCollators = ConstU32<4>;
type MaxInvulnerables = ConstU32<20>;
// should be a multiple of session or things will get inconsistent
type KickThreshold = Period;
type ValidatorId = <Self as frame_system::Config>::AccountId;
type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
type ValidatorRegistration = Session;
type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
}
impl pallet_asset_conversion_tx_payment::Config for Runtime {
type Fungibles = LocalAndForeignAssets;
type OnChargeAssetTransaction =
AssetConversionAdapter<Balances, AssetConversion, WestendLocationV3>;
pub const UniquesCollectionDeposit: Balance = UNITS / 10; // 1 / 10 UNIT deposit to create a collection
pub const UniquesItemDeposit: Balance = UNITS / 1_000; // 1 / 1000 UNIT deposit to mint an item
pub const UniquesMetadataDepositBase: Balance = deposit(1, 129);
pub const UniquesAttributeDepositBase: Balance = deposit(1, 0);
pub const UniquesDepositPerByte: Balance = deposit(0, 1);
}
impl pallet_uniques::Config for Runtime {
type CollectionId = CollectionId;
type ItemId = ItemId;
type Currency = Balances;
type ForceOrigin = AssetsForceOrigin;
type CollectionDeposit = UniquesCollectionDeposit;
type ItemDeposit = UniquesItemDeposit;
type MetadataDepositBase = UniquesMetadataDepositBase;
type AttributeDepositBase = UniquesAttributeDepositBase;
type DepositPerByte = UniquesDepositPerByte;
type StringLimit = ConstU32<128>;
type KeyLimit = ConstU32<32>;
type ValueLimit = ConstU32<64>;
type WeightInfo = weights::pallet_uniques::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
parameter_types! {
pub const NftFractionalizationPalletId: PalletId = PalletId(*b"fraction");
pub NewAssetSymbol: BoundedVec<u8, AssetsStringLimit> = (*b"FRAC").to_vec().try_into().unwrap();
pub NewAssetName: BoundedVec<u8, AssetsStringLimit> = (*b"Frac").to_vec().try_into().unwrap();
}
impl pallet_nft_fractionalization::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Deposit = AssetDeposit;
type Currency = Balances;
type NewAssetSymbol = NewAssetSymbol;
type NewAssetName = NewAssetName;
type StringLimit = AssetsStringLimit;
type NftCollectionId = <Self as pallet_nfts::Config>::CollectionId;
type NftId = <Self as pallet_nfts::Config>::ItemId;
type AssetBalance = <Self as pallet_balances::Config>::Balance;
type AssetId = <Self as pallet_assets::Config<TrustBackedAssetsInstance>>::AssetId;
type Assets = Assets;
type Nfts = Nfts;
type PalletId = NftFractionalizationPalletId;
type WeightInfo = pallet_nft_fractionalization::weights::SubstrateWeight<Runtime>;
type RuntimeHoldReason = RuntimeHoldReason;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}
parameter_types! {
pub NftsPalletFeatures: PalletFeatures = PalletFeatures::all_enabled();
pub const NftsMaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS;
// re-use the Uniques deposits
pub const NftsCollectionDeposit: Balance = UniquesCollectionDeposit::get();
pub const NftsItemDeposit: Balance = UniquesItemDeposit::get();
pub const NftsMetadataDepositBase: Balance = UniquesMetadataDepositBase::get();
pub const NftsAttributeDepositBase: Balance = UniquesAttributeDepositBase::get();
pub const NftsDepositPerByte: Balance = UniquesDepositPerByte::get();
}
impl pallet_nfts::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type CollectionId = CollectionId;
type ItemId = ItemId;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = AssetsForceOrigin;
type Locker = ();
type CollectionDeposit = NftsCollectionDeposit;
type ItemDeposit = NftsItemDeposit;
type MetadataDepositBase = NftsMetadataDepositBase;
type AttributeDepositBase = NftsAttributeDepositBase;
type DepositPerByte = NftsDepositPerByte;
type StringLimit = ConstU32<256>;
type KeyLimit = ConstU32<64>;
type ValueLimit = ConstU32<256>;
type ApprovalsLimit = ConstU32<20>;
type ItemAttributesApprovalsLimit = ConstU32<30>;
type MaxTips = ConstU32<10>;
type MaxDeadlineDuration = NftsMaxDeadlineDuration;
type MaxAttributesPerCall = ConstU32<10>;
type OffchainSignature = Signature;
type OffchainPublic = <Signature as Verify>::Signer;
type WeightInfo = weights::pallet_nfts::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
}
Branislav Kontur
committed
/// XCM router instance to BridgeHub with bridging capabilities for `Rococo` global
/// consensus with dynamic fees and back-pressure.
pub type ToRococoXcmRouterInstance = pallet_xcm_bridge_hub_router::Instance1;
impl pallet_xcm_bridge_hub_router::Config<ToRococoXcmRouterInstance> for Runtime {
type WeightInfo = weights::pallet_xcm_bridge_hub_router::WeightInfo<Runtime>;
type UniversalLocation = xcm_config::UniversalLocation;
type BridgedNetworkId = xcm_config::bridging::to_rococo::RococoNetwork;
type Bridges = xcm_config::bridging::NetworkExportTable;
type DestinationVersion = PolkadotXcm;
Branislav Kontur
committed
#[cfg(not(feature = "runtime-benchmarks"))]
type BridgeHubOrigin = EnsureXcm<Equals<xcm_config::bridging::SiblingBridgeHub>>;
#[cfg(feature = "runtime-benchmarks")]
type BridgeHubOrigin = frame_support::traits::EitherOfDiverse<
// for running benchmarks
EnsureRoot<AccountId>,
// for running tests with `--feature runtime-benchmarks`
EnsureXcm<Equals<xcm_config::bridging::SiblingBridgeHub>>,
>;
type ToBridgeHubSender = XcmpQueue;
type WithBridgeHubChannel =
cumulus_pallet_xcmp_queue::bridging::InAndOutXcmpChannelStatusProvider<
xcm_config::bridging::SiblingBridgeHubParaId,
Runtime,
>;
type ByteFee = xcm_config::bridging::XcmBridgeHubRouterByteFee;
type FeeAsset = xcm_config::bridging::XcmBridgeHubRouterFeeAssetId;
}
// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime
// System support stuff.
System: frame_system = 0,
ParachainSystem: cumulus_pallet_parachain_system = 1,
// RandomnessCollectiveFlip = 2 removed
Timestamp: pallet_timestamp = 3,
ParachainInfo: parachain_info = 4,
// Monetary stuff.
Balances: pallet_balances = 10,
TransactionPayment: pallet_transaction_payment = 11,
// AssetTxPayment: pallet_asset_tx_payment = 12,
AssetTxPayment: pallet_asset_conversion_tx_payment = 13,
// Collator support. the order of these 5 are important and shall not change.
Authorship: pallet_authorship = 20,
CollatorSelection: pallet_collator_selection = 21,
Session: pallet_session = 22,
Aura: pallet_aura = 23,
AuraExt: cumulus_pallet_aura_ext = 24,
XcmpQueue: cumulus_pallet_xcmp_queue = 30,
PolkadotXcm: pallet_xcm = 31,
CumulusXcm: cumulus_pallet_xcm = 32,
Branislav Kontur
committed
// Bridge utilities.
ToRococoXcmRouter: pallet_xcm_bridge_hub_router::<Instance1> = 34,
MessageQueue: pallet_message_queue = 35,
// Handy utilities.
Utility: pallet_utility = 40,
Multisig: pallet_multisig = 41,
Proxy: pallet_proxy = 42,
// The main stage.
Assets: pallet_assets::<Instance1> = 50,
Uniques: pallet_uniques = 51,
Nfts: pallet_nfts = 52,
ForeignAssets: pallet_assets::<Instance2> = 53,
NftFractionalization: pallet_nft_fractionalization = 54,
PoolAssets: pallet_assets::<Instance3> = 55,
AssetConversion: pallet_asset_conversion = 56,
Muharem Ismailov
committed
// TODO: the pallet instance should be removed once all pools have migrated
// to the new account IDs.
AssetConversionMigration: pallet_asset_conversion_ops = 200,
}
);
/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification
pub type SignedBlock = generic::SignedBlock<Block>;
/// BlockId type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckEra<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
/// Migrations to apply on runtime upgrade.
pub type Migrations = (
// v9420
pallet_nfts::migration::v1::MigrateToV1<Runtime>,
// unreleased
pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
Liam Aharon
committed
pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
// unreleased
InitStorageVersions,
Liam Aharon
committed
// unreleased
DeleteUndecodableStorage,
// unreleased
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
Branislav Kontur
committed
// permanent
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
Liam Aharon
committed
/// Asset Hub Westend has some undecodable storage, delete it.
/// See <https://github.com/paritytech/polkadot-sdk/issues/2241> for more info.
///
/// First we remove the bad Hold, then the bad NFT collection.
pub struct DeleteUndecodableStorage;
impl frame_support::traits::OnRuntimeUpgrade for DeleteUndecodableStorage {
fn on_runtime_upgrade() -> Weight {
use sp_core::crypto::Ss58Codec;
let mut writes = 0;
// Remove Holds for account with undecodable hold
// Westend doesn't have any HoldReasons implemented yet, so it's safe to just blanket remove
// any for this account.
match AccountId::from_ss58check("5GCCJthVSwNXRpbeg44gysJUx9vzjdGdfWhioeM7gCg6VyXf") {
Ok(a) => {
log::info!("Removing holds for account with bad hold");
pallet_balances::Holds::<Runtime, ()>::remove(a);
writes.saturating_inc();
},
Err(_) => {