1#![cfg_attr(not(feature = "std"), no_std)]
21#![recursion_limit = "512"]
22
23#[cfg(feature = "std")]
25include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
26
27mod bridge_to_ethereum_config;
28mod genesis_config_presets;
29mod weights;
30pub mod xcm_config;
31
32mod bag_thresholds;
34pub mod governance;
35mod staking;
36use governance::{pallet_custom_origins, FellowshipAdmin, GeneralAdmin, StakingAdmin, Treasurer};
37
38extern crate alloc;
39
40use alloc::{vec, vec::Vec};
41use assets_common::{
42 local_and_foreign_assets::{LocalFromLeft, TargetFromLeft},
43 AssetIdForPoolAssets, AssetIdForPoolAssetsConvert, AssetIdForTrustBackedAssetsConvert,
44};
45use bp_asset_hub_westend::CreateForeignAssetDeposit;
46use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
47use cumulus_pallet_parachain_system::{RelayNumberMonotonicallyIncreases, RelaychainDataProvider};
48use cumulus_primitives_core::{relay_chain::AccountIndex, AggregateMessageOrigin, ParaId};
49use frame_support::{
50 construct_runtime, derive_impl,
51 dispatch::DispatchClass,
52 genesis_builder_helper::{build_state, get_preset},
53 ord_parameter_types, parameter_types,
54 traits::{
55 fungible::{self, HoldConsideration},
56 fungibles,
57 tokens::{imbalance::ResolveAssetTo, nonfungibles_v2::Inspect},
58 AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8,
59 ConstantStoragePrice, EitherOfDiverse, Equals, InstanceFilter, LinearStoragePrice, Nothing,
60 TransformOrigin, WithdrawReasons,
61 },
62 weights::{ConstantMultiplier, Weight},
63 BoundedVec, PalletId,
64};
65use frame_system::{
66 limits::{BlockLength, BlockWeights},
67 EnsureRoot, EnsureSigned, EnsureSignedBy,
68};
69use pallet_asset_conversion_tx_payment::SwapAssetAdapter;
70use pallet_assets::precompiles::{InlineIdConfig, ERC20};
71use pallet_nfts::{DestroyWitness, PalletFeatures};
72use pallet_nomination_pools::PoolId;
73use pallet_revive::evm::runtime::EthExtra;
74use pallet_xcm::{precompiles::XcmPrecompile, EnsureXcm};
75use parachains_common::{
76 impls::DealWithFees, message_queue::*, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
77 BlockNumber, CollectionId, Hash, Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
78 NORMAL_DISPATCH_RATIO,
79};
80use sp_api::impl_runtime_apis;
81use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
82use sp_runtime::{
83 generic, impl_opaque_keys,
84 traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, Saturating, Verify},
85 transaction_validity::{TransactionSource, TransactionValidity},
86 ApplyExtrinsicResult, Perbill, Permill, RuntimeDebug,
87};
88#[cfg(feature = "std")]
89use sp_version::NativeVersion;
90use sp_version::RuntimeVersion;
91use testnet_parachains_constants::westend::{
92 consensus::*, currency::*, fee::WeightToFee, snowbridge::EthereumNetwork, time::*,
93};
94use westend_runtime_constants::time::DAYS as RC_DAYS;
95use xcm_config::{
96 ForeignAssetsConvertedConcreteId, LocationToAccountId, PoolAssetsConvertedConcreteId,
97 PoolAssetsPalletLocation, TrustBackedAssetsConvertedConcreteId,
98 TrustBackedAssetsPalletLocation, WestendLocation, XcmOriginToTransactDispatchOrigin,
99};
100
101#[cfg(any(feature = "std", test))]
102pub use sp_runtime::BuildStorage;
103
104use assets_common::{
105 foreign_creators::ForeignCreators,
106 matching::{FromNetwork, FromSiblingParachain},
107};
108use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
109use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, InMemoryDbWeight};
110use xcm::{
111 latest::prelude::AssetId,
112 prelude::{
113 VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm,
114 XcmVersion,
115 },
116};
117
118#[cfg(feature = "runtime-benchmarks")]
119use frame_support::traits::PalletInfoAccess;
120
121#[cfg(feature = "runtime-benchmarks")]
122use xcm::latest::prelude::{
123 Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location,
124 NetworkId, NonFungible, ParentThen, Response, WeightLimit, XCM_VERSION,
125};
126
127use xcm_runtime_apis::{
128 dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
129 fees::Error as XcmPaymentApiError,
130};
131
132impl_opaque_keys! {
133 pub struct SessionKeys {
134 pub aura: Aura,
135 }
136}
137
138#[sp_version::runtime_version]
139pub const VERSION: RuntimeVersion = RuntimeVersion {
140 spec_name: alloc::borrow::Cow::Borrowed("westmint"),
144 impl_name: alloc::borrow::Cow::Borrowed("westmint"),
145 authoring_version: 1,
146 spec_version: 1_019_003,
147 impl_version: 0,
148 apis: RUNTIME_API_VERSIONS,
149 transaction_version: 16,
150 system_version: 1,
151};
152
153#[cfg(feature = "std")]
155pub fn native_version() -> NativeVersion {
156 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
157}
158
159parameter_types! {
160 pub const Version: RuntimeVersion = VERSION;
161 pub RuntimeBlockLength: BlockLength =
162 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
163 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
164 .base_block(BlockExecutionWeight::get())
165 .for_class(DispatchClass::all(), |weights| {
166 weights.base_extrinsic = ExtrinsicBaseWeight::get();
167 })
168 .for_class(DispatchClass::Normal, |weights| {
169 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
170 })
171 .for_class(DispatchClass::Operational, |weights| {
172 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
173 weights.reserved = Some(
176 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
177 );
178 })
179 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
180 .build_or_panic();
181 pub const SS58Prefix: u8 = 42;
182}
183
184#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
186impl frame_system::Config for Runtime {
187 type BlockWeights = RuntimeBlockWeights;
188 type BlockLength = RuntimeBlockLength;
189 type AccountId = AccountId;
190 type Nonce = Nonce;
191 type Hash = Hash;
192 type Block = Block;
193 type BlockHashCount = BlockHashCount;
194 type DbWeight = InMemoryDbWeight;
195 type Version = Version;
196 type AccountData = pallet_balances::AccountData<Balance>;
197 type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
198 type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
199 type SS58Prefix = SS58Prefix;
200 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
201 type MaxConsumers = frame_support::traits::ConstU32<16>;
202 type MultiBlockMigrator = MultiBlockMigrations;
203}
204
205impl cumulus_pallet_weight_reclaim::Config for Runtime {
206 type WeightInfo = weights::cumulus_pallet_weight_reclaim::WeightInfo<Runtime>;
207}
208
209impl pallet_timestamp::Config for Runtime {
210 type Moment = u64;
212 type OnTimestampSet = Aura;
213 type MinimumPeriod = ConstU64<0>;
214 type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
215}
216
217impl pallet_authorship::Config for Runtime {
218 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
219 type EventHandler = (CollatorSelection,);
220}
221
222parameter_types! {
223 pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
224}
225
226impl pallet_balances::Config for Runtime {
227 type MaxLocks = ConstU32<50>;
228 type Balance = Balance;
230 type RuntimeEvent = RuntimeEvent;
232 type DustRemoval = ();
233 type ExistentialDeposit = ExistentialDeposit;
234 type AccountStore = System;
235 type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
236 type MaxReserves = ConstU32<50>;
237 type ReserveIdentifier = [u8; 8];
238 type RuntimeHoldReason = RuntimeHoldReason;
239 type RuntimeFreezeReason = RuntimeFreezeReason;
240 type FreezeIdentifier = RuntimeFreezeReason;
241 type MaxFreezes = frame_support::traits::VariantCountOf<RuntimeFreezeReason>;
242 type DoneSlashHandler = ();
243}
244
245parameter_types! {
246 pub const TransactionByteFee: Balance = MILLICENTS;
248}
249
250impl pallet_transaction_payment::Config for Runtime {
251 type RuntimeEvent = RuntimeEvent;
252 type OnChargeTransaction =
253 pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
254 type WeightToFee = WeightToFee;
255 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
256 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
257 type OperationalFeeMultiplier = ConstU8<5>;
258 type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
259}
260
261parameter_types! {
262 pub const AssetDeposit: Balance = UNITS / 10; pub const AssetAccountDeposit: Balance = deposit(1, 16);
264 pub const ApprovalDeposit: Balance = EXISTENTIAL_DEPOSIT;
265 pub const AssetsStringLimit: u32 = 50;
266 pub const MetadataDepositBase: Balance = deposit(1, 68);
269 pub const MetadataDepositPerByte: Balance = deposit(0, 1);
270}
271
272pub type AssetsForceOrigin = EnsureRoot<AccountId>;
273
274pub type TrustBackedAssetsInstance = pallet_assets::Instance1;
278type TrustBackedAssetsCall = pallet_assets::Call<Runtime, TrustBackedAssetsInstance>;
279impl pallet_assets::Config<TrustBackedAssetsInstance> for Runtime {
280 type RuntimeEvent = RuntimeEvent;
281 type Balance = Balance;
282 type AssetId = AssetIdForTrustBackedAssets;
283 type AssetIdParameter = codec::Compact<AssetIdForTrustBackedAssets>;
284 type Currency = Balances;
285 type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
286 type ForceOrigin = AssetsForceOrigin;
287 type AssetDeposit = AssetDeposit;
288 type MetadataDepositBase = MetadataDepositBase;
289 type MetadataDepositPerByte = MetadataDepositPerByte;
290 type ApprovalDeposit = ApprovalDeposit;
291 type StringLimit = AssetsStringLimit;
292 type Holder = ();
293 type Freezer = AssetsFreezer;
294 type Extra = ();
295 type WeightInfo = weights::pallet_assets_local::WeightInfo<Runtime>;
296 type CallbackHandle = pallet_assets::AutoIncAssetId<Runtime, TrustBackedAssetsInstance>;
297 type AssetAccountDeposit = AssetAccountDeposit;
298 type RemoveItemsLimit = ConstU32<1000>;
299 #[cfg(feature = "runtime-benchmarks")]
300 type BenchmarkHelper = ();
301}
302
303pub type AssetsFreezerInstance = pallet_assets_freezer::Instance1;
305impl pallet_assets_freezer::Config<AssetsFreezerInstance> for Runtime {
306 type RuntimeFreezeReason = RuntimeFreezeReason;
307 type RuntimeEvent = RuntimeEvent;
308}
309
310parameter_types! {
311 pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon");
312 pub const LiquidityWithdrawalFee: Permill = Permill::from_percent(0);
313}
314
315ord_parameter_types! {
316 pub const AssetConversionOrigin: sp_runtime::AccountId32 =
317 AccountIdConversion::<sp_runtime::AccountId32>::into_account_truncating(&AssetConversionPalletId::get());
318}
319
320pub type PoolAssetsInstance = pallet_assets::Instance3;
321impl pallet_assets::Config<PoolAssetsInstance> for Runtime {
322 type RuntimeEvent = RuntimeEvent;
323 type Balance = Balance;
324 type RemoveItemsLimit = ConstU32<1000>;
325 type AssetId = u32;
326 type AssetIdParameter = u32;
327 type Currency = Balances;
328 type CreateOrigin =
329 AsEnsureOriginWithArg<EnsureSignedBy<AssetConversionOrigin, sp_runtime::AccountId32>>;
330 type ForceOrigin = AssetsForceOrigin;
331 type AssetDeposit = ConstU128<0>;
332 type AssetAccountDeposit = ConstU128<0>;
333 type MetadataDepositBase = ConstU128<0>;
334 type MetadataDepositPerByte = ConstU128<0>;
335 type ApprovalDeposit = ConstU128<0>;
336 type StringLimit = ConstU32<50>;
337 type Holder = ();
338 type Freezer = PoolAssetsFreezer;
339 type Extra = ();
340 type WeightInfo = weights::pallet_assets_pool::WeightInfo<Runtime>;
341 type CallbackHandle = ();
342 #[cfg(feature = "runtime-benchmarks")]
343 type BenchmarkHelper = ();
344}
345
346pub type PoolAssetsFreezerInstance = pallet_assets_freezer::Instance3;
348impl pallet_assets_freezer::Config<PoolAssetsFreezerInstance> for Runtime {
349 type RuntimeFreezeReason = RuntimeFreezeReason;
350 type RuntimeEvent = RuntimeEvent;
351}
352
353pub type LocalAndForeignAssets = fungibles::UnionOf<
355 Assets,
356 ForeignAssets,
357 LocalFromLeft<
358 AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation, xcm::v5::Location>,
359 AssetIdForTrustBackedAssets,
360 xcm::v5::Location,
361 >,
362 xcm::v5::Location,
363 AccountId,
364>;
365
366pub type LocalAndForeignAssetsFreezer = fungibles::UnionOf<
368 AssetsFreezer,
369 ForeignAssetsFreezer,
370 LocalFromLeft<
371 AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation, xcm::v5::Location>,
372 AssetIdForTrustBackedAssets,
373 xcm::v5::Location,
374 >,
375 xcm::v5::Location,
376 AccountId,
377>;
378
379pub type NativeAndNonPoolAssets = fungible::UnionOf<
381 Balances,
382 LocalAndForeignAssets,
383 TargetFromLeft<WestendLocation, xcm::v5::Location>,
384 xcm::v5::Location,
385 AccountId,
386>;
387
388pub type NativeAndNonPoolAssetsFreezer = fungible::UnionOf<
390 Balances,
391 LocalAndForeignAssetsFreezer,
392 TargetFromLeft<WestendLocation, xcm::v5::Location>,
393 xcm::v5::Location,
394 AccountId,
395>;
396
397pub type NativeAndAllAssets = fungibles::UnionOf<
401 PoolAssets,
402 NativeAndNonPoolAssets,
403 LocalFromLeft<
404 AssetIdForPoolAssetsConvert<PoolAssetsPalletLocation, xcm::v5::Location>,
405 AssetIdForPoolAssets,
406 xcm::v5::Location,
407 >,
408 xcm::v5::Location,
409 AccountId,
410>;
411
412pub type NativeAndAllAssetsFreezer = fungibles::UnionOf<
416 PoolAssetsFreezer,
417 NativeAndNonPoolAssetsFreezer,
418 LocalFromLeft<
419 AssetIdForPoolAssetsConvert<PoolAssetsPalletLocation, xcm::v5::Location>,
420 AssetIdForPoolAssets,
421 xcm::v5::Location,
422 >,
423 xcm::v5::Location,
424 AccountId,
425>;
426
427pub type PoolIdToAccountId = pallet_asset_conversion::AccountIdConverter<
428 AssetConversionPalletId,
429 (xcm::v5::Location, xcm::v5::Location),
430>;
431
432impl pallet_asset_conversion::Config for Runtime {
433 type RuntimeEvent = RuntimeEvent;
434 type Balance = Balance;
435 type HigherPrecisionBalance = sp_core::U256;
436 type AssetKind = xcm::v5::Location;
437 type Assets = NativeAndNonPoolAssets;
438 type PoolId = (Self::AssetKind, Self::AssetKind);
439 type PoolLocator = pallet_asset_conversion::WithFirstAsset<
440 WestendLocation,
441 AccountId,
442 Self::AssetKind,
443 PoolIdToAccountId,
444 >;
445 type PoolAssetId = u32;
446 type PoolAssets = PoolAssets;
447 type PoolSetupFee = ConstU128<0>; type PoolSetupFeeAsset = WestendLocation;
449 type PoolSetupFeeTarget = ResolveAssetTo<AssetConversionOrigin, Self::Assets>;
450 type LiquidityWithdrawalFee = LiquidityWithdrawalFee;
451 type LPFee = ConstU32<3>;
452 type PalletId = AssetConversionPalletId;
453 type MaxSwapPathLength = ConstU32<3>;
454 type MintMinLiquidity = ConstU128<100>;
455 type WeightInfo = weights::pallet_asset_conversion::WeightInfo<Runtime>;
456 #[cfg(feature = "runtime-benchmarks")]
457 type BenchmarkHelper = assets_common::benchmarks::AssetPairFactory<
458 WestendLocation,
459 parachain_info::Pallet<Runtime>,
460 xcm_config::TrustBackedAssetsPalletIndex,
461 xcm::v5::Location,
462 >;
463}
464
465#[cfg(feature = "runtime-benchmarks")]
466pub struct PalletAssetRewardsBenchmarkHelper;
467
468#[cfg(feature = "runtime-benchmarks")]
469impl pallet_asset_rewards::benchmarking::BenchmarkHelper<xcm::v5::Location>
470 for PalletAssetRewardsBenchmarkHelper
471{
472 fn staked_asset() -> Location {
473 Location::new(
474 0,
475 [PalletInstance(<Assets as PalletInfoAccess>::index() as u8), GeneralIndex(100)],
476 )
477 }
478 fn reward_asset() -> Location {
479 Location::new(
480 0,
481 [PalletInstance(<Assets as PalletInfoAccess>::index() as u8), GeneralIndex(101)],
482 )
483 }
484}
485
486parameter_types! {
487 pub const MinVestedTransfer: Balance = 100 * CENTS;
488 pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
489 WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
490}
491
492impl pallet_vesting::Config for Runtime {
493 const MAX_VESTING_SCHEDULES: u32 = 100;
494 type BlockNumberProvider = RelaychainDataProvider<Runtime>;
495 type BlockNumberToBalance = ConvertInto;
496 type Currency = Balances;
497 type MinVestedTransfer = MinVestedTransfer;
498 type RuntimeEvent = RuntimeEvent;
499 type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
500 type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
501}
502
503parameter_types! {
504 pub const AssetRewardsPalletId: PalletId = PalletId(*b"py/astrd");
505 pub const RewardsPoolCreationHoldReason: RuntimeHoldReason =
506 RuntimeHoldReason::AssetRewards(pallet_asset_rewards::HoldReason::PoolCreation);
507 pub const StakePoolCreationDeposit: Balance = deposit(1, 135);
509}
510
511impl pallet_asset_rewards::Config for Runtime {
512 type RuntimeEvent = RuntimeEvent;
513 type PalletId = AssetRewardsPalletId;
514 type Balance = Balance;
515 type Assets = NativeAndAllAssets;
516 type AssetsFreezer = NativeAndAllAssetsFreezer;
517 type AssetId = xcm::v5::Location;
518 type CreatePoolOrigin = EnsureSigned<AccountId>;
519 type RuntimeFreezeReason = RuntimeFreezeReason;
520 type Consideration = HoldConsideration<
521 AccountId,
522 Balances,
523 RewardsPoolCreationHoldReason,
524 ConstantStoragePrice<StakePoolCreationDeposit, Balance>,
525 >;
526 type WeightInfo = weights::pallet_asset_rewards::WeightInfo<Runtime>;
527 #[cfg(feature = "runtime-benchmarks")]
528 type BenchmarkHelper = PalletAssetRewardsBenchmarkHelper;
529}
530
531impl pallet_asset_conversion_ops::Config for Runtime {
532 type RuntimeEvent = RuntimeEvent;
533 type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<
534 <Runtime as pallet_asset_conversion::Config>::PoolId,
535 >;
536 type AssetsRefund = <Runtime as pallet_asset_conversion::Config>::Assets;
537 type PoolAssetsRefund = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
538 type PoolAssetsTeam = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
539 type DepositAsset = Balances;
540 type WeightInfo = weights::pallet_asset_conversion_ops::WeightInfo<Runtime>;
541}
542
543parameter_types! {
544 pub const ForeignAssetsAssetDeposit: Balance = CreateForeignAssetDeposit::get();
545 pub const ForeignAssetsAssetAccountDeposit: Balance = AssetAccountDeposit::get();
546 pub const ForeignAssetsApprovalDeposit: Balance = ApprovalDeposit::get();
547 pub const ForeignAssetsAssetsStringLimit: u32 = AssetsStringLimit::get();
548 pub const ForeignAssetsMetadataDepositBase: Balance = MetadataDepositBase::get();
549 pub const ForeignAssetsMetadataDepositPerByte: Balance = MetadataDepositPerByte::get();
550}
551
552pub type ForeignAssetsInstance = pallet_assets::Instance2;
557impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
558 type RuntimeEvent = RuntimeEvent;
559 type Balance = Balance;
560 type AssetId = xcm::v5::Location;
561 type AssetIdParameter = xcm::v5::Location;
562 type Currency = Balances;
563 type CreateOrigin = ForeignCreators<
564 (
565 FromSiblingParachain<parachain_info::Pallet<Runtime>, xcm::v5::Location>,
566 FromNetwork<xcm_config::UniversalLocation, EthereumNetwork, xcm::v5::Location>,
567 xcm_config::bridging::to_rococo::RococoAssetFromAssetHubRococo,
568 ),
569 LocationToAccountId,
570 AccountId,
571 xcm::v5::Location,
572 >;
573 type ForceOrigin = AssetsForceOrigin;
574 type AssetDeposit = ForeignAssetsAssetDeposit;
575 type MetadataDepositBase = ForeignAssetsMetadataDepositBase;
576 type MetadataDepositPerByte = ForeignAssetsMetadataDepositPerByte;
577 type ApprovalDeposit = ForeignAssetsApprovalDeposit;
578 type StringLimit = ForeignAssetsAssetsStringLimit;
579 type Holder = ();
580 type Freezer = ForeignAssetsFreezer;
581 type Extra = ();
582 type WeightInfo = weights::pallet_assets_foreign::WeightInfo<Runtime>;
583 type CallbackHandle = ();
584 type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit;
585 type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
586 #[cfg(feature = "runtime-benchmarks")]
587 type BenchmarkHelper = xcm_config::XcmBenchmarkHelper;
588}
589
590pub type ForeignAssetsFreezerInstance = pallet_assets_freezer::Instance2;
592impl pallet_assets_freezer::Config<ForeignAssetsFreezerInstance> for Runtime {
593 type RuntimeFreezeReason = RuntimeFreezeReason;
594 type RuntimeEvent = RuntimeEvent;
595}
596
597parameter_types! {
598 pub const DepositBase: Balance = deposit(1, 88);
600 pub const DepositFactor: Balance = deposit(0, 32);
602 pub const MaxSignatories: u32 = 100;
603}
604
605impl pallet_multisig::Config for Runtime {
606 type RuntimeEvent = RuntimeEvent;
607 type RuntimeCall = RuntimeCall;
608 type Currency = Balances;
609 type DepositBase = DepositBase;
610 type DepositFactor = DepositFactor;
611 type MaxSignatories = MaxSignatories;
612 type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
613 type BlockNumberProvider = System;
614}
615
616impl pallet_utility::Config for Runtime {
617 type RuntimeEvent = RuntimeEvent;
618 type RuntimeCall = RuntimeCall;
619 type PalletsOrigin = OriginCaller;
620 type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
621}
622
623parameter_types! {
624 pub const ProxyDepositBase: Balance = deposit(1, 40);
626 pub const ProxyDepositFactor: Balance = deposit(0, 33);
628 pub const MaxProxies: u16 = 32;
629 pub const AnnouncementDepositBase: Balance = deposit(1, 48);
631 pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
632 pub const MaxPending: u16 = 32;
633}
634
635#[derive(
637 Copy,
638 Clone,
639 Eq,
640 PartialEq,
641 Ord,
642 PartialOrd,
643 Encode,
644 Decode,
645 DecodeWithMemTracking,
646 RuntimeDebug,
647 MaxEncodedLen,
648 scale_info::TypeInfo,
649)]
650pub enum ProxyType {
651 Any,
653 NonTransfer,
655 CancelProxy,
657 Assets,
659 AssetOwner,
661 AssetManager,
663 Collator,
665 Governance,
671 Staking,
676 NominationPools,
680
681 OldSudoBalances,
683 OldIdentityJudgement,
685 OldAuction,
687 OldParaRegistration,
689}
690impl Default for ProxyType {
691 fn default() -> Self {
692 Self::Any
693 }
694}
695
696impl InstanceFilter<RuntimeCall> for ProxyType {
697 fn filter(&self, c: &RuntimeCall) -> bool {
698 match self {
699 ProxyType::Any => true,
700 ProxyType::OldSudoBalances |
701 ProxyType::OldIdentityJudgement |
702 ProxyType::OldAuction |
703 ProxyType::OldParaRegistration => false,
704 ProxyType::NonTransfer => !matches!(
705 c,
706 RuntimeCall::Balances { .. } |
707 RuntimeCall::Assets { .. } |
708 RuntimeCall::NftFractionalization { .. } |
709 RuntimeCall::Nfts { .. } |
710 RuntimeCall::Uniques { .. } |
711 RuntimeCall::Scheduler(..) |
712 RuntimeCall::Treasury(..) |
713 RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) |
716 RuntimeCall::ConvictionVoting(..) |
717 RuntimeCall::Referenda(..) |
718 RuntimeCall::Whitelist(..)
719 ),
720 ProxyType::CancelProxy => matches!(
721 c,
722 RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
723 RuntimeCall::Utility { .. } |
724 RuntimeCall::Multisig { .. }
725 ),
726 ProxyType::Assets => {
727 matches!(
728 c,
729 RuntimeCall::Assets { .. } |
730 RuntimeCall::Utility { .. } |
731 RuntimeCall::Multisig { .. } |
732 RuntimeCall::NftFractionalization { .. } |
733 RuntimeCall::Nfts { .. } |
734 RuntimeCall::Uniques { .. }
735 )
736 },
737 ProxyType::AssetOwner => matches!(
738 c,
739 RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) |
740 RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) |
741 RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) |
742 RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) |
743 RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) |
744 RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) |
745 RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) |
746 RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) |
747 RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) |
748 RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) |
749 RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) |
750 RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) |
751 RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) |
752 RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) |
753 RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) |
754 RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) |
755 RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) |
756 RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) |
757 RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) |
758 RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) |
759 RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) |
760 RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) |
761 RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) |
762 RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) |
763 RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) |
764 RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) |
765 RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) |
766 RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) |
767 RuntimeCall::Utility { .. } |
768 RuntimeCall::Multisig { .. }
769 ),
770 ProxyType::AssetManager => matches!(
771 c,
772 RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) |
773 RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) |
774 RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) |
775 RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) |
776 RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) |
777 RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) |
778 RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) |
779 RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) |
780 RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) |
781 RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) |
782 RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) |
783 RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) |
784 RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) |
785 RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) |
786 RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) |
787 RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) |
788 RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) |
789 RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) |
790 RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) |
791 RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) |
792 RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) |
793 RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) |
794 RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) |
795 RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) |
796 RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) |
797 RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) |
798 RuntimeCall::Utility { .. } |
799 RuntimeCall::Multisig { .. }
800 ),
801 ProxyType::Collator => matches!(
802 c,
803 RuntimeCall::CollatorSelection { .. } |
804 RuntimeCall::Utility { .. } |
805 RuntimeCall::Multisig { .. }
806 ),
807 ProxyType::Governance => matches!(
809 c,
810 RuntimeCall::Treasury(..) |
811 RuntimeCall::Utility(..) |
812 RuntimeCall::ConvictionVoting(..) |
813 RuntimeCall::Referenda(..) |
814 RuntimeCall::Whitelist(..)
815 ),
816 ProxyType::Staking => {
817 matches!(
818 c,
819 RuntimeCall::Staking(..) |
820 RuntimeCall::Session(..) |
821 RuntimeCall::Utility(..) |
822 RuntimeCall::NominationPools(..) |
823 RuntimeCall::FastUnstake(..) |
824 RuntimeCall::VoterList(..)
825 )
826 },
827 ProxyType::NominationPools => {
828 matches!(c, RuntimeCall::NominationPools(..) | RuntimeCall::Utility(..))
829 },
830 }
831 }
832
833 fn is_superset(&self, o: &Self) -> bool {
834 match (self, o) {
835 (x, y) if x == y => true,
836 (ProxyType::Any, _) => true,
837 (_, ProxyType::Any) => false,
838 (ProxyType::Assets, ProxyType::AssetOwner) => true,
839 (ProxyType::Assets, ProxyType::AssetManager) => true,
840 (
841 ProxyType::NonTransfer,
842 ProxyType::Collator |
843 ProxyType::Governance |
844 ProxyType::Staking |
845 ProxyType::NominationPools,
846 ) => true,
847 _ => false,
848 }
849 }
850}
851
852impl pallet_proxy::Config for Runtime {
853 type RuntimeEvent = RuntimeEvent;
854 type RuntimeCall = RuntimeCall;
855 type Currency = Balances;
856 type ProxyType = ProxyType;
857 type ProxyDepositBase = ProxyDepositBase;
858 type ProxyDepositFactor = ProxyDepositFactor;
859 type MaxProxies = MaxProxies;
860 type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
861 type MaxPending = MaxPending;
862 type CallHasher = BlakeTwo256;
863 type AnnouncementDepositBase = AnnouncementDepositBase;
864 type AnnouncementDepositFactor = AnnouncementDepositFactor;
865 type BlockNumberProvider = RelaychainDataProvider<Runtime>;
866}
867
868parameter_types! {
869 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
870 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
871}
872
873impl cumulus_pallet_parachain_system::Config for Runtime {
874 type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
875 type RuntimeEvent = RuntimeEvent;
876 type OnSystemEvent = ();
877 type SelfParaId = parachain_info::Pallet<Runtime>;
878 type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
879 type ReservedDmpWeight = ReservedDmpWeight;
880 type OutboundXcmpMessageSource = XcmpQueue;
881 type XcmpMessageHandler = XcmpQueue;
882 type ReservedXcmpWeight = ReservedXcmpWeight;
883 type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
884 type ConsensusHook = ConsensusHook;
885 type RelayParentOffset = ConstU32<0>;
886}
887
888type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
889 Runtime,
890 RELAY_CHAIN_SLOT_DURATION_MILLIS,
891 BLOCK_PROCESSING_VELOCITY,
892 UNINCLUDED_SEGMENT_CAPACITY,
893>;
894
895impl parachain_info::Config for Runtime {}
896
897parameter_types! {
898 pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
899}
900
901impl pallet_message_queue::Config for Runtime {
902 type RuntimeEvent = RuntimeEvent;
903 type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
904 #[cfg(feature = "runtime-benchmarks")]
905 type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
906 cumulus_primitives_core::AggregateMessageOrigin,
907 >;
908 #[cfg(not(feature = "runtime-benchmarks"))]
909 type MessageProcessor = xcm_builder::ProcessXcmMessage<
910 AggregateMessageOrigin,
911 xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
912 RuntimeCall,
913 >;
914 type Size = u32;
915 type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
917 type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
918 type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
919 type MaxStale = sp_core::ConstU32<8>;
920 type ServiceWeight = MessageQueueServiceWeight;
921 type IdleMaxServiceWeight = MessageQueueServiceWeight;
922}
923
924impl cumulus_pallet_aura_ext::Config for Runtime {}
925
926parameter_types! {
927 pub FeeAssetId: AssetId = AssetId(xcm_config::WestendLocation::get());
929 pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
931}
932
933pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
934 FeeAssetId,
935 BaseDeliveryFee,
936 TransactionByteFee,
937 XcmpQueue,
938>;
939
940impl cumulus_pallet_xcmp_queue::Config for Runtime {
941 type RuntimeEvent = RuntimeEvent;
942 type ChannelInfo = ParachainSystem;
943 type VersionWrapper = PolkadotXcm;
944 type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
946 type MaxInboundSuspended = ConstU32<1_000>;
947 type MaxActiveOutboundChannels = ConstU32<128>;
948 type MaxPageSize = ConstU32<{ 103 * 1024 }>;
951 type ControllerOrigin = EnsureRoot<AccountId>;
952 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
953 type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
954 type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
955}
956
957impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime {
958 type ChannelList = ParachainSystem;
960}
961
962parameter_types! {
963 pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
964}
965
966parameter_types! {
967 pub const Period: u32 = 6 * HOURS;
968 pub const Offset: u32 = 0;
969}
970
971impl pallet_session::Config for Runtime {
972 type RuntimeEvent = RuntimeEvent;
973 type ValidatorId = <Self as frame_system::Config>::AccountId;
974 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
976 type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
977 type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
978 type SessionManager = CollatorSelection;
979 type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
981 type Keys = SessionKeys;
982 type DisablingStrategy = ();
983 type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
984 type Currency = Balances;
985 type KeyDeposit = ();
986}
987
988impl pallet_aura::Config for Runtime {
989 type AuthorityId = AuraId;
990 type DisabledValidators = ();
991 type MaxAuthorities = ConstU32<100_000>;
992 type AllowMultipleBlocksPerSlot = ConstBool<true>;
993 type SlotDuration = ConstU64<SLOT_DURATION>;
994}
995
996parameter_types! {
997 pub const PotId: PalletId = PalletId(*b"PotStake");
998 pub const SessionLength: BlockNumber = 6 * HOURS;
999}
1000
1001pub type CollatorSelectionUpdateOrigin = EnsureRoot<AccountId>;
1002
1003impl pallet_collator_selection::Config for Runtime {
1004 type RuntimeEvent = RuntimeEvent;
1005 type Currency = Balances;
1006 type UpdateOrigin = CollatorSelectionUpdateOrigin;
1007 type PotId = PotId;
1008 type MaxCandidates = ConstU32<100>;
1009 type MinEligibleCollators = ConstU32<4>;
1010 type MaxInvulnerables = ConstU32<20>;
1011 type KickThreshold = Period;
1013 type ValidatorId = <Self as frame_system::Config>::AccountId;
1014 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
1015 type ValidatorRegistration = Session;
1016 type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
1017}
1018
1019parameter_types! {
1020 pub StakingPot: AccountId = CollatorSelection::account_id();
1021}
1022
1023impl pallet_asset_conversion_tx_payment::Config for Runtime {
1024 type RuntimeEvent = RuntimeEvent;
1025 type AssetId = xcm::v5::Location;
1026 type OnChargeAssetTransaction = SwapAssetAdapter<
1027 WestendLocation,
1028 NativeAndNonPoolAssets,
1029 AssetConversion,
1030 ResolveAssetTo<StakingPot, NativeAndNonPoolAssets>,
1031 >;
1032 type WeightInfo = weights::pallet_asset_conversion_tx_payment::WeightInfo<Runtime>;
1033 #[cfg(feature = "runtime-benchmarks")]
1034 type BenchmarkHelper = AssetConversionTxHelper;
1035}
1036
1037parameter_types! {
1038 pub const UniquesCollectionDeposit: Balance = UNITS / 10; pub const UniquesItemDeposit: Balance = UNITS / 1_000; pub const UniquesMetadataDepositBase: Balance = deposit(1, 129);
1041 pub const UniquesAttributeDepositBase: Balance = deposit(1, 0);
1042 pub const UniquesDepositPerByte: Balance = deposit(0, 1);
1043}
1044
1045impl pallet_uniques::Config for Runtime {
1046 type RuntimeEvent = RuntimeEvent;
1047 type CollectionId = CollectionId;
1048 type ItemId = ItemId;
1049 type Currency = Balances;
1050 type ForceOrigin = AssetsForceOrigin;
1051 type CollectionDeposit = UniquesCollectionDeposit;
1052 type ItemDeposit = UniquesItemDeposit;
1053 type MetadataDepositBase = UniquesMetadataDepositBase;
1054 type AttributeDepositBase = UniquesAttributeDepositBase;
1055 type DepositPerByte = UniquesDepositPerByte;
1056 type StringLimit = ConstU32<128>;
1057 type KeyLimit = ConstU32<32>;
1058 type ValueLimit = ConstU32<64>;
1059 type WeightInfo = weights::pallet_uniques::WeightInfo<Runtime>;
1060 #[cfg(feature = "runtime-benchmarks")]
1061 type Helper = ();
1062 type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
1063 type Locker = ();
1064}
1065
1066parameter_types! {
1067 pub const NftFractionalizationPalletId: PalletId = PalletId(*b"fraction");
1068 pub NewAssetSymbol: BoundedVec<u8, AssetsStringLimit> = (*b"FRAC").to_vec().try_into().unwrap();
1069 pub NewAssetName: BoundedVec<u8, AssetsStringLimit> = (*b"Frac").to_vec().try_into().unwrap();
1070}
1071
1072impl pallet_nft_fractionalization::Config for Runtime {
1073 type RuntimeEvent = RuntimeEvent;
1074 type Deposit = AssetDeposit;
1075 type Currency = Balances;
1076 type NewAssetSymbol = NewAssetSymbol;
1077 type NewAssetName = NewAssetName;
1078 type StringLimit = AssetsStringLimit;
1079 type NftCollectionId = <Self as pallet_nfts::Config>::CollectionId;
1080 type NftId = <Self as pallet_nfts::Config>::ItemId;
1081 type AssetBalance = <Self as pallet_balances::Config>::Balance;
1082 type AssetId = <Self as pallet_assets::Config<TrustBackedAssetsInstance>>::AssetId;
1083 type Assets = Assets;
1084 type Nfts = Nfts;
1085 type PalletId = NftFractionalizationPalletId;
1086 type WeightInfo = weights::pallet_nft_fractionalization::WeightInfo<Runtime>;
1087 type RuntimeHoldReason = RuntimeHoldReason;
1088 #[cfg(feature = "runtime-benchmarks")]
1089 type BenchmarkHelper = ();
1090}
1091
1092parameter_types! {
1093 pub NftsPalletFeatures: PalletFeatures = PalletFeatures::all_enabled();
1094 pub const NftsMaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS;
1095 pub const NftsCollectionDeposit: Balance = UniquesCollectionDeposit::get();
1097 pub const NftsItemDeposit: Balance = UniquesItemDeposit::get();
1098 pub const NftsMetadataDepositBase: Balance = UniquesMetadataDepositBase::get();
1099 pub const NftsAttributeDepositBase: Balance = UniquesAttributeDepositBase::get();
1100 pub const NftsDepositPerByte: Balance = UniquesDepositPerByte::get();
1101}
1102
1103impl pallet_nfts::Config for Runtime {
1104 type RuntimeEvent = RuntimeEvent;
1105 type CollectionId = CollectionId;
1106 type ItemId = ItemId;
1107 type Currency = Balances;
1108 type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
1109 type ForceOrigin = AssetsForceOrigin;
1110 type Locker = ();
1111 type CollectionDeposit = NftsCollectionDeposit;
1112 type ItemDeposit = NftsItemDeposit;
1113 type MetadataDepositBase = NftsMetadataDepositBase;
1114 type AttributeDepositBase = NftsAttributeDepositBase;
1115 type DepositPerByte = NftsDepositPerByte;
1116 type StringLimit = ConstU32<256>;
1117 type KeyLimit = ConstU32<64>;
1118 type ValueLimit = ConstU32<256>;
1119 type ApprovalsLimit = ConstU32<20>;
1120 type ItemAttributesApprovalsLimit = ConstU32<30>;
1121 type MaxTips = ConstU32<10>;
1122 type MaxDeadlineDuration = NftsMaxDeadlineDuration;
1123 type MaxAttributesPerCall = ConstU32<10>;
1124 type Features = NftsPalletFeatures;
1125 type OffchainSignature = Signature;
1126 type OffchainPublic = <Signature as Verify>::Signer;
1127 type WeightInfo = weights::pallet_nfts::WeightInfo<Runtime>;
1128 #[cfg(feature = "runtime-benchmarks")]
1129 type Helper = ();
1130 type BlockNumberProvider = RelaychainDataProvider<Runtime>;
1131}
1132
1133pub type ToRococoXcmRouterInstance = pallet_xcm_bridge_hub_router::Instance1;
1136impl pallet_xcm_bridge_hub_router::Config<ToRococoXcmRouterInstance> for Runtime {
1137 type RuntimeEvent = RuntimeEvent;
1138 type WeightInfo = weights::pallet_xcm_bridge_hub_router::WeightInfo<Runtime>;
1139
1140 type UniversalLocation = xcm_config::UniversalLocation;
1141 type SiblingBridgeHubLocation = xcm_config::bridging::SiblingBridgeHub;
1142 type BridgedNetworkId = xcm_config::bridging::to_rococo::RococoNetwork;
1143 type Bridges = xcm_config::bridging::NetworkExportTable;
1144 type DestinationVersion = PolkadotXcm;
1145
1146 type BridgeHubOrigin = frame_support::traits::EitherOfDiverse<
1147 EnsureRoot<AccountId>,
1148 EnsureXcm<Equals<Self::SiblingBridgeHubLocation>>,
1149 >;
1150 type ToBridgeHubSender = XcmpQueue;
1151 type LocalXcmChannelManager =
1152 cumulus_pallet_xcmp_queue::bridging::InAndOutXcmpChannelStatusProvider<Runtime>;
1153
1154 type ByteFee = xcm_config::bridging::XcmBridgeHubRouterByteFee;
1155 type FeeAsset = xcm_config::bridging::XcmBridgeHubRouterFeeAssetId;
1156}
1157
1158parameter_types! {
1159 pub const DepositPerItem: Balance = deposit(1, 0);
1160 pub const DepositPerByte: Balance = deposit(0, 1);
1161 pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
1162}
1163
1164impl pallet_revive::Config for Runtime {
1165 type Time = Timestamp;
1166 type Currency = Balances;
1167 type RuntimeEvent = RuntimeEvent;
1168 type RuntimeCall = RuntimeCall;
1169 type DepositPerItem = DepositPerItem;
1170 type DepositPerByte = DepositPerByte;
1171 type WeightPrice = pallet_transaction_payment::Pallet<Self>;
1172 type WeightInfo = pallet_revive::weights::SubstrateWeight<Self>;
1173 type Precompiles = (
1174 ERC20<Self, InlineIdConfig<0x120>, TrustBackedAssetsInstance>,
1175 ERC20<Self, InlineIdConfig<0x320>, PoolAssetsInstance>,
1176 XcmPrecompile<Self>,
1177 );
1178 type AddressMapper = pallet_revive::AccountId32Mapper<Self>;
1179 type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>;
1180 type PVFMemory = ConstU32<{ 512 * 1024 * 1024 }>;
1181 type UnsafeUnstableInterface = ConstBool<false>;
1182 #[cfg(feature = "runtime-benchmarks")]
1183 type AllowEVMBytecode = ConstBool<true>;
1184 #[cfg(not(feature = "runtime-benchmarks"))]
1185 type AllowEVMBytecode = ConstBool<false>;
1186 type UploadOrigin = EnsureSigned<Self::AccountId>;
1187 type InstantiateOrigin = EnsureSigned<Self::AccountId>;
1188 type RuntimeHoldReason = RuntimeHoldReason;
1189 type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
1190 type ChainId = ConstU64<420_420_421>;
1191 type NativeToEthRatio = ConstU32<1_000_000>; type EthGasEncoder = ();
1193 type FindAuthor = <Runtime as pallet_authorship::Config>::FindAuthor;
1194}
1195
1196parameter_types! {
1197 pub MbmServiceWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
1198}
1199
1200impl pallet_migrations::Config for Runtime {
1201 type RuntimeEvent = RuntimeEvent;
1202 #[cfg(not(feature = "runtime-benchmarks"))]
1203 type Migrations = (
1204 pallet_revive::migrations::v1::Migration<Runtime>,
1205 pallet_revive::migrations::v2::Migration<Runtime>,
1206 );
1207 #[cfg(feature = "runtime-benchmarks")]
1209 type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
1210 type CursorMaxLen = ConstU32<65_536>;
1211 type IdentifierMaxLen = ConstU32<256>;
1212 type MigrationStatusHandler = ();
1213 type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
1214 type MaxServiceWeight = MbmServiceWeight;
1215 type WeightInfo = weights::pallet_migrations::WeightInfo<Runtime>;
1216}
1217
1218parameter_types! {
1219 pub MaximumSchedulerWeight: frame_support::weights::Weight = Perbill::from_percent(80) *
1220 RuntimeBlockWeights::get().max_block;
1221}
1222
1223impl pallet_scheduler::Config for Runtime {
1224 type RuntimeOrigin = RuntimeOrigin;
1225 type RuntimeEvent = RuntimeEvent;
1226 type PalletsOrigin = OriginCaller;
1227 type RuntimeCall = RuntimeCall;
1228 type MaximumWeight = MaximumSchedulerWeight;
1229 type ScheduleOrigin = EnsureRoot<AccountId>;
1230 #[cfg(feature = "runtime-benchmarks")]
1231 type MaxScheduledPerBlock = ConstU32<{ 512 * 15 }>; #[cfg(not(feature = "runtime-benchmarks"))]
1233 type MaxScheduledPerBlock = ConstU32<50>;
1234 type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
1235 type OriginPrivilegeCmp = frame_support::traits::EqualPrivilegeOnly;
1236 type Preimages = Preimage;
1237 type BlockNumberProvider = RelaychainDataProvider<Runtime>;
1238}
1239
1240parameter_types! {
1241 pub const PreimageBaseDeposit: Balance = deposit(2, 64);
1242 pub const PreimageByteDeposit: Balance = deposit(0, 1);
1243 pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
1244}
1245
1246impl pallet_preimage::Config for Runtime {
1247 type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
1248 type RuntimeEvent = RuntimeEvent;
1249 type Currency = Balances;
1250 type ManagerOrigin = EnsureRoot<AccountId>;
1251 type Consideration = HoldConsideration<
1252 AccountId,
1253 Balances,
1254 PreimageHoldReason,
1255 LinearStoragePrice<PreimageBaseDeposit, PreimageByteDeposit, Balance>,
1256 >;
1257}
1258
1259parameter_types! {
1260 pub const IndexDeposit: Balance = deposit(1, 32 + 16);
1265}
1266
1267impl pallet_indices::Config for Runtime {
1268 type AccountIndex = AccountIndex;
1269 type Currency = Balances;
1270 type Deposit = IndexDeposit;
1271 type RuntimeEvent = RuntimeEvent;
1272 type WeightInfo = weights::pallet_indices::WeightInfo<Runtime>;
1273}
1274
1275impl pallet_ah_ops::Config for Runtime {
1276 type Currency = Balances;
1277 type RcBlockNumberProvider = RelaychainDataProvider<Runtime>;
1278 type WeightInfo = weights::pallet_ah_ops::WeightInfo<Runtime>;
1279}
1280
1281impl pallet_sudo::Config for Runtime {
1282 type RuntimeEvent = RuntimeEvent;
1283 type RuntimeCall = RuntimeCall;
1284 type WeightInfo = weights::pallet_sudo::WeightInfo<Runtime>;
1285}
1286
1287construct_runtime!(
1289 pub enum Runtime
1290 {
1291 System: frame_system = 0,
1293 ParachainSystem: cumulus_pallet_parachain_system = 1,
1294 Timestamp: pallet_timestamp = 3,
1296 ParachainInfo: parachain_info = 4,
1297 WeightReclaim: cumulus_pallet_weight_reclaim = 5,
1298 MultiBlockMigrations: pallet_migrations = 6,
1299 Preimage: pallet_preimage = 7,
1300 Scheduler: pallet_scheduler = 8,
1301 Sudo: pallet_sudo = 9,
1302
1303 Balances: pallet_balances = 10,
1305 TransactionPayment: pallet_transaction_payment = 11,
1306 AssetTxPayment: pallet_asset_conversion_tx_payment = 13,
1308 Vesting: pallet_vesting = 14,
1309
1310 Authorship: pallet_authorship = 20,
1312 CollatorSelection: pallet_collator_selection = 21,
1313 Session: pallet_session = 22,
1314 Aura: pallet_aura = 23,
1315 AuraExt: cumulus_pallet_aura_ext = 24,
1316
1317 XcmpQueue: cumulus_pallet_xcmp_queue = 30,
1319 PolkadotXcm: pallet_xcm = 31,
1320 CumulusXcm: cumulus_pallet_xcm = 32,
1321 ToRococoXcmRouter: pallet_xcm_bridge_hub_router::<Instance1> = 34,
1323 MessageQueue: pallet_message_queue = 35,
1324 SnowbridgeSystemFrontend: snowbridge_pallet_system_frontend = 36,
1326
1327 Utility: pallet_utility = 40,
1329 Multisig: pallet_multisig = 41,
1330 Proxy: pallet_proxy = 42,
1331 Indices: pallet_indices = 43,
1332
1333 Assets: pallet_assets::<Instance1> = 50,
1335 Uniques: pallet_uniques = 51,
1336 Nfts: pallet_nfts = 52,
1337 ForeignAssets: pallet_assets::<Instance2> = 53,
1338 NftFractionalization: pallet_nft_fractionalization = 54,
1339 PoolAssets: pallet_assets::<Instance3> = 55,
1340 AssetConversion: pallet_asset_conversion = 56,
1341
1342 AssetsFreezer: pallet_assets_freezer::<Instance1> = 57,
1343 ForeignAssetsFreezer: pallet_assets_freezer::<Instance2> = 58,
1344 PoolAssetsFreezer: pallet_assets_freezer::<Instance3> = 59,
1345 Revive: pallet_revive = 60,
1346
1347 AssetRewards: pallet_asset_rewards = 61,
1348
1349 StateTrieMigration: pallet_state_trie_migration = 70,
1350
1351 Staking: pallet_staking_async = 80,
1353 NominationPools: pallet_nomination_pools = 81,
1354 FastUnstake: pallet_fast_unstake = 82,
1355 VoterList: pallet_bags_list::<Instance1> = 83,
1356 DelegatedStaking: pallet_delegated_staking = 84,
1357 StakingRcClient: pallet_staking_async_rc_client = 89,
1358
1359 MultiBlockElection: pallet_election_provider_multi_block = 85,
1361 MultiBlockElectionVerifier: pallet_election_provider_multi_block::verifier = 86,
1362 MultiBlockElectionUnsigned: pallet_election_provider_multi_block::unsigned = 87,
1363 MultiBlockElectionSigned: pallet_election_provider_multi_block::signed = 88,
1364
1365 ConvictionVoting: pallet_conviction_voting = 90,
1367 Referenda: pallet_referenda = 91,
1368 Origins: pallet_custom_origins = 92,
1369 Whitelist: pallet_whitelist = 93,
1370 Treasury: pallet_treasury = 94,
1371 AssetRate: pallet_asset_rate = 95,
1372
1373 AssetConversionMigration: pallet_asset_conversion_ops = 200,
1376
1377 AhOps: pallet_ah_ops = 254,
1378 }
1379);
1380
1381pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
1383pub type Block = generic::Block<Header, UncheckedExtrinsic>;
1385pub type SignedBlock = generic::SignedBlock<Block>;
1387pub type BlockId = generic::BlockId<Block>;
1389pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
1391 Runtime,
1392 (
1393 frame_system::AuthorizeCall<Runtime>,
1394 frame_system::CheckNonZeroSender<Runtime>,
1395 frame_system::CheckSpecVersion<Runtime>,
1396 frame_system::CheckTxVersion<Runtime>,
1397 frame_system::CheckGenesis<Runtime>,
1398 frame_system::CheckEra<Runtime>,
1399 frame_system::CheckNonce<Runtime>,
1400 frame_system::CheckWeight<Runtime>,
1401 pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
1402 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
1403 ),
1404>;
1405
1406#[derive(Clone, PartialEq, Eq, Debug)]
1408pub struct EthExtraImpl;
1409
1410impl EthExtra for EthExtraImpl {
1411 type Config = Runtime;
1412 type Extension = TxExtension;
1413
1414 fn get_eth_extension(nonce: u32, tip: Balance) -> Self::Extension {
1415 (
1416 frame_system::AuthorizeCall::<Runtime>::new(),
1417 frame_system::CheckNonZeroSender::<Runtime>::new(),
1418 frame_system::CheckSpecVersion::<Runtime>::new(),
1419 frame_system::CheckTxVersion::<Runtime>::new(),
1420 frame_system::CheckGenesis::<Runtime>::new(),
1421 frame_system::CheckMortality::from(generic::Era::Immortal),
1422 frame_system::CheckNonce::<Runtime>::from(nonce),
1423 frame_system::CheckWeight::<Runtime>::new(),
1424 pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(tip, None),
1425 frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
1426 )
1427 .into()
1428 }
1429}
1430
1431pub type UncheckedExtrinsic =
1433 pallet_revive::evm::runtime::UncheckedExtrinsic<Address, Signature, EthExtraImpl>;
1434
1435pub type Migrations = (
1437 pallet_nfts::migration::v1::MigrateToV1<Runtime>,
1439 pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
1441 pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
1443 InitStorageVersions,
1445 DeleteUndecodableStorage,
1447 cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
1449 cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5<Runtime>,
1450 pallet_assets::migration::next_asset_id::SetNextAssetId<
1452 ConstU32<50_000_000>,
1453 Runtime,
1454 TrustBackedAssetsInstance,
1455 >,
1456 pallet_session::migrations::v1::MigrateV0ToV1<
1457 Runtime,
1458 pallet_session::migrations::v1::InitOffenceSeverity<Runtime>,
1459 >,
1460 pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
1462 cumulus_pallet_aura_ext::migration::MigrateV0ToV1<Runtime>,
1463);
1464
1465pub struct DeleteUndecodableStorage;
1470
1471impl frame_support::traits::OnRuntimeUpgrade for DeleteUndecodableStorage {
1472 fn on_runtime_upgrade() -> Weight {
1473 use sp_core::crypto::Ss58Codec;
1474
1475 let mut writes = 0;
1476
1477 match AccountId::from_ss58check("5GCCJthVSwNXRpbeg44gysJUx9vzjdGdfWhioeM7gCg6VyXf") {
1481 Ok(a) => {
1482 tracing::info!(target: "bridges::on_runtime_upgrade", "Removing holds for account with bad hold");
1483 pallet_balances::Holds::<Runtime, ()>::remove(a);
1484 writes.saturating_inc();
1485 },
1486 Err(_) => {
1487 tracing::error!(target: "bridges::on_runtime_upgrade", "CleanupUndecodableStorage: Somehow failed to convert valid SS58 address into an AccountId!");
1488 },
1489 };
1490
1491 writes.saturating_inc();
1493 match pallet_nfts::Pallet::<Runtime, ()>::do_burn(3, 1, |_| Ok(())) {
1494 Ok(_) => {
1495 tracing::info!(target: "bridges::on_runtime_upgrade", "Destroyed undecodable NFT item 1");
1496 },
1497 Err(e) => {
1498 tracing::error!(target: "bridges::on_runtime_upgrade", error=?e, "Failed to destroy undecodable NFT item");
1499 return <Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, writes);
1500 },
1501 }
1502
1503 writes.saturating_inc();
1505 match pallet_nfts::Pallet::<Runtime, ()>::do_burn(3, 2, |_| Ok(())) {
1506 Ok(_) => {
1507 tracing::info!(target: "bridges::on_runtime_upgrade", "Destroyed undecodable NFT item 2");
1508 },
1509 Err(e) => {
1510 tracing::error!(target: "bridges::on_runtime_upgrade", error=?e, "Failed to destroy undecodable NFT item");
1511 return <Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, writes);
1512 },
1513 }
1514
1515 writes.saturating_inc();
1517 match pallet_nfts::Pallet::<Runtime, ()>::do_destroy_collection(
1518 3,
1519 DestroyWitness { attributes: 0, item_metadatas: 1, item_configs: 0 },
1520 None,
1521 ) {
1522 Ok(_) => {
1523 tracing::info!(target: "bridges::on_runtime_upgrade", "Destroyed undecodable NFT collection");
1524 },
1525 Err(e) => {
1526 tracing::error!(target: "bridges::on_runtime_upgrade", error=?e, "Failed to destroy undecodable NFT collection");
1527 },
1528 };
1529
1530 <Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, writes)
1531 }
1532}
1533
1534pub struct InitStorageVersions;
1541
1542impl frame_support::traits::OnRuntimeUpgrade for InitStorageVersions {
1543 fn on_runtime_upgrade() -> Weight {
1544 use frame_support::traits::{GetStorageVersion, StorageVersion};
1545
1546 let mut writes = 0;
1547
1548 if PolkadotXcm::on_chain_storage_version() == StorageVersion::new(0) {
1549 PolkadotXcm::in_code_storage_version().put::<PolkadotXcm>();
1550 writes.saturating_inc();
1551 }
1552
1553 if ForeignAssets::on_chain_storage_version() == StorageVersion::new(0) {
1554 ForeignAssets::in_code_storage_version().put::<ForeignAssets>();
1555 writes.saturating_inc();
1556 }
1557
1558 if PoolAssets::on_chain_storage_version() == StorageVersion::new(0) {
1559 PoolAssets::in_code_storage_version().put::<PoolAssets>();
1560 writes.saturating_inc();
1561 }
1562
1563 <Runtime as frame_system::Config>::DbWeight::get().reads_writes(3, writes)
1564 }
1565}
1566
1567pub type Executive = frame_executive::Executive<
1569 Runtime,
1570 Block,
1571 frame_system::ChainContext<Runtime>,
1572 Runtime,
1573 AllPalletsWithSystem,
1574 Migrations,
1575>;
1576
1577#[cfg(feature = "runtime-benchmarks")]
1578pub struct AssetConversionTxHelper;
1579
1580#[cfg(feature = "runtime-benchmarks")]
1581impl
1582 pallet_asset_conversion_tx_payment::BenchmarkHelperTrait<
1583 AccountId,
1584 cumulus_primitives_core::Location,
1585 cumulus_primitives_core::Location,
1586 > for AssetConversionTxHelper
1587{
1588 fn create_asset_id_parameter(
1589 seed: u32,
1590 ) -> (cumulus_primitives_core::Location, cumulus_primitives_core::Location) {
1591 let asset_id = cumulus_primitives_core::Location::new(
1593 1,
1594 [
1595 cumulus_primitives_core::Junction::Parachain(3000),
1596 cumulus_primitives_core::Junction::PalletInstance(53),
1597 cumulus_primitives_core::Junction::GeneralIndex(seed.into()),
1598 ],
1599 );
1600 (asset_id.clone(), asset_id)
1601 }
1602
1603 fn setup_balances_and_pool(asset_id: cumulus_primitives_core::Location, account: AccountId) {
1604 use frame_support::{assert_ok, traits::fungibles::Mutate};
1605 assert_ok!(ForeignAssets::force_create(
1606 RuntimeOrigin::root(),
1607 asset_id.clone().into(),
1608 account.clone().into(), true, 1,
1611 ));
1612
1613 let lp_provider = account.clone();
1614 use frame_support::traits::Currency;
1615 let _ = Balances::deposit_creating(&lp_provider, u64::MAX.into());
1616 assert_ok!(ForeignAssets::mint_into(
1617 asset_id.clone().into(),
1618 &lp_provider,
1619 u64::MAX.into()
1620 ));
1621
1622 let token_native = alloc::boxed::Box::new(cumulus_primitives_core::Location::new(
1623 1,
1624 cumulus_primitives_core::Junctions::Here,
1625 ));
1626 let token_second = alloc::boxed::Box::new(asset_id);
1627
1628 assert_ok!(AssetConversion::create_pool(
1629 RuntimeOrigin::signed(lp_provider.clone()),
1630 token_native.clone(),
1631 token_second.clone()
1632 ));
1633
1634 assert_ok!(AssetConversion::add_liquidity(
1635 RuntimeOrigin::signed(lp_provider.clone()),
1636 token_native,
1637 token_second,
1638 (u32::MAX / 2).into(), u32::MAX.into(), 1, 1, lp_provider,
1643 ));
1644 }
1645}
1646
1647#[cfg(feature = "runtime-benchmarks")]
1648mod benches {
1649 frame_benchmarking::define_benchmarks!(
1650 [frame_system, SystemBench::<Runtime>]
1651 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
1652 [pallet_asset_conversion_ops, AssetConversionMigration]
1653 [pallet_asset_rate, AssetRate]
1654 [pallet_assets, Local]
1655 [pallet_assets, Foreign]
1656 [pallet_assets, Pool]
1657 [pallet_asset_conversion, AssetConversion]
1658 [pallet_asset_rewards, AssetRewards]
1659 [pallet_asset_conversion_tx_payment, AssetTxPayment]
1660 [pallet_bags_list, VoterList]
1661 [pallet_balances, Balances]
1662 [pallet_conviction_voting, ConvictionVoting]
1663 [pallet_election_provider_multi_block_unsigned, MultiBlockElectionUnsigned]
1667 [pallet_election_provider_multi_block_signed, MultiBlockElectionSigned]
1668 [pallet_fast_unstake, FastUnstake]
1669 [pallet_message_queue, MessageQueue]
1670 [pallet_migrations, MultiBlockMigrations]
1671 [pallet_multisig, Multisig]
1672 [pallet_nft_fractionalization, NftFractionalization]
1673 [pallet_nfts, Nfts]
1674 [pallet_proxy, Proxy]
1675 [pallet_session, SessionBench::<Runtime>]
1676 [pallet_staking_async, Staking]
1677 [pallet_uniques, Uniques]
1678 [pallet_utility, Utility]
1679 [pallet_timestamp, Timestamp]
1680 [pallet_transaction_payment, TransactionPayment]
1681 [pallet_collator_selection, CollatorSelection]
1682 [cumulus_pallet_parachain_system, ParachainSystem]
1683 [cumulus_pallet_xcmp_queue, XcmpQueue]
1684 [pallet_treasury, Treasury]
1685 [pallet_vesting, Vesting]
1686 [pallet_whitelist, Whitelist]
1687 [pallet_xcm_bridge_hub_router, ToRococo]
1688 [pallet_asset_conversion_ops, AssetConversionMigration]
1689 [pallet_revive, Revive]
1690 [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
1692 [pallet_xcm_benchmarks::fungible, XcmBalances]
1694 [pallet_xcm_benchmarks::generic, XcmGeneric]
1695 [cumulus_pallet_weight_reclaim, WeightReclaim]
1696 [snowbridge_pallet_system_frontend, SnowbridgeSystemFrontend]
1697 );
1698}
1699
1700pallet_revive::impl_runtime_apis_plus_revive!(
1701 Runtime,
1702 Executive,
1703 EthExtraImpl,
1704
1705 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
1706 fn slot_duration() -> sp_consensus_aura::SlotDuration {
1707 sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
1708 }
1709
1710 fn authorities() -> Vec<AuraId> {
1711 pallet_aura::Authorities::<Runtime>::get().into_inner()
1712 }
1713 }
1714
1715 impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
1716 fn relay_parent_offset() -> u32 {
1717 0
1718 }
1719 }
1720
1721 impl cumulus_primitives_core::GetParachainInfo<Block> for Runtime {
1722 fn parachain_id() -> ParaId {
1723 ParachainInfo::parachain_id()
1724 }
1725 }
1726
1727 impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
1728 fn can_build_upon(
1729 included_hash: <Block as BlockT>::Hash,
1730 slot: cumulus_primitives_aura::Slot,
1731 ) -> bool {
1732 ConsensusHook::can_build_upon(included_hash, slot)
1733 }
1734 }
1735
1736 impl sp_api::Core<Block> for Runtime {
1737 fn version() -> RuntimeVersion {
1738 VERSION
1739 }
1740
1741 fn execute_block(block: Block) {
1742 Executive::execute_block(block)
1743 }
1744
1745 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
1746 Executive::initialize_block(header)
1747 }
1748 }
1749
1750 impl sp_api::Metadata<Block> for Runtime {
1751 fn metadata() -> OpaqueMetadata {
1752 OpaqueMetadata::new(Runtime::metadata().into())
1753 }
1754
1755 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
1756 Runtime::metadata_at_version(version)
1757 }
1758
1759 fn metadata_versions() -> alloc::vec::Vec<u32> {
1760 Runtime::metadata_versions()
1761 }
1762 }
1763
1764 impl sp_block_builder::BlockBuilder<Block> for Runtime {
1765 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
1766 Executive::apply_extrinsic(extrinsic)
1767 }
1768
1769 fn finalize_block() -> <Block as BlockT>::Header {
1770 Executive::finalize_block()
1771 }
1772
1773 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
1774 data.create_extrinsics()
1775 }
1776
1777 fn check_inherents(
1778 block: Block,
1779 data: sp_inherents::InherentData,
1780 ) -> sp_inherents::CheckInherentsResult {
1781 data.check_extrinsics(&block)
1782 }
1783 }
1784
1785 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
1786 fn validate_transaction(
1787 source: TransactionSource,
1788 tx: <Block as BlockT>::Extrinsic,
1789 block_hash: <Block as BlockT>::Hash,
1790 ) -> TransactionValidity {
1791 Executive::validate_transaction(source, tx, block_hash)
1792 }
1793 }
1794
1795 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
1796 fn offchain_worker(header: &<Block as BlockT>::Header) {
1797 Executive::offchain_worker(header)
1798 }
1799 }
1800
1801 impl sp_session::SessionKeys<Block> for Runtime {
1802 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
1803 SessionKeys::generate(seed)
1804 }
1805
1806 fn decode_session_keys(
1807 encoded: Vec<u8>,
1808 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
1809 SessionKeys::decode_into_raw_public_keys(&encoded)
1810 }
1811 }
1812
1813 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
1814 fn account_nonce(account: AccountId) -> Nonce {
1815 System::account_nonce(account)
1816 }
1817 }
1818
1819 impl pallet_nfts_runtime_api::NftsApi<Block, AccountId, u32, u32> for Runtime {
1820 fn owner(collection: u32, item: u32) -> Option<AccountId> {
1821 <Nfts as Inspect<AccountId>>::owner(&collection, &item)
1822 }
1823
1824 fn collection_owner(collection: u32) -> Option<AccountId> {
1825 <Nfts as Inspect<AccountId>>::collection_owner(&collection)
1826 }
1827
1828 fn attribute(
1829 collection: u32,
1830 item: u32,
1831 key: Vec<u8>,
1832 ) -> Option<Vec<u8>> {
1833 <Nfts as Inspect<AccountId>>::attribute(&collection, &item, &key)
1834 }
1835
1836 fn custom_attribute(
1837 account: AccountId,
1838 collection: u32,
1839 item: u32,
1840 key: Vec<u8>,
1841 ) -> Option<Vec<u8>> {
1842 <Nfts as Inspect<AccountId>>::custom_attribute(
1843 &account,
1844 &collection,
1845 &item,
1846 &key,
1847 )
1848 }
1849
1850 fn system_attribute(
1851 collection: u32,
1852 item: Option<u32>,
1853 key: Vec<u8>,
1854 ) -> Option<Vec<u8>> {
1855 <Nfts as Inspect<AccountId>>::system_attribute(&collection, item.as_ref(), &key)
1856 }
1857
1858 fn collection_attribute(collection: u32, key: Vec<u8>) -> Option<Vec<u8>> {
1859 <Nfts as Inspect<AccountId>>::collection_attribute(&collection, &key)
1860 }
1861 }
1862
1863 impl pallet_asset_conversion::AssetConversionApi<
1864 Block,
1865 Balance,
1866 xcm::v5::Location,
1867 > for Runtime
1868 {
1869 fn quote_price_exact_tokens_for_tokens(asset1: xcm::v5::Location, asset2: xcm::v5::Location, amount: Balance, include_fee: bool) -> Option<Balance> {
1870 AssetConversion::quote_price_exact_tokens_for_tokens(asset1, asset2, amount, include_fee)
1871 }
1872
1873 fn quote_price_tokens_for_exact_tokens(asset1: xcm::v5::Location, asset2: xcm::v5::Location, amount: Balance, include_fee: bool) -> Option<Balance> {
1874 AssetConversion::quote_price_tokens_for_exact_tokens(asset1, asset2, amount, include_fee)
1875 }
1876
1877 fn get_reserves(asset1: xcm::v5::Location, asset2: xcm::v5::Location) -> Option<(Balance, Balance)> {
1878 AssetConversion::get_reserves(asset1, asset2).ok()
1879 }
1880 }
1881
1882 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
1883 fn query_info(
1884 uxt: <Block as BlockT>::Extrinsic,
1885 len: u32,
1886 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
1887 TransactionPayment::query_info(uxt, len)
1888 }
1889 fn query_fee_details(
1890 uxt: <Block as BlockT>::Extrinsic,
1891 len: u32,
1892 ) -> pallet_transaction_payment::FeeDetails<Balance> {
1893 TransactionPayment::query_fee_details(uxt, len)
1894 }
1895 fn query_weight_to_fee(weight: Weight) -> Balance {
1896 TransactionPayment::weight_to_fee(weight)
1897 }
1898 fn query_length_to_fee(length: u32) -> Balance {
1899 TransactionPayment::length_to_fee(length)
1900 }
1901 }
1902
1903 impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
1904 fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
1905 let native_token = xcm_config::WestendLocation::get();
1906 let mut acceptable_assets = vec![AssetId(native_token.clone())];
1908 acceptable_assets.extend(
1910 assets_common::PoolAdapter::<Runtime>::get_assets_in_pool_with(native_token)
1911 .map_err(|()| XcmPaymentApiError::VersionedConversionFailed)?
1912 );
1913 PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
1914 }
1915
1916 fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
1917 use crate::xcm_config::XcmConfig;
1918
1919 type Trader = <XcmConfig as xcm_executor::Config>::Trader;
1920
1921 PolkadotXcm::query_weight_to_asset_fee::<Trader>(weight, asset)
1922 }
1923
1924 fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
1925 PolkadotXcm::query_xcm_weight(message)
1926 }
1927
1928 fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result<VersionedAssets, XcmPaymentApiError> {
1929 PolkadotXcm::query_delivery_fees(destination, message)
1930 }
1931 }
1932
1933 impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
1934 fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
1935 PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
1936 }
1937
1938 fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
1939 PolkadotXcm::dry_run_xcm::<Runtime, xcm_config::XcmRouter, RuntimeCall, xcm_config::XcmConfig>(origin_location, xcm)
1940 }
1941 }
1942
1943 impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
1944 fn convert_location(location: VersionedLocation) -> Result<
1945 AccountId,
1946 xcm_runtime_apis::conversions::Error
1947 > {
1948 xcm_runtime_apis::conversions::LocationToAccountHelper::<
1949 AccountId,
1950 xcm_config::LocationToAccountId,
1951 >::convert_location(location)
1952 }
1953 }
1954
1955 impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
1956 fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
1957 PolkadotXcm::is_trusted_reserve(asset, location)
1958 }
1959 fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
1960 PolkadotXcm::is_trusted_teleporter(asset, location)
1961 }
1962 }
1963
1964 impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi<Block> for Runtime {
1965 fn authorized_aliasers(target: VersionedLocation) -> Result<
1966 Vec<xcm_runtime_apis::authorized_aliases::OriginAliaser>,
1967 xcm_runtime_apis::authorized_aliases::Error
1968 > {
1969 PolkadotXcm::authorized_aliasers(target)
1970 }
1971 fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result<
1972 bool,
1973 xcm_runtime_apis::authorized_aliases::Error
1974 > {
1975 PolkadotXcm::is_authorized_alias(origin, target)
1976 }
1977 }
1978
1979 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
1980 for Runtime
1981 {
1982 fn query_call_info(
1983 call: RuntimeCall,
1984 len: u32,
1985 ) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
1986 TransactionPayment::query_call_info(call, len)
1987 }
1988 fn query_call_fee_details(
1989 call: RuntimeCall,
1990 len: u32,
1991 ) -> pallet_transaction_payment::FeeDetails<Balance> {
1992 TransactionPayment::query_call_fee_details(call, len)
1993 }
1994 fn query_weight_to_fee(weight: Weight) -> Balance {
1995 TransactionPayment::weight_to_fee(weight)
1996 }
1997 fn query_length_to_fee(length: u32) -> Balance {
1998 TransactionPayment::length_to_fee(length)
1999 }
2000 }
2001
2002 impl assets_common::runtime_api::FungiblesApi<
2003 Block,
2004 AccountId,
2005 > for Runtime
2006 {
2007 fn query_account_balances(account: AccountId) -> Result<xcm::VersionedAssets, assets_common::runtime_api::FungiblesAccessError> {
2008 use assets_common::fungible_conversion::{convert, convert_balance};
2009 Ok([
2010 {
2012 let balance = Balances::free_balance(account.clone());
2013 if balance > 0 {
2014 vec![convert_balance::<WestendLocation, Balance>(balance)?]
2015 } else {
2016 vec![]
2017 }
2018 },
2019 convert::<_, _, _, _, TrustBackedAssetsConvertedConcreteId>(
2021 Assets::account_balances(account.clone())
2022 .iter()
2023 .filter(|(_, balance)| balance > &0)
2024 )?,
2025 convert::<_, _, _, _, ForeignAssetsConvertedConcreteId>(
2027 ForeignAssets::account_balances(account.clone())
2028 .iter()
2029 .filter(|(_, balance)| balance > &0)
2030 )?,
2031 convert::<_, _, _, _, PoolAssetsConvertedConcreteId>(
2033 PoolAssets::account_balances(account)
2034 .iter()
2035 .filter(|(_, balance)| balance > &0)
2036 )?,
2037 ].concat().into())
2039 }
2040 }
2041
2042 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
2043 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
2044 ParachainSystem::collect_collation_info(header)
2045 }
2046 }
2047
2048 impl pallet_asset_rewards::AssetRewards<Block, Balance> for Runtime {
2049 fn pool_creation_cost() -> Balance {
2050 StakePoolCreationDeposit::get()
2051 }
2052 }
2053
2054 #[cfg(feature = "try-runtime")]
2055 impl frame_try_runtime::TryRuntime<Block> for Runtime {
2056 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
2057 let weight = Executive::try_runtime_upgrade(checks).unwrap();
2058 (weight, RuntimeBlockWeights::get().max_block)
2059 }
2060
2061 fn execute_block(
2062 block: Block,
2063 state_root_check: bool,
2064 signature_check: bool,
2065 select: frame_try_runtime::TryStateSelect,
2066 ) -> Weight {
2067 Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
2070 }
2071 }
2072
2073
2074 impl pallet_nomination_pools_runtime_api::NominationPoolsApi<
2075 Block,
2076 AccountId,
2077 Balance,
2078 > for Runtime {
2079 fn pending_rewards(member: AccountId) -> Balance {
2080 NominationPools::api_pending_rewards(member).unwrap_or_default()
2081 }
2082
2083 fn points_to_balance(pool_id: PoolId, points: Balance) -> Balance {
2084 NominationPools::api_points_to_balance(pool_id, points)
2085 }
2086
2087 fn balance_to_points(pool_id: PoolId, new_funds: Balance) -> Balance {
2088 NominationPools::api_balance_to_points(pool_id, new_funds)
2089 }
2090
2091 fn pool_pending_slash(pool_id: PoolId) -> Balance {
2092 NominationPools::api_pool_pending_slash(pool_id)
2093 }
2094
2095 fn member_pending_slash(member: AccountId) -> Balance {
2096 NominationPools::api_member_pending_slash(member)
2097 }
2098
2099 fn pool_needs_delegate_migration(pool_id: PoolId) -> bool {
2100 NominationPools::api_pool_needs_delegate_migration(pool_id)
2101 }
2102
2103 fn member_needs_delegate_migration(member: AccountId) -> bool {
2104 NominationPools::api_member_needs_delegate_migration(member)
2105 }
2106
2107 fn member_total_balance(member: AccountId) -> Balance {
2108 NominationPools::api_member_total_balance(member)
2109 }
2110
2111 fn pool_balance(pool_id: PoolId) -> Balance {
2112 NominationPools::api_pool_balance(pool_id)
2113 }
2114
2115 fn pool_accounts(pool_id: PoolId) -> (AccountId, AccountId) {
2116 NominationPools::api_pool_accounts(pool_id)
2117 }
2118 }
2119
2120 impl pallet_staking_runtime_api::StakingApi<Block, Balance, AccountId> for Runtime {
2121 fn nominations_quota(balance: Balance) -> u32 {
2122 Staking::api_nominations_quota(balance)
2123 }
2124
2125 fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
2126 Staking::api_eras_stakers_page_count(era, account)
2127 }
2128
2129 fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool {
2130 Staking::api_pending_rewards(era, account)
2131 }
2132 }
2133
2134 #[cfg(feature = "runtime-benchmarks")]
2135 impl frame_benchmarking::Benchmark<Block> for Runtime {
2136 fn benchmark_metadata(extra: bool) -> (
2137 Vec<frame_benchmarking::BenchmarkList>,
2138 Vec<frame_support::traits::StorageInfo>,
2139 ) {
2140 use frame_benchmarking::BenchmarkList;
2141 use frame_support::traits::StorageInfoTrait;
2142 use frame_system_benchmarking::Pallet as SystemBench;
2143 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2144 use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
2145 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2146 use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench;
2147
2148 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
2152 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
2153
2154 type Local = pallet_assets::Pallet::<Runtime, TrustBackedAssetsInstance>;
2159 type Foreign = pallet_assets::Pallet::<Runtime, ForeignAssetsInstance>;
2160 type Pool = pallet_assets::Pallet::<Runtime, PoolAssetsInstance>;
2161
2162 type ToRococo = XcmBridgeHubRouterBench<Runtime, ToRococoXcmRouterInstance>;
2163
2164 let mut list = Vec::<BenchmarkList>::new();
2165 list_benchmarks!(list, extra);
2166
2167 let storage_info = AllPalletsWithSystem::storage_info();
2168 (list, storage_info)
2169 }
2170
2171 #[allow(non_local_definitions)]
2172 fn dispatch_benchmark(
2173 config: frame_benchmarking::BenchmarkConfig
2174 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
2175 use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
2176 use frame_support::assert_ok;
2177 use sp_storage::TrackedStorageKey;
2178 use frame_system_benchmarking::Pallet as SystemBench;
2179 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2180 impl frame_system_benchmarking::Config for Runtime {
2181 fn setup_set_code_requirements(code: &alloc::vec::Vec<u8>) -> Result<(), BenchmarkError> {
2182 ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
2183 Ok(())
2184 }
2185
2186 fn verify_set_code() {
2187 System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
2188 }
2189 }
2190
2191 use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
2192 use xcm_config::{MaxAssetsIntoHolding, WestendLocation};
2193
2194 impl cumulus_pallet_session_benchmarking::Config for Runtime {}
2195 use testnet_parachains_constants::westend::locations::{PeopleParaId, PeopleLocation};
2196 parameter_types! {
2197 pub ExistentialDepositAsset: Option<Asset> = Some((
2198 WestendLocation::get(),
2199 ExistentialDeposit::get()
2200 ).into());
2201
2202 pub RandomParaId: ParaId = ParaId::new(43211234);
2203 }
2204
2205 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2206 impl pallet_xcm::benchmarking::Config for Runtime {
2207 type DeliveryHelper = (
2208 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2209 xcm_config::XcmConfig,
2210 ExistentialDepositAsset,
2211 PriceForSiblingParachainDelivery,
2212 RandomParaId,
2213 ParachainSystem
2214 >,
2215 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2216 xcm_config::XcmConfig,
2217 ExistentialDepositAsset,
2218 PriceForSiblingParachainDelivery,
2219 PeopleParaId,
2220 ParachainSystem
2221 >);
2222
2223 fn reachable_dest() -> Option<Location> {
2224 Some(PeopleLocation::get())
2225 }
2226
2227 fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
2228 Some((
2230 Asset {
2231 fun: Fungible(ExistentialDeposit::get()),
2232 id: AssetId(WestendLocation::get())
2233 },
2234 PeopleLocation::get(),
2235 ))
2236 }
2237
2238 fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
2239 let account = frame_benchmarking::whitelisted_caller();
2241 assert_ok!(<Balances as fungible::Mutate<_>>::mint_into(
2242 &account,
2243 ExistentialDeposit::get() + (1_000 * UNITS)
2244 ));
2245
2246 let usdt_id = 1984u32;
2248 let usdt_location = Location::new(0, [PalletInstance(50), GeneralIndex(usdt_id.into())]);
2249 assert_ok!(Assets::force_create(
2250 RuntimeOrigin::root(),
2251 usdt_id.into(),
2252 account.clone().into(),
2253 true,
2254 1
2255 ));
2256
2257 Some((
2259 Asset { fun: Fungible(ExistentialDeposit::get()), id: AssetId(usdt_location) },
2260 ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
2261 ))
2262 }
2263
2264 fn set_up_complex_asset_transfer(
2265 ) -> Option<(XcmAssets, u32, Location, alloc::boxed::Box<dyn FnOnce()>)> {
2266 let dest: Location = PeopleLocation::get();
2270
2271 let fee_amount = EXISTENTIAL_DEPOSIT;
2272 let fee_asset: Asset = (WestendLocation::get(), fee_amount).into();
2273
2274 let who = frame_benchmarking::whitelisted_caller();
2275 let balance = fee_amount + EXISTENTIAL_DEPOSIT * 1000;
2277 let _ = <Balances as frame_support::traits::Currency<_>>::make_free_balance_be(
2278 &who, balance,
2279 );
2280 assert_eq!(Balances::free_balance(&who), balance);
2282
2283 let asset_amount = 10u128;
2285 let initial_asset_amount = asset_amount * 10;
2286 let (asset_id, _, _) = pallet_assets::benchmarking::create_default_minted_asset::<
2287 Runtime,
2288 pallet_assets::Instance1
2289 >(true, initial_asset_amount);
2290 let asset_location = Location::new(
2291 0,
2292 [PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]
2293 );
2294 let transfer_asset: Asset = (asset_location, asset_amount).into();
2295
2296 let assets: XcmAssets = vec![fee_asset.clone(), transfer_asset].into();
2297 let fee_index = if assets.get(0).unwrap().eq(&fee_asset) { 0 } else { 1 };
2298
2299 let verify = alloc::boxed::Box::new(move || {
2301 assert!(Balances::free_balance(&who) <= balance - fee_amount);
2304 assert_eq!(
2306 Assets::balance(asset_id.into(), &who),
2307 initial_asset_amount - asset_amount,
2308 );
2309 });
2310 Some((assets, fee_index as u32, dest, verify))
2311 }
2312
2313 fn get_asset() -> Asset {
2314 use frame_benchmarking::whitelisted_caller;
2315 use frame_support::traits::tokens::fungible::{Inspect, Mutate};
2316 let account = whitelisted_caller();
2317 assert_ok!(<Balances as Mutate<_>>::mint_into(
2318 &account,
2319 <Balances as Inspect<_>>::minimum_balance(),
2320 ));
2321 let asset_id = 1984;
2322 assert_ok!(Assets::force_create(
2323 RuntimeOrigin::root(),
2324 asset_id.into(),
2325 account.into(),
2326 true,
2327 1u128,
2328 ));
2329 let amount = 1_000_000u128;
2330 let asset_location = Location::new(0, [PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]);
2331
2332 Asset {
2333 id: AssetId(asset_location),
2334 fun: Fungible(amount),
2335 }
2336 }
2337 }
2338
2339 use pallet_xcm_bridge_hub_router::benchmarking::{
2340 Pallet as XcmBridgeHubRouterBench,
2341 Config as XcmBridgeHubRouterConfig,
2342 };
2343
2344 impl XcmBridgeHubRouterConfig<ToRococoXcmRouterInstance> for Runtime {
2345 fn make_congested() {
2346 cumulus_pallet_xcmp_queue::bridging::suspend_channel_for_benchmarks::<Runtime>(
2347 xcm_config::bridging::SiblingBridgeHubParaId::get().into()
2348 );
2349 }
2350 fn ensure_bridged_target_destination() -> Result<Location, BenchmarkError> {
2351 ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
2352 xcm_config::bridging::SiblingBridgeHubParaId::get().into()
2353 );
2354 let bridged_asset_hub = xcm_config::bridging::to_rococo::AssetHubRococo::get();
2355 let _ = PolkadotXcm::force_xcm_version(
2356 RuntimeOrigin::root(),
2357 alloc::boxed::Box::new(bridged_asset_hub.clone()),
2358 XCM_VERSION,
2359 ).map_err(|e| {
2360 tracing::error!(
2361 target: "bridges::benchmark",
2362 error=?e,
2363 origin=?RuntimeOrigin::root(),
2364 location=?bridged_asset_hub,
2365 version=?XCM_VERSION,
2366 "Failed to dispatch `force_xcm_version`"
2367 );
2368 BenchmarkError::Stop("XcmVersion was not stored!")
2369 })?;
2370 Ok(bridged_asset_hub)
2371 }
2372 }
2373
2374 use pallet_xcm_benchmarks::asset_instance_from;
2375
2376 impl pallet_xcm_benchmarks::Config for Runtime {
2377 type XcmConfig = xcm_config::XcmConfig;
2378 type AccountIdConverter = xcm_config::LocationToAccountId;
2379 type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2380 xcm_config::XcmConfig,
2381 ExistentialDepositAsset,
2382 PriceForSiblingParachainDelivery,
2383 PeopleParaId,
2384 ParachainSystem
2385 >;
2386 fn valid_destination() -> Result<Location, BenchmarkError> {
2387 Ok(PeopleLocation::get())
2388 }
2389 fn worst_case_holding(depositable_count: u32) -> XcmAssets {
2390 let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
2392 let holding_fungibles = holding_non_fungibles - 2; let fungibles_amount: u128 = 100;
2394 (0..holding_fungibles)
2395 .map(|i| {
2396 Asset {
2397 id: AssetId(GeneralIndex(i as u128).into()),
2398 fun: Fungible(fungibles_amount * (i + 1) as u128), }
2400 })
2401 .chain(core::iter::once(Asset { id: AssetId(Here.into()), fun: Fungible(u128::MAX) }))
2402 .chain(core::iter::once(Asset { id: AssetId(WestendLocation::get()), fun: Fungible(1_000_000 * UNITS) }))
2403 .chain((0..holding_non_fungibles).map(|i| Asset {
2404 id: AssetId(GeneralIndex(i as u128).into()),
2405 fun: NonFungible(asset_instance_from(i)),
2406 }))
2407 .collect::<Vec<_>>()
2408 .into()
2409 }
2410 }
2411
2412 parameter_types! {
2413 pub TrustedTeleporter: Option<(Location, Asset)> = Some((
2414 PeopleLocation::get(),
2415 Asset { fun: Fungible(UNITS), id: AssetId(WestendLocation::get()) },
2416 ));
2417 pub TrustedReserve: Option<(Location, Asset)> = Some(
2419 (
2420 xcm_config::bridging::to_rococo::AssetHubRococo::get(),
2421 Asset::from((xcm_config::bridging::to_rococo::RocLocation::get(), 1000000000000 as u128))
2422 )
2423 );
2424 }
2425
2426 impl pallet_xcm_benchmarks::fungible::Config for Runtime {
2427 type TransactAsset = Balances;
2428
2429 type CheckedAccount = xcm_config::TeleportTracking;
2430 type TrustedTeleporter = TrustedTeleporter;
2431 type TrustedReserve = TrustedReserve;
2432
2433 fn get_asset() -> Asset {
2434 use frame_support::traits::tokens::fungible::{Inspect, Mutate};
2435 let (account, _) = pallet_xcm_benchmarks::account_and_location::<Runtime>(1);
2436 assert_ok!(<Balances as Mutate<_>>::mint_into(
2437 &account,
2438 <Balances as Inspect<_>>::minimum_balance(),
2439 ));
2440 let asset_id = 1984;
2441 assert_ok!(Assets::force_create(
2442 RuntimeOrigin::root(),
2443 asset_id.into(),
2444 account.clone().into(),
2445 true,
2446 1u128,
2447 ));
2448 let amount = 1_000_000u128;
2449 let asset_location = Location::new(0, [PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]);
2450
2451 Asset {
2452 id: AssetId(asset_location),
2453 fun: Fungible(amount),
2454 }
2455 }
2456 }
2457
2458 impl pallet_xcm_benchmarks::generic::Config for Runtime {
2459 type TransactAsset = Balances;
2460 type RuntimeCall = RuntimeCall;
2461
2462 fn worst_case_response() -> (u64, Response) {
2463 (0u64, Response::Version(Default::default()))
2464 }
2465
2466 fn worst_case_asset_exchange() -> Result<(XcmAssets, XcmAssets), BenchmarkError> {
2467 let native_asset_location = WestendLocation::get();
2468 let native_asset_id = AssetId(native_asset_location.clone());
2469 let (account, _) = pallet_xcm_benchmarks::account_and_location::<Runtime>(1);
2470 let origin = RuntimeOrigin::signed(account.clone());
2471 let asset_location = Location::new(1, [Parachain(2001)]);
2472 let asset_id = AssetId(asset_location.clone());
2473
2474 assert_ok!(<Balances as fungible::Mutate<_>>::mint_into(
2475 &account,
2476 ExistentialDeposit::get() + (1_000 * UNITS)
2477 ));
2478
2479 assert_ok!(ForeignAssets::force_create(
2480 RuntimeOrigin::root(),
2481 asset_location.clone().into(),
2482 account.clone().into(),
2483 true,
2484 1,
2485 ));
2486
2487 assert_ok!(ForeignAssets::mint(
2488 origin.clone(),
2489 asset_location.clone().into(),
2490 account.clone().into(),
2491 3_000 * UNITS,
2492 ));
2493
2494 assert_ok!(AssetConversion::create_pool(
2495 origin.clone(),
2496 native_asset_location.clone().into(),
2497 asset_location.clone().into(),
2498 ));
2499
2500 assert_ok!(AssetConversion::add_liquidity(
2501 origin,
2502 native_asset_location.into(),
2503 asset_location.into(),
2504 1_000 * UNITS,
2505 2_000 * UNITS,
2506 1,
2507 1,
2508 account.into(),
2509 ));
2510
2511 let give_assets: XcmAssets = (native_asset_id, 500 * UNITS).into();
2512 let receive_assets: XcmAssets = (asset_id, 660 * UNITS).into();
2513
2514 Ok((give_assets, receive_assets))
2515 }
2516
2517 fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
2518 xcm_config::bridging::BridgingBenchmarksHelper::prepare_universal_alias()
2519 .ok_or(BenchmarkError::Skip)
2520 }
2521
2522 fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
2523 Ok((
2524 PeopleLocation::get(),
2525 frame_system::Call::remark_with_event { remark: vec![] }.into()
2526 ))
2527 }
2528
2529 fn subscribe_origin() -> Result<Location, BenchmarkError> {
2530 Ok(PeopleLocation::get())
2531 }
2532
2533 fn claimable_asset() -> Result<(Location, Location, XcmAssets), BenchmarkError> {
2534 let origin = PeopleLocation::get();
2535 let assets: XcmAssets = (AssetId(WestendLocation::get()), 1_000 * UNITS).into();
2536 let ticket = Location { parents: 0, interior: Here };
2537 Ok((origin, ticket, assets))
2538 }
2539
2540 fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
2541 Ok((Asset {
2542 id: AssetId(WestendLocation::get()),
2543 fun: Fungible(1_000 * UNITS),
2544 }, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
2545 }
2546
2547 fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
2548 Err(BenchmarkError::Skip)
2549 }
2550
2551 fn export_message_origin_and_destination(
2552 ) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
2553 Err(BenchmarkError::Skip)
2554 }
2555
2556 fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
2557 Ok((
2560 Location::new(1, [Parachain(1001)]),
2561 Location::new(1, [Parachain(1001), AccountId32 { id: [111u8; 32], network: None }]),
2562 ))
2563 }
2564 }
2565
2566 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
2567 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
2568
2569 type Local = pallet_assets::Pallet::<Runtime, TrustBackedAssetsInstance>;
2570 type Foreign = pallet_assets::Pallet::<Runtime, ForeignAssetsInstance>;
2571 type Pool = pallet_assets::Pallet::<Runtime, PoolAssetsInstance>;
2572
2573 type ToRococo = XcmBridgeHubRouterBench<Runtime, ToRococoXcmRouterInstance>;
2574
2575 use frame_support::traits::WhitelistedStorageKeys;
2576 let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
2577
2578 let mut batches = Vec::<BenchmarkBatch>::new();
2579 let params = (&config, &whitelist);
2580 add_benchmarks!(params, batches);
2581
2582 Ok(batches)
2583 }
2584 }
2585
2586 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
2587 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
2588 build_state::<RuntimeGenesisConfig>(config)
2589 }
2590
2591 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
2592 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
2593 }
2594
2595 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
2596 genesis_config_presets::preset_names()
2597 }
2598 }
2599);
2600
2601cumulus_pallet_parachain_system::register_validate_block! {
2602 Runtime = Runtime,
2603 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
2604}
2605
2606parameter_types! {
2607 pub const MigrationSignedDepositPerItem: Balance = CENTS;
2609 pub const MigrationSignedDepositBase: Balance = 2_000 * CENTS;
2610 pub const MigrationMaxKeyLen: u32 = 512;
2611}
2612
2613impl pallet_state_trie_migration::Config for Runtime {
2614 type RuntimeEvent = RuntimeEvent;
2615 type Currency = Balances;
2616 type RuntimeHoldReason = RuntimeHoldReason;
2617 type SignedDepositPerItem = MigrationSignedDepositPerItem;
2618 type SignedDepositBase = MigrationSignedDepositBase;
2619 type ControlOrigin = frame_system::EnsureSignedBy<RootMigController, AccountId>;
2621 type SignedFilter = frame_system::EnsureSignedBy<MigController, AccountId>;
2623
2624 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;
2626
2627 type MaxKeyLen = MigrationMaxKeyLen;
2628}
2629
2630frame_support::ord_parameter_types! {
2631 pub const MigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
2632 pub const RootMigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
2633}
2634
2635#[test]
2636fn ensure_key_ss58() {
2637 use frame_support::traits::SortedMembers;
2638 use sp_core::crypto::Ss58Codec;
2639 let acc =
2640 AccountId::from_ss58check("5F4EbSkZz18X36xhbsjvDNs6NuZ82HyYtq5UiJ1h9SBHJXZD").unwrap();
2641 assert_eq!(acc, MigController::sorted_members()[0]);
2642 let acc =
2643 AccountId::from_ss58check("5F4EbSkZz18X36xhbsjvDNs6NuZ82HyYtq5UiJ1h9SBHJXZD").unwrap();
2644 assert_eq!(acc, RootMigController::sorted_members()[0]);
2645}