1#![cfg_attr(not(feature = "std"), no_std)]
20#![recursion_limit = "512"]
22
23#[cfg(all(any(target_arch = "riscv32", target_arch = "riscv64"), target_feature = "e"))]
24::core::arch::global_asm!(
29 ".pushsection .polkavm_min_stack_size,\"R\",@note\n",
30 ".4byte 2097152",
31 ".popsection\n",
32);
33
34extern crate alloc;
35
36use alloc::{
37 collections::{btree_map::BTreeMap, vec_deque::VecDeque},
38 vec,
39 vec::Vec,
40};
41use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
42use core::cmp::Ordering;
43use frame_support::{
44 dynamic_params::{dynamic_pallet_params, dynamic_params},
45 traits::FromContains,
46};
47use pallet_balances::WeightInfo;
48use pallet_nis::WithMaximumOf;
49use polkadot_primitives::{
50 slashing,
51 vstaging::{
52 async_backing::Constraints, CandidateEvent,
53 CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CoreState, ScrapedOnChainVotes,
54 },
55 AccountId, AccountIndex, ApprovalVotingParams, Balance, BlockNumber, CandidateHash, CoreIndex,
56 DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage,
57 InboundHrmpMessage, Moment, NodeFeatures, Nonce, OccupiedCoreAssumption,
58 PersistedValidationData, SessionInfo, Signature, ValidationCode, ValidationCodeHash,
59 ValidatorId, ValidatorIndex, PARACHAIN_KEY_TYPE_ID,
60};
61use polkadot_runtime_common::{
62 assigned_slots, auctions, claims, crowdloan, identity_migrator, impl_runtime_weights,
63 impls::{
64 ContainsParts, LocatableAssetConverter, ToAuthor, VersionedLocatableAsset,
65 VersionedLocationConverter,
66 },
67 paras_registrar, paras_sudo_wrapper, prod_or_fast, slots,
68 traits::{Leaser, OnSwap},
69 BlockHashCount, BlockLength, SlowAdjustingFeeUpdate,
70};
71use polkadot_runtime_parachains::{
72 assigner_coretime as parachains_assigner_coretime, configuration as parachains_configuration,
73 configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio,
74 coretime, disputes as parachains_disputes,
75 disputes::slashing as parachains_slashing,
76 dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
77 inclusion::{AggregateMessageOrigin, UmpQueueId},
78 initializer as parachains_initializer, on_demand as parachains_on_demand,
79 origin as parachains_origin, paras as parachains_paras,
80 paras_inherent as parachains_paras_inherent,
81 runtime_api_impl::{
82 v11 as parachains_runtime_api_impl, vstaging as parachains_staging_runtime_api_impl,
83 },
84 scheduler as parachains_scheduler, session_info as parachains_session_info,
85 shared as parachains_shared,
86};
87use rococo_runtime_constants::system_parachain::{coretime::TIMESLICE_PERIOD, BROKER_ID};
88use scale_info::TypeInfo;
89use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
90use sp_consensus_beefy::{
91 ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
92 mmr::{BeefyDataProvider, MmrLeafVersion},
93};
94use sp_genesis_builder::PresetId;
95
96use frame_support::{
97 construct_runtime, derive_impl,
98 genesis_builder_helper::{build_state, get_preset},
99 parameter_types,
100 traits::{
101 fungible::HoldConsideration, tokens::UnityOrOuterConversion, Contains, EitherOf,
102 EitherOfDiverse, EnsureOrigin, EnsureOriginWithArg, EverythingBut, InstanceFilter,
103 KeyOwnerProofSystem, LinearStoragePrice, PrivilegeCmp, ProcessMessage, ProcessMessageError,
104 StorageMapShim, WithdrawReasons,
105 },
106 weights::{ConstantMultiplier, WeightMeter},
107 PalletId,
108};
109use frame_system::{EnsureRoot, EnsureSigned};
110use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
111use pallet_identity::legacy::IdentityInfo;
112use pallet_session::historical as session_historical;
113use pallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo};
114use sp_core::{ConstU128, ConstU8, ConstUint, Get, OpaqueMetadata, H256};
115use sp_runtime::{
116 generic, impl_opaque_keys,
117 traits::{
118 AccountIdConversion, BlakeTwo256, Block as BlockT, ConstU32, ConvertInto, IdentityLookup,
119 Keccak256, OpaqueKeys, SaturatedConversion, Verify,
120 },
121 transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
122 ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill, RuntimeDebug,
123};
124use sp_staking::SessionIndex;
125#[cfg(any(feature = "std", test))]
126use sp_version::NativeVersion;
127use sp_version::RuntimeVersion;
128use xcm::{
129 latest::prelude::*, Version as XcmVersion, VersionedAsset, VersionedAssetId, VersionedAssets,
130 VersionedLocation, VersionedXcm,
131};
132use xcm_builder::PayOverXcm;
133
134pub use frame_system::Call as SystemCall;
135pub use pallet_balances::Call as BalancesCall;
136
137use rococo_runtime_constants::{currency::*, fee::*, time::*};
139
140mod weights;
142
143pub mod xcm_config;
145
146mod impls;
148use impls::ToParachainIdentityReaper;
149
150pub mod governance;
152use governance::{
153 pallet_custom_origins, AuctionAdmin, Fellows, GeneralAdmin, LeaseAdmin, Treasurer,
154 TreasurySpender,
155};
156use xcm_runtime_apis::{
157 dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
158 fees::Error as XcmPaymentApiError,
159};
160
161#[cfg(test)]
162mod tests;
163
164mod genesis_config_presets;
165mod validator_manager;
166
167impl_runtime_weights!(rococo_runtime_constants);
168
169#[cfg(feature = "std")]
171include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
172
173#[cfg(feature = "std")]
177pub mod fast_runtime_binary {
178 include!(concat!(env!("OUT_DIR"), "/fast_runtime_binary.rs"));
179}
180
181#[sp_version::runtime_version]
183pub const VERSION: RuntimeVersion = RuntimeVersion {
184 spec_name: alloc::borrow::Cow::Borrowed("rococo"),
185 impl_name: alloc::borrow::Cow::Borrowed("parity-rococo-v2.0"),
186 authoring_version: 0,
187 spec_version: 1_019_003,
188 impl_version: 0,
189 apis: RUNTIME_API_VERSIONS,
190 transaction_version: 26,
191 system_version: 1,
192};
193
194pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
196 sp_consensus_babe::BabeEpochConfiguration {
197 c: PRIMARY_PROBABILITY,
198 allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots,
199 };
200
201#[cfg(any(feature = "std", test))]
203pub fn native_version() -> NativeVersion {
204 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
205}
206
207pub struct IsIdentityCall;
212impl Contains<RuntimeCall> for IsIdentityCall {
213 fn contains(c: &RuntimeCall) -> bool {
214 matches!(c, RuntimeCall::Identity(_))
215 }
216}
217
218parameter_types! {
219 pub const Version: RuntimeVersion = VERSION;
220 pub const SS58Prefix: u8 = 42;
221}
222
223#[derive_impl(frame_system::config_preludes::RelayChainDefaultConfig)]
224impl frame_system::Config for Runtime {
225 type BaseCallFilter = EverythingBut<IsIdentityCall>;
226 type BlockWeights = BlockWeights;
227 type BlockLength = BlockLength;
228 type DbWeight = RocksDbWeight;
229 type Nonce = Nonce;
230 type Hash = Hash;
231 type AccountId = AccountId;
232 type Block = Block;
233 type BlockHashCount = BlockHashCount;
234 type Version = Version;
235 type AccountData = pallet_balances::AccountData<Balance>;
236 type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
237 type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
238 type SS58Prefix = SS58Prefix;
239 type MaxConsumers = frame_support::traits::ConstU32<16>;
240 type MultiBlockMigrator = MultiBlockMigrations;
241}
242
243parameter_types! {
244 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
245 BlockWeights::get().max_block;
246 pub const MaxScheduledPerBlock: u32 = 50;
247 pub const NoPreimagePostponement: Option<u32> = Some(10);
248}
249
250pub struct OriginPrivilegeCmp;
252
253impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
254 fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> {
255 if left == right {
256 return Some(Ordering::Equal);
257 }
258
259 match (left, right) {
260 (OriginCaller::system(frame_system::RawOrigin::Root), _) => Some(Ordering::Greater),
262 _ => None,
264 }
265 }
266}
267
268#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::<Runtime>)]
270pub mod dynamic_params {
271 use super::*;
272
273 #[dynamic_pallet_params]
274 #[codec(index = 0)]
275 pub mod nis {
276 use super::*;
277
278 #[codec(index = 0)]
279 pub static Target: Perquintill = Perquintill::zero();
280
281 #[codec(index = 1)]
282 pub static MinBid: Balance = 100 * UNITS;
283 }
284
285 #[dynamic_pallet_params]
286 #[codec(index = 1)]
287 pub mod preimage {
288 use super::*;
289
290 #[codec(index = 0)]
291 pub static BaseDeposit: Balance = deposit(2, 64);
292
293 #[codec(index = 1)]
294 pub static ByteDeposit: Balance = deposit(0, 1);
295 }
296}
297
298#[cfg(feature = "runtime-benchmarks")]
299impl Default for RuntimeParameters {
300 fn default() -> Self {
301 RuntimeParameters::Preimage(dynamic_params::preimage::Parameters::BaseDeposit(
302 dynamic_params::preimage::BaseDeposit,
303 Some(1u32.into()),
304 ))
305 }
306}
307
308pub struct DynamicParameterOrigin;
310impl EnsureOriginWithArg<RuntimeOrigin, RuntimeParametersKey> for DynamicParameterOrigin {
311 type Success = ();
312
313 fn try_origin(
314 origin: RuntimeOrigin,
315 key: &RuntimeParametersKey,
316 ) -> Result<Self::Success, RuntimeOrigin> {
317 use crate::{dynamic_params::*, governance::*, RuntimeParametersKey::*};
318
319 match key {
320 Nis(nis::ParametersKey::MinBid(_)) => StakingAdmin::ensure_origin(origin.clone()),
321 Nis(nis::ParametersKey::Target(_)) => GeneralAdmin::ensure_origin(origin.clone()),
322 Preimage(_) => frame_system::ensure_root(origin.clone()),
323 }
324 .map_err(|_| origin)
325 }
326
327 #[cfg(feature = "runtime-benchmarks")]
328 fn try_successful_origin(_key: &RuntimeParametersKey) -> Result<RuntimeOrigin, ()> {
329 Ok(RuntimeOrigin::root())
331 }
332}
333
334impl pallet_scheduler::Config for Runtime {
335 type RuntimeOrigin = RuntimeOrigin;
336 type RuntimeEvent = RuntimeEvent;
337 type PalletsOrigin = OriginCaller;
338 type RuntimeCall = RuntimeCall;
339 type MaximumWeight = MaximumSchedulerWeight;
340 type ScheduleOrigin = EitherOf<EnsureRoot<AccountId>, AuctionAdmin>;
343 type MaxScheduledPerBlock = MaxScheduledPerBlock;
344 type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
345 type OriginPrivilegeCmp = OriginPrivilegeCmp;
346 type Preimages = Preimage;
347 type BlockNumberProvider = frame_system::Pallet<Runtime>;
348}
349
350parameter_types! {
351 pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
352}
353
354impl pallet_preimage::Config for Runtime {
355 type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
356 type RuntimeEvent = RuntimeEvent;
357 type Currency = Balances;
358 type ManagerOrigin = EnsureRoot<AccountId>;
359 type Consideration = HoldConsideration<
360 AccountId,
361 Balances,
362 PreimageHoldReason,
363 LinearStoragePrice<
364 dynamic_params::preimage::BaseDeposit,
365 dynamic_params::preimage::ByteDeposit,
366 Balance,
367 >,
368 >;
369}
370
371parameter_types! {
372 pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
373 pub ReportLongevity: u64 = EpochDurationInBlocks::get() as u64 * 10;
374}
375
376impl pallet_babe::Config for Runtime {
377 type EpochDuration = EpochDurationInBlocks;
378 type ExpectedBlockTime = ExpectedBlockTime;
379 type EpochChangeTrigger = pallet_babe::ExternalTrigger;
381 type DisabledValidators = Session;
382 type WeightInfo = ();
383 type MaxAuthorities = MaxAuthorities;
384 type MaxNominators = ConstU32<0>;
385 type KeyOwnerProof = sp_session::MembershipProof;
386 type EquivocationReportSystem =
387 pallet_babe::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
388}
389
390parameter_types! {
391 pub const IndexDeposit: Balance = 100 * CENTS;
392}
393
394impl pallet_indices::Config for Runtime {
395 type AccountIndex = AccountIndex;
396 type Currency = Balances;
397 type Deposit = IndexDeposit;
398 type RuntimeEvent = RuntimeEvent;
399 type WeightInfo = weights::pallet_indices::WeightInfo<Runtime>;
400}
401
402parameter_types! {
403 pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
404 pub const MaxLocks: u32 = 50;
405 pub const MaxReserves: u32 = 50;
406}
407
408impl pallet_balances::Config for Runtime {
409 type Balance = Balance;
410 type DustRemoval = ();
411 type RuntimeEvent = RuntimeEvent;
412 type ExistentialDeposit = ExistentialDeposit;
413 type AccountStore = System;
414 type MaxLocks = MaxLocks;
415 type MaxReserves = MaxReserves;
416 type ReserveIdentifier = [u8; 8];
417 type WeightInfo = weights::pallet_balances_balances::WeightInfo<Runtime>;
418 type FreezeIdentifier = ();
419 type RuntimeHoldReason = RuntimeHoldReason;
420 type RuntimeFreezeReason = RuntimeFreezeReason;
421 type MaxFreezes = ConstU32<1>;
422 type DoneSlashHandler = ();
423}
424
425parameter_types! {
426 pub const TransactionByteFee: Balance = 10 * MILLICENTS;
427 pub const OperationalFeeMultiplier: u8 = 5;
430}
431
432impl pallet_transaction_payment::Config for Runtime {
433 type RuntimeEvent = RuntimeEvent;
434 type OnChargeTransaction = FungibleAdapter<Balances, ToAuthor<Runtime>>;
435 type OperationalFeeMultiplier = OperationalFeeMultiplier;
436 type WeightToFee = WeightToFee;
437 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
438 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
439 type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
440}
441
442parameter_types! {
443 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
444}
445impl pallet_timestamp::Config for Runtime {
446 type Moment = u64;
447 type OnTimestampSet = Babe;
448 type MinimumPeriod = MinimumPeriod;
449 type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
450}
451
452impl pallet_authorship::Config for Runtime {
453 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
454 type EventHandler = ();
455}
456
457impl_opaque_keys! {
458 pub struct SessionKeys {
459 pub grandpa: Grandpa,
460 pub babe: Babe,
461 pub para_validator: Initializer,
462 pub para_assignment: ParaSessionInfo,
463 pub authority_discovery: AuthorityDiscovery,
464 pub beefy: Beefy,
465 }
466}
467
468pub struct ValidatorIdOf;
470impl sp_runtime::traits::Convert<AccountId, Option<AccountId>> for ValidatorIdOf {
471 fn convert(a: AccountId) -> Option<AccountId> {
472 Some(a)
473 }
474}
475
476impl pallet_session::Config for Runtime {
477 type RuntimeEvent = RuntimeEvent;
478 type ValidatorId = AccountId;
479 type ValidatorIdOf = ValidatorIdOf;
480 type ShouldEndSession = Babe;
481 type NextSessionRotation = Babe;
482 type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, ValidatorManager>;
483 type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
484 type Keys = SessionKeys;
485 type DisablingStrategy = ();
486 type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
487}
488
489pub struct FullIdentificationOf;
490impl sp_runtime::traits::Convert<AccountId, Option<()>> for FullIdentificationOf {
491 fn convert(_: AccountId) -> Option<()> {
492 Some(Default::default())
493 }
494}
495
496impl pallet_session::historical::Config for Runtime {
497 type RuntimeEvent = RuntimeEvent;
498 type FullIdentification = ();
499 type FullIdentificationOf = FullIdentificationOf;
500}
501
502parameter_types! {
503 pub const SessionsPerEra: SessionIndex = 6;
504 pub const BondingDuration: sp_staking::EraIndex = 28;
505}
506
507parameter_types! {
508 pub const SpendPeriod: BlockNumber = 6 * DAYS;
509 pub const Burn: Permill = Permill::from_perthousand(2);
510 pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
511 pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
512 pub TreasuryInteriorLocation: InteriorLocation = PalletInstance(18).into();
515
516 pub const TipCountdown: BlockNumber = 1 * DAYS;
517 pub const TipFindersFee: Percent = Percent::from_percent(20);
518 pub const TipReportDepositBase: Balance = 100 * CENTS;
519 pub const DataDepositPerByte: Balance = 1 * CENTS;
520 pub const MaxApprovals: u32 = 100;
521 pub const MaxAuthorities: u32 = 100_000;
522 pub const MaxKeys: u32 = 10_000;
523 pub const MaxPeerInHeartbeats: u32 = 10_000;
524 pub const MaxBalance: Balance = Balance::max_value();
525}
526
527impl pallet_treasury::Config for Runtime {
528 type PalletId = TreasuryPalletId;
529 type Currency = Balances;
530 type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
531 type RuntimeEvent = RuntimeEvent;
532 type SpendPeriod = SpendPeriod;
533 type Burn = Burn;
534 type BurnDestination = Society;
535 type MaxApprovals = MaxApprovals;
536 type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
537 type SpendFunds = Bounties;
538 type SpendOrigin = TreasurySpender;
539 type AssetKind = VersionedLocatableAsset;
540 type Beneficiary = VersionedLocation;
541 type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
542 type Paymaster = PayOverXcm<
543 TreasuryInteriorLocation,
544 crate::xcm_config::XcmRouter,
545 crate::XcmPallet,
546 ConstU32<{ 6 * HOURS }>,
547 Self::Beneficiary,
548 Self::AssetKind,
549 LocatableAssetConverter,
550 VersionedLocationConverter,
551 >;
552 type BalanceConverter = UnityOrOuterConversion<
553 ContainsParts<
554 FromContains<
555 xcm_builder::IsChildSystemParachain<ParaId>,
556 xcm_builder::IsParentsOnly<ConstU8<1>>,
557 >,
558 >,
559 AssetRate,
560 >;
561 type PayoutPeriod = PayoutSpendPeriod;
562 type BlockNumberProvider = System;
563 #[cfg(feature = "runtime-benchmarks")]
564 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments;
565}
566
567parameter_types! {
568 pub const BountyDepositBase: Balance = 100 * CENTS;
569 pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS;
570 pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS;
571 pub const MaximumReasonLength: u32 = 16384;
572 pub const CuratorDepositMultiplier: Permill = Permill::from_percent(50);
573 pub const CuratorDepositMin: Balance = 10 * CENTS;
574 pub const CuratorDepositMax: Balance = 500 * CENTS;
575 pub const BountyValueMinimum: Balance = 200 * CENTS;
576}
577
578impl pallet_bounties::Config for Runtime {
579 type BountyDepositBase = BountyDepositBase;
580 type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
581 type BountyUpdatePeriod = BountyUpdatePeriod;
582 type CuratorDepositMultiplier = CuratorDepositMultiplier;
583 type CuratorDepositMin = CuratorDepositMin;
584 type CuratorDepositMax = CuratorDepositMax;
585 type BountyValueMinimum = BountyValueMinimum;
586 type ChildBountyManager = ChildBounties;
587 type DataDepositPerByte = DataDepositPerByte;
588 type RuntimeEvent = RuntimeEvent;
589 type MaximumReasonLength = MaximumReasonLength;
590 type WeightInfo = weights::pallet_bounties::WeightInfo<Runtime>;
591 type OnSlash = Treasury;
592}
593
594parameter_types! {
595 pub const MaxActiveChildBountyCount: u32 = 100;
596 pub ChildBountyValueMinimum: Balance = BountyValueMinimum::get() / 10;
597}
598
599impl pallet_child_bounties::Config for Runtime {
600 type RuntimeEvent = RuntimeEvent;
601 type MaxActiveChildBountyCount = MaxActiveChildBountyCount;
602 type ChildBountyValueMinimum = ChildBountyValueMinimum;
603 type WeightInfo = weights::pallet_child_bounties::WeightInfo<Runtime>;
604}
605
606impl pallet_offences::Config for Runtime {
607 type RuntimeEvent = RuntimeEvent;
608 type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
609 type OnOffenceHandler = ();
610}
611
612impl pallet_authority_discovery::Config for Runtime {
613 type MaxAuthorities = MaxAuthorities;
614}
615
616parameter_types! {
617 pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
618}
619
620impl pallet_grandpa::Config for Runtime {
621 type RuntimeEvent = RuntimeEvent;
622 type WeightInfo = ();
623 type MaxAuthorities = MaxAuthorities;
624 type MaxNominators = ConstU32<0>;
625 type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
626 type KeyOwnerProof = sp_session::MembershipProof;
627 type EquivocationReportSystem =
628 pallet_grandpa::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
629}
630
631impl frame_system::offchain::SigningTypes for Runtime {
632 type Public = <Signature as Verify>::Signer;
633 type Signature = Signature;
634}
635
636impl<LocalCall> frame_system::offchain::CreateTransactionBase<LocalCall> for Runtime
637where
638 RuntimeCall: From<LocalCall>,
639{
640 type Extrinsic = UncheckedExtrinsic;
641 type RuntimeCall = RuntimeCall;
642}
643
644impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
647where
648 RuntimeCall: From<LocalCall>,
649{
650 fn create_signed_transaction<
651 C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
652 >(
653 call: RuntimeCall,
654 public: <Signature as Verify>::Signer,
655 account: AccountId,
656 nonce: <Runtime as frame_system::Config>::Nonce,
657 ) -> Option<UncheckedExtrinsic> {
658 use sp_runtime::traits::StaticLookup;
659 let period =
661 BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
662
663 let current_block = System::block_number()
664 .saturated_into::<u64>()
665 .saturating_sub(1);
668 let tip = 0;
669 let tx_ext: TxExtension = (
670 frame_system::AuthorizeCall::<Runtime>::new(),
671 frame_system::CheckNonZeroSender::<Runtime>::new(),
672 frame_system::CheckSpecVersion::<Runtime>::new(),
673 frame_system::CheckTxVersion::<Runtime>::new(),
674 frame_system::CheckGenesis::<Runtime>::new(),
675 frame_system::CheckMortality::<Runtime>::from(generic::Era::mortal(
676 period,
677 current_block,
678 )),
679 frame_system::CheckNonce::<Runtime>::from(nonce),
680 frame_system::CheckWeight::<Runtime>::new(),
681 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
682 frame_metadata_hash_extension::CheckMetadataHash::new(true),
683 frame_system::WeightReclaim::<Runtime>::new(),
684 )
685 .into();
686 let raw_payload = SignedPayload::new(call, tx_ext)
687 .map_err(|e| {
688 log::warn!("Unable to create signed payload: {:?}", e);
689 })
690 .ok()?;
691 let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
692 let (call, tx_ext, _) = raw_payload.deconstruct();
693 let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
694 let transaction = UncheckedExtrinsic::new_signed(call, address, signature, tx_ext);
695 Some(transaction)
696 }
697}
698
699impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
700where
701 RuntimeCall: From<LocalCall>,
702{
703 type Extension = TxExtension;
704
705 fn create_transaction(call: RuntimeCall, tx_ext: Self::Extension) -> UncheckedExtrinsic {
706 UncheckedExtrinsic::new_transaction(call, tx_ext)
707 }
708}
709
710impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
711where
712 RuntimeCall: From<LocalCall>,
713{
714 fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
715 UncheckedExtrinsic::new_bare(call)
716 }
717}
718
719impl<LocalCall> frame_system::offchain::CreateAuthorizedTransaction<LocalCall> for Runtime
720where
721 RuntimeCall: From<LocalCall>,
722{
723 fn create_extension() -> Self::Extension {
724 (
725 frame_system::AuthorizeCall::<Runtime>::new(),
726 frame_system::CheckNonZeroSender::<Runtime>::new(),
727 frame_system::CheckSpecVersion::<Runtime>::new(),
728 frame_system::CheckTxVersion::<Runtime>::new(),
729 frame_system::CheckGenesis::<Runtime>::new(),
730 frame_system::CheckMortality::<Runtime>::from(generic::Era::Immortal),
731 frame_system::CheckNonce::<Runtime>::from(0),
732 frame_system::CheckWeight::<Runtime>::new(),
733 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
734 frame_metadata_hash_extension::CheckMetadataHash::new(false),
735 frame_system::WeightReclaim::<Runtime>::new(),
736 )
737 }
738}
739
740parameter_types! {
741 pub Prefix: &'static [u8] = b"Pay ROCs to the Rococo account:";
742}
743
744impl claims::Config for Runtime {
745 type RuntimeEvent = RuntimeEvent;
746 type VestingSchedule = Vesting;
747 type Prefix = Prefix;
748 type MoveClaimOrigin = EnsureRoot<AccountId>;
749 type WeightInfo = weights::polkadot_runtime_common_claims::WeightInfo<Runtime>;
750}
751
752parameter_types! {
753 pub const BasicDeposit: Balance = 1000 * CENTS; pub const ByteDeposit: Balance = deposit(0, 1);
756 pub const UsernameDeposit: Balance = deposit(0, 32);
757 pub const SubAccountDeposit: Balance = 200 * CENTS; pub const MaxSubAccounts: u32 = 100;
759 pub const MaxAdditionalFields: u32 = 100;
760 pub const MaxRegistrars: u32 = 20;
761}
762
763impl pallet_identity::Config for Runtime {
764 type RuntimeEvent = RuntimeEvent;
765 type Currency = Balances;
766 type BasicDeposit = BasicDeposit;
767 type ByteDeposit = ByteDeposit;
768 type UsernameDeposit = UsernameDeposit;
769 type SubAccountDeposit = SubAccountDeposit;
770 type MaxSubAccounts = MaxSubAccounts;
771 type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
772 type MaxRegistrars = MaxRegistrars;
773 type Slashed = Treasury;
774 type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
775 type RegistrarOrigin = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
776 type OffchainSignature = Signature;
777 type SigningPublicKey = <Signature as Verify>::Signer;
778 type UsernameAuthorityOrigin = EnsureRoot<Self::AccountId>;
779 type PendingUsernameExpiration = ConstU32<{ 7 * DAYS }>;
780 type UsernameGracePeriod = ConstU32<{ 30 * DAYS }>;
781 type MaxSuffixLength = ConstU32<7>;
782 type MaxUsernameLength = ConstU32<32>;
783 #[cfg(feature = "runtime-benchmarks")]
784 type BenchmarkHelper = ();
785 type WeightInfo = weights::pallet_identity::WeightInfo<Runtime>;
786}
787
788impl pallet_utility::Config for Runtime {
789 type RuntimeEvent = RuntimeEvent;
790 type RuntimeCall = RuntimeCall;
791 type PalletsOrigin = OriginCaller;
792 type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
793}
794
795parameter_types! {
796 pub const DepositBase: Balance = deposit(1, 88);
798 pub const DepositFactor: Balance = deposit(0, 32);
800 pub const MaxSignatories: u32 = 100;
801}
802
803impl pallet_multisig::Config for Runtime {
804 type RuntimeEvent = RuntimeEvent;
805 type RuntimeCall = RuntimeCall;
806 type Currency = Balances;
807 type DepositBase = DepositBase;
808 type DepositFactor = DepositFactor;
809 type MaxSignatories = MaxSignatories;
810 type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
811 type BlockNumberProvider = frame_system::Pallet<Runtime>;
812}
813
814parameter_types! {
815 pub const ConfigDepositBase: Balance = 500 * CENTS;
816 pub const FriendDepositFactor: Balance = 50 * CENTS;
817 pub const MaxFriends: u16 = 9;
818 pub const RecoveryDeposit: Balance = 500 * CENTS;
819}
820
821impl pallet_recovery::Config for Runtime {
822 type RuntimeEvent = RuntimeEvent;
823 type WeightInfo = ();
824 type RuntimeCall = RuntimeCall;
825 type BlockNumberProvider = System;
826 type Currency = Balances;
827 type ConfigDepositBase = ConfigDepositBase;
828 type FriendDepositFactor = FriendDepositFactor;
829 type MaxFriends = MaxFriends;
830 type RecoveryDeposit = RecoveryDeposit;
831}
832
833parameter_types! {
834 pub const SocietyPalletId: PalletId = PalletId(*b"py/socie");
835}
836
837impl pallet_society::Config for Runtime {
838 type RuntimeEvent = RuntimeEvent;
839 type Currency = Balances;
840 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
841 type GraceStrikes = ConstU32<1>;
842 type PeriodSpend = ConstU128<{ 50_000 * CENTS }>;
843 type VotingPeriod = ConstU32<{ 5 * DAYS }>;
844 type ClaimPeriod = ConstU32<{ 2 * DAYS }>;
845 type MaxLockDuration = ConstU32<{ 36 * 30 * DAYS }>;
846 type FounderSetOrigin = EnsureRoot<AccountId>;
847 type ChallengePeriod = ConstU32<{ 7 * DAYS }>;
848 type MaxPayouts = ConstU32<8>;
849 type MaxBids = ConstU32<512>;
850 type PalletId = SocietyPalletId;
851 type BlockNumberProvider = System;
852 type WeightInfo = ();
853}
854
855parameter_types! {
856 pub const MinVestedTransfer: Balance = 100 * CENTS;
857 pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
858 WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
859}
860
861impl pallet_vesting::Config for Runtime {
862 type RuntimeEvent = RuntimeEvent;
863 type Currency = Balances;
864 type BlockNumberToBalance = ConvertInto;
865 type MinVestedTransfer = MinVestedTransfer;
866 type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
867 type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
868 type BlockNumberProvider = System;
869 const MAX_VESTING_SCHEDULES: u32 = 28;
870}
871
872parameter_types! {
873 pub const ProxyDepositBase: Balance = deposit(1, 8);
875 pub const ProxyDepositFactor: Balance = deposit(0, 33);
877 pub const MaxProxies: u16 = 32;
878 pub const AnnouncementDepositBase: Balance = deposit(1, 8);
879 pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
880 pub const MaxPending: u16 = 32;
881}
882
883#[derive(
885 Copy,
886 Clone,
887 Eq,
888 PartialEq,
889 Ord,
890 PartialOrd,
891 Encode,
892 Decode,
893 DecodeWithMemTracking,
894 RuntimeDebug,
895 MaxEncodedLen,
896 TypeInfo,
897)]
898pub enum ProxyType {
899 Any,
900 NonTransfer,
901 Governance,
902 IdentityJudgement,
903 CancelProxy,
904 Auction,
905 Society,
906 OnDemandOrdering,
907}
908impl Default for ProxyType {
909 fn default() -> Self {
910 Self::Any
911 }
912}
913impl InstanceFilter<RuntimeCall> for ProxyType {
914 fn filter(&self, c: &RuntimeCall) -> bool {
915 match self {
916 ProxyType::Any => true,
917 ProxyType::NonTransfer => matches!(
918 c,
919 RuntimeCall::System(..) |
920 RuntimeCall::Babe(..) |
921 RuntimeCall::Timestamp(..) |
922 RuntimeCall::Indices(pallet_indices::Call::claim {..}) |
923 RuntimeCall::Indices(pallet_indices::Call::free {..}) |
924 RuntimeCall::Indices(pallet_indices::Call::freeze {..}) |
925 RuntimeCall::Session(..) |
928 RuntimeCall::Grandpa(..) |
929 RuntimeCall::Treasury(..) |
930 RuntimeCall::Bounties(..) |
931 RuntimeCall::ChildBounties(..) |
932 RuntimeCall::ConvictionVoting(..) |
933 RuntimeCall::Referenda(..) |
934 RuntimeCall::FellowshipCollective(..) |
935 RuntimeCall::FellowshipReferenda(..) |
936 RuntimeCall::Whitelist(..) |
937 RuntimeCall::Claims(..) |
938 RuntimeCall::Utility(..) |
939 RuntimeCall::Identity(..) |
940 RuntimeCall::Society(..) |
941 RuntimeCall::Recovery(pallet_recovery::Call::as_recovered {..}) |
942 RuntimeCall::Recovery(pallet_recovery::Call::vouch_recovery {..}) |
943 RuntimeCall::Recovery(pallet_recovery::Call::claim_recovery {..}) |
944 RuntimeCall::Recovery(pallet_recovery::Call::close_recovery {..}) |
945 RuntimeCall::Recovery(pallet_recovery::Call::remove_recovery {..}) |
946 RuntimeCall::Recovery(pallet_recovery::Call::cancel_recovered {..}) |
947 RuntimeCall::Vesting(pallet_vesting::Call::vest {..}) |
949 RuntimeCall::Vesting(pallet_vesting::Call::vest_other {..}) |
950 RuntimeCall::Scheduler(..) |
952 RuntimeCall::Proxy(..) |
953 RuntimeCall::Multisig(..) |
954 RuntimeCall::Nis(..) |
955 RuntimeCall::Registrar(paras_registrar::Call::register {..}) |
956 RuntimeCall::Registrar(paras_registrar::Call::deregister {..}) |
957 RuntimeCall::Registrar(paras_registrar::Call::reserve {..}) |
959 RuntimeCall::Crowdloan(..) |
960 RuntimeCall::Slots(..) |
961 RuntimeCall::Auctions(..) ),
963 ProxyType::Governance => matches!(
964 c,
965 RuntimeCall::Bounties(..) |
966 RuntimeCall::Utility(..) |
967 RuntimeCall::ChildBounties(..) |
968 RuntimeCall::ConvictionVoting(..) |
970 RuntimeCall::Referenda(..) |
971 RuntimeCall::FellowshipCollective(..) |
972 RuntimeCall::FellowshipReferenda(..) |
973 RuntimeCall::Whitelist(..)
974 ),
975 ProxyType::IdentityJudgement => matches!(
976 c,
977 RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
978 RuntimeCall::Utility(..)
979 ),
980 ProxyType::CancelProxy => {
981 matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }))
982 },
983 ProxyType::Auction => matches!(
984 c,
985 RuntimeCall::Auctions { .. } |
986 RuntimeCall::Crowdloan { .. } |
987 RuntimeCall::Registrar { .. } |
988 RuntimeCall::Multisig(..) |
989 RuntimeCall::Slots { .. }
990 ),
991 ProxyType::Society => matches!(c, RuntimeCall::Society(..)),
992 ProxyType::OnDemandOrdering => matches!(c, RuntimeCall::OnDemandAssignmentProvider(..)),
993 }
994 }
995 fn is_superset(&self, o: &Self) -> bool {
996 match (self, o) {
997 (x, y) if x == y => true,
998 (ProxyType::Any, _) => true,
999 (_, ProxyType::Any) => false,
1000 (ProxyType::NonTransfer, _) => true,
1001 _ => false,
1002 }
1003 }
1004}
1005
1006impl pallet_proxy::Config for Runtime {
1007 type RuntimeEvent = RuntimeEvent;
1008 type RuntimeCall = RuntimeCall;
1009 type Currency = Balances;
1010 type ProxyType = ProxyType;
1011 type ProxyDepositBase = ProxyDepositBase;
1012 type ProxyDepositFactor = ProxyDepositFactor;
1013 type MaxProxies = MaxProxies;
1014 type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
1015 type MaxPending = MaxPending;
1016 type CallHasher = BlakeTwo256;
1017 type AnnouncementDepositBase = AnnouncementDepositBase;
1018 type AnnouncementDepositFactor = AnnouncementDepositFactor;
1019 type BlockNumberProvider = frame_system::Pallet<Runtime>;
1020}
1021
1022impl parachains_origin::Config for Runtime {}
1023
1024impl parachains_configuration::Config for Runtime {
1025 type WeightInfo = weights::polkadot_runtime_parachains_configuration::WeightInfo<Runtime>;
1026}
1027
1028impl parachains_shared::Config for Runtime {
1029 type DisabledValidators = Session;
1030}
1031
1032impl parachains_session_info::Config for Runtime {
1033 type ValidatorSet = Historical;
1034}
1035
1036pub struct RewardValidators;
1038impl polkadot_runtime_parachains::inclusion::RewardValidators for RewardValidators {
1039 fn reward_backing(_: impl IntoIterator<Item = ValidatorIndex>) {}
1040 fn reward_bitfields(_: impl IntoIterator<Item = ValidatorIndex>) {}
1041}
1042
1043impl parachains_inclusion::Config for Runtime {
1044 type RuntimeEvent = RuntimeEvent;
1045 type DisputesHandler = ParasDisputes;
1046 type RewardValidators = RewardValidators;
1047 type MessageQueue = MessageQueue;
1048 type WeightInfo = weights::polkadot_runtime_parachains_inclusion::WeightInfo<Runtime>;
1049}
1050
1051parameter_types! {
1052 pub const ParasUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
1053}
1054
1055impl parachains_paras::Config for Runtime {
1056 type RuntimeEvent = RuntimeEvent;
1057 type WeightInfo = weights::polkadot_runtime_parachains_paras::WeightInfo<Runtime>;
1058 type UnsignedPriority = ParasUnsignedPriority;
1059 type QueueFootprinter = ParaInclusion;
1060 type NextSessionRotation = Babe;
1061 type OnNewHead = Registrar;
1062 type AssignCoretime = CoretimeAssignmentProvider;
1063 type Fungible = Balances;
1064 type CooldownRemovalMultiplier = ConstUint<{ 1000 * UNITS / DAYS as u128 }>;
1066 type AuthorizeCurrentCodeOrigin = EnsureRoot<AccountId>;
1067}
1068
1069parameter_types! {
1070 pub MessageQueueServiceWeight: Weight = Perbill::from_percent(20) * BlockWeights::get().max_block;
1076 pub const MessageQueueHeapSize: u32 = 32 * 1024;
1077 pub const MessageQueueMaxStale: u32 = 96;
1078}
1079
1080pub struct MessageProcessor;
1082impl ProcessMessage for MessageProcessor {
1083 type Origin = AggregateMessageOrigin;
1084
1085 fn process_message(
1086 message: &[u8],
1087 origin: Self::Origin,
1088 meter: &mut WeightMeter,
1089 id: &mut [u8; 32],
1090 ) -> Result<bool, ProcessMessageError> {
1091 let para = match origin {
1092 AggregateMessageOrigin::Ump(UmpQueueId::Para(para)) => para,
1093 };
1094 xcm_builder::ProcessXcmMessage::<
1095 Junction,
1096 xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
1097 RuntimeCall,
1098 >::process_message(message, Junction::Parachain(para.into()), meter, id)
1099 }
1100}
1101
1102impl pallet_message_queue::Config for Runtime {
1103 type RuntimeEvent = RuntimeEvent;
1104 type Size = u32;
1105 type HeapSize = MessageQueueHeapSize;
1106 type MaxStale = MessageQueueMaxStale;
1107 type ServiceWeight = MessageQueueServiceWeight;
1108 type IdleMaxServiceWeight = MessageQueueServiceWeight;
1109 #[cfg(not(feature = "runtime-benchmarks"))]
1110 type MessageProcessor = MessageProcessor;
1111 #[cfg(feature = "runtime-benchmarks")]
1112 type MessageProcessor =
1113 pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
1114 type QueueChangeHandler = ParaInclusion;
1115 type QueuePausedQuery = ();
1116 type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
1117}
1118
1119impl parachains_dmp::Config for Runtime {}
1120
1121parameter_types! {
1122 pub const HrmpChannelSizeAndCapacityWithSystemRatio: Percent = Percent::from_percent(100);
1123}
1124
1125impl parachains_hrmp::Config for Runtime {
1126 type RuntimeOrigin = RuntimeOrigin;
1127 type RuntimeEvent = RuntimeEvent;
1128 type ChannelManager = EnsureRoot<AccountId>;
1129 type Currency = Balances;
1130 type DefaultChannelSizeAndCapacityWithSystem = ActiveConfigHrmpChannelSizeAndCapacityRatio<
1131 Runtime,
1132 HrmpChannelSizeAndCapacityWithSystemRatio,
1133 >;
1134 type VersionWrapper = crate::XcmPallet;
1135 type WeightInfo = weights::polkadot_runtime_parachains_hrmp::WeightInfo<Runtime>;
1136}
1137
1138impl parachains_paras_inherent::Config for Runtime {
1139 type WeightInfo = weights::polkadot_runtime_parachains_paras_inherent::WeightInfo<Runtime>;
1140}
1141
1142impl parachains_scheduler::Config for Runtime {
1143 type AssignmentProvider = CoretimeAssignmentProvider;
1146}
1147
1148parameter_types! {
1149 pub const BrokerId: u32 = BROKER_ID;
1150 pub const BrokerPalletId: PalletId = PalletId(*b"py/broke");
1151 pub MaxXcmTransactWeight: Weight = Weight::from_parts(200_000_000, 20_000);
1152}
1153
1154pub struct BrokerPot;
1155impl Get<InteriorLocation> for BrokerPot {
1156 fn get() -> InteriorLocation {
1157 Junction::AccountId32 { network: None, id: BrokerPalletId::get().into_account_truncating() }
1158 .into()
1159 }
1160}
1161
1162impl coretime::Config for Runtime {
1163 type RuntimeOrigin = RuntimeOrigin;
1164 type RuntimeEvent = RuntimeEvent;
1165 type BrokerId = BrokerId;
1166 type BrokerPotLocation = BrokerPot;
1167 type WeightInfo = weights::polkadot_runtime_parachains_coretime::WeightInfo<Runtime>;
1168 type SendXcm = crate::xcm_config::XcmRouter;
1169 type AssetTransactor = crate::xcm_config::LocalAssetTransactor;
1170 type AccountToLocation = xcm_builder::AliasesIntoAccountId32<
1171 xcm_config::ThisNetwork,
1172 <Runtime as frame_system::Config>::AccountId,
1173 >;
1174 type MaxXcmTransactWeight = MaxXcmTransactWeight;
1175}
1176
1177parameter_types! {
1178 pub const OnDemandTrafficDefaultValue: FixedU128 = FixedU128::from_u32(1);
1179 pub const MaxHistoricalRevenue: BlockNumber = 2 * TIMESLICE_PERIOD;
1181 pub const OnDemandPalletId: PalletId = PalletId(*b"py/ondmd");
1182}
1183
1184impl parachains_on_demand::Config for Runtime {
1185 type RuntimeEvent = RuntimeEvent;
1186 type Currency = Balances;
1187 type TrafficDefaultValue = OnDemandTrafficDefaultValue;
1188 type WeightInfo = weights::polkadot_runtime_parachains_on_demand::WeightInfo<Runtime>;
1189 type MaxHistoricalRevenue = MaxHistoricalRevenue;
1190 type PalletId = OnDemandPalletId;
1191}
1192
1193impl parachains_assigner_coretime::Config for Runtime {}
1194
1195impl parachains_initializer::Config for Runtime {
1196 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
1197 type ForceOrigin = EnsureRoot<AccountId>;
1198 type WeightInfo = weights::polkadot_runtime_parachains_initializer::WeightInfo<Runtime>;
1199 type CoretimeOnNewSession = Coretime;
1200}
1201
1202impl parachains_disputes::Config for Runtime {
1203 type RuntimeEvent = RuntimeEvent;
1204 type RewardValidators = ();
1205 type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes<ParasSlashing>;
1206 type WeightInfo = weights::polkadot_runtime_parachains_disputes::WeightInfo<Runtime>;
1207}
1208
1209impl parachains_slashing::Config for Runtime {
1210 type KeyOwnerProofSystem = Historical;
1211 type KeyOwnerProof =
1212 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::Proof;
1213 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
1214 KeyTypeId,
1215 ValidatorId,
1216 )>>::IdentificationTuple;
1217 type HandleReports = parachains_slashing::SlashingReportHandler<
1218 Self::KeyOwnerIdentification,
1219 Offences,
1220 ReportLongevity,
1221 >;
1222 type WeightInfo = parachains_slashing::TestWeightInfo;
1223 type BenchmarkingConfig = parachains_slashing::BenchConfig<200>;
1224}
1225
1226parameter_types! {
1227 pub const ParaDeposit: Balance = 40 * UNITS;
1228}
1229
1230impl paras_registrar::Config for Runtime {
1231 type RuntimeOrigin = RuntimeOrigin;
1232 type RuntimeEvent = RuntimeEvent;
1233 type Currency = Balances;
1234 type OnSwap = (Crowdloan, Slots, SwapLeases);
1235 type ParaDeposit = ParaDeposit;
1236 type DataDepositPerByte = DataDepositPerByte;
1237 type WeightInfo = weights::polkadot_runtime_common_paras_registrar::WeightInfo<Runtime>;
1238}
1239
1240parameter_types! {
1241 pub LeasePeriod: BlockNumber = prod_or_fast!(1 * DAYS, 1 * DAYS, "ROC_LEASE_PERIOD");
1242}
1243
1244impl slots::Config for Runtime {
1245 type RuntimeEvent = RuntimeEvent;
1246 type Currency = Balances;
1247 type Registrar = Registrar;
1248 type LeasePeriod = LeasePeriod;
1249 type LeaseOffset = ();
1250 type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, LeaseAdmin>;
1251 type WeightInfo = weights::polkadot_runtime_common_slots::WeightInfo<Runtime>;
1252}
1253
1254parameter_types! {
1255 pub const CrowdloanId: PalletId = PalletId(*b"py/cfund");
1256 pub const SubmissionDeposit: Balance = 3 * GRAND;
1257 pub const MinContribution: Balance = 3_000 * CENTS;
1258 pub const RemoveKeysLimit: u32 = 1000;
1259 pub const MaxMemoLength: u8 = 32;
1261}
1262
1263impl crowdloan::Config for Runtime {
1264 type RuntimeEvent = RuntimeEvent;
1265 type PalletId = CrowdloanId;
1266 type SubmissionDeposit = SubmissionDeposit;
1267 type MinContribution = MinContribution;
1268 type RemoveKeysLimit = RemoveKeysLimit;
1269 type Registrar = Registrar;
1270 type Auctioneer = Auctions;
1271 type MaxMemoLength = MaxMemoLength;
1272 type WeightInfo = weights::polkadot_runtime_common_crowdloan::WeightInfo<Runtime>;
1273}
1274
1275parameter_types! {
1276 pub const EndingPeriod: BlockNumber = 5 * DAYS;
1279 pub const SampleLength: BlockNumber = 2 * MINUTES;
1281}
1282
1283impl auctions::Config for Runtime {
1284 type RuntimeEvent = RuntimeEvent;
1285 type Leaser = Slots;
1286 type Registrar = Registrar;
1287 type EndingPeriod = EndingPeriod;
1288 type SampleLength = SampleLength;
1289 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
1290 type InitiateOrigin = EitherOf<EnsureRoot<Self::AccountId>, AuctionAdmin>;
1291 type WeightInfo = weights::polkadot_runtime_common_auctions::WeightInfo<Runtime>;
1292}
1293
1294impl identity_migrator::Config for Runtime {
1295 type RuntimeEvent = RuntimeEvent;
1296 type Reaper = EnsureSigned<AccountId>;
1297 type ReapIdentityHandler = ToParachainIdentityReaper<Runtime, Self::AccountId>;
1298 type WeightInfo = weights::polkadot_runtime_common_identity_migrator::WeightInfo<Runtime>;
1299}
1300
1301type NisCounterpartInstance = pallet_balances::Instance2;
1302impl pallet_balances::Config<NisCounterpartInstance> for Runtime {
1303 type Balance = Balance;
1304 type DustRemoval = ();
1305 type RuntimeEvent = RuntimeEvent;
1306 type ExistentialDeposit = ConstU128<10_000_000_000>; type AccountStore = StorageMapShim<
1308 pallet_balances::Account<Runtime, NisCounterpartInstance>,
1309 AccountId,
1310 pallet_balances::AccountData<u128>,
1311 >;
1312 type MaxLocks = ConstU32<4>;
1313 type MaxReserves = ConstU32<4>;
1314 type ReserveIdentifier = [u8; 8];
1315 type WeightInfo = weights::pallet_balances_nis_counterpart_balances::WeightInfo<Runtime>;
1316 type RuntimeHoldReason = RuntimeHoldReason;
1317 type RuntimeFreezeReason = RuntimeFreezeReason;
1318 type FreezeIdentifier = ();
1319 type MaxFreezes = ConstU32<1>;
1320 type DoneSlashHandler = ();
1321}
1322
1323parameter_types! {
1324 pub const NisBasePeriod: BlockNumber = 30 * DAYS;
1325 pub MinReceipt: Perquintill = Perquintill::from_rational(1u64, 10_000_000u64);
1326 pub const IntakePeriod: BlockNumber = 5 * MINUTES;
1327 pub MaxIntakeWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
1328 pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5);
1329 pub const NisPalletId: PalletId = PalletId(*b"py/nis ");
1330}
1331
1332impl pallet_nis::Config for Runtime {
1333 type WeightInfo = weights::pallet_nis::WeightInfo<Runtime>;
1334 type RuntimeEvent = RuntimeEvent;
1335 type Currency = Balances;
1336 type CurrencyBalance = Balance;
1337 type FundOrigin = frame_system::EnsureSigned<AccountId>;
1338 type Counterpart = NisCounterpartBalances;
1339 type CounterpartAmount = WithMaximumOf<ConstU128<21_000_000_000_000_000_000u128>>;
1340 type Deficit = (); type IgnoredIssuance = ();
1342 type Target = dynamic_params::nis::Target;
1343 type PalletId = NisPalletId;
1344 type QueueCount = ConstU32<300>;
1345 type MaxQueueLen = ConstU32<1000>;
1346 type FifoQueueLen = ConstU32<250>;
1347 type BasePeriod = NisBasePeriod;
1348 type MinBid = dynamic_params::nis::MinBid;
1349 type MinReceipt = MinReceipt;
1350 type IntakePeriod = IntakePeriod;
1351 type MaxIntakeWeight = MaxIntakeWeight;
1352 type ThawThrottle = ThawThrottle;
1353 type RuntimeHoldReason = RuntimeHoldReason;
1354 #[cfg(feature = "runtime-benchmarks")]
1355 type BenchmarkSetup = ();
1356}
1357
1358impl pallet_parameters::Config for Runtime {
1359 type RuntimeEvent = RuntimeEvent;
1360 type RuntimeParameters = RuntimeParameters;
1361 type AdminOrigin = DynamicParameterOrigin;
1362 type WeightInfo = weights::pallet_parameters::WeightInfo<Runtime>;
1363}
1364
1365parameter_types! {
1366 pub BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
1367}
1368
1369impl pallet_beefy::Config for Runtime {
1370 type BeefyId = BeefyId;
1371 type MaxAuthorities = MaxAuthorities;
1372 type MaxNominators = ConstU32<0>;
1373 type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
1374 type OnNewValidatorSet = MmrLeaf;
1375 type AncestryHelper = MmrLeaf;
1376 type WeightInfo = ();
1377 type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, BeefyId)>>::Proof;
1378 type EquivocationReportSystem =
1379 pallet_beefy::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
1380}
1381
1382mod mmr {
1384 use super::Runtime;
1385 pub use pallet_mmr::primitives::*;
1386
1387 pub type Leaf = <<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider>::LeafData;
1388 pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
1389 pub type Hash = <Hashing as sp_runtime::traits::Hash>::Output;
1390}
1391
1392impl pallet_mmr::Config for Runtime {
1393 const INDEXING_PREFIX: &'static [u8] = mmr::INDEXING_PREFIX;
1394 type Hashing = Keccak256;
1395 type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
1396 type LeafData = pallet_beefy_mmr::Pallet<Runtime>;
1397 type BlockHashProvider = pallet_mmr::DefaultBlockHashProvider<Runtime>;
1398 type WeightInfo = weights::pallet_mmr::WeightInfo<Runtime>;
1399 #[cfg(feature = "runtime-benchmarks")]
1400 type BenchmarkHelper = parachains_paras::benchmarking::mmr_setup::MmrSetup<Runtime>;
1401}
1402
1403parameter_types! {
1404 pub LeafVersion: MmrLeafVersion = MmrLeafVersion::new(0, 0);
1405}
1406
1407pub struct ParaHeadsRootProvider;
1408impl BeefyDataProvider<H256> for ParaHeadsRootProvider {
1409 fn extra_data() -> H256 {
1410 let para_heads: Vec<(u32, Vec<u8>)> =
1411 parachains_paras::Pallet::<Runtime>::sorted_para_heads();
1412 binary_merkle_tree::merkle_root::<mmr::Hashing, _>(
1413 para_heads.into_iter().map(|pair| pair.encode()),
1414 )
1415 .into()
1416 }
1417}
1418
1419impl pallet_beefy_mmr::Config for Runtime {
1420 type LeafVersion = LeafVersion;
1421 type BeefyAuthorityToMerkleLeaf = pallet_beefy_mmr::BeefyEcdsaToEthereum;
1422 type LeafExtra = H256;
1423 type BeefyDataProvider = ParaHeadsRootProvider;
1424 type WeightInfo = weights::pallet_beefy_mmr::WeightInfo<Runtime>;
1425}
1426
1427impl paras_sudo_wrapper::Config for Runtime {}
1428
1429parameter_types! {
1430 pub const PermanentSlotLeasePeriodLength: u32 = 365;
1431 pub const TemporarySlotLeasePeriodLength: u32 = 5;
1432 pub const MaxTemporarySlotPerLeasePeriod: u32 = 5;
1433}
1434
1435impl assigned_slots::Config for Runtime {
1436 type RuntimeEvent = RuntimeEvent;
1437 type AssignSlotOrigin = EnsureRoot<AccountId>;
1438 type Leaser = Slots;
1439 type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength;
1440 type TemporarySlotLeasePeriodLength = TemporarySlotLeasePeriodLength;
1441 type MaxTemporarySlotPerLeasePeriod = MaxTemporarySlotPerLeasePeriod;
1442 type WeightInfo = weights::polkadot_runtime_common_assigned_slots::WeightInfo<Runtime>;
1443}
1444
1445impl validator_manager::Config for Runtime {
1446 type RuntimeEvent = RuntimeEvent;
1447 type PrivilegedOrigin = EnsureRoot<AccountId>;
1448}
1449
1450parameter_types! {
1451 pub MbmServiceWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
1452}
1453
1454impl pallet_migrations::Config for Runtime {
1455 type RuntimeEvent = RuntimeEvent;
1456 #[cfg(not(feature = "runtime-benchmarks"))]
1457 type Migrations = pallet_identity::migration::v2::LazyMigrationV1ToV2<Runtime>;
1458 #[cfg(feature = "runtime-benchmarks")]
1460 type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
1461 type CursorMaxLen = ConstU32<65_536>;
1462 type IdentifierMaxLen = ConstU32<256>;
1463 type MigrationStatusHandler = ();
1464 type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
1465 type MaxServiceWeight = MbmServiceWeight;
1466 type WeightInfo = weights::pallet_migrations::WeightInfo<Runtime>;
1467}
1468
1469impl pallet_sudo::Config for Runtime {
1470 type RuntimeEvent = RuntimeEvent;
1471 type RuntimeCall = RuntimeCall;
1472 type WeightInfo = weights::pallet_sudo::WeightInfo<Runtime>;
1473}
1474
1475impl pallet_root_testing::Config for Runtime {
1476 type RuntimeEvent = RuntimeEvent;
1477}
1478
1479impl pallet_asset_rate::Config for Runtime {
1480 type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
1481 type RuntimeEvent = RuntimeEvent;
1482 type CreateOrigin = EnsureRoot<AccountId>;
1483 type RemoveOrigin = EnsureRoot<AccountId>;
1484 type UpdateOrigin = EnsureRoot<AccountId>;
1485 type Currency = Balances;
1486 type AssetKind = <Runtime as pallet_treasury::Config>::AssetKind;
1487 #[cfg(feature = "runtime-benchmarks")]
1488 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments;
1489}
1490
1491pub struct SwapLeases;
1493impl OnSwap for SwapLeases {
1494 fn on_swap(one: ParaId, other: ParaId) {
1495 coretime::Pallet::<Runtime>::on_legacy_lease_swap(one, other);
1496 }
1497}
1498
1499construct_runtime! {
1500 pub enum Runtime
1501 {
1502 System: frame_system = 0,
1504
1505 Babe: pallet_babe = 1,
1507
1508 Timestamp: pallet_timestamp = 2,
1509 Indices: pallet_indices = 3,
1510 Balances: pallet_balances = 4,
1511 Parameters: pallet_parameters = 6,
1512 TransactionPayment: pallet_transaction_payment = 33,
1513
1514 Authorship: pallet_authorship = 5,
1517 Offences: pallet_offences = 7,
1518 Historical: session_historical = 34,
1519
1520 Session: pallet_session = 8,
1521 Grandpa: pallet_grandpa = 10,
1522 AuthorityDiscovery: pallet_authority_discovery = 12,
1523
1524 Treasury: pallet_treasury = 18,
1526 ConvictionVoting: pallet_conviction_voting = 20,
1527 Referenda: pallet_referenda = 21,
1528 FellowshipCollective: pallet_ranked_collective::<Instance1> = 22,
1530 FellowshipReferenda: pallet_referenda::<Instance2> = 23,
1532 Origins: pallet_custom_origins = 43,
1533 Whitelist: pallet_whitelist = 44,
1534 Claims: claims = 19,
1536
1537 Utility: pallet_utility = 24,
1539
1540 Identity: pallet_identity = 25,
1542
1543 Society: pallet_society = 26,
1545
1546 Recovery: pallet_recovery = 27,
1548
1549 Vesting: pallet_vesting = 28,
1551
1552 Scheduler: pallet_scheduler = 29,
1554
1555 Proxy: pallet_proxy = 30,
1557
1558 Multisig: pallet_multisig = 31,
1560
1561 Preimage: pallet_preimage = 32,
1563
1564 AssetRate: pallet_asset_rate = 39,
1566
1567 Bounties: pallet_bounties = 35,
1569 ChildBounties: pallet_child_bounties = 40,
1570
1571 Nis: pallet_nis = 38,
1573 NisCounterpartBalances: pallet_balances::<Instance2> = 45,
1575
1576 ParachainsOrigin: parachains_origin = 50,
1578 Configuration: parachains_configuration = 51,
1579 ParasShared: parachains_shared = 52,
1580 ParaInclusion: parachains_inclusion = 53,
1581 ParaInherent: parachains_paras_inherent = 54,
1582 ParaScheduler: parachains_scheduler = 55,
1583 Paras: parachains_paras = 56,
1584 Initializer: parachains_initializer = 57,
1585 Dmp: parachains_dmp = 58,
1586 Hrmp: parachains_hrmp = 60,
1587 ParaSessionInfo: parachains_session_info = 61,
1588 ParasDisputes: parachains_disputes = 62,
1589 ParasSlashing: parachains_slashing = 63,
1590 MessageQueue: pallet_message_queue = 64,
1591 OnDemandAssignmentProvider: parachains_on_demand = 66,
1592 CoretimeAssignmentProvider: parachains_assigner_coretime = 68,
1593
1594 Registrar: paras_registrar = 70,
1596 Slots: slots = 71,
1597 Auctions: auctions = 72,
1598 Crowdloan: crowdloan = 73,
1599 Coretime: coretime = 74,
1600
1601 MultiBlockMigrations: pallet_migrations = 98,
1603
1604 XcmPallet: pallet_xcm = 99,
1606
1607 Beefy: pallet_beefy = 240,
1609 Mmr: pallet_mmr = 241,
1612 MmrLeaf: pallet_beefy_mmr = 242,
1613
1614 IdentityMigrator: identity_migrator = 248,
1616
1617 ParasSudoWrapper: paras_sudo_wrapper = 250,
1618 AssignedSlots: assigned_slots = 251,
1619
1620 ValidatorManager: validator_manager = 252,
1622
1623 StateTrieMigration: pallet_state_trie_migration = 254,
1625
1626 RootTesting: pallet_root_testing = 249,
1628
1629 Sudo: pallet_sudo = 255,
1631 }
1632}
1633
1634pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
1636pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
1638pub type Block = generic::Block<Header, UncheckedExtrinsic>;
1640pub type SignedBlock = generic::SignedBlock<Block>;
1642pub type BlockId = generic::BlockId<Block>;
1644pub type TxExtension = (
1646 frame_system::AuthorizeCall<Runtime>,
1647 frame_system::CheckNonZeroSender<Runtime>,
1648 frame_system::CheckSpecVersion<Runtime>,
1649 frame_system::CheckTxVersion<Runtime>,
1650 frame_system::CheckGenesis<Runtime>,
1651 frame_system::CheckMortality<Runtime>,
1652 frame_system::CheckNonce<Runtime>,
1653 frame_system::CheckWeight<Runtime>,
1654 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
1655 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
1656 frame_system::WeightReclaim<Runtime>,
1657);
1658
1659pub type UncheckedExtrinsic =
1661 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
1662pub type UncheckedSignaturePayload =
1664 generic::UncheckedSignaturePayload<Address, Signature, TxExtension>;
1665
1666pub type Migrations = migrations::Unreleased;
1671
1672#[allow(deprecated, missing_docs)]
1674pub mod migrations {
1675 use super::*;
1676
1677 use frame_support::traits::LockIdentifier;
1678 use frame_system::pallet_prelude::BlockNumberFor;
1679
1680 pub struct GetLegacyLeaseImpl;
1681 impl coretime::migration::GetLegacyLease<BlockNumber> for GetLegacyLeaseImpl {
1682 fn get_parachain_lease_in_blocks(para: ParaId) -> Option<BlockNumber> {
1683 let now = frame_system::Pallet::<Runtime>::block_number();
1684 let lease = slots::Leases::<Runtime>::get(para);
1685 if lease.is_empty() {
1686 return None;
1687 }
1688 if lease.iter().any(Option::is_none) {
1690 return None;
1691 }
1692 let (index, _) =
1693 <slots::Pallet<Runtime> as Leaser<BlockNumber>>::lease_period_index(now)?;
1694 Some(index.saturating_add(lease.len() as u32).saturating_mul(LeasePeriod::get()))
1695 }
1696
1697 fn get_all_parachains_with_leases() -> Vec<ParaId> {
1698 slots::Leases::<Runtime>::iter()
1699 .filter(|(_, lease)| !lease.is_empty())
1700 .map(|(para, _)| para)
1701 .collect::<Vec<_>>()
1702 }
1703 }
1704
1705 parameter_types! {
1706 pub const DemocracyPalletName: &'static str = "Democracy";
1707 pub const CouncilPalletName: &'static str = "Council";
1708 pub const TechnicalCommitteePalletName: &'static str = "TechnicalCommittee";
1709 pub const PhragmenElectionPalletName: &'static str = "PhragmenElection";
1710 pub const TechnicalMembershipPalletName: &'static str = "TechnicalMembership";
1711 pub const TipsPalletName: &'static str = "Tips";
1712 pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect";
1713 pub BalanceUnreserveWeight: Weight = weights::pallet_balances_balances::WeightInfo::<Runtime>::force_unreserve();
1715 pub BalanceTransferAllowDeath: Weight = weights::pallet_balances_balances::WeightInfo::<Runtime>::transfer_allow_death();
1716 }
1717
1718 pub struct UnlockConfig;
1721 impl pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockConfig for UnlockConfig {
1722 type Currency = Balances;
1723 type MaxVotes = ConstU32<100>;
1724 type MaxDeposits = ConstU32<100>;
1725 type AccountId = AccountId;
1726 type BlockNumber = BlockNumberFor<Runtime>;
1727 type DbWeight = <Runtime as frame_system::Config>::DbWeight;
1728 type PalletName = DemocracyPalletName;
1729 }
1730 impl pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockConfig
1731 for UnlockConfig
1732 {
1733 type Currency = Balances;
1734 type MaxVotesPerVoter = ConstU32<16>;
1735 type PalletId = PhragmenElectionPalletId;
1736 type AccountId = AccountId;
1737 type DbWeight = <Runtime as frame_system::Config>::DbWeight;
1738 type PalletName = PhragmenElectionPalletName;
1739 }
1740 impl pallet_tips::migrations::unreserve_deposits::UnlockConfig<()> for UnlockConfig {
1741 type Currency = Balances;
1742 type Hash = Hash;
1743 type DataDepositPerByte = DataDepositPerByte;
1744 type TipReportDepositBase = TipReportDepositBase;
1745 type AccountId = AccountId;
1746 type BlockNumber = BlockNumberFor<Runtime>;
1747 type DbWeight = <Runtime as frame_system::Config>::DbWeight;
1748 type PalletName = TipsPalletName;
1749 }
1750
1751 const IDENTITY_MIGRATION_KEY_LIMIT: u64 = u64::MAX;
1753
1754 pub type Unreleased = (
1756 pallet_society::migrations::MigrateToV2<Runtime, (), ()>,
1757 parachains_configuration::migration::v7::MigrateToV7<Runtime>,
1758 assigned_slots::migration::v1::MigrateToV1<Runtime>,
1759 parachains_scheduler::migration::MigrateV1ToV2<Runtime>,
1760 parachains_configuration::migration::v8::MigrateToV8<Runtime>,
1761 parachains_configuration::migration::v9::MigrateToV9<Runtime>,
1762 paras_registrar::migration::MigrateToV1<Runtime, ()>,
1763 pallet_referenda::migration::v1::MigrateV0ToV1<Runtime, ()>,
1764 pallet_referenda::migration::v1::MigrateV0ToV1<Runtime, pallet_referenda::Instance2>,
1765 pallet_child_bounties::migration::MigrateV0ToV1<Runtime, BalanceTransferAllowDeath>,
1766
1767 pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
1770 pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
1771 pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<UnlockConfig, ()>,
1772 pallet_treasury::migration::cleanup_proposals::Migration<Runtime, (), BalanceUnreserveWeight>,
1773
1774 frame_support::migrations::RemovePallet<DemocracyPalletName, <Runtime as frame_system::Config>::DbWeight>,
1777 frame_support::migrations::RemovePallet<CouncilPalletName, <Runtime as frame_system::Config>::DbWeight>,
1778 frame_support::migrations::RemovePallet<TechnicalCommitteePalletName, <Runtime as frame_system::Config>::DbWeight>,
1779 frame_support::migrations::RemovePallet<PhragmenElectionPalletName, <Runtime as frame_system::Config>::DbWeight>,
1780 frame_support::migrations::RemovePallet<TechnicalMembershipPalletName, <Runtime as frame_system::Config>::DbWeight>,
1781 frame_support::migrations::RemovePallet<TipsPalletName, <Runtime as frame_system::Config>::DbWeight>,
1782 pallet_grandpa::migrations::MigrateV4ToV5<Runtime>,
1783 parachains_configuration::migration::v10::MigrateToV10<Runtime>,
1784
1785 pallet_identity::migration::versioned::V0ToV1<Runtime, IDENTITY_MIGRATION_KEY_LIMIT>,
1787 parachains_configuration::migration::v11::MigrateToV11<Runtime>,
1788 coretime::migration::MigrateToCoretime<Runtime, crate::xcm_config::XcmRouter, GetLegacyLeaseImpl, TIMESLICE_PERIOD>,
1790 parachains_configuration::migration::v12::MigrateToV12<Runtime>,
1791 parachains_on_demand::migration::MigrateV0ToV1<Runtime>,
1792
1793 pallet_session::migrations::v1::MigrateV0ToV1<Runtime, pallet_session::migrations::v1::InitOffenceSeverity<Runtime>>,
1795
1796 pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
1798 parachains_inclusion::migration::MigrateToV1<Runtime>,
1799 parachains_shared::migration::MigrateToV1<Runtime>,
1800 parachains_scheduler::migration::MigrateV2ToV3<Runtime>,
1801 );
1802}
1803
1804pub type Executive = frame_executive::Executive<
1806 Runtime,
1807 Block,
1808 frame_system::ChainContext<Runtime>,
1809 Runtime,
1810 AllPalletsWithSystem,
1811 Migrations,
1812>;
1813pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
1815
1816parameter_types! {
1817 pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS;
1819 pub const MigrationSignedDepositBase: Balance = 20 * CENTS * 100;
1820 pub const MigrationMaxKeyLen: u32 = 512;
1821}
1822
1823impl pallet_state_trie_migration::Config for Runtime {
1824 type RuntimeEvent = RuntimeEvent;
1825 type Currency = Balances;
1826 type RuntimeHoldReason = RuntimeHoldReason;
1827 type SignedDepositPerItem = MigrationSignedDepositPerItem;
1828 type SignedDepositBase = MigrationSignedDepositBase;
1829 type ControlOrigin = EnsureRoot<AccountId>;
1830 type SignedFilter = frame_system::EnsureSignedBy<MigController, AccountId>;
1832
1833 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;
1835 type MaxKeyLen = MigrationMaxKeyLen;
1836}
1837
1838frame_support::ord_parameter_types! {
1839 pub const MigController: AccountId = AccountId::from(hex_literal::hex!("52bc71c1eca5353749542dfdf0af97bf764f9c2f44e860cd485f1cd86400f649"));
1840}
1841
1842#[cfg(feature = "runtime-benchmarks")]
1843mod benches {
1844 frame_benchmarking::define_benchmarks!(
1845 [polkadot_runtime_common::assigned_slots, AssignedSlots]
1849 [polkadot_runtime_common::auctions, Auctions]
1850 [polkadot_runtime_common::crowdloan, Crowdloan]
1851 [polkadot_runtime_common::claims, Claims]
1852 [polkadot_runtime_common::identity_migrator, IdentityMigrator]
1853 [polkadot_runtime_common::slots, Slots]
1854 [polkadot_runtime_common::paras_registrar, Registrar]
1855 [polkadot_runtime_parachains::configuration, Configuration]
1856 [polkadot_runtime_parachains::coretime, Coretime]
1857 [polkadot_runtime_parachains::hrmp, Hrmp]
1858 [polkadot_runtime_parachains::disputes, ParasDisputes]
1859 [polkadot_runtime_parachains::inclusion, ParaInclusion]
1860 [polkadot_runtime_parachains::initializer, Initializer]
1861 [polkadot_runtime_parachains::paras_inherent, ParaInherent]
1862 [polkadot_runtime_parachains::paras, Paras]
1863 [polkadot_runtime_parachains::on_demand, OnDemandAssignmentProvider]
1864 [pallet_balances, Balances]
1866 [pallet_balances, NisCounterpartBalances]
1867 [pallet_beefy_mmr, MmrLeaf]
1868 [frame_benchmarking::baseline, Baseline::<Runtime>]
1869 [pallet_bounties, Bounties]
1870 [pallet_child_bounties, ChildBounties]
1871 [pallet_conviction_voting, ConvictionVoting]
1872 [pallet_nis, Nis]
1873 [pallet_identity, Identity]
1874 [pallet_indices, Indices]
1875 [pallet_message_queue, MessageQueue]
1876 [pallet_migrations, MultiBlockMigrations]
1877 [pallet_mmr, Mmr]
1878 [pallet_multisig, Multisig]
1879 [pallet_parameters, Parameters]
1880 [pallet_preimage, Preimage]
1881 [pallet_proxy, Proxy]
1882 [pallet_ranked_collective, FellowshipCollective]
1883 [pallet_recovery, Recovery]
1884 [pallet_referenda, Referenda]
1885 [pallet_referenda, FellowshipReferenda]
1886 [pallet_scheduler, Scheduler]
1887 [pallet_sudo, Sudo]
1888 [frame_system, SystemBench::<Runtime>]
1889 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
1890 [pallet_timestamp, Timestamp]
1891 [pallet_transaction_payment, TransactionPayment]
1892 [pallet_treasury, Treasury]
1893 [pallet_utility, Utility]
1894 [pallet_vesting, Vesting]
1895 [pallet_asset_rate, AssetRate]
1896 [pallet_whitelist, Whitelist]
1897 [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
1899 [pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
1900 [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
1901 );
1902}
1903
1904sp_api::impl_runtime_apis! {
1905 impl sp_api::Core<Block> for Runtime {
1906 fn version() -> RuntimeVersion {
1907 VERSION
1908 }
1909
1910 fn execute_block(block: Block) {
1911 Executive::execute_block(block);
1912 }
1913
1914 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
1915 Executive::initialize_block(header)
1916 }
1917 }
1918
1919 impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
1920 fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
1921 let acceptable_assets = vec![AssetId(xcm_config::TokenLocation::get())];
1922 XcmPallet::query_acceptable_payment_assets(xcm_version, acceptable_assets)
1923 }
1924
1925 fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
1926 use crate::xcm_config::XcmConfig;
1927
1928 type Trader = <XcmConfig as xcm_executor::Config>::Trader;
1929
1930 XcmPallet::query_weight_to_asset_fee::<Trader>(weight, asset)
1931 }
1932
1933 fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
1934 XcmPallet::query_xcm_weight(message)
1935 }
1936
1937 fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result<VersionedAssets, XcmPaymentApiError> {
1938 XcmPallet::query_delivery_fees(destination, message)
1939 }
1940 }
1941
1942 impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
1943 fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
1944 XcmPallet::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
1945 }
1946
1947 fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
1948 XcmPallet::dry_run_xcm::<Runtime, xcm_config::XcmRouter, RuntimeCall, xcm_config::XcmConfig>(origin_location, xcm)
1949 }
1950 }
1951
1952 impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
1953 fn convert_location(location: VersionedLocation) -> Result<
1954 AccountId,
1955 xcm_runtime_apis::conversions::Error
1956 > {
1957 xcm_runtime_apis::conversions::LocationToAccountHelper::<
1958 AccountId,
1959 xcm_config::LocationConverter,
1960 >::convert_location(location)
1961 }
1962 }
1963
1964 impl sp_api::Metadata<Block> for Runtime {
1965 fn metadata() -> OpaqueMetadata {
1966 OpaqueMetadata::new(Runtime::metadata().into())
1967 }
1968
1969 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
1970 Runtime::metadata_at_version(version)
1971 }
1972
1973 fn metadata_versions() -> alloc::vec::Vec<u32> {
1974 Runtime::metadata_versions()
1975 }
1976 }
1977
1978 impl sp_block_builder::BlockBuilder<Block> for Runtime {
1979 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
1980 Executive::apply_extrinsic(extrinsic)
1981 }
1982
1983 fn finalize_block() -> <Block as BlockT>::Header {
1984 Executive::finalize_block()
1985 }
1986
1987 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
1988 data.create_extrinsics()
1989 }
1990
1991 fn check_inherents(
1992 block: Block,
1993 data: sp_inherents::InherentData,
1994 ) -> sp_inherents::CheckInherentsResult {
1995 data.check_extrinsics(&block)
1996 }
1997 }
1998
1999 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
2000 fn validate_transaction(
2001 source: TransactionSource,
2002 tx: <Block as BlockT>::Extrinsic,
2003 block_hash: <Block as BlockT>::Hash,
2004 ) -> TransactionValidity {
2005 Executive::validate_transaction(source, tx, block_hash)
2006 }
2007 }
2008
2009 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
2010 fn offchain_worker(header: &<Block as BlockT>::Header) {
2011 Executive::offchain_worker(header)
2012 }
2013 }
2014
2015 #[api_version(13)]
2016 impl polkadot_primitives::runtime_api::ParachainHost<Block> for Runtime {
2017 fn validators() -> Vec<ValidatorId> {
2018 parachains_runtime_api_impl::validators::<Runtime>()
2019 }
2020
2021 fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>) {
2022 parachains_runtime_api_impl::validator_groups::<Runtime>()
2023 }
2024
2025 fn availability_cores() -> Vec<CoreState<Hash, BlockNumber>> {
2026 parachains_runtime_api_impl::availability_cores::<Runtime>()
2027 }
2028
2029 fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
2030 -> Option<PersistedValidationData<Hash, BlockNumber>> {
2031 parachains_runtime_api_impl::persisted_validation_data::<Runtime>(para_id, assumption)
2032 }
2033
2034 fn assumed_validation_data(
2035 para_id: ParaId,
2036 expected_persisted_validation_data_hash: Hash,
2037 ) -> Option<(PersistedValidationData<Hash, BlockNumber>, ValidationCodeHash)> {
2038 parachains_runtime_api_impl::assumed_validation_data::<Runtime>(
2039 para_id,
2040 expected_persisted_validation_data_hash,
2041 )
2042 }
2043
2044 fn check_validation_outputs(
2045 para_id: ParaId,
2046 outputs: polkadot_primitives::CandidateCommitments,
2047 ) -> bool {
2048 parachains_runtime_api_impl::check_validation_outputs::<Runtime>(para_id, outputs)
2049 }
2050
2051 fn session_index_for_child() -> SessionIndex {
2052 parachains_runtime_api_impl::session_index_for_child::<Runtime>()
2053 }
2054
2055 fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption)
2056 -> Option<ValidationCode> {
2057 parachains_runtime_api_impl::validation_code::<Runtime>(para_id, assumption)
2058 }
2059
2060 fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
2061 #[allow(deprecated)]
2062 parachains_runtime_api_impl::candidate_pending_availability::<Runtime>(para_id)
2063 }
2064
2065 fn candidate_events() -> Vec<CandidateEvent<Hash>> {
2066 parachains_runtime_api_impl::candidate_events::<Runtime, _>(|ev| {
2067 match ev {
2068 RuntimeEvent::ParaInclusion(ev) => {
2069 Some(ev)
2070 }
2071 _ => None,
2072 }
2073 })
2074 }
2075
2076 fn session_info(index: SessionIndex) -> Option<SessionInfo> {
2077 parachains_runtime_api_impl::session_info::<Runtime>(index)
2078 }
2079
2080 fn session_executor_params(session_index: SessionIndex) -> Option<ExecutorParams> {
2081 parachains_runtime_api_impl::session_executor_params::<Runtime>(session_index)
2082 }
2083
2084 fn dmq_contents(recipient: ParaId) -> Vec<InboundDownwardMessage<BlockNumber>> {
2085 parachains_runtime_api_impl::dmq_contents::<Runtime>(recipient)
2086 }
2087
2088 fn inbound_hrmp_channels_contents(
2089 recipient: ParaId
2090 ) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
2091 parachains_runtime_api_impl::inbound_hrmp_channels_contents::<Runtime>(recipient)
2092 }
2093
2094 fn validation_code_by_hash(hash: ValidationCodeHash) -> Option<ValidationCode> {
2095 parachains_runtime_api_impl::validation_code_by_hash::<Runtime>(hash)
2096 }
2097
2098 fn on_chain_votes() -> Option<ScrapedOnChainVotes<Hash>> {
2099 parachains_runtime_api_impl::on_chain_votes::<Runtime>()
2100 }
2101
2102 fn submit_pvf_check_statement(
2103 stmt: polkadot_primitives::PvfCheckStatement,
2104 signature: polkadot_primitives::ValidatorSignature
2105 ) {
2106 parachains_runtime_api_impl::submit_pvf_check_statement::<Runtime>(stmt, signature)
2107 }
2108
2109 fn pvfs_require_precheck() -> Vec<ValidationCodeHash> {
2110 parachains_runtime_api_impl::pvfs_require_precheck::<Runtime>()
2111 }
2112
2113 fn validation_code_hash(para_id: ParaId, assumption: OccupiedCoreAssumption)
2114 -> Option<ValidationCodeHash>
2115 {
2116 parachains_runtime_api_impl::validation_code_hash::<Runtime>(para_id, assumption)
2117 }
2118
2119 fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)> {
2120 parachains_runtime_api_impl::get_session_disputes::<Runtime>()
2121 }
2122
2123 fn unapplied_slashes(
2124 ) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
2125 parachains_runtime_api_impl::unapplied_slashes::<Runtime>()
2126 }
2127
2128 fn key_ownership_proof(
2129 validator_id: ValidatorId,
2130 ) -> Option<slashing::OpaqueKeyOwnershipProof> {
2131 use codec::Encode;
2132
2133 Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
2134 .map(|p| p.encode())
2135 .map(slashing::OpaqueKeyOwnershipProof::new)
2136 }
2137
2138 fn submit_report_dispute_lost(
2139 dispute_proof: slashing::DisputeProof,
2140 key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
2141 ) -> Option<()> {
2142 parachains_runtime_api_impl::submit_unsigned_slashing_report::<Runtime>(
2143 dispute_proof,
2144 key_ownership_proof,
2145 )
2146 }
2147
2148 fn minimum_backing_votes() -> u32 {
2149 parachains_runtime_api_impl::minimum_backing_votes::<Runtime>()
2150 }
2151
2152 fn para_backing_state(para_id: ParaId) -> Option<polkadot_primitives::vstaging::async_backing::BackingState> {
2153 #[allow(deprecated)]
2154 parachains_runtime_api_impl::backing_state::<Runtime>(para_id)
2155 }
2156
2157 fn async_backing_params() -> polkadot_primitives::AsyncBackingParams {
2158 #[allow(deprecated)]
2159 parachains_runtime_api_impl::async_backing_params::<Runtime>()
2160 }
2161
2162 fn approval_voting_params() -> ApprovalVotingParams {
2163 parachains_runtime_api_impl::approval_voting_params::<Runtime>()
2164 }
2165
2166 fn disabled_validators() -> Vec<ValidatorIndex> {
2167 parachains_runtime_api_impl::disabled_validators::<Runtime>()
2168 }
2169
2170 fn node_features() -> NodeFeatures {
2171 parachains_runtime_api_impl::node_features::<Runtime>()
2172 }
2173
2174 fn claim_queue() -> BTreeMap<CoreIndex, VecDeque<ParaId>> {
2175 parachains_runtime_api_impl::claim_queue::<Runtime>()
2176 }
2177
2178 fn candidates_pending_availability(para_id: ParaId) -> Vec<CommittedCandidateReceipt<Hash>> {
2179 parachains_runtime_api_impl::candidates_pending_availability::<Runtime>(para_id)
2180 }
2181
2182 fn backing_constraints(para_id: ParaId) -> Option<Constraints> {
2183 parachains_staging_runtime_api_impl::backing_constraints::<Runtime>(para_id)
2184 }
2185
2186 fn scheduling_lookahead() -> u32 {
2187 parachains_staging_runtime_api_impl::scheduling_lookahead::<Runtime>()
2188 }
2189
2190 fn validation_code_bomb_limit() -> u32 {
2191 parachains_staging_runtime_api_impl::validation_code_bomb_limit::<Runtime>()
2192 }
2193 }
2194
2195 #[api_version(5)]
2196 impl sp_consensus_beefy::BeefyApi<Block, BeefyId> for Runtime {
2197 fn beefy_genesis() -> Option<BlockNumber> {
2198 pallet_beefy::GenesisBlock::<Runtime>::get()
2199 }
2200
2201 fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<BeefyId>> {
2202 Beefy::validator_set()
2203 }
2204
2205 fn submit_report_double_voting_unsigned_extrinsic(
2206 equivocation_proof: sp_consensus_beefy::DoubleVotingProof<
2207 BlockNumber,
2208 BeefyId,
2209 BeefySignature,
2210 >,
2211 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2212 ) -> Option<()> {
2213 let key_owner_proof = key_owner_proof.decode()?;
2214
2215 Beefy::submit_unsigned_double_voting_report(
2216 equivocation_proof,
2217 key_owner_proof,
2218 )
2219 }
2220
2221 fn submit_report_fork_voting_unsigned_extrinsic(
2222 equivocation_proof:
2223 sp_consensus_beefy::ForkVotingProof<
2224 <Block as BlockT>::Header,
2225 BeefyId,
2226 sp_runtime::OpaqueValue
2227 >,
2228 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2229 ) -> Option<()> {
2230 Beefy::submit_unsigned_fork_voting_report(
2231 equivocation_proof.try_into()?,
2232 key_owner_proof.decode()?,
2233 )
2234 }
2235
2236 fn submit_report_future_block_voting_unsigned_extrinsic(
2237 equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof<BlockNumber, BeefyId>,
2238 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2239 ) -> Option<()> {
2240 Beefy::submit_unsigned_future_block_voting_report(
2241 equivocation_proof,
2242 key_owner_proof.decode()?,
2243 )
2244 }
2245
2246 fn generate_key_ownership_proof(
2247 _set_id: sp_consensus_beefy::ValidatorSetId,
2248 authority_id: BeefyId,
2249 ) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> {
2250 use codec::Encode;
2251
2252 Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id))
2253 .map(|p| p.encode())
2254 .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new)
2255 }
2256
2257 fn generate_ancestry_proof(
2258 prev_block_number: BlockNumber,
2259 best_known_block_number: Option<BlockNumber>,
2260 ) -> Option<sp_runtime::OpaqueValue> {
2261 use sp_consensus_beefy::AncestryHelper;
2262
2263 MmrLeaf::generate_proof(prev_block_number, best_known_block_number)
2264 .map(|p| p.encode())
2265 .map(sp_runtime::OpaqueValue::new)
2266 }
2267 }
2268
2269 #[api_version(2)]
2270 impl mmr::MmrApi<Block, mmr::Hash, BlockNumber> for Runtime {
2271 fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
2272 Ok(pallet_mmr::RootHash::<Runtime>::get())
2273 }
2274
2275 fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
2276 Ok(pallet_mmr::NumberOfLeaves::<Runtime>::get())
2277 }
2278
2279 fn generate_proof(
2280 block_numbers: Vec<BlockNumber>,
2281 best_known_block_number: Option<BlockNumber>,
2282 ) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::LeafProof<mmr::Hash>), mmr::Error> {
2283 Mmr::generate_proof(block_numbers, best_known_block_number).map(
2284 |(leaves, proof)| {
2285 (
2286 leaves
2287 .into_iter()
2288 .map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
2289 .collect(),
2290 proof,
2291 )
2292 },
2293 )
2294 }
2295
2296 fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::LeafProof<mmr::Hash>)
2297 -> Result<(), mmr::Error>
2298 {
2299 let leaves = leaves.into_iter().map(|leaf|
2300 leaf.into_opaque_leaf()
2301 .try_decode()
2302 .ok_or(mmr::Error::Verify)).collect::<Result<Vec<mmr::Leaf>, mmr::Error>>()?;
2303 Mmr::verify_leaves(leaves, proof)
2304 }
2305
2306 fn verify_proof_stateless(
2307 root: mmr::Hash,
2308 leaves: Vec<mmr::EncodableOpaqueLeaf>,
2309 proof: mmr::LeafProof<mmr::Hash>
2310 ) -> Result<(), mmr::Error> {
2311 let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect();
2312 pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(root, nodes, proof)
2313 }
2314 }
2315
2316 impl fg_primitives::GrandpaApi<Block> for Runtime {
2317 fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
2318 Grandpa::grandpa_authorities()
2319 }
2320
2321 fn current_set_id() -> fg_primitives::SetId {
2322 pallet_grandpa::CurrentSetId::<Runtime>::get()
2323 }
2324
2325 fn submit_report_equivocation_unsigned_extrinsic(
2326 equivocation_proof: fg_primitives::EquivocationProof<
2327 <Block as BlockT>::Hash,
2328 sp_runtime::traits::NumberFor<Block>,
2329 >,
2330 key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
2331 ) -> Option<()> {
2332 let key_owner_proof = key_owner_proof.decode()?;
2333
2334 Grandpa::submit_unsigned_equivocation_report(
2335 equivocation_proof,
2336 key_owner_proof,
2337 )
2338 }
2339
2340 fn generate_key_ownership_proof(
2341 _set_id: fg_primitives::SetId,
2342 authority_id: fg_primitives::AuthorityId,
2343 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
2344 use codec::Encode;
2345
2346 Historical::prove((fg_primitives::KEY_TYPE, authority_id))
2347 .map(|p| p.encode())
2348 .map(fg_primitives::OpaqueKeyOwnershipProof::new)
2349 }
2350 }
2351
2352 impl sp_consensus_babe::BabeApi<Block> for Runtime {
2353 fn configuration() -> sp_consensus_babe::BabeConfiguration {
2354 let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
2355 sp_consensus_babe::BabeConfiguration {
2356 slot_duration: Babe::slot_duration(),
2357 epoch_length: EpochDurationInBlocks::get().into(),
2358 c: epoch_config.c,
2359 authorities: Babe::authorities().to_vec(),
2360 randomness: Babe::randomness(),
2361 allowed_slots: epoch_config.allowed_slots,
2362 }
2363 }
2364
2365 fn current_epoch_start() -> sp_consensus_babe::Slot {
2366 Babe::current_epoch_start()
2367 }
2368
2369 fn current_epoch() -> sp_consensus_babe::Epoch {
2370 Babe::current_epoch()
2371 }
2372
2373 fn next_epoch() -> sp_consensus_babe::Epoch {
2374 Babe::next_epoch()
2375 }
2376
2377 fn generate_key_ownership_proof(
2378 _slot: sp_consensus_babe::Slot,
2379 authority_id: sp_consensus_babe::AuthorityId,
2380 ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
2381 use codec::Encode;
2382
2383 Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id))
2384 .map(|p| p.encode())
2385 .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new)
2386 }
2387
2388 fn submit_report_equivocation_unsigned_extrinsic(
2389 equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>,
2390 key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
2391 ) -> Option<()> {
2392 let key_owner_proof = key_owner_proof.decode()?;
2393
2394 Babe::submit_unsigned_equivocation_report(
2395 equivocation_proof,
2396 key_owner_proof,
2397 )
2398 }
2399 }
2400
2401 impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
2402 fn authorities() -> Vec<AuthorityDiscoveryId> {
2403 parachains_runtime_api_impl::relevant_authority_ids::<Runtime>()
2404 }
2405 }
2406
2407 impl sp_session::SessionKeys<Block> for Runtime {
2408 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
2409 SessionKeys::generate(seed)
2410 }
2411
2412 fn decode_session_keys(
2413 encoded: Vec<u8>,
2414 ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
2415 SessionKeys::decode_into_raw_public_keys(&encoded)
2416 }
2417 }
2418
2419 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
2420 fn account_nonce(account: AccountId) -> Nonce {
2421 System::account_nonce(account)
2422 }
2423 }
2424
2425 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
2426 Block,
2427 Balance,
2428 > for Runtime {
2429 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
2430 TransactionPayment::query_info(uxt, len)
2431 }
2432 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
2433 TransactionPayment::query_fee_details(uxt, len)
2434 }
2435 fn query_weight_to_fee(weight: Weight) -> Balance {
2436 TransactionPayment::weight_to_fee(weight)
2437 }
2438 fn query_length_to_fee(length: u32) -> Balance {
2439 TransactionPayment::length_to_fee(length)
2440 }
2441 }
2442
2443 impl pallet_beefy_mmr::BeefyMmrApi<Block, Hash> for RuntimeApi {
2444 fn authority_set_proof() -> sp_consensus_beefy::mmr::BeefyAuthoritySet<Hash> {
2445 MmrLeaf::authority_set_proof()
2446 }
2447
2448 fn next_authority_set_proof() -> sp_consensus_beefy::mmr::BeefyNextAuthoritySet<Hash> {
2449 MmrLeaf::next_authority_set_proof()
2450 }
2451 }
2452
2453 #[cfg(feature = "try-runtime")]
2454 impl frame_try_runtime::TryRuntime<Block> for Runtime {
2455 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
2456 log::info!("try-runtime::on_runtime_upgrade rococo.");
2457 let weight = Executive::try_runtime_upgrade(checks).unwrap();
2458 (weight, BlockWeights::get().max_block)
2459 }
2460
2461 fn execute_block(
2462 block: Block,
2463 state_root_check: bool,
2464 signature_check: bool,
2465 select: frame_try_runtime::TryStateSelect,
2466 ) -> Weight {
2467 Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
2470 }
2471 }
2472
2473 #[cfg(feature = "runtime-benchmarks")]
2474 impl frame_benchmarking::Benchmark<Block> for Runtime {
2475 fn benchmark_metadata(extra: bool) -> (
2476 Vec<frame_benchmarking::BenchmarkList>,
2477 Vec<frame_support::traits::StorageInfo>,
2478 ) {
2479 use frame_benchmarking::BenchmarkList;
2480 use frame_support::traits::StorageInfoTrait;
2481
2482 use frame_system_benchmarking::Pallet as SystemBench;
2483 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2484 use frame_benchmarking::baseline::Pallet as Baseline;
2485
2486 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2487
2488 let mut list = Vec::<BenchmarkList>::new();
2489 list_benchmarks!(list, extra);
2490
2491 let storage_info = AllPalletsWithSystem::storage_info();
2492 return (list, storage_info)
2493 }
2494
2495 #[allow(non_local_definitions)]
2496 fn dispatch_benchmark(
2497 config: frame_benchmarking::BenchmarkConfig,
2498 ) -> Result<
2499 Vec<frame_benchmarking::BenchmarkBatch>,
2500 alloc::string::String,
2501 > {
2502 use frame_support::traits::WhitelistedStorageKeys;
2503 use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
2504 use frame_system_benchmarking::Pallet as SystemBench;
2505 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2506 use frame_benchmarking::baseline::Pallet as Baseline;
2507 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2508 use sp_storage::TrackedStorageKey;
2509 use xcm::latest::prelude::*;
2510 use xcm_config::{
2511 AssetHub, LocalCheckAccount, LocationConverter, TokenLocation, XcmConfig,
2512 };
2513
2514 parameter_types! {
2515 pub ExistentialDepositAsset: Option<Asset> = Some((
2516 TokenLocation::get(),
2517 ExistentialDeposit::get()
2518 ).into());
2519 pub AssetHubParaId: ParaId = rococo_runtime_constants::system_parachain::ASSET_HUB_ID.into();
2520 pub const RandomParaId: ParaId = ParaId::new(43211234);
2521 }
2522
2523 impl frame_system_benchmarking::Config for Runtime {}
2524 impl frame_benchmarking::baseline::Config for Runtime {}
2525 impl pallet_xcm::benchmarking::Config for Runtime {
2526 type DeliveryHelper = (
2527 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2528 XcmConfig,
2529 ExistentialDepositAsset,
2530 xcm_config::PriceForChildParachainDelivery,
2531 AssetHubParaId,
2532 Dmp,
2533 >,
2534 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2535 XcmConfig,
2536 ExistentialDepositAsset,
2537 xcm_config::PriceForChildParachainDelivery,
2538 RandomParaId,
2539 Dmp,
2540 >
2541 );
2542
2543 fn reachable_dest() -> Option<Location> {
2544 Some(crate::xcm_config::AssetHub::get())
2545 }
2546
2547 fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
2548 Some((
2550 Asset {
2551 fun: Fungible(ExistentialDeposit::get()),
2552 id: AssetId(Here.into())
2553 },
2554 crate::xcm_config::AssetHub::get(),
2555 ))
2556 }
2557
2558 fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
2559 None
2560 }
2561
2562 fn set_up_complex_asset_transfer(
2563 ) -> Option<(Assets, u32, Location, alloc::boxed::Box<dyn FnOnce()>)> {
2564 let native_location = Here.into();
2569 let dest = crate::xcm_config::AssetHub::get();
2570 pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
2571 native_location,
2572 dest
2573 )
2574 }
2575
2576 fn get_asset() -> Asset {
2577 Asset {
2578 id: AssetId(Location::here()),
2579 fun: Fungible(ExistentialDeposit::get()),
2580 }
2581 }
2582 }
2583 impl pallet_xcm_benchmarks::Config for Runtime {
2584 type XcmConfig = XcmConfig;
2585 type AccountIdConverter = LocationConverter;
2586 type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2587 XcmConfig,
2588 ExistentialDepositAsset,
2589 xcm_config::PriceForChildParachainDelivery,
2590 AssetHubParaId,
2591 Dmp,
2592 >;
2593 fn valid_destination() -> Result<Location, BenchmarkError> {
2594 Ok(AssetHub::get())
2595 }
2596 fn worst_case_holding(_depositable_count: u32) -> Assets {
2597 vec![Asset{
2599 id: AssetId(TokenLocation::get()),
2600 fun: Fungible(1_000_000 * UNITS),
2601 }].into()
2602 }
2603 }
2604
2605 parameter_types! {
2606 pub TrustedTeleporter: Option<(Location, Asset)> = Some((
2607 AssetHub::get(),
2608 Asset { fun: Fungible(1 * UNITS), id: AssetId(TokenLocation::get()) },
2609 ));
2610 pub TrustedReserve: Option<(Location, Asset)> = None;
2611 }
2612
2613 impl pallet_xcm_benchmarks::fungible::Config for Runtime {
2614 type TransactAsset = Balances;
2615
2616 type CheckedAccount = LocalCheckAccount;
2617 type TrustedTeleporter = TrustedTeleporter;
2618 type TrustedReserve = TrustedReserve;
2619
2620 fn get_asset() -> Asset {
2621 Asset {
2622 id: AssetId(TokenLocation::get()),
2623 fun: Fungible(1 * UNITS),
2624 }
2625 }
2626 }
2627
2628 impl pallet_xcm_benchmarks::generic::Config for Runtime {
2629 type TransactAsset = Balances;
2630 type RuntimeCall = RuntimeCall;
2631
2632 fn worst_case_response() -> (u64, Response) {
2633 (0u64, Response::Version(Default::default()))
2634 }
2635
2636 fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
2637 Err(BenchmarkError::Skip)
2639 }
2640
2641 fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
2642 Err(BenchmarkError::Skip)
2644 }
2645
2646 fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
2647 Ok((AssetHub::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
2648 }
2649
2650 fn subscribe_origin() -> Result<Location, BenchmarkError> {
2651 Ok(AssetHub::get())
2652 }
2653
2654 fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
2655 let origin = AssetHub::get();
2656 let assets: Assets = (AssetId(TokenLocation::get()), 1_000 * UNITS).into();
2657 let ticket = Location { parents: 0, interior: Here };
2658 Ok((origin, ticket, assets))
2659 }
2660
2661 fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
2662 Ok((Asset {
2663 id: AssetId(TokenLocation::get()),
2664 fun: Fungible(1_000_000 * UNITS),
2665 }, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
2666 }
2667
2668 fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
2669 Err(BenchmarkError::Skip)
2671 }
2672
2673 fn export_message_origin_and_destination(
2674 ) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
2675 Err(BenchmarkError::Skip)
2677 }
2678
2679 fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
2680 Err(BenchmarkError::Skip)
2682 }
2683 }
2684
2685 let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
2686 let treasury_key = frame_system::Account::<Runtime>::hashed_key_for(Treasury::account_id());
2687 whitelist.push(treasury_key.to_vec().into());
2688
2689 let mut batches = Vec::<BenchmarkBatch>::new();
2690 let params = (&config, &whitelist);
2691
2692 add_benchmarks!(params, batches);
2693
2694 Ok(batches)
2695 }
2696 }
2697
2698 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
2699 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
2700 build_state::<RuntimeGenesisConfig>(config)
2701 }
2702
2703 fn get_preset(id: &Option<PresetId>) -> Option<Vec<u8>> {
2704 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
2705 }
2706
2707 fn preset_names() -> Vec<PresetId> {
2708 genesis_config_presets::preset_names()
2709 }
2710 }
2711
2712 impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
2713 fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
2714 XcmPallet::is_trusted_reserve(asset, location)
2715 }
2716 fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
2717 XcmPallet::is_trusted_teleporter(asset, location)
2718 }
2719 }
2720}
2721
2722#[cfg(all(test, feature = "try-runtime"))]
2723mod remote_tests {
2724 use super::*;
2725 use frame_try_runtime::{runtime_decl_for_try_runtime::TryRuntime, UpgradeCheckSelect};
2726 use remote_externalities::{
2727 Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig, Transport,
2728 };
2729 use std::env::var;
2730
2731 #[tokio::test]
2732 async fn run_migrations() {
2733 if var("RUN_MIGRATION_TESTS").is_err() {
2734 return;
2735 }
2736
2737 sp_tracing::try_init_simple();
2738 let transport: Transport =
2739 var("WS").unwrap_or("wss://rococo-rpc.polkadot.io:443".to_string()).into();
2740 let maybe_state_snapshot: Option<SnapshotConfig> = var("SNAP").map(|s| s.into()).ok();
2741 let mut ext = Builder::<Block>::default()
2742 .mode(if let Some(state_snapshot) = maybe_state_snapshot {
2743 Mode::OfflineOrElseOnline(
2744 OfflineConfig { state_snapshot: state_snapshot.clone() },
2745 OnlineConfig {
2746 transport,
2747 state_snapshot: Some(state_snapshot),
2748 ..Default::default()
2749 },
2750 )
2751 } else {
2752 Mode::Online(OnlineConfig { transport, ..Default::default() })
2753 })
2754 .build()
2755 .await
2756 .unwrap();
2757 ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost));
2758 }
2759}