1#![cfg_attr(not(feature = "std"), no_std)]
20#![recursion_limit = "256"]
22
23extern crate alloc;
24
25use alloc::{
26 collections::{btree_map::BTreeMap, vec_deque::VecDeque},
27 vec,
28 vec::Vec,
29};
30use codec::Encode;
31use pallet_transaction_payment::FungibleAdapter;
32
33use polkadot_runtime_parachains::{
34 assigner_coretime as parachains_assigner_coretime, configuration as parachains_configuration,
35 configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio,
36 coretime, disputes as parachains_disputes,
37 disputes::slashing as parachains_slashing,
38 dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
39 initializer as parachains_initializer, on_demand as parachains_on_demand,
40 origin as parachains_origin, paras as parachains_paras,
41 paras_inherent as parachains_paras_inherent,
42 runtime_api_impl::{v13 as runtime_impl, vstaging as staging_runtime_impl},
43 scheduler as parachains_scheduler, session_info as parachains_session_info,
44 shared as parachains_shared,
45};
46
47use frame_election_provider_support::{
48 bounds::{ElectionBounds, ElectionBoundsBuilder},
49 onchain, SequentialPhragmen,
50};
51use frame_support::{
52 construct_runtime, derive_impl,
53 genesis_builder_helper::{build_state, get_preset},
54 parameter_types,
55 traits::{KeyOwnerProofSystem, WithdrawReasons},
56 PalletId,
57};
58use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
59use pallet_session::historical as session_historical;
60use pallet_timestamp::Now;
61use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
62use polkadot_primitives::{
63 async_backing::Constraints, slashing, AccountId, AccountIndex, Balance, BlockNumber,
64 CandidateEvent, CandidateHash, CommittedCandidateReceiptV2 as CommittedCandidateReceipt,
65 CoreIndex, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash as HashT,
66 Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce,
67 OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes,
68 SessionInfo as SessionInfoData, Signature, ValidationCode, ValidationCodeHash, ValidatorId,
69 ValidatorIndex, PARACHAIN_KEY_TYPE_ID,
70};
71use polkadot_runtime_common::{
72 claims, impl_runtime_weights, paras_sudo_wrapper, BlockHashCount, BlockLength,
73 SlowAdjustingFeeUpdate,
74};
75use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints;
76use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
77use sp_consensus_beefy::ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
78use sp_core::{ConstBool, ConstU32, ConstUint, Get, OpaqueMetadata};
79use sp_mmr_primitives as mmr;
80use sp_runtime::{
81 curve::PiecewiseLinear,
82 generic, impl_opaque_keys,
83 traits::{
84 BlakeTwo256, Block as BlockT, ConvertInto, OpaqueKeys, SaturatedConversion, StaticLookup,
85 Verify,
86 },
87 transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
88 ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent,
89};
90use sp_staking::SessionIndex;
91#[cfg(any(feature = "std", test))]
92use sp_version::NativeVersion;
93use sp_version::RuntimeVersion;
94use xcm::latest::{Assets, InteriorLocation, Location, SendError, SendResult, SendXcm, XcmHash};
95
96pub use pallet_balances::Call as BalancesCall;
97#[cfg(feature = "std")]
98pub use pallet_staking::StakerStatus;
99pub use pallet_sudo::Call as SudoCall;
100pub use pallet_timestamp::Call as TimestampCall;
101pub use parachains_paras::Call as ParasCall;
102pub use paras_sudo_wrapper::Call as ParasSudoWrapperCall;
103#[cfg(any(feature = "std", test))]
104pub use sp_runtime::BuildStorage;
105
106use test_runtime_constants::{currency::*, fee::*, time::*};
108pub mod xcm_config;
109
110impl_runtime_weights!(test_runtime_constants);
111
112#[cfg(feature = "std")]
114include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
115
116#[sp_version::runtime_version]
118pub const VERSION: RuntimeVersion = RuntimeVersion {
119 spec_name: alloc::borrow::Cow::Borrowed("polkadot-test-runtime"),
120 impl_name: alloc::borrow::Cow::Borrowed("parity-polkadot-test-runtime"),
121 authoring_version: 2,
122 spec_version: 1056,
123 impl_version: 0,
124 apis: RUNTIME_API_VERSIONS,
125 transaction_version: 1,
126 system_version: 1,
127};
128
129pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
131 sp_consensus_babe::BabeEpochConfiguration {
132 c: PRIMARY_PROBABILITY,
133 allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots,
134 };
135
136#[cfg(any(feature = "std", test))]
138pub fn native_version() -> NativeVersion {
139 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
140}
141
142sp_api::decl_runtime_apis! {
143 pub trait GetLastTimestamp {
144 fn get_last_timestamp() -> u64;
146 }
147}
148
149parameter_types! {
150 pub const Version: RuntimeVersion = VERSION;
151 pub const SS58Prefix: u8 = 42;
152}
153
154#[derive_impl(frame_system::config_preludes::RelayChainDefaultConfig)]
155impl frame_system::Config for Runtime {
156 type BlockWeights = BlockWeights;
157 type BlockLength = BlockLength;
158 type Nonce = Nonce;
159 type Hash = HashT;
160 type AccountId = AccountId;
161 type Lookup = Indices;
162 type Block = Block;
163 type BlockHashCount = BlockHashCount;
164 type Version = Version;
165 type AccountData = pallet_balances::AccountData<Balance>;
166 type SS58Prefix = SS58Prefix;
167 type MaxConsumers = frame_support::traits::ConstU32<16>;
168}
169
170impl<C> frame_system::offchain::CreateTransactionBase<C> for Runtime
171where
172 RuntimeCall: From<C>,
173{
174 type RuntimeCall = RuntimeCall;
175 type Extrinsic = UncheckedExtrinsic;
176}
177
178impl<C> frame_system::offchain::CreateBare<C> for Runtime
179where
180 RuntimeCall: From<C>,
181{
182 fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
183 UncheckedExtrinsic::new_bare(call)
184 }
185}
186
187impl<C> frame_system::offchain::CreateTransaction<C> for Runtime
188where
189 RuntimeCall: From<C>,
190{
191 type Extension = TxExtension;
192
193 fn create_transaction(call: Self::RuntimeCall, extension: Self::Extension) -> Self::Extrinsic {
194 UncheckedExtrinsic::new_transaction(call, extension)
195 }
196}
197
198impl<C> frame_system::offchain::CreateAuthorizedTransaction<C> for Runtime
199where
200 RuntimeCall: From<C>,
201{
202 fn create_extension() -> Self::Extension {
203 (
204 frame_system::AuthorizeCall::<Runtime>::new(),
205 frame_system::CheckNonZeroSender::<Runtime>::new(),
206 frame_system::CheckSpecVersion::<Runtime>::new(),
207 frame_system::CheckTxVersion::<Runtime>::new(),
208 frame_system::CheckGenesis::<Runtime>::new(),
209 frame_system::CheckMortality::<Runtime>::from(generic::Era::Immortal),
210 frame_system::CheckNonce::<Runtime>::from(0),
211 frame_system::CheckWeight::<Runtime>::new(),
212 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
213 frame_system::WeightReclaim::<Runtime>::new(),
214 )
215 }
216}
217
218parameter_types! {
219 pub storage EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64;
220 pub storage ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
221 pub ReportLongevity: u64 =
222 BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * EpochDuration::get();
223}
224
225impl pallet_babe::Config for Runtime {
226 type EpochDuration = EpochDuration;
227 type ExpectedBlockTime = ExpectedBlockTime;
228
229 type EpochChangeTrigger = pallet_babe::ExternalTrigger;
231
232 type DisabledValidators = ();
233
234 type WeightInfo = ();
235
236 type MaxAuthorities = MaxAuthorities;
237 type MaxNominators = MaxNominators;
238
239 type KeyOwnerProof =
240 <Historical as KeyOwnerProofSystem<(KeyTypeId, pallet_babe::AuthorityId)>>::Proof;
241
242 type EquivocationReportSystem = ();
243}
244
245parameter_types! {
246 pub storage IndexDeposit: Balance = 1 * DOLLARS;
247}
248
249impl pallet_indices::Config for Runtime {
250 type AccountIndex = AccountIndex;
251 type Currency = Balances;
252 type Deposit = IndexDeposit;
253 type RuntimeEvent = RuntimeEvent;
254 type WeightInfo = ();
255}
256
257parameter_types! {
258 pub const ExistentialDeposit: Balance = 1 * CENTS;
259 pub storage MaxLocks: u32 = 50;
260 pub const MaxReserves: u32 = 50;
261}
262
263impl pallet_balances::Config for Runtime {
264 type Balance = Balance;
265 type DustRemoval = ();
266 type RuntimeEvent = RuntimeEvent;
267 type ExistentialDeposit = ExistentialDeposit;
268 type AccountStore = System;
269 type MaxLocks = MaxLocks;
270 type MaxReserves = MaxReserves;
271 type ReserveIdentifier = [u8; 8];
272 type WeightInfo = ();
273 type RuntimeHoldReason = RuntimeHoldReason;
274 type RuntimeFreezeReason = RuntimeFreezeReason;
275 type FreezeIdentifier = ();
276 type MaxFreezes = ConstU32<0>;
277 type DoneSlashHandler = ();
278}
279
280parameter_types! {
281 pub storage TransactionByteFee: Balance = 10 * MILLICENTS;
282 pub const OperationalFeeMultiplier: u8 = 5;
285}
286
287impl pallet_transaction_payment::Config for Runtime {
288 type RuntimeEvent = RuntimeEvent;
289 type OnChargeTransaction = FungibleAdapter<Balances, ()>;
290 type OperationalFeeMultiplier = OperationalFeeMultiplier;
291 type WeightToFee = WeightToFee;
292 type LengthToFee = frame_support::weights::ConstantMultiplier<Balance, TransactionByteFee>;
293 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
294 type WeightInfo = ();
295}
296
297parameter_types! {
298 pub storage SlotDuration: u64 = SLOT_DURATION;
299 pub storage MinimumPeriod: u64 = SlotDuration::get() / 2;
300}
301impl pallet_timestamp::Config for Runtime {
302 type Moment = u64;
303 type OnTimestampSet = Babe;
304 type MinimumPeriod = MinimumPeriod;
305 type WeightInfo = ();
306}
307
308impl pallet_authorship::Config for Runtime {
309 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
310 type EventHandler = Staking;
311}
312
313parameter_types! {
314 pub storage Period: BlockNumber = 10 * MINUTES;
315 pub storage Offset: BlockNumber = 0;
316}
317
318impl_opaque_keys! {
319 pub struct SessionKeys {
320 pub grandpa: Grandpa,
321 pub babe: Babe,
322 pub para_validator: Initializer,
323 pub para_assignment: ParaSessionInfo,
324 pub authority_discovery: AuthorityDiscovery,
325 }
326}
327
328impl pallet_session::Config for Runtime {
329 type RuntimeEvent = RuntimeEvent;
330 type ValidatorId = AccountId;
331 type ValidatorIdOf = sp_runtime::traits::ConvertInto;
332 type ShouldEndSession = Babe;
333 type NextSessionRotation = Babe;
334 type SessionManager = Staking;
335 type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
336 type Keys = SessionKeys;
337 type DisablingStrategy = pallet_session::disabling::UpToLimitWithReEnablingDisablingStrategy;
338 type WeightInfo = ();
339 type Currency = Balances;
340 type KeyDeposit = ();
341}
342
343impl pallet_session::historical::Config for Runtime {
344 type RuntimeEvent = RuntimeEvent;
345 type FullIdentification = ();
346 type FullIdentificationOf = pallet_staking::UnitIdentificationOf<Self>;
347}
348
349pallet_staking_reward_curve::build! {
350 const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
351 min_inflation: 0_025_000,
352 max_inflation: 0_100_000,
353 ideal_stake: 0_500_000,
354 falloff: 0_050_000,
355 max_piece_count: 40,
356 test_precision: 0_005_000,
357 );
358}
359
360parameter_types! {
361 pub storage SessionsPerEra: SessionIndex = 6;
363 pub storage BondingDuration: sp_staking::EraIndex = 28;
365 pub storage SlashDeferDuration: sp_staking::EraIndex = 27;
367 pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
368 pub const MaxExposurePageSize: u32 = 64;
369 pub const MaxNominators: u32 = 256;
370 pub const MaxAuthorities: u32 = 100_000;
371 pub const OnChainMaxWinners: u32 = MaxAuthorities::get();
372 pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build();
374}
375
376pub struct OnChainSeqPhragmen;
377impl onchain::Config for OnChainSeqPhragmen {
378 type System = Runtime;
379 type Solver =
380 SequentialPhragmen<AccountId, polkadot_runtime_common::elections::OnChainAccuracy>;
381 type DataProvider = Staking;
382 type WeightInfo = ();
383 type Bounds = ElectionBoundsOnChain;
384 type MaxWinnersPerPage = OnChainMaxWinners;
385 type MaxBackersPerWinner = ConstU32<{ u32::MAX }>;
386 type Sort = ConstBool<true>;
387}
388
389const MAX_QUOTA_NOMINATIONS: u32 = 16;
391
392impl pallet_staking::Config for Runtime {
393 type OldCurrency = Balances;
394 type Currency = Balances;
395 type CurrencyBalance = Balance;
396 type UnixTime = Timestamp;
397 type CurrencyToVote = polkadot_runtime_common::CurrencyToVote;
398 type RewardRemainder = ();
399 type RuntimeHoldReason = RuntimeHoldReason;
400 type RuntimeEvent = RuntimeEvent;
401 type Slash = ();
402 type Reward = ();
403 type SessionsPerEra = SessionsPerEra;
404 type BondingDuration = BondingDuration;
405 type SlashDeferDuration = SlashDeferDuration;
406 type AdminOrigin = frame_system::EnsureNever<()>;
407 type SessionInterface = Self;
408 type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
409 type MaxExposurePageSize = MaxExposurePageSize;
410 type NextNewSession = Session;
411 type ElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
412 type GenesisElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
413 type VoterList = pallet_staking::UseNominatorsAndValidatorsMap<Runtime>;
416 type TargetList = pallet_staking::UseValidatorsMap<Runtime>;
417 type NominationsQuota = pallet_staking::FixedNominationsQuota<MAX_QUOTA_NOMINATIONS>;
418 type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
419 type MaxControllersInDeprecationBatch = ConstU32<5900>;
420 type HistoryDepth = frame_support::traits::ConstU32<84>;
421 type BenchmarkingConfig = polkadot_runtime_common::StakingBenchmarkingConfig;
422 type EventListeners = ();
423 type WeightInfo = ();
424 type MaxValidatorSet = MaxAuthorities;
425 type Filter = frame_support::traits::Nothing;
426}
427
428parameter_types! {
429 pub MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
430}
431
432impl pallet_grandpa::Config for Runtime {
433 type RuntimeEvent = RuntimeEvent;
434
435 type WeightInfo = ();
436 type MaxAuthorities = MaxAuthorities;
437 type MaxNominators = MaxNominators;
438 type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
439
440 type KeyOwnerProof = sp_core::Void;
441 type EquivocationReportSystem = ();
442}
443
444impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
445where
446 RuntimeCall: From<LocalCall>,
447{
448 fn create_signed_transaction<
449 C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
450 >(
451 call: RuntimeCall,
452 public: <Signature as Verify>::Signer,
453 account: AccountId,
454 nonce: <Runtime as frame_system::Config>::Nonce,
455 ) -> Option<UncheckedExtrinsic> {
456 let period =
457 BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
458
459 let current_block = System::block_number().saturated_into::<u64>().saturating_sub(1);
460 let tip = 0;
461 let tx_ext: TxExtension = (
462 frame_system::AuthorizeCall::<Runtime>::new(),
463 frame_system::CheckNonZeroSender::<Runtime>::new(),
464 frame_system::CheckSpecVersion::<Runtime>::new(),
465 frame_system::CheckTxVersion::<Runtime>::new(),
466 frame_system::CheckGenesis::<Runtime>::new(),
467 frame_system::CheckMortality::<Runtime>::from(generic::Era::mortal(
468 period,
469 current_block,
470 )),
471 frame_system::CheckNonce::<Runtime>::from(nonce),
472 frame_system::CheckWeight::<Runtime>::new(),
473 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
474 frame_system::WeightReclaim::<Runtime>::new(),
475 )
476 .into();
477 let raw_payload = SignedPayload::new(call, tx_ext)
478 .map_err(|e| {
479 log::warn!("Unable to create signed payload: {:?}", e);
480 })
481 .ok()?;
482 let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
483 let (call, tx_ext, _) = raw_payload.deconstruct();
484 let address = Indices::unlookup(account);
485 let transaction = UncheckedExtrinsic::new_signed(call, address, signature, tx_ext);
486 Some(transaction)
487 }
488}
489
490impl frame_system::offchain::SigningTypes for Runtime {
491 type Public = <Signature as Verify>::Signer;
492 type Signature = Signature;
493}
494
495impl pallet_offences::Config for Runtime {
496 type RuntimeEvent = RuntimeEvent;
497 type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
498 type OnOffenceHandler = Staking;
499}
500
501impl pallet_authority_discovery::Config for Runtime {
502 type MaxAuthorities = MaxAuthorities;
503}
504
505parameter_types! {
506 pub storage LeasePeriod: BlockNumber = 100_000;
507 pub storage EndingPeriod: BlockNumber = 1000;
508}
509
510parameter_types! {
511 pub Prefix: &'static [u8] = b"Pay KSMs to the Kusama account:";
512}
513
514impl claims::Config for Runtime {
515 type RuntimeEvent = RuntimeEvent;
516 type VestingSchedule = Vesting;
517 type Prefix = Prefix;
518 type MoveClaimOrigin = frame_system::EnsureRoot<AccountId>;
519 type WeightInfo = claims::TestWeightInfo;
520}
521
522parameter_types! {
523 pub storage MinVestedTransfer: Balance = 100 * DOLLARS;
524 pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
525 WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
526}
527
528impl pallet_vesting::Config for Runtime {
529 type RuntimeEvent = RuntimeEvent;
530 type Currency = Balances;
531 type BlockNumberToBalance = ConvertInto;
532 type MinVestedTransfer = MinVestedTransfer;
533 type WeightInfo = ();
534 type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
535 type BlockNumberProvider = System;
536 const MAX_VESTING_SCHEDULES: u32 = 28;
537}
538
539impl pallet_sudo::Config for Runtime {
540 type RuntimeEvent = RuntimeEvent;
541 type RuntimeCall = RuntimeCall;
542 type WeightInfo = ();
543}
544
545impl parachains_configuration::Config for Runtime {
546 type WeightInfo = parachains_configuration::TestWeightInfo;
547}
548
549impl parachains_shared::Config for Runtime {
550 type DisabledValidators = Session;
551}
552
553impl parachains_inclusion::Config for Runtime {
554 type RuntimeEvent = RuntimeEvent;
555 type DisputesHandler = ParasDisputes;
556 type RewardValidators = RewardValidatorsWithEraPoints<Runtime, Staking>;
557 type MessageQueue = ();
558 type WeightInfo = ();
559}
560
561impl parachains_disputes::Config for Runtime {
562 type RuntimeEvent = RuntimeEvent;
563 type RewardValidators = ();
564 type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes<ParasSlashing>;
565 type WeightInfo = parachains_disputes::TestWeightInfo;
566}
567
568impl parachains_slashing::Config for Runtime {
569 type KeyOwnerProofSystem = Historical;
570 type KeyOwnerProof =
571 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::Proof;
572 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
573 KeyTypeId,
574 ValidatorId,
575 )>>::IdentificationTuple;
576 type HandleReports = parachains_slashing::SlashingReportHandler<
577 Self::KeyOwnerIdentification,
578 Offences,
579 ReportLongevity,
580 >;
581 type WeightInfo = parachains_disputes::slashing::TestWeightInfo;
582 type BenchmarkingConfig = parachains_slashing::BenchConfig<1000>;
583}
584
585impl parachains_paras_inherent::Config for Runtime {
586 type WeightInfo = parachains_paras_inherent::TestWeightInfo;
587}
588
589impl parachains_initializer::Config for Runtime {
590 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
591 type ForceOrigin = frame_system::EnsureRoot<AccountId>;
592 type WeightInfo = ();
593 type CoretimeOnNewSession = Coretime;
594}
595
596impl parachains_session_info::Config for Runtime {
597 type ValidatorSet = Historical;
598}
599
600parameter_types! {
601 pub const ParasUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
602}
603
604impl parachains_paras::Config for Runtime {
605 type RuntimeEvent = RuntimeEvent;
606 type WeightInfo = parachains_paras::TestWeightInfo;
607 type UnsignedPriority = ParasUnsignedPriority;
608 type QueueFootprinter = ParaInclusion;
609 type NextSessionRotation = Babe;
610 type OnNewHead = ();
611 type AssignCoretime = CoretimeAssignmentProvider;
612 type Fungible = Balances;
613 type CooldownRemovalMultiplier = ConstUint<1>;
614 type AuthorizeCurrentCodeOrigin = frame_system::EnsureRoot<AccountId>;
615}
616
617parameter_types! {
618 pub const BrokerId: u32 = 10u32;
619 pub MaxXcmTransactWeight: Weight = Weight::from_parts(10_000_000, 10_000);
620}
621
622pub struct BrokerPot;
623impl Get<InteriorLocation> for BrokerPot {
624 fn get() -> InteriorLocation {
625 unimplemented!()
626 }
627}
628
629parameter_types! {
630 pub const OnDemandTrafficDefaultValue: FixedU128 = FixedU128::from_u32(1);
631 pub const MaxHistoricalRevenue: BlockNumber = 2 * 5;
633 pub const OnDemandPalletId: PalletId = PalletId(*b"py/ondmd");
634}
635
636impl parachains_dmp::Config for Runtime {}
637
638parameter_types! {
639 pub const HrmpChannelSizeAndCapacityWithSystemRatio: Percent = Percent::from_percent(100);
640}
641
642impl parachains_hrmp::Config for Runtime {
643 type RuntimeOrigin = RuntimeOrigin;
644 type RuntimeEvent = RuntimeEvent;
645 type ChannelManager = frame_system::EnsureRoot<AccountId>;
646 type Currency = Balances;
647 type DefaultChannelSizeAndCapacityWithSystem = ActiveConfigHrmpChannelSizeAndCapacityRatio<
648 Runtime,
649 HrmpChannelSizeAndCapacityWithSystemRatio,
650 >;
651 type VersionWrapper = crate::Xcm;
652 type WeightInfo = parachains_hrmp::TestWeightInfo;
653}
654
655impl parachains_on_demand::Config for Runtime {
656 type RuntimeEvent = RuntimeEvent;
657 type Currency = Balances;
658 type TrafficDefaultValue = OnDemandTrafficDefaultValue;
659 type WeightInfo = parachains_on_demand::TestWeightInfo;
660 type MaxHistoricalRevenue = MaxHistoricalRevenue;
661 type PalletId = OnDemandPalletId;
662}
663
664impl parachains_assigner_coretime::Config for Runtime {}
665
666impl parachains_scheduler::Config for Runtime {
667 type AssignmentProvider = CoretimeAssignmentProvider;
668}
669
670pub struct DummyXcmSender;
671impl SendXcm for DummyXcmSender {
672 type Ticket = ();
673 fn validate(
674 _: &mut Option<Location>,
675 _: &mut Option<xcm::latest::Xcm<()>>,
676 ) -> SendResult<Self::Ticket> {
677 Ok(((), Assets::new()))
678 }
679
680 fn deliver(_ticket: Self::Ticket) -> Result<XcmHash, SendError> {
682 Ok([0u8; 32])
683 }
684}
685
686impl coretime::Config for Runtime {
687 type RuntimeOrigin = RuntimeOrigin;
688 type RuntimeEvent = RuntimeEvent;
689 type BrokerId = BrokerId;
690 type WeightInfo = crate::coretime::TestWeightInfo;
691 type SendXcm = DummyXcmSender;
692 type MaxXcmTransactWeight = MaxXcmTransactWeight;
693 type BrokerPotLocation = BrokerPot;
694 type AssetTransactor = ();
695 type AccountToLocation = ();
696}
697
698impl paras_sudo_wrapper::Config for Runtime {}
699
700impl parachains_origin::Config for Runtime {}
701
702impl pallet_test_notifier::Config for Runtime {
703 type RuntimeEvent = RuntimeEvent;
704 type RuntimeOrigin = RuntimeOrigin;
705 type RuntimeCall = RuntimeCall;
706}
707
708#[frame_support::pallet(dev_mode)]
709pub mod pallet_test_notifier {
710 use frame_support::pallet_prelude::*;
711 use frame_system::pallet_prelude::*;
712 use pallet_xcm::ensure_response;
713 use sp_runtime::DispatchResult;
714 use xcm::latest::prelude::*;
715 use xcm_executor::traits::QueryHandler as XcmQueryHandler;
716
717 #[pallet::pallet]
718 pub struct Pallet<T>(_);
719
720 #[pallet::config]
721 pub trait Config: frame_system::Config + pallet_xcm::Config {
722 #[allow(deprecated)]
723 type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>;
724 type RuntimeOrigin: IsType<<Self as frame_system::Config>::RuntimeOrigin>
725 + Into<Result<pallet_xcm::Origin, <Self as Config>::RuntimeOrigin>>;
726 type RuntimeCall: IsType<<Self as pallet_xcm::Config>::RuntimeCall> + From<Call<Self>>;
727 }
728
729 #[pallet::event]
730 #[pallet::generate_deposit(pub(super) fn deposit_event)]
731 pub enum Event<T: Config> {
732 QueryPrepared(QueryId),
733 NotifyQueryPrepared(QueryId),
734 ResponseReceived(Location, QueryId, Response),
735 }
736
737 #[pallet::error]
738 pub enum Error<T> {
739 UnexpectedId,
740 BadAccountFormat,
741 }
742
743 #[pallet::call]
744 impl<T: Config> Pallet<T> {
745 #[pallet::call_index(0)]
746 #[pallet::weight(1_000_000)]
747 pub fn prepare_new_query(origin: OriginFor<T>) -> DispatchResult {
748 let who = ensure_signed(origin)?;
749 let id = who
750 .using_encoded(|mut d| <[u8; 32]>::decode(&mut d))
751 .map_err(|_| Error::<T>::BadAccountFormat)?;
752 let qid = <pallet_xcm::Pallet<T> as XcmQueryHandler>::new_query(
753 Junction::AccountId32 { network: None, id },
754 100u32.into(),
755 Here,
756 );
757 Self::deposit_event(Event::<T>::QueryPrepared(qid));
758 Ok(())
759 }
760
761 #[pallet::call_index(1)]
762 #[pallet::weight(1_000_000)]
763 pub fn prepare_new_notify_query(origin: OriginFor<T>) -> DispatchResult {
764 let who = ensure_signed(origin)?;
765 let id = who
766 .using_encoded(|mut d| <[u8; 32]>::decode(&mut d))
767 .map_err(|_| Error::<T>::BadAccountFormat)?;
768 let call =
769 Call::<T>::notification_received { query_id: 0, response: Default::default() };
770 let qid = pallet_xcm::Pallet::<T>::new_notify_query(
771 Junction::AccountId32 { network: None, id },
772 <T as Config>::RuntimeCall::from(call),
773 100u32.into(),
774 Here,
775 );
776 Self::deposit_event(Event::<T>::NotifyQueryPrepared(qid));
777 Ok(())
778 }
779
780 #[pallet::call_index(2)]
781 #[pallet::weight(1_000_000)]
782 pub fn notification_received(
783 origin: OriginFor<T>,
784 query_id: QueryId,
785 response: Response,
786 ) -> DispatchResult {
787 let responder = ensure_response(<T as Config>::RuntimeOrigin::from(origin))?;
788 Self::deposit_event(Event::<T>::ResponseReceived(responder, query_id, response));
789 Ok(())
790 }
791 }
792}
793
794construct_runtime! {
795 pub enum Runtime
796 {
797 System: frame_system,
799
800 Babe: pallet_babe,
802
803 Timestamp: pallet_timestamp,
804 Indices: pallet_indices,
805 Balances: pallet_balances,
806 TransactionPayment: pallet_transaction_payment,
807
808 Authorship: pallet_authorship,
810 Staking: pallet_staking,
811 Offences: pallet_offences,
812 Historical: session_historical,
813 Session: pallet_session,
814 Grandpa: pallet_grandpa,
815 AuthorityDiscovery: pallet_authority_discovery,
816
817 Claims: claims,
819
820 Vesting: pallet_vesting,
822
823 Configuration: parachains_configuration,
825 ParaInclusion: parachains_inclusion,
826 ParaInherent: parachains_paras_inherent,
827 Initializer: parachains_initializer,
828 Paras: parachains_paras,
829 ParasShared: parachains_shared,
830 Scheduler: parachains_scheduler,
831 ParasSudoWrapper: paras_sudo_wrapper,
832 ParasOrigin: parachains_origin,
833 ParaSessionInfo: parachains_session_info,
834 Hrmp: parachains_hrmp,
835 Dmp: parachains_dmp,
836 Xcm: pallet_xcm,
837 ParasDisputes: parachains_disputes,
838 ParasSlashing: parachains_slashing,
839 OnDemandAssignmentProvider: parachains_on_demand,
840 CoretimeAssignmentProvider: parachains_assigner_coretime,
841 Coretime: coretime,
842
843 Sudo: pallet_sudo,
844
845 TestNotifier: pallet_test_notifier,
846 }
847}
848
849pub type Address = sp_runtime::MultiAddress<AccountId, AccountIndex>;
851pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
853pub type Block = generic::Block<Header, UncheckedExtrinsic>;
855pub type SignedBlock = generic::SignedBlock<Block>;
857pub type BlockId = generic::BlockId<Block>;
859pub type TxExtension = (
861 frame_system::AuthorizeCall<Runtime>,
862 frame_system::CheckNonZeroSender<Runtime>,
863 frame_system::CheckSpecVersion<Runtime>,
864 frame_system::CheckTxVersion<Runtime>,
865 frame_system::CheckGenesis<Runtime>,
866 frame_system::CheckMortality<Runtime>,
867 frame_system::CheckNonce<Runtime>,
868 frame_system::CheckWeight<Runtime>,
869 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
870 frame_system::WeightReclaim<Runtime>,
871);
872pub type UncheckedExtrinsic =
874 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
875pub type UncheckedSignaturePayload =
877 generic::UncheckedSignaturePayload<Address, Signature, TxExtension>;
878
879pub type Executive = frame_executive::Executive<
881 Runtime,
882 Block,
883 frame_system::ChainContext<Runtime>,
884 Runtime,
885 AllPalletsWithSystem,
886>;
887pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
889
890pub type Hash = <Block as BlockT>::Hash;
891pub type Extrinsic = <Block as BlockT>::Extrinsic;
892
893sp_api::impl_runtime_apis! {
894 impl sp_api::Core<Block> for Runtime {
895 fn version() -> RuntimeVersion {
896 VERSION
897 }
898
899 fn execute_block(block: Block) {
900 Executive::execute_block(block);
901 }
902
903 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
904 Executive::initialize_block(header)
905 }
906 }
907
908 impl sp_api::Metadata<Block> for Runtime {
909 fn metadata() -> OpaqueMetadata {
910 OpaqueMetadata::new(Runtime::metadata().into())
911 }
912
913 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
914 Runtime::metadata_at_version(version)
915 }
916
917 fn metadata_versions() -> Vec<u32> {
918 Runtime::metadata_versions()
919 }
920 }
921
922 impl sp_block_builder::BlockBuilder<Block> for Runtime {
923 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
924 Executive::apply_extrinsic(extrinsic)
925 }
926
927 fn finalize_block() -> <Block as BlockT>::Header {
928 Executive::finalize_block()
929 }
930
931 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
932 data.create_extrinsics()
933 }
934
935 fn check_inherents(
936 block: Block,
937 data: sp_inherents::InherentData,
938 ) -> sp_inherents::CheckInherentsResult {
939 data.check_extrinsics(&block)
940 }
941 }
942
943 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
944 fn validate_transaction(
945 source: TransactionSource,
946 tx: <Block as BlockT>::Extrinsic,
947 block_hash: <Block as BlockT>::Hash,
948 ) -> TransactionValidity {
949 Executive::validate_transaction(source, tx, block_hash)
950 }
951 }
952
953 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
954 fn offchain_worker(header: &<Block as BlockT>::Header) {
955 Executive::offchain_worker(header)
956 }
957 }
958
959 impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
960 fn authorities() -> Vec<AuthorityDiscoveryId> {
961 runtime_impl::relevant_authority_ids::<Runtime>()
962 }
963 }
964
965 #[api_version(14)]
966 impl polkadot_primitives::runtime_api::ParachainHost<Block> for Runtime {
967 fn validators() -> Vec<ValidatorId> {
968 runtime_impl::validators::<Runtime>()
969 }
970
971 fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>) {
972 runtime_impl::validator_groups::<Runtime>()
973 }
974
975 fn availability_cores() -> Vec<CoreState<Hash, BlockNumber>> {
976 runtime_impl::availability_cores::<Runtime>()
977 }
978
979 fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
980 -> Option<PersistedValidationData<Hash, BlockNumber>>
981 {
982 runtime_impl::persisted_validation_data::<Runtime>(para_id, assumption)
983 }
984
985 fn assumed_validation_data(
986 para_id: ParaId,
987 expected_persisted_validation_data_hash: Hash,
988 ) -> Option<(PersistedValidationData<Hash, BlockNumber>, ValidationCodeHash)> {
989 runtime_impl::assumed_validation_data::<Runtime>(
990 para_id,
991 expected_persisted_validation_data_hash,
992 )
993 }
994
995 fn check_validation_outputs(
996 para_id: ParaId,
997 outputs: polkadot_primitives::CandidateCommitments,
998 ) -> bool {
999 runtime_impl::check_validation_outputs::<Runtime>(para_id, outputs)
1000 }
1001
1002 fn session_index_for_child() -> SessionIndex {
1003 runtime_impl::session_index_for_child::<Runtime>()
1004 }
1005
1006 fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption)
1007 -> Option<ValidationCode>
1008 {
1009 runtime_impl::validation_code::<Runtime>(para_id, assumption)
1010 }
1011
1012 fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
1013 #[allow(deprecated)]
1014 runtime_impl::candidate_pending_availability::<Runtime>(para_id)
1015 }
1016
1017 fn candidate_events() -> Vec<CandidateEvent<Hash>> {
1018 runtime_impl::candidate_events::<Runtime, _>(|trait_event| trait_event.try_into().ok())
1019 }
1020
1021 fn session_info(index: SessionIndex) -> Option<SessionInfoData> {
1022 runtime_impl::session_info::<Runtime>(index)
1023 }
1024
1025 fn session_executor_params(session_index: SessionIndex) -> Option<ExecutorParams> {
1026 runtime_impl::session_executor_params::<Runtime>(session_index)
1027 }
1028
1029 fn dmq_contents(
1030 recipient: ParaId,
1031 ) -> Vec<InboundDownwardMessage<BlockNumber>> {
1032 runtime_impl::dmq_contents::<Runtime>(recipient)
1033 }
1034
1035 fn inbound_hrmp_channels_contents(
1036 recipient: ParaId,
1037 ) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
1038 runtime_impl::inbound_hrmp_channels_contents::<Runtime>(recipient)
1039 }
1040
1041 fn validation_code_by_hash(hash: ValidationCodeHash) -> Option<ValidationCode> {
1042 runtime_impl::validation_code_by_hash::<Runtime>(hash)
1043 }
1044
1045 fn on_chain_votes() -> Option<ScrapedOnChainVotes<Hash>> {
1046 runtime_impl::on_chain_votes::<Runtime>()
1047 }
1048
1049 fn submit_pvf_check_statement(
1050 stmt: polkadot_primitives::PvfCheckStatement,
1051 signature: polkadot_primitives::ValidatorSignature,
1052 ) {
1053 runtime_impl::submit_pvf_check_statement::<Runtime>(stmt, signature)
1054 }
1055
1056 fn pvfs_require_precheck() -> Vec<ValidationCodeHash> {
1057 runtime_impl::pvfs_require_precheck::<Runtime>()
1058 }
1059
1060 fn validation_code_hash(para_id: ParaId, assumption: OccupiedCoreAssumption)
1061 -> Option<ValidationCodeHash>
1062 {
1063 runtime_impl::validation_code_hash::<Runtime>(para_id, assumption)
1064 }
1065
1066 fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)> {
1067 runtime_impl::get_session_disputes::<Runtime>()
1068 }
1069
1070 fn unapplied_slashes(
1071 ) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
1072 runtime_impl::unapplied_slashes::<Runtime>()
1073 }
1074
1075 fn key_ownership_proof(
1076 validator_id: ValidatorId,
1077 ) -> Option<slashing::OpaqueKeyOwnershipProof> {
1078 use codec::Encode;
1079
1080 Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
1081 .map(|p| p.encode())
1082 .map(slashing::OpaqueKeyOwnershipProof::new)
1083 }
1084
1085 fn submit_report_dispute_lost(
1086 dispute_proof: slashing::DisputeProof,
1087 key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
1088 ) -> Option<()> {
1089 runtime_impl::submit_unsigned_slashing_report::<Runtime>(
1090 dispute_proof,
1091 key_ownership_proof,
1092 )
1093 }
1094
1095 fn minimum_backing_votes() -> u32 {
1096 runtime_impl::minimum_backing_votes::<Runtime>()
1097 }
1098
1099 fn para_backing_state(para_id: ParaId) -> Option<polkadot_primitives::async_backing::BackingState> {
1100 #[allow(deprecated)]
1101 runtime_impl::backing_state::<Runtime>(para_id)
1102 }
1103
1104 fn async_backing_params() -> polkadot_primitives::AsyncBackingParams {
1105 #[allow(deprecated)]
1106 runtime_impl::async_backing_params::<Runtime>()
1107 }
1108
1109 fn approval_voting_params() -> polkadot_primitives::ApprovalVotingParams {
1110 runtime_impl::approval_voting_params::<Runtime>()
1111 }
1112
1113 fn disabled_validators() -> Vec<ValidatorIndex> {
1114 runtime_impl::disabled_validators::<Runtime>()
1115 }
1116
1117 fn node_features() -> polkadot_primitives::NodeFeatures {
1118 runtime_impl::node_features::<Runtime>()
1119 }
1120
1121 fn claim_queue() -> BTreeMap<CoreIndex, VecDeque<ParaId>> {
1122 runtime_impl::claim_queue::<Runtime>()
1123 }
1124
1125 fn candidates_pending_availability(para_id: ParaId) -> Vec<CommittedCandidateReceipt<Hash>> {
1126 runtime_impl::candidates_pending_availability::<Runtime>(para_id)
1127 }
1128
1129 fn backing_constraints(para_id: ParaId) -> Option<Constraints> {
1130 runtime_impl::backing_constraints::<Runtime>(para_id)
1131 }
1132
1133 fn scheduling_lookahead() -> u32 {
1134 runtime_impl::scheduling_lookahead::<Runtime>()
1135 }
1136
1137 fn validation_code_bomb_limit() -> u32 {
1138 runtime_impl::validation_code_bomb_limit::<Runtime>()
1139 }
1140
1141 fn para_ids() -> Vec<ParaId> {
1142 staging_runtime_impl::para_ids::<Runtime>()
1143 }
1144 }
1145
1146 impl sp_consensus_beefy::BeefyApi<Block, BeefyId> for Runtime {
1147 fn beefy_genesis() -> Option<BlockNumber> {
1148 None
1150 }
1151
1152 fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<BeefyId>> {
1153 None
1155 }
1156
1157 fn submit_report_double_voting_unsigned_extrinsic(
1158 _equivocation_proof: sp_consensus_beefy::DoubleVotingProof<
1159 BlockNumber,
1160 BeefyId,
1161 BeefySignature,
1162 >,
1163 _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
1164 ) -> Option<()> {
1165 None
1166 }
1167
1168 fn submit_report_fork_voting_unsigned_extrinsic(
1169 _equivocation_proof:
1170 sp_consensus_beefy::ForkVotingProof<
1171 <Block as BlockT>::Header,
1172 BeefyId,
1173 sp_runtime::OpaqueValue
1174 >,
1175 _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
1176 ) -> Option<()> {
1177 None
1178 }
1179
1180 fn submit_report_future_block_voting_unsigned_extrinsic(
1181 _equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof<BlockNumber, BeefyId>,
1182 _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
1183 ) -> Option<()> {
1184 None
1185 }
1186
1187 fn generate_key_ownership_proof(
1188 _set_id: sp_consensus_beefy::ValidatorSetId,
1189 _authority_id: BeefyId,
1190 ) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> {
1191 None
1192 }
1193
1194 fn generate_ancestry_proof(
1195 _prev_block_number: BlockNumber,
1196 _best_known_block_number: Option<BlockNumber>,
1197 ) -> Option<sp_runtime::OpaqueValue> {
1198 None
1199 }
1200 }
1201
1202 impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
1203 fn mmr_root() -> Result<Hash, mmr::Error> {
1204 Err(mmr::Error::PalletNotIncluded)
1205 }
1206
1207 fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
1208 Err(mmr::Error::PalletNotIncluded)
1209 }
1210
1211 fn generate_proof(
1212 _block_numbers: Vec<BlockNumber>,
1213 _best_known_block_number: Option<BlockNumber>,
1214 ) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::LeafProof<Hash>), mmr::Error> {
1215 Err(mmr::Error::PalletNotIncluded)
1216 }
1217
1218 fn verify_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::LeafProof<Hash>)
1219 -> Result<(), mmr::Error>
1220 {
1221 Err(mmr::Error::PalletNotIncluded)
1222 }
1223
1224 fn verify_proof_stateless(
1225 _root: Hash,
1226 _leaves: Vec<mmr::EncodableOpaqueLeaf>,
1227 _proof: mmr::LeafProof<Hash>
1228 ) -> Result<(), mmr::Error> {
1229 Err(mmr::Error::PalletNotIncluded)
1230 }
1231 }
1232
1233 impl fg_primitives::GrandpaApi<Block> for Runtime {
1234 fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
1235 Grandpa::grandpa_authorities()
1236 }
1237
1238 fn current_set_id() -> fg_primitives::SetId {
1239 pallet_grandpa::CurrentSetId::<Runtime>::get()
1240 }
1241
1242 fn submit_report_equivocation_unsigned_extrinsic(
1243 _equivocation_proof: fg_primitives::EquivocationProof<
1244 <Block as BlockT>::Hash,
1245 sp_runtime::traits::NumberFor<Block>,
1246 >,
1247 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
1248 ) -> Option<()> {
1249 None
1250 }
1251
1252 fn generate_key_ownership_proof(
1253 _set_id: fg_primitives::SetId,
1254 _authority_id: fg_primitives::AuthorityId,
1255 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
1256 None
1257 }
1258 }
1259
1260 impl sp_consensus_babe::BabeApi<Block> for Runtime {
1261 fn configuration() -> sp_consensus_babe::BabeConfiguration {
1262 let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
1263 sp_consensus_babe::BabeConfiguration {
1264 slot_duration: Babe::slot_duration(),
1265 epoch_length: EpochDuration::get(),
1266 c: epoch_config.c,
1267 authorities: Babe::authorities().to_vec(),
1268 randomness: Babe::randomness(),
1269 allowed_slots: epoch_config.allowed_slots,
1270 }
1271 }
1272
1273 fn current_epoch_start() -> sp_consensus_babe::Slot {
1274 Babe::current_epoch_start()
1275 }
1276
1277 fn current_epoch() -> sp_consensus_babe::Epoch {
1278 Babe::current_epoch()
1279 }
1280
1281 fn next_epoch() -> sp_consensus_babe::Epoch {
1282 Babe::next_epoch()
1283 }
1284
1285 fn generate_key_ownership_proof(
1286 _slot: sp_consensus_babe::Slot,
1287 _authority_id: sp_consensus_babe::AuthorityId,
1288 ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
1289 None
1290 }
1291
1292 fn submit_report_equivocation_unsigned_extrinsic(
1293 _equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>,
1294 _key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
1295 ) -> Option<()> {
1296 None
1297 }
1298 }
1299
1300 impl sp_session::SessionKeys<Block> for Runtime {
1301 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
1302 SessionKeys::generate(seed)
1303 }
1304
1305 fn decode_session_keys(
1306 encoded: Vec<u8>,
1307 ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
1308 SessionKeys::decode_into_raw_public_keys(&encoded)
1309 }
1310 }
1311
1312 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
1313 fn account_nonce(account: AccountId) -> Nonce {
1314 System::account_nonce(account)
1315 }
1316 }
1317
1318 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
1319 Block,
1320 Balance,
1321 > for Runtime {
1322 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
1323 TransactionPayment::query_info(uxt, len)
1324 }
1325 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
1326 TransactionPayment::query_fee_details(uxt, len)
1327 }
1328 fn query_weight_to_fee(weight: Weight) -> Balance {
1329 TransactionPayment::weight_to_fee(weight)
1330 }
1331 fn query_length_to_fee(length: u32) -> Balance {
1332 TransactionPayment::length_to_fee(length)
1333 }
1334 }
1335
1336 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
1337 for Runtime
1338 {
1339 fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo<Balance> {
1340 TransactionPayment::query_call_info(call, len)
1341 }
1342 fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails<Balance> {
1343 TransactionPayment::query_call_fee_details(call, len)
1344 }
1345 fn query_weight_to_fee(weight: Weight) -> Balance {
1346 TransactionPayment::weight_to_fee(weight)
1347 }
1348 fn query_length_to_fee(length: u32) -> Balance {
1349 TransactionPayment::length_to_fee(length)
1350 }
1351 }
1352
1353 impl crate::GetLastTimestamp<Block> for Runtime {
1354 fn get_last_timestamp() -> u64 {
1355 Now::<Runtime>::get()
1356 }
1357 }
1358
1359 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
1360 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
1361 build_state::<RuntimeGenesisConfig>(config)
1362 }
1363
1364 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
1365 get_preset::<RuntimeGenesisConfig>(id, |_| None)
1366 }
1367
1368 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1369 vec![]
1370 }
1371 }
1372}