1#![cfg_attr(not(feature = "std"), no_std)]
2#![recursion_limit = "256"]
4
5extern crate alloc;
6#[cfg(feature = "runtime-benchmarks")]
7#[macro_use]
8extern crate frame_benchmarking; #[cfg(feature = "std")]
10include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
11
12#[cfg(feature = "std")]
13#[allow(clippy::expect_used)]
14pub fn wasm_binary_unwrap() -> &'static [u8] {
16 WASM_BINARY.expect(
17 "wasm binary is not available. This means the client is \
18 built with `WASM_BINARY` flag and it is only usable for \
19 production chains. Please rebuild with the flag disabled.",
20 )
21}
22
23#[cfg(feature = "frequency-bridging")]
24pub mod xcm;
25
26#[cfg(feature = "frequency-bridging")]
27use frame_support::traits::AsEnsureOriginWithArg;
28
29#[cfg(feature = "frequency-bridging")]
30use frame_system::EnsureNever;
31
32#[cfg(feature = "frequency-bridging")]
33use xcm::{
34 parameters::{
35 ForeignAssetsAssetId, NativeToken, RelayLocation, RelayOrigin, ReservedDmpWeight,
36 ReservedXcmpWeight,
37 },
38 queue::XcmRouter,
39 LocationToAccountId, XcmConfig,
40};
41
42#[cfg(test)]
43mod migration_tests;
44
45use alloc::borrow::Cow;
46use common_runtime::constants::currency::UNITS;
47
48#[cfg(feature = "frequency-bridging")]
49use staging_xcm::{
50 prelude::AssetId as AssetLocationId, Version as XcmVersion, VersionedAsset, VersionedAssetId,
51 VersionedAssets, VersionedLocation, VersionedXcm,
52};
53
54#[cfg(feature = "frequency-bridging")]
55use xcm_runtime_apis::{
56 dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
57 fees::Error as XcmPaymentApiError,
58};
59
60#[cfg(any(
61 not(feature = "frequency-no-relay"),
62 feature = "frequency-lint-check",
63 feature = "frequency-bridging"
64))]
65use cumulus_pallet_parachain_system::{
66 DefaultCoreSelector, RelayNumberMonotonicallyIncreases, RelaychainDataProvider,
67};
68#[cfg(any(feature = "runtime-benchmarks", feature = "test"))]
69use frame_support::traits::MapSuccess;
70use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
71#[cfg(any(feature = "runtime-benchmarks", feature = "test"))]
72use sp_runtime::traits::Replace;
73use sp_runtime::{
74 generic, impl_opaque_keys,
75 traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, IdentityLookup},
76 transaction_validity::{TransactionSource, TransactionValidity},
77 ApplyExtrinsicResult, DispatchError,
78};
79
80use pallet_collective::Members;
81
82#[cfg(any(feature = "runtime-benchmarks", feature = "test"))]
83use pallet_collective::ProposalCount;
84
85use parity_scale_codec::Encode;
86
87#[cfg(feature = "std")]
88use sp_version::NativeVersion;
89
90use sp_version::RuntimeVersion;
91use static_assertions::const_assert;
92
93use common_primitives::{
94 handles::{
95 BaseHandle, CheckHandleResponse, DisplayHandle, HandleResponse, PresumptiveSuffixesResponse,
96 },
97 messages::MessageResponse,
98 msa::{
99 AccountId20Response, DelegationResponse, DelegationValidator, DelegatorId, MessageSourceId,
100 ProviderId, SchemaGrant, SchemaGrantValidator, H160,
101 },
102 node::{
103 AccountId, Address, Balance, BlockNumber, Hash, Header, Index, ProposalProvider, Signature,
104 UtilityProvider,
105 },
106 rpc::RpcEvent,
107 schema::{PayloadLocation, SchemaId, SchemaResponse, SchemaVersionResponse},
108 stateful_storage::{ItemizedStoragePageResponse, PaginatedStorageResponse},
109};
110
111pub use common_runtime::{
112 constants::{
113 currency::{CENTS, EXISTENTIAL_DEPOSIT},
114 *,
115 },
116 fee::WeightToFee,
117 prod_or_testnet_or_local,
118 proxy::ProxyType,
119};
120
121use frame_support::{
122 construct_runtime,
123 dispatch::{DispatchClass, GetDispatchInfo, Pays},
124 genesis_builder_helper::{build_state, get_preset},
125 pallet_prelude::DispatchResultWithPostInfo,
126 parameter_types,
127 traits::{
128 fungible::HoldConsideration,
129 schedule::LOWEST_PRIORITY,
130 tokens::{PayFromAccount, UnityAssetBalanceConversion},
131 ConstBool, ConstU128, ConstU32, ConstU64, EitherOfDiverse, EnsureOrigin,
132 EqualPrivilegeOnly, GetStorageVersion, InstanceFilter, LinearStoragePrice,
133 OnRuntimeUpgrade,
134 },
135 weights::{constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight},
136 Twox128,
137};
138
139use frame_system::{
140 limits::{BlockLength, BlockWeights},
141 EnsureRoot, EnsureSigned,
142};
143
144use alloc::{boxed::Box, vec, vec::Vec};
145
146pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
147pub use sp_runtime::Perbill;
148
149#[cfg(any(feature = "std", test))]
150pub use sp_runtime::BuildStorage;
151
152pub use pallet_capacity;
153pub use pallet_frequency_tx_payment::{capacity_stable_weights, types::GetStableWeight};
154pub use pallet_msa;
155pub use pallet_passkey;
156pub use pallet_schemas;
157pub use pallet_time_release::types::{ScheduleName, SchedulerProviderTrait};
158
159use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
161
162use common_primitives::capacity::UnclaimedRewardInfo;
163use common_runtime::weights::rocksdb_weights::constants::RocksDbWeight;
164pub use common_runtime::{
165 constants::MaxSchemaGrants,
166 weights,
167 weights::{block_weights::BlockExecutionWeight, extrinsic_weights::ExtrinsicBaseWeight},
168};
169use frame_support::traits::Contains;
170#[cfg(feature = "try-runtime")]
171use frame_support::traits::{TryStateSelect, UpgradeCheckSelect};
172
173mod ethereum;
174mod genesis;
175
176pub mod polkadot_xcm_fee {
177 use crate::{Balance, ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND};
178 pub const MICRO_DOT: Balance = 10_000;
179 pub const MILLI_DOT: Balance = 1_000 * MICRO_DOT;
180
181 pub fn default_fee_per_second() -> u128 {
182 let base_weight = Balance::from(ExtrinsicBaseWeight::get().ref_time());
183 let base_tx_per_second = (WEIGHT_REF_TIME_PER_SECOND as u128) / base_weight;
184 base_tx_per_second * base_relay_tx_fee()
185 }
186
187 pub fn base_relay_tx_fee() -> Balance {
188 MILLI_DOT
189 }
190}
191
192pub struct SchedulerProvider;
193
194impl SchedulerProviderTrait<RuntimeOrigin, BlockNumber, RuntimeCall> for SchedulerProvider {
195 fn schedule(
196 origin: RuntimeOrigin,
197 id: ScheduleName,
198 when: BlockNumber,
199 call: Box<RuntimeCall>,
200 ) -> Result<(), DispatchError> {
201 Scheduler::schedule_named(origin, id, when, None, LOWEST_PRIORITY, call)?;
202
203 Ok(())
204 }
205
206 fn cancel(origin: RuntimeOrigin, id: [u8; 32]) -> Result<(), DispatchError> {
207 Scheduler::cancel_named(origin, id)?;
208
209 Ok(())
210 }
211}
212
213pub struct CouncilProposalProvider;
214
215impl ProposalProvider<AccountId, RuntimeCall> for CouncilProposalProvider {
216 fn propose(
217 who: AccountId,
218 threshold: u32,
219 proposal: Box<RuntimeCall>,
220 ) -> Result<(u32, u32), DispatchError> {
221 let length_bound: u32 = proposal.using_encoded(|p| p.len() as u32);
222 Council::do_propose_proposed(who, threshold, proposal, length_bound)
223 }
224
225 fn propose_with_simple_majority(
226 who: AccountId,
227 proposal: Box<RuntimeCall>,
228 ) -> Result<(u32, u32), DispatchError> {
229 let members = Members::<Runtime, CouncilCollective>::get();
230 let threshold: u32 = ((members.len() / 2) + 1) as u32;
231 let length_bound: u32 = proposal.using_encoded(|p| p.len() as u32);
232 Council::do_propose_proposed(who, threshold, proposal, length_bound)
233 }
234
235 #[cfg(any(feature = "runtime-benchmarks", feature = "test"))]
236 fn proposal_count() -> u32 {
237 ProposalCount::<Runtime, CouncilCollective>::get()
238 }
239}
240
241pub struct CapacityBatchProvider;
242
243impl UtilityProvider<RuntimeOrigin, RuntimeCall> for CapacityBatchProvider {
244 fn batch_all(origin: RuntimeOrigin, calls: Vec<RuntimeCall>) -> DispatchResultWithPostInfo {
245 Utility::batch_all(origin, calls)
246 }
247}
248
249pub struct BaseCallFilter;
251
252impl Contains<RuntimeCall> for BaseCallFilter {
253 fn contains(call: &RuntimeCall) -> bool {
254 #[cfg(not(feature = "frequency"))]
255 {
256 match call {
257 RuntimeCall::Utility(pallet_utility_call) =>
258 Self::is_utility_call_allowed(pallet_utility_call),
259 _ => true,
260 }
261 }
262 #[cfg(feature = "frequency")]
263 {
264 match call {
265 RuntimeCall::Utility(pallet_utility_call) =>
266 Self::is_utility_call_allowed(pallet_utility_call),
267 RuntimeCall::Msa(pallet_msa::Call::create_provider { .. }) => false,
269 RuntimeCall::Schemas(pallet_schemas::Call::create_schema_v3 { .. }) => false,
270 #[cfg(feature = "frequency-bridging")]
271 RuntimeCall::PolkadotXcm(pallet_xcm_call) => Self::is_xcm_call_allowed(pallet_xcm_call),
272 _ => true,
274 }
275 }
276 }
277}
278
279impl BaseCallFilter {
280 #[cfg(all(feature = "frequency", feature = "frequency-bridging"))]
281 fn is_xcm_call_allowed(call: &pallet_xcm::Call<Runtime>) -> bool {
282 !matches!(
283 call,
284 pallet_xcm::Call::transfer_assets { .. } |
285 pallet_xcm::Call::teleport_assets { .. } |
286 pallet_xcm::Call::limited_teleport_assets { .. } |
287 pallet_xcm::Call::reserve_transfer_assets { .. } |
288 pallet_xcm::Call::add_authorized_alias { .. } |
289 pallet_xcm::Call::remove_authorized_alias { .. } |
290 pallet_xcm::Call::remove_all_authorized_aliases { .. }
291 )
292 }
293
294 fn is_utility_call_allowed(call: &pallet_utility::Call<Runtime>) -> bool {
295 match call {
296 pallet_utility::Call::batch { calls, .. } |
297 pallet_utility::Call::batch_all { calls, .. } |
298 pallet_utility::Call::force_batch { calls, .. } => calls.iter().any(Self::is_batch_call_allowed),
299 _ => true,
300 }
301 }
302
303 fn is_batch_call_allowed(call: &RuntimeCall) -> bool {
304 match call {
305 RuntimeCall::Utility(pallet_utility::Call::batch { .. }) |
307 RuntimeCall::Utility(pallet_utility::Call::batch_all { .. }) |
308 RuntimeCall::Utility(pallet_utility::Call::force_batch { .. }) => false,
309
310 RuntimeCall::FrequencyTxPayment(..) => false,
312
313 RuntimeCall::Msa(pallet_msa::Call::create_provider { .. }) |
315 RuntimeCall::Schemas(pallet_schemas::Call::create_schema_v3 { .. }) => false,
316
317 _ if Self::is_pays_no_call(call) => false,
319
320 _ => true,
322 }
323 }
324
325 fn is_pays_no_call(call: &RuntimeCall) -> bool {
326 call.get_dispatch_info().pays_fee == Pays::No
327 }
328}
329
330impl InstanceFilter<RuntimeCall> for ProxyType {
332 fn filter(&self, c: &RuntimeCall) -> bool {
333 match self {
334 ProxyType::Any => true,
335 ProxyType::NonTransfer => matches!(
336 c,
337 RuntimeCall::Capacity(..)
340 | RuntimeCall::CollatorSelection(..)
341 | RuntimeCall::Council(..)
342 | RuntimeCall::Democracy(..)
343 | RuntimeCall::FrequencyTxPayment(..) | RuntimeCall::Handles(..)
345 | RuntimeCall::Messages(..)
346 | RuntimeCall::Msa(..)
347 | RuntimeCall::Multisig(..)
348 | RuntimeCall::Preimage(..)
350 | RuntimeCall::Scheduler(..)
351 | RuntimeCall::Schemas(..)
352 | RuntimeCall::Session(..)
353 | RuntimeCall::StatefulStorage(..)
354 | RuntimeCall::TechnicalCommittee(..)
357 | RuntimeCall::TimeRelease(pallet_time_release::Call::claim{..})
359 | RuntimeCall::TimeRelease(pallet_time_release::Call::claim_for{..})
360 | RuntimeCall::Treasury(..)
362 | RuntimeCall::Utility(..) ),
364 ProxyType::Governance => matches!(
365 c,
366 RuntimeCall::Treasury(..) |
367 RuntimeCall::Democracy(..) |
368 RuntimeCall::TechnicalCommittee(..) |
369 RuntimeCall::Council(..) |
370 RuntimeCall::Utility(..) ),
372 ProxyType::Staking => {
373 matches!(
374 c,
375 RuntimeCall::Capacity(pallet_capacity::Call::stake { .. }) |
376 RuntimeCall::CollatorSelection(
377 pallet_collator_selection::Call::set_candidacy_bond { .. }
378 )
379 )
380 },
381 ProxyType::CancelProxy => {
382 matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }))
383 },
384 }
385 }
386 fn is_superset(&self, o: &Self) -> bool {
387 match (self, o) {
388 (x, y) if x == y => true,
389 (ProxyType::Any, _) => true,
390 (_, ProxyType::Any) => false,
391 (ProxyType::NonTransfer, _) => true,
392 _ => false,
393 }
394 }
395}
396
397pub struct PasskeyCallFilter;
399
400impl Contains<RuntimeCall> for PasskeyCallFilter {
401 fn contains(call: &RuntimeCall) -> bool {
402 match call {
403 #[cfg(feature = "runtime-benchmarks")]
404 RuntimeCall::System(frame_system::Call::remark { .. }) => true,
405
406 RuntimeCall::Balances(_) | RuntimeCall::Capacity(_) => true,
407 _ => false,
408 }
409 }
410}
411
412pub struct MsaCallFilter;
413use pallet_frequency_tx_payment::types::GetAddKeyData;
414impl GetAddKeyData<RuntimeCall, AccountId, MessageSourceId> for MsaCallFilter {
415 fn get_add_key_data(call: &RuntimeCall) -> Option<(AccountId, AccountId, MessageSourceId)> {
416 match call {
417 RuntimeCall::Msa(MsaCall::add_public_key_to_msa {
418 add_key_payload,
419 new_key_owner_proof: _,
420 msa_owner_public_key,
421 msa_owner_proof: _,
422 }) => {
423 let new_key = add_key_payload.clone().new_public_key;
424 Some((msa_owner_public_key.clone(), new_key, add_key_payload.msa_id))
425 },
426 _ => None,
427 }
428 }
429}
430
431pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
433 Runtime,
434 (
435 frame_system::CheckNonZeroSender<Runtime>,
436 (frame_system::CheckSpecVersion<Runtime>, frame_system::CheckTxVersion<Runtime>),
438 frame_system::CheckGenesis<Runtime>,
439 frame_system::CheckEra<Runtime>,
440 common_runtime::extensions::check_nonce::CheckNonce<Runtime>,
441 pallet_frequency_tx_payment::ChargeFrqTransactionPayment<Runtime>,
442 pallet_msa::CheckFreeExtrinsicUse<Runtime>,
443 pallet_handles::handles_signed_extension::HandlesSignedExtension<Runtime>,
444 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
445 frame_system::CheckWeight<Runtime>,
446 ),
447>;
448
449pub type SignedBlock = generic::SignedBlock<Block>;
451
452pub type BlockId = generic::BlockId<Block>;
454
455pub type Block = generic::Block<Header, UncheckedExtrinsic>;
457
458#[cfg(feature = "frequency-bridging")]
459pub type AssetBalance = Balance;
460
461pub type UncheckedExtrinsic =
463 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
464
465#[cfg(feature = "frequency-bridging")]
467pub type Executive = frame_executive::Executive<
468 Runtime,
469 Block,
470 frame_system::ChainContext<Runtime>,
471 Runtime,
472 AllPalletsWithSystem,
473 (MigratePalletsCurrentStorage<Runtime>, SetSafeXcmVersion<Runtime>),
474>;
475
476#[cfg(not(feature = "frequency-bridging"))]
477pub type Executive = frame_executive::Executive<
478 Runtime,
479 Block,
480 frame_system::ChainContext<Runtime>,
481 Runtime,
482 AllPalletsWithSystem,
483 (MigratePalletsCurrentStorage<Runtime>,),
484>;
485
486pub struct MigratePalletsCurrentStorage<T>(core::marker::PhantomData<T>);
487
488impl<T: pallet_collator_selection::Config> OnRuntimeUpgrade for MigratePalletsCurrentStorage<T> {
489 fn on_runtime_upgrade() -> Weight {
490 use sp_core::Get;
491
492 if pallet_collator_selection::Pallet::<T>::on_chain_storage_version() !=
493 pallet_collator_selection::Pallet::<T>::in_code_storage_version()
494 {
495 pallet_collator_selection::Pallet::<T>::in_code_storage_version()
496 .put::<pallet_collator_selection::Pallet<T>>();
497
498 log::info!("Setting version on pallet_collator_selection");
499 }
500
501 T::DbWeight::get().reads_writes(1, 1)
502 }
503}
504
505pub struct SetSafeXcmVersion<T>(core::marker::PhantomData<T>);
507
508#[cfg(feature = "frequency-bridging")]
509use common_runtime::constants::xcm_version::SAFE_XCM_VERSION;
510
511#[cfg(feature = "frequency-bridging")]
512impl<T: pallet_xcm::Config> OnRuntimeUpgrade for SetSafeXcmVersion<T> {
513 fn on_runtime_upgrade() -> Weight {
514 use sp_core::Get;
515
516 let storage_key = frame_support::storage::storage_prefix(b"PolkadotXcm", b"SafeXcmVersion");
518 log::info!("Checking SafeXcmVersion in storage with key: {storage_key:?}");
519
520 let current_version = frame_support::storage::unhashed::get::<u32>(&storage_key);
521 match current_version {
522 Some(version) if version == SAFE_XCM_VERSION => {
523 log::info!("SafeXcmVersion already set to {version}, skipping migration.");
524 T::DbWeight::get().reads(1)
525 },
526 Some(version) => {
527 log::info!(
528 "SafeXcmVersion currently set to {version}, updating to {SAFE_XCM_VERSION}"
529 );
530 frame_support::storage::unhashed::put(&storage_key, &(SAFE_XCM_VERSION));
532 T::DbWeight::get().reads(1).saturating_add(T::DbWeight::get().writes(1))
533 },
534 None => {
535 log::info!("SafeXcmVersion not set, setting to {SAFE_XCM_VERSION}");
536 frame_support::storage::unhashed::put(&storage_key, &(SAFE_XCM_VERSION));
538 T::DbWeight::get().reads(1).saturating_add(T::DbWeight::get().writes(1))
539 },
540 }
541 }
542
543 #[cfg(feature = "try-runtime")]
544 fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
545 use parity_scale_codec::Encode;
546
547 pallet_xcm::Pallet::<T>::do_try_state()?;
549 log::info!("pre_upgrade: PolkadotXcm pallet state is valid before migration");
550
551 let storage_key = frame_support::storage::storage_prefix(b"PolkadotXcm", b"SafeXcmVersion");
553 let current_version = frame_support::storage::unhashed::get::<u32>(&storage_key);
554
555 log::info!("pre_upgrade: Current SafeXcmVersion = {:?}", current_version);
556
557 Ok(current_version.encode())
559 }
560
561 #[cfg(feature = "try-runtime")]
562 fn post_upgrade(state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
563 use parity_scale_codec::Decode;
564
565 let pre_upgrade_version = Option::<u32>::decode(&mut &state[..])
567 .map_err(|_| "Failed to decode pre-upgrade state")?;
568
569 let storage_key = frame_support::storage::storage_prefix(b"PolkadotXcm", b"SafeXcmVersion");
570 let current_version = frame_support::storage::unhashed::get::<u32>(&storage_key);
571
572 log::info!(
573 "post_upgrade: Pre-upgrade version = {:?}, Current version = {:?}",
574 pre_upgrade_version,
575 current_version
576 );
577
578 match current_version {
580 Some(version) if version == SAFE_XCM_VERSION => {
581 log::info!(
582 "post_upgrade: Migration successful - SafeXcmVersion correctly set to {}",
583 version
584 );
585 },
586 Some(version) => {
587 log::error!("post_upgrade: Migration failed - SafeXcmVersion was set to {}, but expected {}", version, SAFE_XCM_VERSION);
588 return Err(sp_runtime::TryRuntimeError::Other(
589 "SafeXcmVersion was set to incorrect version after migration",
590 ));
591 },
592 None => {
593 return Err(sp_runtime::TryRuntimeError::Other(
594 "SafeXcmVersion should be set after migration but found None",
595 ));
596 },
597 }
598
599 pallet_xcm::Pallet::<T>::do_try_state()?;
601 log::info!("post_upgrade: PolkadotXcm pallet state is valid after migration");
602
603 Ok(())
604 }
605}
606
607pub mod opaque {
612 use super::*;
613 use sp_runtime::{
614 generic,
615 traits::{BlakeTwo256, Hash as HashT},
616 };
617
618 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
619 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
621 pub type Block = generic::Block<Header, UncheckedExtrinsic>;
623 pub type BlockId = generic::BlockId<Block>;
625 pub type Hash = <BlakeTwo256 as HashT>::Output;
627}
628
629impl_opaque_keys! {
630 pub struct SessionKeys {
631 pub aura: Aura,
632 }
633}
634
635#[cfg(feature = "frequency")]
637#[sp_version::runtime_version]
638pub const VERSION: RuntimeVersion = RuntimeVersion {
639 spec_name: Cow::Borrowed("frequency"),
640 impl_name: Cow::Borrowed("frequency"),
641 authoring_version: 1,
642 spec_version: 176,
643 impl_version: 0,
644 apis: RUNTIME_API_VERSIONS,
645 transaction_version: 1,
646 system_version: 1,
647};
648
649#[cfg(not(feature = "frequency"))]
651#[sp_version::runtime_version]
652pub const VERSION: RuntimeVersion = RuntimeVersion {
653 spec_name: Cow::Borrowed("frequency-testnet"),
654 impl_name: Cow::Borrowed("frequency"),
655 authoring_version: 1,
656 spec_version: 176,
657 impl_version: 0,
658 apis: RUNTIME_API_VERSIONS,
659 transaction_version: 1,
660 system_version: 1,
661};
662
663#[cfg(feature = "std")]
665pub fn native_version() -> NativeVersion {
666 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
667}
668
669parameter_types! {
671 pub const Version: RuntimeVersion = VERSION;
672
673 pub RuntimeBlockLength: BlockLength =
678 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
679
680 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
681 .base_block(BlockExecutionWeight::get())
682 .for_class(DispatchClass::all(), |weights| {
683 weights.base_extrinsic = ExtrinsicBaseWeight::get();
684 })
685 .for_class(DispatchClass::Normal, |weights| {
686 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
687 })
688 .for_class(DispatchClass::Operational, |weights| {
689 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
690 weights.reserved = Some(
693 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
694 );
695 })
696 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
697 .build_or_panic();
698}
699
700#[cfg(feature = "frequency-bridging")]
702parameter_types! {
703 pub const AssetDeposit: Balance = 0;
704 pub const AssetAccountDeposit: Balance = 0;
705 pub const MetadataDepositBase: Balance = 0;
706 pub const MetadataDepositPerByte: Balance = 0;
707 pub const ApprovalDeposit: Balance = 0;
708 pub const AssetsStringLimit: u32 = 50;
709
710 pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get();
712 pub const ForeignAssetsAssetAccountDeposit: Balance = AssetAccountDeposit::get();
713 pub const ForeignAssetsApprovalDeposit: Balance = ApprovalDeposit::get();
714 pub const ForeignAssetsAssetsStringLimit: u32 = AssetsStringLimit::get();
715 pub const ForeignAssetsMetadataDepositBase: Balance = MetadataDepositBase::get();
716 pub const ForeignAssetsMetadataDepositPerByte: Balance = MetadataDepositPerByte::get();
717}
718
719impl frame_system::Config for Runtime {
722 type RuntimeTask = RuntimeTask;
723 type AccountId = AccountId;
725 type BaseCallFilter = BaseCallFilter;
728 type RuntimeCall = RuntimeCall;
730 type Lookup = EthereumCompatibleAccountIdLookup<AccountId, ()>;
732 type Nonce = Index;
734 type Block = Block;
736 type Hash = Hash;
738 type Hashing = BlakeTwo256;
740 type RuntimeEvent = RuntimeEvent;
742 type RuntimeOrigin = RuntimeOrigin;
744 type BlockHashCount = BlockHashCount;
746 type Version = Version;
748 type PalletInfo = PalletInfo;
750 type AccountData = pallet_balances::AccountData<Balance>;
752 type OnNewAccount = ();
754 type OnKilledAccount = ();
756 type DbWeight = RocksDbWeight;
758 type SystemWeightInfo = ();
760 type BlockWeights = RuntimeBlockWeights;
762 type BlockLength = RuntimeBlockLength;
764 type SS58Prefix = Ss58Prefix;
766 #[cfg(any(
768 not(feature = "frequency-no-relay"),
769 feature = "frequency-lint-check",
770 feature = "frequency-bridging"
771 ))]
772 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
773 #[cfg(feature = "frequency-no-relay")]
774 type OnSetCode = ();
775 type MaxConsumers = FrameSystemMaxConsumers;
776 type SingleBlockMigrations = ();
778 type MultiBlockMigrator = ();
780 type PreInherents = ();
782 type PostInherents = ();
784 type PostTransactions = ();
786 type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
787}
788
789impl pallet_msa::Config for Runtime {
790 type RuntimeEvent = RuntimeEvent;
791 type WeightInfo = pallet_msa::weights::SubstrateWeight<Runtime>;
792 type ConvertIntoAccountId32 = ConvertInto;
794 type MaxPublicKeysPerMsa = MsaMaxPublicKeysPerMsa;
796 type MaxSchemaGrantsPerDelegation = MaxSchemaGrants;
798 type MaxProviderNameSize = MsaMaxProviderNameSize;
800 type SchemaValidator = Schemas;
802 type HandleProvider = Handles;
804 type MortalityWindowSize = MSAMortalityWindowSize;
806 type MaxSignaturesStored = MSAMaxSignaturesStored;
808 type Proposal = RuntimeCall;
810 type ProposalProvider = CouncilProposalProvider;
812 #[cfg(any(feature = "frequency", feature = "runtime-benchmarks"))]
814 type RecoveryProviderApprovalOrigin = EitherOfDiverse<
815 EnsureRoot<AccountId>,
816 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>,
817 >;
818 #[cfg(not(any(feature = "frequency", feature = "runtime-benchmarks")))]
819 type RecoveryProviderApprovalOrigin = EnsureSigned<AccountId>;
820 type CreateProviderViaGovernanceOrigin = EitherOfDiverse<
822 EnsureRoot<AccountId>,
823 pallet_collective::EnsureMembers<AccountId, CouncilCollective, 1>,
824 >;
825 type Currency = Balances;
827}
828
829parameter_types! {
830 pub const ProviderBoostHistoryLimit : u32 = 30;
832 pub const RewardPoolChunkLength: u32 = 5;
834}
835const_assert!(ProviderBoostHistoryLimit::get() % RewardPoolChunkLength::get() == 0);
837
838impl pallet_capacity::Config for Runtime {
839 type RuntimeEvent = RuntimeEvent;
840 type WeightInfo = pallet_capacity::weights::SubstrateWeight<Runtime>;
841 type Currency = Balances;
842 type MinimumStakingAmount = CapacityMinimumStakingAmount;
843 type MinimumTokenBalance = CapacityMinimumTokenBalance;
844 type TargetValidator = Msa;
845 type MaxUnlockingChunks = CapacityMaxUnlockingChunks;
846 #[cfg(feature = "runtime-benchmarks")]
847 type BenchmarkHelper = Msa;
848 type UnstakingThawPeriod = CapacityUnstakingThawPeriod;
849 type MaxEpochLength = CapacityMaxEpochLength;
850 type EpochNumber = u32;
851 type CapacityPerToken = CapacityPerToken;
852 type RuntimeFreezeReason = RuntimeFreezeReason;
853 type EraLength = CapacityRewardEraLength;
854 type ProviderBoostHistoryLimit = ProviderBoostHistoryLimit;
855 type RewardsProvider = Capacity;
856 type MaxRetargetsPerRewardEra = ConstU32<2>;
857 type RewardPoolPerEra = ConstU128<{ currency::CENTS.saturating_mul(153_424_650u128) }>;
859 type RewardPercentCap = CapacityRewardCap;
860 type RewardPoolChunkLength = RewardPoolChunkLength;
862}
863
864impl pallet_schemas::Config for Runtime {
865 type RuntimeEvent = RuntimeEvent;
866 type WeightInfo = pallet_schemas::weights::SubstrateWeight<Runtime>;
867 type MinSchemaModelSizeBytes = SchemasMinModelSizeBytes;
869 type MaxSchemaRegistrations = SchemasMaxRegistrations;
871 type SchemaModelMaxBytesBoundedVecLimit = SchemasMaxBytesBoundedVecLimit;
873 type Proposal = RuntimeCall;
875 type ProposalProvider = CouncilProposalProvider;
877 type CreateSchemaViaGovernanceOrigin = EitherOfDiverse<
879 EnsureRoot<AccountId>,
880 pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
881 >;
882 type MaxSchemaSettingsPerSchema = MaxSchemaSettingsPerSchema;
884}
885
886pub type DepositBase = ConstU128<{ currency::deposit(1, 88) }>;
888pub type DepositFactor = ConstU128<{ currency::deposit(0, 32) }>;
890pub type MaxSignatories = ConstU32<100>;
891
892impl pallet_multisig::Config for Runtime {
895 type BlockNumberProvider = System;
896 type RuntimeEvent = RuntimeEvent;
897 type RuntimeCall = RuntimeCall;
898 type Currency = Balances;
899 type DepositBase = DepositBase;
900 type DepositFactor = DepositFactor;
901 type MaxSignatories = MaxSignatories;
902 type WeightInfo = weights::pallet_multisig::SubstrateWeight<Runtime>;
903}
904
905impl cumulus_pallet_weight_reclaim::Config for Runtime {
906 type WeightInfo = weights::cumulus_pallet_weight_reclaim::SubstrateWeight<Runtime>;
907}
908
909pub type MaxReleaseSchedules = ConstU32<{ MAX_RELEASE_SCHEDULES }>;
911
912pub struct EnsureTimeReleaseOrigin;
913
914impl EnsureOrigin<RuntimeOrigin> for EnsureTimeReleaseOrigin {
915 type Success = AccountId;
916
917 fn try_origin(o: RuntimeOrigin) -> Result<Self::Success, RuntimeOrigin> {
918 match o.clone().into() {
919 Ok(pallet_time_release::Origin::<Runtime>::TimeRelease(who)) => Ok(who),
920 _ => Err(o),
921 }
922 }
923
924 #[cfg(feature = "runtime-benchmarks")]
925 fn try_successful_origin() -> Result<RuntimeOrigin, ()> {
926 Ok(RuntimeOrigin::root())
927 }
928}
929
930impl pallet_time_release::Config for Runtime {
933 type RuntimeEvent = RuntimeEvent;
934 type Balance = Balance;
935 type Currency = Balances;
936 type RuntimeOrigin = RuntimeOrigin;
937 type RuntimeHoldReason = RuntimeHoldReason;
938 type MinReleaseTransfer = MinReleaseTransfer;
939 type TransferOrigin = EnsureSigned<AccountId>;
940 type WeightInfo = pallet_time_release::weights::SubstrateWeight<Runtime>;
941 type MaxReleaseSchedules = MaxReleaseSchedules;
942 #[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check"))]
943 type BlockNumberProvider = RelaychainDataProvider<Runtime>;
944 #[cfg(feature = "frequency-no-relay")]
945 type BlockNumberProvider = System;
946 type RuntimeFreezeReason = RuntimeFreezeReason;
947 type SchedulerProvider = SchedulerProvider;
948 type RuntimeCall = RuntimeCall;
949 type TimeReleaseOrigin = EnsureTimeReleaseOrigin;
950}
951
952impl pallet_timestamp::Config for Runtime {
955 type Moment = u64;
957 #[cfg(not(feature = "frequency-no-relay"))]
958 type OnTimestampSet = Aura;
959 #[cfg(feature = "frequency-no-relay")]
960 type OnTimestampSet = ();
961 type MinimumPeriod = MinimumPeriod;
962 type WeightInfo = weights::pallet_timestamp::SubstrateWeight<Runtime>;
963}
964
965impl pallet_authorship::Config for Runtime {
968 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
969 type EventHandler = (CollatorSelection,);
970}
971
972parameter_types! {
973 pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;
974}
975
976impl pallet_balances::Config for Runtime {
977 type MaxLocks = BalancesMaxLocks;
978 type Balance = Balance;
980 type RuntimeEvent = RuntimeEvent;
982 type DustRemoval = ();
983 type ExistentialDeposit = ExistentialDeposit;
984 type AccountStore = System;
985 type WeightInfo = weights::pallet_balances::SubstrateWeight<Runtime>;
986 type MaxReserves = BalancesMaxReserves;
987 type ReserveIdentifier = [u8; 8];
988 type MaxFreezes = BalancesMaxFreezes;
989 type RuntimeHoldReason = RuntimeHoldReason;
990 type RuntimeFreezeReason = RuntimeFreezeReason;
991 type FreezeIdentifier = RuntimeFreezeReason;
992 type DoneSlashHandler = ();
993}
994parameter_types! {
996 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(30) * RuntimeBlockWeights::get().max_block;
998 pub MaxCollectivesProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
999}
1000
1001impl pallet_scheduler::Config for Runtime {
1003 type BlockNumberProvider = System;
1004 type RuntimeEvent = RuntimeEvent;
1005 type RuntimeOrigin = RuntimeOrigin;
1006 type PalletsOrigin = OriginCaller;
1007 type RuntimeCall = RuntimeCall;
1008 type MaximumWeight = MaximumSchedulerWeight;
1009 type ScheduleOrigin = EitherOfDiverse<
1012 EitherOfDiverse<
1013 EnsureRoot<AccountId>,
1014 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
1015 >,
1016 EnsureTimeReleaseOrigin,
1017 >;
1018
1019 type MaxScheduledPerBlock = SchedulerMaxScheduledPerBlock;
1020 type WeightInfo = weights::pallet_scheduler::SubstrateWeight<Runtime>;
1021 type OriginPrivilegeCmp = EqualPrivilegeOnly;
1022 type Preimages = Preimage;
1023}
1024
1025parameter_types! {
1026 pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
1027}
1028
1029impl pallet_preimage::Config for Runtime {
1032 type WeightInfo = weights::pallet_preimage::SubstrateWeight<Runtime>;
1033 type RuntimeEvent = RuntimeEvent;
1034 type Currency = Balances;
1035 type ManagerOrigin = EitherOfDiverse<
1037 EnsureRoot<AccountId>,
1038 pallet_collective::EnsureMember<AccountId, TechnicalCommitteeCollective>,
1039 >;
1040
1041 type Consideration = HoldConsideration<
1042 AccountId,
1043 Balances,
1044 PreimageHoldReason,
1045 LinearStoragePrice<PreimageBaseDeposit, PreimageByteDeposit, Balance>,
1046 >;
1047}
1048
1049type CouncilCollective = pallet_collective::Instance1;
1052impl pallet_collective::Config<CouncilCollective> for Runtime {
1053 type RuntimeOrigin = RuntimeOrigin;
1054 type Proposal = RuntimeCall;
1055 type RuntimeEvent = RuntimeEvent;
1056 type MotionDuration = CouncilMotionDuration;
1057 type MaxProposals = CouncilMaxProposals;
1058 type MaxMembers = CouncilMaxMembers;
1059 type DefaultVote = pallet_collective::PrimeDefaultVote;
1060 type WeightInfo = weights::pallet_collective_council::SubstrateWeight<Runtime>;
1061 type SetMembersOrigin = EnsureRoot<Self::AccountId>;
1062 type MaxProposalWeight = MaxCollectivesProposalWeight;
1063 type DisapproveOrigin = EitherOfDiverse<
1064 EnsureRoot<AccountId>,
1065 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>,
1066 >;
1067 type KillOrigin = EitherOfDiverse<
1068 EnsureRoot<AccountId>,
1069 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>,
1070 >;
1071 type Consideration = ();
1072}
1073
1074type TechnicalCommitteeCollective = pallet_collective::Instance2;
1075impl pallet_collective::Config<TechnicalCommitteeCollective> for Runtime {
1076 type RuntimeOrigin = RuntimeOrigin;
1077 type Proposal = RuntimeCall;
1078 type RuntimeEvent = RuntimeEvent;
1079 type MotionDuration = TCMotionDuration;
1080 type MaxProposals = TCMaxProposals;
1081 type MaxMembers = TCMaxMembers;
1082 type DefaultVote = pallet_collective::PrimeDefaultVote;
1083 type WeightInfo = weights::pallet_collective_technical_committee::SubstrateWeight<Runtime>;
1084 type SetMembersOrigin = EnsureRoot<Self::AccountId>;
1085 type MaxProposalWeight = MaxCollectivesProposalWeight;
1086 type DisapproveOrigin = EitherOfDiverse<
1087 EnsureRoot<AccountId>,
1088 pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCommitteeCollective, 2, 3>,
1089 >;
1090 type KillOrigin = EitherOfDiverse<
1091 EnsureRoot<AccountId>,
1092 pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCommitteeCollective, 2, 3>,
1093 >;
1094 type Consideration = ();
1095}
1096
1097impl pallet_democracy::Config for Runtime {
1100 type CooloffPeriod = CooloffPeriod;
1101 type Currency = Balances;
1102 type EnactmentPeriod = EnactmentPeriod;
1103 type RuntimeEvent = RuntimeEvent;
1104 type FastTrackVotingPeriod = FastTrackVotingPeriod;
1105 type InstantAllowed = ConstBool<true>;
1106 type LaunchPeriod = LaunchPeriod;
1107 type MaxProposals = DemocracyMaxProposals;
1108 type MaxVotes = DemocracyMaxVotes;
1109 type MinimumDeposit = MinimumDeposit;
1110 type Scheduler = Scheduler;
1111 type Slash = ();
1112 type WeightInfo = weights::pallet_democracy::SubstrateWeight<Runtime>;
1114 type VoteLockingPeriod = EnactmentPeriod;
1115 type VotingPeriod = VotingPeriod;
1117 type Preimages = Preimage;
1118 type MaxDeposits = ConstU32<100>;
1119 type MaxBlacklisted = ConstU32<100>;
1120
1121 type ExternalDefaultOrigin = EitherOfDiverse<
1128 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>,
1129 frame_system::EnsureRoot<AccountId>,
1130 >;
1131
1132 type ExternalMajorityOrigin = EitherOfDiverse<
1134 pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
1135 frame_system::EnsureRoot<AccountId>,
1136 >;
1137 type ExternalOrigin = EitherOfDiverse<
1139 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
1140 frame_system::EnsureRoot<AccountId>,
1141 >;
1142 type SubmitOrigin = frame_system::EnsureSigned<AccountId>;
1145
1146 type FastTrackOrigin = EitherOfDiverse<
1149 pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCommitteeCollective, 2, 3>,
1150 frame_system::EnsureRoot<AccountId>,
1151 >;
1152 type InstantOrigin = EitherOfDiverse<
1156 pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCommitteeCollective, 1, 1>,
1157 frame_system::EnsureRoot<AccountId>,
1158 >;
1159 type PalletsOrigin = OriginCaller;
1161
1162 type CancellationOrigin = EitherOfDiverse<
1164 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>,
1165 EnsureRoot<AccountId>,
1166 >;
1167 type CancelProposalOrigin = EitherOfDiverse<
1170 EnsureRoot<AccountId>,
1171 pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCommitteeCollective, 1, 1>,
1172 >;
1173
1174 type BlacklistOrigin = EnsureRoot<AccountId>;
1176
1177 type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCommitteeCollective>;
1180}
1181
1182parameter_types! {
1183 pub TreasuryAccount: AccountId = TreasuryPalletId::get().into_account_truncating();
1184 pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
1185 pub const MaxSpending : Balance = 100_000_000 * UNITS;
1186}
1187
1188impl pallet_treasury::Config for Runtime {
1191 type PalletId = TreasuryPalletId;
1193 type Currency = Balances;
1194 type RuntimeEvent = RuntimeEvent;
1195 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
1196
1197 type ApproveOrigin = EitherOfDiverse<
1201 EnsureRoot<AccountId>,
1202 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 5>,
1203 >;
1204
1205 type RejectOrigin = EitherOfDiverse<
1209 EnsureRoot<AccountId>,
1210 pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
1211 >;
1212
1213 #[cfg(not(feature = "runtime-benchmarks"))]
1216 type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
1217 #[cfg(feature = "runtime-benchmarks")]
1218 type SpendOrigin = MapSuccess<EnsureSigned<AccountId>, Replace<MaxSpending>>;
1219
1220 type OnSlash = ();
1224
1225 type ProposalBond = ProposalBondPercent;
1227
1228 type ProposalBondMinimum = ProposalBondMinimum;
1230
1231 type ProposalBondMaximum = ProposalBondMaximum;
1233
1234 type SpendPeriod = SpendPeriod;
1236
1237 type Burn = ();
1239
1240 type BurnDestination = ();
1243
1244 type SpendFunds = ();
1248
1249 type MaxApprovals = MaxApprovals;
1251
1252 type AssetKind = ();
1253 type Beneficiary = AccountId;
1254 type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
1255 type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
1256 type BalanceConverter = UnityAssetBalanceConversion;
1257 type PayoutPeriod = PayoutSpendPeriod;
1258 #[cfg(feature = "runtime-benchmarks")]
1259 type BenchmarkHelper = ();
1260}
1261
1262impl pallet_transaction_payment::Config for Runtime {
1265 type RuntimeEvent = RuntimeEvent;
1266 type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
1267 type WeightToFee = WeightToFee;
1268 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
1269 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
1270 type OperationalFeeMultiplier = TransactionPaymentOperationalFeeMultiplier;
1271 type WeightInfo = weights::pallet_transaction_payment::SubstrateWeight<Runtime>;
1272}
1273
1274use crate::ethereum::EthereumCompatibleAccountIdLookup;
1275use pallet_frequency_tx_payment::Call as FrequencyPaymentCall;
1276use pallet_handles::Call as HandlesCall;
1277use pallet_messages::Call as MessagesCall;
1278use pallet_msa::Call as MsaCall;
1279use pallet_stateful_storage::Call as StatefulStorageCall;
1280
1281pub struct CapacityEligibleCalls;
1282impl GetStableWeight<RuntimeCall, Weight> for CapacityEligibleCalls {
1283 fn get_stable_weight(call: &RuntimeCall) -> Option<Weight> {
1284 use pallet_frequency_tx_payment::capacity_stable_weights::WeightInfo;
1285 match call {
1286 RuntimeCall::Msa(MsaCall::add_public_key_to_msa { .. }) => Some(
1287 capacity_stable_weights::SubstrateWeight::<Runtime>::add_public_key_to_msa()
1288 ),
1289 RuntimeCall::Msa(MsaCall::create_sponsored_account_with_delegation { add_provider_payload, .. }) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::create_sponsored_account_with_delegation(add_provider_payload.schema_ids.len() as u32)),
1290 RuntimeCall::Msa(MsaCall::grant_delegation { add_provider_payload, .. }) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::grant_delegation(add_provider_payload.schema_ids.len() as u32)),
1291 &RuntimeCall::Msa(MsaCall::add_recovery_commitment { .. }) => Some(
1292 capacity_stable_weights::SubstrateWeight::<Runtime>::add_recovery_commitment()
1293 ),
1294 &RuntimeCall::Msa(MsaCall::recover_account { .. }) => Some(
1295 capacity_stable_weights::SubstrateWeight::<Runtime>::recover_account()
1296 ),
1297 RuntimeCall::Messages(MessagesCall::add_ipfs_message { .. }) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::add_ipfs_message()),
1298 RuntimeCall::Messages(MessagesCall::add_onchain_message { payload, .. }) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::add_onchain_message(payload.len() as u32)),
1299 RuntimeCall::StatefulStorage(StatefulStorageCall::apply_item_actions { actions, ..}) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::apply_item_actions(StatefulStorage::sum_add_actions_bytes(actions))),
1300 RuntimeCall::StatefulStorage(StatefulStorageCall::upsert_page { payload, ..}) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::upsert_page(payload.len() as u32)),
1301 RuntimeCall::StatefulStorage(StatefulStorageCall::delete_page { .. }) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::delete_page()),
1302 RuntimeCall::StatefulStorage(StatefulStorageCall::apply_item_actions_with_signature_v2 { payload, ..}) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::apply_item_actions_with_signature(StatefulStorage::sum_add_actions_bytes(&payload.actions))),
1303 RuntimeCall::StatefulStorage(StatefulStorageCall::upsert_page_with_signature_v2 { payload, ..}) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::upsert_page_with_signature(payload.payload.len() as u32 )),
1304 RuntimeCall::StatefulStorage(StatefulStorageCall::delete_page_with_signature_v2 { .. }) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::delete_page_with_signature()), RuntimeCall::Handles(HandlesCall::claim_handle { payload, .. }) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::claim_handle(payload.base_handle.len() as u32)),
1305 RuntimeCall::Handles(HandlesCall::change_handle { payload, .. }) => Some(capacity_stable_weights::SubstrateWeight::<Runtime>::change_handle(payload.base_handle.len() as u32)),
1306 _ => None,
1307 }
1308 }
1309
1310 fn get_inner_calls(outer_call: &RuntimeCall) -> Option<Vec<&RuntimeCall>> {
1311 match outer_call {
1312 RuntimeCall::FrequencyTxPayment(FrequencyPaymentCall::pay_with_capacity {
1313 call,
1314 ..
1315 }) => Some(vec![call]),
1316 RuntimeCall::FrequencyTxPayment(
1317 FrequencyPaymentCall::pay_with_capacity_batch_all { calls, .. },
1318 ) => Some(calls.iter().collect()),
1319 _ => Some(vec![outer_call]),
1320 }
1321 }
1322}
1323
1324impl pallet_frequency_tx_payment::Config for Runtime {
1325 type RuntimeEvent = RuntimeEvent;
1326 type RuntimeCall = RuntimeCall;
1327 type Capacity = Capacity;
1328 type WeightInfo = pallet_frequency_tx_payment::weights::SubstrateWeight<Runtime>;
1329 type CapacityCalls = CapacityEligibleCalls;
1330 type OnChargeCapacityTransaction = pallet_frequency_tx_payment::CapacityAdapter<Balances, Msa>;
1331 type BatchProvider = CapacityBatchProvider;
1332 type MaximumCapacityBatchLength = MaximumCapacityBatchLength;
1333 type MsaKeyProvider = Msa;
1334 type MsaCallFilter = MsaCallFilter;
1335}
1336
1337impl pallet_passkey::Config for Runtime {
1339 type RuntimeEvent = RuntimeEvent;
1340 type RuntimeCall = RuntimeCall;
1341 type WeightInfo = pallet_passkey::weights::SubstrateWeight<Runtime>;
1342 type ConvertIntoAccountId32 = ConvertInto;
1343 type PasskeyCallFilter = PasskeyCallFilter;
1344 #[cfg(feature = "runtime-benchmarks")]
1345 type Currency = Balances;
1346}
1347
1348#[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check"))]
1349const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
1352
1353#[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check"))]
1354const BLOCK_PROCESSING_VELOCITY: u32 = 1;
1357#[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check"))]
1358const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6_000;
1360
1361#[cfg(any(
1364 not(feature = "frequency-no-relay"),
1365 feature = "frequency-lint-check",
1366 feature = "frequency-bridging"
1367))]
1368impl cumulus_pallet_parachain_system::Config for Runtime {
1369 type RuntimeEvent = RuntimeEvent;
1370 type OnSystemEvent = ();
1371 type SelfParaId = parachain_info::Pallet<Runtime>;
1372
1373 #[cfg(feature = "frequency-bridging")]
1374 type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
1375
1376 #[cfg(not(feature = "frequency-bridging"))]
1377 type DmpQueue = frame_support::traits::EnqueueWithOrigin<(), sp_core::ConstU8<0>>;
1378
1379 #[cfg(not(feature = "frequency-bridging"))]
1380 type ReservedDmpWeight = ();
1381
1382 #[cfg(feature = "frequency-bridging")]
1383 type ReservedDmpWeight = ReservedDmpWeight;
1384
1385 #[cfg(not(feature = "frequency-bridging"))]
1386 type OutboundXcmpMessageSource = ();
1387
1388 #[cfg(feature = "frequency-bridging")]
1389 type OutboundXcmpMessageSource = XcmpQueue;
1390
1391 #[cfg(not(feature = "frequency-bridging"))]
1392 type XcmpMessageHandler = ();
1393
1394 #[cfg(feature = "frequency-bridging")]
1395 type XcmpMessageHandler = XcmpQueue;
1396
1397 #[cfg(not(feature = "frequency-bridging"))]
1398 type ReservedXcmpWeight = ();
1399
1400 #[cfg(feature = "frequency-bridging")]
1401 type ReservedXcmpWeight = ReservedXcmpWeight;
1402
1403 type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
1404 type WeightInfo = ();
1405 type ConsensusHook = ConsensusHook;
1406 type SelectCore = DefaultCoreSelector<Runtime>;
1407}
1408
1409#[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check"))]
1410pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
1411 Runtime,
1412 RELAY_CHAIN_SLOT_DURATION_MILLIS,
1413 BLOCK_PROCESSING_VELOCITY,
1414 UNINCLUDED_SEGMENT_CAPACITY,
1415>;
1416
1417impl parachain_info::Config for Runtime {}
1418
1419impl cumulus_pallet_aura_ext::Config for Runtime {}
1420
1421impl pallet_session::Config for Runtime {
1424 type RuntimeEvent = RuntimeEvent;
1425 type ValidatorId = <Self as frame_system::Config>::AccountId;
1426 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
1428 type ShouldEndSession = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;
1429 type NextSessionRotation = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;
1430 type SessionManager = CollatorSelection;
1431 type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
1433 type Keys = SessionKeys;
1434 type DisablingStrategy = ();
1435 type WeightInfo = weights::pallet_session::SubstrateWeight<Runtime>;
1436}
1437
1438impl pallet_aura::Config for Runtime {
1441 type AuthorityId = AuraId;
1442 type DisabledValidators = ();
1443 type MaxAuthorities = AuraMaxAuthorities;
1444 type AllowMultipleBlocksPerSlot = ConstBool<true>;
1445 type SlotDuration = ConstU64<SLOT_DURATION>;
1446}
1447
1448impl pallet_collator_selection::Config for Runtime {
1451 type RuntimeEvent = RuntimeEvent;
1452 type Currency = Balances;
1453
1454 type UpdateOrigin = EitherOfDiverse<
1457 EnsureRoot<AccountId>,
1458 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 5>,
1459 >;
1460
1461 type PotId = NeverDepositIntoId;
1464
1465 type MaxCandidates = CollatorMaxCandidates;
1469
1470 type MinEligibleCollators = CollatorMinCandidates;
1474
1475 type MaxInvulnerables = CollatorMaxInvulnerables;
1477
1478 type KickThreshold = CollatorKickThreshold;
1481
1482 type ValidatorId = <Self as frame_system::Config>::AccountId;
1484
1485 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
1489
1490 type ValidatorRegistration = Session;
1492
1493 type WeightInfo = weights::pallet_collator_selection::SubstrateWeight<Runtime>;
1494}
1495
1496impl pallet_proxy::Config for Runtime {
1498 type RuntimeEvent = RuntimeEvent;
1499 type RuntimeCall = RuntimeCall;
1500 type Currency = Balances;
1501 type ProxyType = ProxyType;
1502 type ProxyDepositBase = ProxyDepositBase;
1503 type ProxyDepositFactor = ProxyDepositFactor;
1504 type MaxProxies = MaxProxies;
1505 type MaxPending = MaxPending;
1506 type CallHasher = BlakeTwo256;
1507 type AnnouncementDepositBase = AnnouncementDepositBase;
1508 type AnnouncementDepositFactor = AnnouncementDepositFactor;
1509 type WeightInfo = weights::pallet_proxy::SubstrateWeight<Runtime>;
1510 type BlockNumberProvider = System;
1511}
1512
1513impl pallet_messages::Config for Runtime {
1516 type RuntimeEvent = RuntimeEvent;
1517 type WeightInfo = pallet_messages::weights::SubstrateWeight<Runtime>;
1518 type MsaInfoProvider = Msa;
1520 type SchemaGrantValidator = Msa;
1522 type SchemaProvider = Schemas;
1524 type MessagesMaxPayloadSizeBytes = MessagesMaxPayloadSizeBytes;
1526
1527 #[cfg(feature = "runtime-benchmarks")]
1529 type MsaBenchmarkHelper = Msa;
1530 #[cfg(feature = "runtime-benchmarks")]
1531 type SchemaBenchmarkHelper = Schemas;
1532}
1533
1534impl pallet_stateful_storage::Config for Runtime {
1535 type RuntimeEvent = RuntimeEvent;
1536 type WeightInfo = pallet_stateful_storage::weights::SubstrateWeight<Runtime>;
1537 type MaxItemizedPageSizeBytes = MaxItemizedPageSizeBytes;
1539 type MaxPaginatedPageSizeBytes = MaxPaginatedPageSizeBytes;
1541 type MaxItemizedBlobSizeBytes = MaxItemizedBlobSizeBytes;
1543 type MaxPaginatedPageId = MaxPaginatedPageId;
1545 type MaxItemizedActionsCount = MaxItemizedActionsCount;
1547 type MsaInfoProvider = Msa;
1549 type SchemaGrantValidator = Msa;
1551 type SchemaProvider = Schemas;
1553 type KeyHasher = Twox128;
1555 type ConvertIntoAccountId32 = ConvertInto;
1557 type MortalityWindowSize = StatefulMortalityWindowSize;
1559
1560 #[cfg(feature = "runtime-benchmarks")]
1562 type MsaBenchmarkHelper = Msa;
1563 #[cfg(feature = "runtime-benchmarks")]
1564 type SchemaBenchmarkHelper = Schemas;
1565}
1566
1567impl pallet_handles::Config for Runtime {
1568 type RuntimeEvent = RuntimeEvent;
1570 type WeightInfo = pallet_handles::weights::SubstrateWeight<Runtime>;
1572 type MsaInfoProvider = Msa;
1574 type HandleSuffixMin = HandleSuffixMin;
1576 type HandleSuffixMax = HandleSuffixMax;
1578 type ConvertIntoAccountId32 = ConvertInto;
1580 type MortalityWindowSize = MSAMortalityWindowSize;
1582 #[cfg(feature = "runtime-benchmarks")]
1584 type MsaBenchmarkHelper = Msa;
1585}
1586
1587#[cfg(feature = "frequency-bridging")]
1589impl pallet_assets::Config for Runtime {
1590 type RuntimeEvent = RuntimeEvent;
1591 type Balance = Balance;
1592 type AssetId = ForeignAssetsAssetId;
1593 type AssetIdParameter = ForeignAssetsAssetId;
1594 type Currency = Balances;
1595
1596 type CreateOrigin = AsEnsureOriginWithArg<EnsureNever<AccountId>>;
1597 type ForceOrigin = EnsureRoot<AccountId>;
1598
1599 type AssetDeposit = ForeignAssetsAssetDeposit;
1600 type MetadataDepositBase = ForeignAssetsMetadataDepositBase;
1601 type MetadataDepositPerByte = ForeignAssetsMetadataDepositPerByte;
1602 type ApprovalDeposit = ForeignAssetsApprovalDeposit;
1603 type StringLimit = ForeignAssetsAssetsStringLimit;
1604
1605 type Freezer = ();
1606 type Extra = ();
1607 type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
1608 type CallbackHandle = ();
1609 type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit;
1610 type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
1611
1612 #[cfg(feature = "runtime-benchmarks")]
1613 type BenchmarkHelper = xcm::xcm_config::XcmBenchmarkHelper;
1614 type Holder = ();
1615}
1616
1617#[cfg(any(not(feature = "frequency"), feature = "frequency-lint-check"))]
1620impl pallet_sudo::Config for Runtime {
1621 type RuntimeEvent = RuntimeEvent;
1622 type RuntimeCall = RuntimeCall;
1623 type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
1625}
1626
1627impl pallet_utility::Config for Runtime {
1630 type RuntimeEvent = RuntimeEvent;
1631 type RuntimeCall = RuntimeCall;
1632 type PalletsOrigin = OriginCaller;
1633 type WeightInfo = weights::pallet_utility::SubstrateWeight<Runtime>;
1634}
1635
1636construct_runtime!(
1638 pub enum Runtime {
1639 System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>} = 0,
1641 #[cfg(any(
1642 not(feature = "frequency-no-relay"),
1643 feature = "frequency-lint-check",
1644 feature = "frequency-bridging"
1645 ))]
1646 ParachainSystem: cumulus_pallet_parachain_system::{ Pallet, Call, Config<T>, Storage, Inherent, Event<T> } = 1,
1647 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2,
1648 ParachainInfo: parachain_info::{Pallet, Storage, Config<T>} = 3,
1649
1650 #[cfg(any(not(feature = "frequency"), feature = "frequency-lint-check"))]
1652 Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T> }= 4,
1653
1654 Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>, HoldReason} = 5,
1655 Democracy: pallet_democracy::{Pallet, Call, Config<T>, Storage, Event<T> } = 6,
1656 Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T> } = 8,
1657 Utility: pallet_utility::{Pallet, Call, Event} = 9,
1658
1659 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 10,
1661 TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>} = 11,
1662
1663 Council: pallet_collective::<Instance1>::{Pallet, Call, Config<T,I>, Storage, Event<T>, Origin<T>} = 12,
1665 TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Config<T,I>, Storage, Event<T>, Origin<T>} = 13,
1666
1667 Treasury: pallet_treasury::{Pallet, Call, Storage, Config<T>, Event<T>} = 14,
1669
1670 Authorship: pallet_authorship::{Pallet, Storage} = 20,
1672 CollatorSelection: pallet_collator_selection::{Pallet, Call, Storage, Event<T>, Config<T>} = 21,
1673 Session: pallet_session::{Pallet, Call, Storage, Event<T>, Config<T>} = 22,
1674 Aura: pallet_aura::{Pallet, Storage, Config<T>} = 23,
1675 AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config<T>} = 24,
1676
1677 Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 30,
1679
1680 TimeRelease: pallet_time_release::{Pallet, Call, Storage, Event<T>, Config<T>, Origin<T>, FreezeReason, HoldReason} = 40,
1682
1683 Proxy: pallet_proxy = 43,
1685
1686 WeightReclaim: cumulus_pallet_weight_reclaim::{Pallet, Storage} = 50,
1688
1689 Msa: pallet_msa::{Pallet, Call, Storage, Event<T>} = 60,
1691 Messages: pallet_messages::{Pallet, Call, Storage, Event<T>} = 61,
1692 Schemas: pallet_schemas::{Pallet, Call, Storage, Event<T>, Config<T>} = 62,
1693 StatefulStorage: pallet_stateful_storage::{Pallet, Call, Storage, Event<T>} = 63,
1694 Capacity: pallet_capacity::{Pallet, Call, Storage, Event<T>, FreezeReason} = 64,
1695 FrequencyTxPayment: pallet_frequency_tx_payment::{Pallet, Call, Event<T>} = 65,
1696 Handles: pallet_handles::{Pallet, Call, Storage, Event<T>} = 66,
1697 Passkey: pallet_passkey::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 67,
1698
1699 #[cfg(feature = "frequency-bridging")]
1700 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 71,
1701
1702 #[cfg(feature = "frequency-bridging")]
1703 PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin } = 72,
1704
1705 #[cfg(feature = "frequency-bridging")]
1706 CumulusXcm: cumulus_pallet_xcm::{Pallet, Event<T>, Origin} = 73,
1707
1708 #[cfg(feature = "frequency-bridging")]
1709 MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>} = 74,
1710
1711 #[cfg(feature = "frequency-bridging")]
1712 ForeignAssets: pallet_assets::{Pallet, Call, Storage, Event<T>} = 75,
1713 }
1714);
1715
1716#[cfg(feature = "runtime-benchmarks")]
1717mod benches {
1718 define_benchmarks!(
1719 [frame_system, SystemBench::<Runtime>]
1721 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
1722 [cumulus_pallet_weight_reclaim, WeightReclaim]
1723 [pallet_assets, ForeignAssets]
1724 [pallet_balances, Balances]
1725 [pallet_collective, Council]
1726 [pallet_collective, TechnicalCommittee]
1727 [pallet_preimage, Preimage]
1728 [pallet_democracy, Democracy]
1729 [pallet_scheduler, Scheduler]
1730 [pallet_session, SessionBench::<Runtime>]
1731 [pallet_timestamp, Timestamp]
1732 [pallet_collator_selection, CollatorSelection]
1733 [pallet_multisig, Multisig]
1734 [pallet_utility, Utility]
1735 [pallet_proxy, Proxy]
1736 [pallet_transaction_payment, TransactionPayment]
1737 [cumulus_pallet_xcmp_queue, XcmpQueue]
1738 [pallet_message_queue, MessageQueue]
1739
1740 [pallet_msa, Msa]
1742 [pallet_schemas, Schemas]
1743 [pallet_messages, Messages]
1744 [pallet_stateful_storage, StatefulStorage]
1745 [pallet_handles, Handles]
1746 [pallet_time_release, TimeRelease]
1747 [pallet_treasury, Treasury]
1748 [pallet_capacity, Capacity]
1749 [pallet_frequency_tx_payment, FrequencyTxPayment]
1750 [pallet_passkey, Passkey]
1751
1752 [pallet_xcm_benchmarks::fungible, XcmBalances]
1753 [pallet_xcm_benchmarks::generic, XcmGeneric]
1754 );
1755}
1756
1757#[cfg(any(
1758 not(feature = "frequency-no-relay"),
1759 feature = "frequency-lint-check",
1760 feature = "frequency-bridging"
1761))]
1762cumulus_pallet_parachain_system::register_validate_block! {
1763 Runtime = Runtime,
1764 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
1765}
1766
1767sp_api::impl_runtime_apis! {
1770 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
1771 fn slot_duration() -> sp_consensus_aura::SlotDuration {
1772 sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
1773 }
1774
1775 fn authorities() -> Vec<AuraId> {
1776 pallet_aura::Authorities::<Runtime>::get().into_inner()
1777 }
1778 }
1779
1780 #[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check"))]
1781 impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
1782 fn can_build_upon(
1783 included_hash: <Block as BlockT>::Hash,
1784 slot: cumulus_primitives_aura::Slot,
1785 ) -> bool {
1786 ConsensusHook::can_build_upon(included_hash, slot)
1787 }
1788 }
1789
1790 impl sp_api::Core<Block> for Runtime {
1791 fn version() -> RuntimeVersion {
1792 VERSION
1793 }
1794
1795 fn execute_block(block: Block) {
1796 Executive::execute_block(block)
1797 }
1798
1799 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
1800 Executive::initialize_block(header)
1801 }
1802 }
1803
1804 impl sp_api::Metadata<Block> for Runtime {
1805 fn metadata() -> OpaqueMetadata {
1806 OpaqueMetadata::new(Runtime::metadata().into())
1807 }
1808
1809 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
1810 Runtime::metadata_at_version(version)
1811 }
1812
1813 fn metadata_versions() -> Vec<u32> {
1814 Runtime::metadata_versions()
1815 }
1816 }
1817
1818 impl sp_block_builder::BlockBuilder<Block> for Runtime {
1819 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
1820 Executive::apply_extrinsic(extrinsic)
1821 }
1822
1823 fn finalize_block() -> <Block as BlockT>::Header {
1824 Executive::finalize_block()
1825 }
1826
1827 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
1828 data.create_extrinsics()
1829 }
1830
1831 fn check_inherents(
1832 block: Block,
1833 data: sp_inherents::InherentData,
1834 ) -> sp_inherents::CheckInherentsResult {
1835 data.check_extrinsics(&block)
1836 }
1837 }
1838
1839 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
1840 fn validate_transaction(
1841 source: TransactionSource,
1842 tx: <Block as BlockT>::Extrinsic,
1843 block_hash: <Block as BlockT>::Hash,
1844 ) -> TransactionValidity {
1845 Executive::validate_transaction(source, tx, block_hash)
1846 }
1847 }
1848
1849 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
1850 fn offchain_worker(header: &<Block as BlockT>::Header) {
1851 Executive::offchain_worker(header)
1852 }
1853 }
1854
1855 impl sp_session::SessionKeys<Block> for Runtime {
1856 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
1857 SessionKeys::generate(seed)
1858 }
1859
1860 fn decode_session_keys(
1861 encoded: Vec<u8>,
1862 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
1863 SessionKeys::decode_into_raw_public_keys(&encoded)
1864 }
1865 }
1866
1867 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
1868 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
1869 build_state::<RuntimeGenesisConfig>(config)
1870 }
1871
1872 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
1873 get_preset::<RuntimeGenesisConfig>(id, &crate::genesis::presets::get_preset)
1874 }
1875
1876 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1877 let mut presets = vec![];
1878
1879 #[cfg(any(
1880 feature = "frequency-no-relay",
1881 feature = "frequency-local",
1882 feature = "frequency-lint-check"
1883 ))]
1884 presets.extend(
1885 vec![
1886 sp_genesis_builder::PresetId::from("development"),
1887 sp_genesis_builder::PresetId::from("frequency-local"),
1888 sp_genesis_builder::PresetId::from("frequency"),
1889 sp_genesis_builder::PresetId::from("frequency-westend-local"),
1890 ]);
1891
1892
1893 #[cfg(feature = "frequency-testnet")]
1894 presets.push(sp_genesis_builder::PresetId::from("frequency-testnet"));
1895
1896 #[cfg(feature = "frequency-westend")]
1897 presets.push(sp_genesis_builder::PresetId::from("frequency-westend"));
1898
1899 #[cfg(feature = "frequency")]
1900 presets.push(sp_genesis_builder::PresetId::from("frequency"));
1901
1902 presets
1903 }
1904 }
1905
1906 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
1907 fn account_nonce(account: AccountId) -> Index {
1908 System::account_nonce(account)
1909 }
1910 }
1911
1912 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
1913 fn query_info(
1917 uxt: <Block as BlockT>::Extrinsic,
1918 len: u32,
1919 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
1920 TransactionPayment::query_info(uxt, len)
1921 }
1922 fn query_fee_details(
1923 uxt: <Block as BlockT>::Extrinsic,
1924 len: u32,
1925 ) -> pallet_transaction_payment::FeeDetails<Balance> {
1926 TransactionPayment::query_fee_details(uxt, len)
1927 }
1928 fn query_weight_to_fee(weight: Weight) -> Balance {
1929 TransactionPayment::weight_to_fee(weight)
1930 }
1931 fn query_length_to_fee(len: u32) -> Balance {
1932 TransactionPayment::length_to_fee(len)
1933 }
1934 }
1935
1936 impl pallet_frequency_tx_payment_runtime_api::CapacityTransactionPaymentRuntimeApi<Block, Balance> for Runtime {
1937 fn compute_capacity_fee(
1938 uxt: <Block as BlockT>::Extrinsic,
1939 len: u32,
1940 ) ->pallet_transaction_payment::FeeDetails<Balance> {
1941
1942 let dispatch_weight = match &uxt.function {
1945 RuntimeCall::FrequencyTxPayment(pallet_frequency_tx_payment::Call::pay_with_capacity { .. }) |
1946 RuntimeCall::FrequencyTxPayment(pallet_frequency_tx_payment::Call::pay_with_capacity_batch_all { .. }) => {
1947 <<Block as BlockT>::Extrinsic as GetDispatchInfo>::get_dispatch_info(&uxt).call_weight
1948 },
1949 _ => {
1950 Weight::zero()
1951 }
1952 };
1953 FrequencyTxPayment::compute_capacity_fee_details(&uxt.function, &dispatch_weight, len)
1954 }
1955 }
1956
1957 #[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check"))]
1958 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
1959 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
1960 ParachainSystem::collect_collation_info(header)
1961 }
1962 }
1963
1964 impl pallet_messages_runtime_api::MessagesRuntimeApi<Block> for Runtime {
1966 fn get_messages_by_schema_and_block(schema_id: SchemaId, schema_payload_location: PayloadLocation, block_number: BlockNumber,) ->
1967 Vec<MessageResponse> {
1968 Messages::get_messages_by_schema_and_block(schema_id, schema_payload_location, block_number)
1969 }
1970
1971 fn get_schema_by_id(schema_id: SchemaId) -> Option<SchemaResponse> {
1972 Schemas::get_schema_by_id(schema_id)
1973 }
1974 }
1975
1976 impl pallet_schemas_runtime_api::SchemasRuntimeApi<Block> for Runtime {
1977 fn get_by_schema_id(schema_id: SchemaId) -> Option<SchemaResponse> {
1978 Schemas::get_schema_by_id(schema_id)
1979 }
1980
1981 fn get_schema_versions_by_name(schema_name: Vec<u8>) -> Option<Vec<SchemaVersionResponse>> {
1982 Schemas::get_schema_versions(schema_name)
1983 }
1984 }
1985
1986 impl system_runtime_api::AdditionalRuntimeApi<Block> for Runtime {
1987 fn get_events() -> Vec<RpcEvent> {
1988 System::read_events_no_consensus().map(|e| (*e).into()).collect()
1989 }
1990 }
1991
1992 impl pallet_msa_runtime_api::MsaRuntimeApi<Block, AccountId> for Runtime {
1993 fn has_delegation(delegator: DelegatorId, provider: ProviderId, block_number: BlockNumber, schema_id: Option<SchemaId>) -> bool {
1994 match schema_id {
1995 Some(sid) => Msa::ensure_valid_schema_grant(provider, delegator, sid, block_number).is_ok(),
1996 None => Msa::ensure_valid_delegation(provider, delegator, Some(block_number)).is_ok(),
1997 }
1998 }
1999
2000 fn get_granted_schemas_by_msa_id(delegator: DelegatorId, provider: ProviderId) -> Option<Vec<SchemaGrant<SchemaId, BlockNumber>>> {
2001 match Msa::get_granted_schemas_by_msa_id(delegator, Some(provider)) {
2002 Ok(res) => match res.into_iter().next() {
2003 Some(delegation) => Some(delegation.permissions),
2004 None => None,
2005 },
2006 _ => None,
2007 }
2008 }
2009
2010 fn get_all_granted_delegations_by_msa_id(delegator: DelegatorId) -> Vec<DelegationResponse<SchemaId, BlockNumber>> {
2011 Msa::get_granted_schemas_by_msa_id(delegator, None).unwrap_or_default()
2012 }
2013
2014 fn get_ethereum_address_for_msa_id(msa_id: MessageSourceId) -> AccountId20Response {
2015 let account_id = Msa::msa_id_to_eth_address(msa_id);
2016 let account_id_checksummed = Msa::eth_address_to_checksummed_string(&account_id);
2017 AccountId20Response { account_id, account_id_checksummed }
2018 }
2019
2020 fn validate_eth_address_for_msa(address: &H160, msa_id: MessageSourceId) -> bool {
2021 Msa::validate_eth_address_for_msa(address, msa_id)
2022 }
2023 }
2024
2025 impl pallet_stateful_storage_runtime_api::StatefulStorageRuntimeApi<Block> for Runtime {
2026 fn get_paginated_storage(msa_id: MessageSourceId, schema_id: SchemaId) -> Result<Vec<PaginatedStorageResponse>, DispatchError> {
2027 StatefulStorage::get_paginated_storage(msa_id, schema_id)
2028 }
2029
2030 fn get_itemized_storage(msa_id: MessageSourceId, schema_id: SchemaId) -> Result<ItemizedStoragePageResponse, DispatchError> {
2031 StatefulStorage::get_itemized_storage(msa_id, schema_id)
2032 }
2033 }
2034
2035 #[api_version(3)]
2036 impl pallet_handles_runtime_api::HandlesRuntimeApi<Block> for Runtime {
2037 fn get_handle_for_msa(msa_id: MessageSourceId) -> Option<HandleResponse> {
2038 Handles::get_handle_for_msa(msa_id)
2039 }
2040
2041 fn get_next_suffixes(base_handle: BaseHandle, count: u16) -> PresumptiveSuffixesResponse {
2042 Handles::get_next_suffixes(base_handle, count)
2043 }
2044
2045 fn get_msa_for_handle(display_handle: DisplayHandle) -> Option<MessageSourceId> {
2046 Handles::get_msa_id_for_handle(display_handle)
2047 }
2048 fn validate_handle(base_handle: BaseHandle) -> bool {
2049 Handles::validate_handle(base_handle.to_vec())
2050 }
2051 fn check_handle(base_handle: BaseHandle) -> CheckHandleResponse {
2052 Handles::check_handle(base_handle.to_vec())
2053 }
2054 }
2055
2056 impl pallet_capacity_runtime_api::CapacityRuntimeApi<Block, AccountId, Balance, BlockNumber> for Runtime {
2057 fn list_unclaimed_rewards(who: AccountId) -> Vec<UnclaimedRewardInfo<Balance, BlockNumber>> {
2058 match Capacity::list_unclaimed_rewards(&who) {
2059 Ok(rewards) => rewards.into_inner(),
2060 Err(_) => Vec::new(),
2061 }
2062 }
2063 }
2064
2065 #[cfg(feature = "try-runtime")]
2066 impl frame_try_runtime::TryRuntime<Block> for Runtime {
2067 fn on_runtime_upgrade(checks: UpgradeCheckSelect) -> (Weight, Weight) {
2068 log::info!("try-runtime::on_runtime_upgrade frequency.");
2069 let weight = Executive::try_runtime_upgrade(checks).unwrap();
2070 (weight, RuntimeBlockWeights::get().max_block)
2071 }
2072
2073 fn execute_block(block: Block,
2074 state_root_check: bool,
2075 signature_check: bool,
2076 try_state: TryStateSelect,
2077 ) -> Weight {
2078 log::info!(
2079 target: "runtime::frequency", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
2080 block.header.number,
2081 block.header.hash(),
2082 state_root_check,
2083 try_state,
2084 );
2085 Executive::try_execute_block(block, state_root_check, signature_check, try_state).expect("try_execute_block failed")
2086 }
2087 }
2088
2089 #[cfg(feature = "runtime-benchmarks")]
2090 impl frame_benchmarking::Benchmark<Block> for Runtime {
2091 fn benchmark_metadata(extra: bool) -> (
2092 Vec<frame_benchmarking::BenchmarkList>,
2093 Vec<frame_support::traits::StorageInfo>,
2094 ) {
2095 use frame_benchmarking::{BenchmarkList};
2096 use frame_support::traits::StorageInfoTrait;
2097 use frame_system_benchmarking::Pallet as SystemBench;
2098 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2099 use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
2100
2101 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
2105 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
2106
2107 let mut list = Vec::<BenchmarkList>::new();
2108 list_benchmarks!(list, extra);
2109
2110 let storage_info = AllPalletsWithSystem::storage_info();
2111 (list, storage_info)
2112 }
2113
2114 #[allow(deprecated, non_local_definitions)]
2115 fn dispatch_benchmark(
2116 config: frame_benchmarking::BenchmarkConfig
2117 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
2118 use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
2119
2120 use frame_system_benchmarking::Pallet as SystemBench;
2121 impl frame_system_benchmarking::Config for Runtime {}
2122
2123 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2124
2125 use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
2126 impl cumulus_pallet_session_benchmarking::Config for Runtime {}
2127
2128 use frame_support::traits::{WhitelistedStorageKeys, TrackedStorageKey};
2129 let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
2130
2131 #[cfg(feature = "frequency-bridging")]
2132 impl pallet_xcm_benchmarks::Config for Runtime {
2133 type XcmConfig = xcm::xcm_config::XcmConfig;
2134 type AccountIdConverter = xcm::LocationToAccountId;
2135 type DeliveryHelper = xcm::benchmarks::ParachainDeliveryHelper;
2136
2137 fn valid_destination() -> Result<xcm::benchmarks::Location, BenchmarkError> {
2138 xcm::benchmarks::create_foreign_asset_dot_on_frequency();
2139 Ok(xcm::benchmarks::AssetHubParachainLocation::get())
2140 }
2141
2142 fn worst_case_holding(_depositable_count: u32) -> xcm::benchmarks::Assets {
2143 let mut assets = xcm::benchmarks::Assets::new();
2144 assets.push(xcm::benchmarks::Asset { id: xcm::benchmarks::AssetId(xcm::benchmarks::HereLocation::get()), fun: xcm::benchmarks::Fungibility::Fungible(u128::MAX) });
2145 assets.push(xcm::benchmarks::Asset { id: xcm::benchmarks::RelayAssetId::get(), fun: xcm::benchmarks::Fungibility::Fungible(u128::MAX / 2) });
2146 assets
2147 }
2148 }
2149
2150 #[cfg(feature = "frequency-bridging")]
2151 impl pallet_xcm_benchmarks::fungible::Config for Runtime {
2152 type TransactAsset = Balances;
2153 type CheckedAccount = xcm::benchmarks::CheckAccount;
2154 type TrustedTeleporter = xcm::benchmarks::TrustedTeleporter;
2155 type TrustedReserve = xcm::benchmarks::TrustedReserve;
2156
2157 fn get_asset() -> xcm::benchmarks::Asset {
2158 xcm::benchmarks::create_foreign_asset_dot_on_frequency();
2159 xcm::benchmarks::RelayAsset::get()
2160 }
2161 }
2162
2163 #[cfg(feature = "frequency-bridging")]
2164 impl pallet_xcm_benchmarks::generic::Config for Runtime {
2165 type RuntimeCall = RuntimeCall;
2166 type TransactAsset = Balances;
2167
2168 fn worst_case_response() -> (u64, xcm::benchmarks::Response) {
2169 (0u64, xcm::benchmarks::Response::Version(Default::default()))
2170 }
2171
2172 fn worst_case_asset_exchange() -> Result<(xcm::benchmarks::Assets, xcm::benchmarks::Assets), BenchmarkError> {
2174 Err(BenchmarkError::Skip)
2175 }
2176
2177 fn universal_alias() -> Result<(xcm::benchmarks::Location, xcm::benchmarks::Junction), BenchmarkError> {
2179 Err(BenchmarkError::Skip)
2180 }
2181
2182 fn transact_origin_and_runtime_call() -> Result<(xcm::benchmarks::Location, RuntimeCall), BenchmarkError> {
2185 Ok((xcm::benchmarks::RelayLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
2186 }
2187
2188 fn subscribe_origin() -> Result<xcm::benchmarks::Location, BenchmarkError> {
2189 Ok(xcm::benchmarks::RelayLocation::get())
2190 }
2191
2192 fn claimable_asset() -> Result<(xcm::benchmarks::Location, xcm::benchmarks::Location, xcm::benchmarks::Assets), BenchmarkError> {
2193 let origin = xcm::benchmarks::AssetHubParachainLocation::get();
2194 let assets = xcm::benchmarks::RelayAsset::get().into();
2195 let ticket = xcm::benchmarks::HereLocation::get();
2196 Ok((origin, ticket, assets))
2197 }
2198
2199 fn fee_asset() -> Result<xcm::benchmarks::Asset, BenchmarkError> {
2200 Ok(xcm::benchmarks::RelayAsset::get())
2201 }
2202
2203 fn unlockable_asset() -> Result<(xcm::benchmarks::Location, xcm::benchmarks::Location, xcm::benchmarks::Asset), BenchmarkError> {
2205 Err(BenchmarkError::Skip)
2206 }
2207
2208 fn export_message_origin_and_destination() -> Result<(xcm::benchmarks::Location, xcm::benchmarks::NetworkId, xcm::benchmarks::InteriorLocation), BenchmarkError> {
2210 Err(BenchmarkError::Skip)
2211 }
2212
2213 fn alias_origin() -> Result<(xcm::benchmarks::Location, xcm::benchmarks::Location), BenchmarkError> {
2215 Err(BenchmarkError::Skip)
2216 }
2217 }
2218
2219 #[cfg(feature = "frequency-bridging")]
2220 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
2221 #[cfg(feature = "frequency-bridging")]
2222 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
2223
2224
2225 let mut batches = Vec::<BenchmarkBatch>::new();
2226 let params = (&config, &whitelist);
2227 add_benchmarks!(params, batches);
2228
2229 Ok(batches)
2230 }
2231
2232
2233 }
2234
2235 #[cfg(feature = "frequency-bridging")]
2236 impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
2237 fn query_acceptable_payment_assets(xcm_version: staging_xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
2238 let acceptable_assets = vec![AssetLocationId(RelayLocation::get())];
2239 PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
2240 }
2241
2242 fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
2244 use frame_support::weights::WeightToFee;
2245
2246 match asset.try_as::<AssetLocationId>() {
2247 Ok(asset_id) if asset_id.0 == NativeToken::get().0 => {
2248 Ok(common_runtime::fee::WeightToFee::weight_to_fee(&weight))
2250 },
2251 Ok(asset_id) if asset_id.0 == RelayLocation::get() => {
2252 let dot_fee = crate::polkadot_xcm_fee::default_fee_per_second()
2255 .saturating_mul(weight.ref_time() as u128)
2256 .saturating_div(WEIGHT_REF_TIME_PER_SECOND as u128);
2257 Ok(dot_fee)
2258 },
2259 Ok(asset_id) => {
2260 log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - unhandled asset_id: {asset_id:?}!");
2261 Err(XcmPaymentApiError::AssetNotFound)
2262 },
2263 Err(_) => {
2264 log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - failed to convert asset: {asset:?}!");
2265 Err(XcmPaymentApiError::VersionedConversionFailed)
2266 }
2267 }
2268 }
2269
2270 fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
2271 PolkadotXcm::query_xcm_weight(message)
2272 }
2273
2274 fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result<VersionedAssets, XcmPaymentApiError> {
2275 PolkadotXcm::query_delivery_fees(destination, message)
2276 }
2277 }
2278
2279 #[cfg(feature = "frequency-bridging")]
2280 impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
2281 fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
2282 PolkadotXcm::dry_run_call::<Runtime, XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
2283 }
2284
2285 fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
2286 PolkadotXcm::dry_run_xcm::<Runtime, XcmRouter, RuntimeCall, XcmConfig>(origin_location, xcm)
2287 }
2288 }
2289
2290 #[cfg(feature = "frequency-bridging")]
2291 impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
2292 fn convert_location(location: VersionedLocation) -> Result<
2293 AccountId,
2294 xcm_runtime_apis::conversions::Error
2295 > {
2296 xcm_runtime_apis::conversions::LocationToAccountHelper::<
2297 AccountId,
2298 LocationToAccountId,
2299 >::convert_location(location)
2300 }
2301 }
2302
2303 #[cfg(feature = "frequency-bridging")]
2304 impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
2305 fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
2306 PolkadotXcm::is_trusted_reserve(asset, location)
2307 }
2308 fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
2309 PolkadotXcm::is_trusted_teleporter(asset, location)
2310 }
2311 }
2312
2313 #[cfg(feature = "frequency-bridging")]
2314 impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi<Block> for Runtime {
2315 fn authorized_aliasers(target: VersionedLocation) -> Result<
2316 Vec<xcm_runtime_apis::authorized_aliases::OriginAliaser>,
2317 xcm_runtime_apis::authorized_aliases::Error
2318 > {
2319 PolkadotXcm::authorized_aliasers(target)
2320 }
2321 fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result<
2322 bool,
2323 xcm_runtime_apis::authorized_aliases::Error
2324 > {
2325 PolkadotXcm::is_authorized_alias(origin, target)
2326 }
2327 }
2328}