referrerpolicy=no-referrer-when-downgrade

cumulus_test_runtime/
lib.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Cumulus.
3
4// Cumulus is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Cumulus is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Cumulus.  If not, see <http://www.gnu.org/licenses/>.
16
17#![cfg_attr(not(feature = "std"), no_std)]
18// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
19#![recursion_limit = "256"]
20
21// Make the WASM binary available.
22#[cfg(feature = "std")]
23include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
24
25pub mod wasm_spec_version_incremented {
26	#[cfg(feature = "std")]
27	include!(concat!(env!("OUT_DIR"), "/wasm_binary_spec_version_incremented.rs"));
28}
29
30pub mod relay_parent_offset {
31	#[cfg(feature = "std")]
32	include!(concat!(env!("OUT_DIR"), "/wasm_binary_relay_parent_offset.rs"));
33}
34
35pub mod elastic_scaling_500ms {
36	#[cfg(feature = "std")]
37	include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling_500ms.rs"));
38}
39pub mod elastic_scaling_mvp {
40	#[cfg(feature = "std")]
41	include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling_mvp.rs"));
42}
43
44pub mod elastic_scaling {
45	#[cfg(feature = "std")]
46	include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling.rs"));
47}
48
49pub mod elastic_scaling_multi_block_slot {
50	#[cfg(feature = "std")]
51	include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling_multi_block_slot.rs"));
52}
53
54pub mod elastic_scaling_12s_slot {
55	#[cfg(feature = "std")]
56	include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling_12s_slot.rs"));
57}
58
59pub mod sync_backing {
60	#[cfg(feature = "std")]
61	include!(concat!(env!("OUT_DIR"), "/wasm_binary_sync_backing.rs"));
62}
63
64pub mod async_backing {
65	#[cfg(feature = "std")]
66	include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
67}
68
69mod genesis_config_presets;
70mod test_pallet;
71
72extern crate alloc;
73
74use alloc::{vec, vec::Vec};
75use frame_support::{derive_impl, traits::OnRuntimeUpgrade, PalletId};
76use sp_api::{decl_runtime_apis, impl_runtime_apis};
77pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
78use sp_core::{ConstBool, ConstU32, ConstU64, OpaqueMetadata};
79
80use sp_runtime::{
81	generic, impl_opaque_keys,
82	traits::{BlakeTwo256, Block as BlockT, IdentifyAccount, Verify},
83	transaction_validity::{TransactionSource, TransactionValidity},
84	ApplyExtrinsicResult, MultiAddress, MultiSignature,
85};
86#[cfg(feature = "std")]
87use sp_version::NativeVersion;
88use sp_version::RuntimeVersion;
89
90use cumulus_primitives_core::ParaId;
91
92// A few exports that help ease life for downstream crates.
93pub use frame_support::{
94	construct_runtime,
95	dispatch::DispatchClass,
96	genesis_builder_helper::{build_state, get_preset},
97	parameter_types,
98	traits::{ConstU8, Randomness},
99	weights::{
100		constants::{
101			BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND,
102		},
103		ConstantMultiplier, IdentityFee, Weight,
104	},
105	StorageValue,
106};
107pub use frame_system::Call as SystemCall;
108use frame_system::{
109	limits::{BlockLength, BlockWeights},
110	EnsureRoot,
111};
112pub use pallet_balances::Call as BalancesCall;
113pub use pallet_glutton::Call as GluttonCall;
114pub use pallet_sudo::Call as SudoCall;
115pub use pallet_timestamp::{Call as TimestampCall, Now};
116#[cfg(any(feature = "std", test))]
117pub use sp_runtime::BuildStorage;
118pub use sp_runtime::{Perbill, Permill};
119pub use test_pallet::Call as TestPalletCall;
120
121pub type SessionHandlers = ();
122
123impl_opaque_keys! {
124	pub struct SessionKeys {
125		pub aura: Aura,
126	}
127}
128
129/// The para-id used in this runtime.
130pub const PARACHAIN_ID: u32 = 100;
131
132#[cfg(feature = "elastic-scaling-500ms")]
133pub const BLOCK_PROCESSING_VELOCITY: u32 = 12;
134
135#[cfg(all(feature = "elastic-scaling-multi-block-slot", not(feature = "elastic-scaling-500ms")))]
136pub const BLOCK_PROCESSING_VELOCITY: u32 = 6;
137
138#[cfg(all(
139	any(feature = "elastic-scaling", feature = "relay-parent-offset"),
140	not(feature = "elastic-scaling-500ms"),
141	not(feature = "elastic-scaling-multi-block-slot")
142))]
143pub const BLOCK_PROCESSING_VELOCITY: u32 = 3;
144
145#[cfg(not(any(
146	feature = "elastic-scaling",
147	feature = "elastic-scaling-500ms",
148	feature = "elastic-scaling-multi-block-slot",
149	feature = "relay-parent-offset",
150)))]
151pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
152
153#[cfg(feature = "async-backing")]
154const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
155
156#[cfg(all(feature = "sync-backing", not(feature = "async-backing")))]
157const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
158
159// The `+2` shouldn't be needed, https://github.com/paritytech/polkadot-sdk/issues/5260
160#[cfg(all(not(feature = "sync-backing"), not(feature = "async-backing")))]
161const UNINCLUDED_SEGMENT_CAPACITY: u32 = BLOCK_PROCESSING_VELOCITY * (2 + RELAY_PARENT_OFFSET) + 2;
162
163#[cfg(any(feature = "sync-backing", feature = "elastic-scaling-12s-slot"))]
164pub const SLOT_DURATION: u64 = 12000;
165#[cfg(not(any(feature = "sync-backing", feature = "elastic-scaling-12s-slot")))]
166pub const SLOT_DURATION: u64 = 6000;
167
168const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
169
170// The only difference between the two declarations below is the `spec_version`. With the
171// `increment-spec-version` feature enabled `spec_version` should be greater than the one of without
172// the `increment-spec-version` feature.
173//
174// The duplication here is unfortunate necessity.
175//
176// runtime_version macro is dumb. It accepts a const item declaration, passes it through and
177// also emits runtime version custom section. It parses the expressions to extract the version
178// details. Since macro kicks in early, it operates on AST. Thus you cannot use constants.
179// Macros are expanded top to bottom, meaning we also cannot use `cfg` here.
180
181#[cfg(all(not(feature = "increment-spec-version"), not(feature = "elastic-scaling")))]
182#[sp_version::runtime_version]
183pub const VERSION: RuntimeVersion = RuntimeVersion {
184	spec_name: alloc::borrow::Cow::Borrowed("cumulus-test-parachain"),
185	impl_name: alloc::borrow::Cow::Borrowed("cumulus-test-parachain"),
186	authoring_version: 1,
187	// Read the note above.
188	spec_version: 2,
189	impl_version: 1,
190	apis: RUNTIME_API_VERSIONS,
191	transaction_version: 1,
192	system_version: 1,
193};
194
195#[cfg(any(feature = "increment-spec-version", feature = "elastic-scaling"))]
196#[sp_version::runtime_version]
197pub const VERSION: RuntimeVersion = RuntimeVersion {
198	spec_name: alloc::borrow::Cow::Borrowed("cumulus-test-parachain"),
199	impl_name: alloc::borrow::Cow::Borrowed("cumulus-test-parachain"),
200	authoring_version: 1,
201	// Read the note above.
202	spec_version: 3,
203	impl_version: 1,
204	apis: RUNTIME_API_VERSIONS,
205	transaction_version: 1,
206	system_version: 1,
207};
208
209pub const EPOCH_DURATION_IN_BLOCKS: u32 = 10 * MINUTES;
210
211// These time units are defined in number of blocks.
212pub const MINUTES: BlockNumber = 60_000 / (SLOT_DURATION as BlockNumber);
213pub const HOURS: BlockNumber = MINUTES * 60;
214pub const DAYS: BlockNumber = HOURS * 24;
215
216// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
217pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
218
219/// The version information used to identify this runtime when compiled natively.
220#[cfg(feature = "std")]
221pub fn native_version() -> NativeVersion {
222	NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
223}
224
225/// We assume that ~10% of the block weight is consumed by `on_initialize` handlers.
226/// This is used to limit the maximal weight of a single extrinsic.
227const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
228/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used
229/// by  Operational  extrinsics.
230const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
231/// We allow for 1 second of compute with a 6 second average block time.
232const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
233	WEIGHT_REF_TIME_PER_SECOND,
234	cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
235);
236
237parameter_types! {
238	/// Target number of blocks per relay chain slot.
239	pub const NumberOfBlocksPerRelaySlot: u32 = 12;
240	pub const BlockHashCount: BlockNumber = 250;
241	pub const Version: RuntimeVersion = VERSION;
242	pub RuntimeBlockLength: BlockLength =
243		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
244	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
245		.base_block(BlockExecutionWeight::get())
246		.for_class(DispatchClass::all(), |weights| {
247			weights.base_extrinsic = ExtrinsicBaseWeight::get();
248		})
249		.for_class(DispatchClass::Normal, |weights| {
250			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
251		})
252		.for_class(DispatchClass::Operational, |weights| {
253			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
254			// Operational transactions have some extra reserved space, so that they
255			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
256			weights.reserved = Some(
257				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
258			);
259		})
260		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
261		.build_or_panic();
262	pub const SS58Prefix: u8 = 42;
263}
264
265#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
266impl frame_system::Config for Runtime {
267	/// The identifier used to distinguish between accounts.
268	type AccountId = AccountId;
269	/// The index type for storing how many extrinsics an account has signed.
270	type Nonce = Nonce;
271	/// The type for hashing blocks and tries.
272	type Hash = Hash;
273	/// The block type.
274	type Block = Block;
275	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
276	type BlockHashCount = BlockHashCount;
277	/// Runtime version.
278	type Version = Version;
279	type AccountData = pallet_balances::AccountData<Balance>;
280	type BlockWeights = RuntimeBlockWeights;
281	type BlockLength = RuntimeBlockLength;
282	type SS58Prefix = SS58Prefix;
283	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
284	type MaxConsumers = frame_support::traits::ConstU32<16>;
285	type SingleBlockMigrations = SingleBlockMigrations;
286}
287
288impl cumulus_pallet_weight_reclaim::Config for Runtime {
289	type WeightInfo = ();
290}
291
292parameter_types! {
293	pub const MinimumPeriod: u64 = 0;
294}
295
296parameter_types! {
297	pub const PotId: PalletId = PalletId(*b"PotStake");
298	pub const SessionLength: BlockNumber = 10 * MINUTES;
299	pub const Offset: u32 = 0;
300}
301
302impl cumulus_pallet_aura_ext::Config for Runtime {}
303
304impl pallet_timestamp::Config for Runtime {
305	/// A timestamp: milliseconds since the unix epoch.
306	type Moment = u64;
307	type OnTimestampSet = Aura;
308	type MinimumPeriod = MinimumPeriod;
309	type WeightInfo = ();
310}
311
312parameter_types! {
313	pub const ExistentialDeposit: u128 = 500;
314	pub const TransferFee: u128 = 0;
315	pub const CreationFee: u128 = 0;
316	pub const TransactionByteFee: u128 = 1;
317	pub const MaxReserves: u32 = 50;
318}
319
320impl pallet_balances::Config for Runtime {
321	/// The type for recording an account's balance.
322	type Balance = Balance;
323	/// The ubiquitous event type.
324	type RuntimeEvent = RuntimeEvent;
325	type DustRemoval = ();
326	type ExistentialDeposit = ExistentialDeposit;
327	type AccountStore = System;
328	type WeightInfo = ();
329	type MaxLocks = ();
330	type MaxReserves = MaxReserves;
331	type ReserveIdentifier = [u8; 8];
332	type RuntimeHoldReason = RuntimeHoldReason;
333	type RuntimeFreezeReason = RuntimeFreezeReason;
334	type FreezeIdentifier = ();
335	type MaxFreezes = ConstU32<0>;
336	type DoneSlashHandler = ();
337}
338
339impl pallet_transaction_payment::Config for Runtime {
340	type RuntimeEvent = RuntimeEvent;
341	type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
342	type WeightToFee = IdentityFee<Balance>;
343	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
344	type FeeMultiplierUpdate = ();
345	type OperationalFeeMultiplier = ConstU8<5>;
346	type WeightInfo = pallet_transaction_payment::weights::SubstrateWeight<Runtime>;
347}
348
349impl pallet_sudo::Config for Runtime {
350	type RuntimeCall = RuntimeCall;
351	type RuntimeEvent = RuntimeEvent;
352	type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
353}
354
355impl pallet_glutton::Config for Runtime {
356	type RuntimeEvent = RuntimeEvent;
357	type AdminOrigin = EnsureRoot<AccountId>;
358	type WeightInfo = pallet_glutton::weights::SubstrateWeight<Runtime>;
359}
360
361#[cfg(feature = "relay-parent-offset")]
362const RELAY_PARENT_OFFSET: u32 = 2;
363
364#[cfg(not(feature = "relay-parent-offset"))]
365const RELAY_PARENT_OFFSET: u32 = 0;
366
367type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
368	Runtime,
369	RELAY_CHAIN_SLOT_DURATION_MILLIS,
370	BLOCK_PROCESSING_VELOCITY,
371	UNINCLUDED_SEGMENT_CAPACITY,
372>;
373impl cumulus_pallet_parachain_system::Config for Runtime {
374	type WeightInfo = ();
375	type SelfParaId = parachain_info::Pallet<Runtime>;
376	type RuntimeEvent = RuntimeEvent;
377	type OnSystemEvent = ();
378	type OutboundXcmpMessageSource = ();
379	// Ignore all DMP messages by enqueueing them into `()`:
380	type DmpQueue = frame_support::traits::EnqueueWithOrigin<(), sp_core::ConstU8<0>>;
381	type ReservedDmpWeight = ();
382	type XcmpMessageHandler = ();
383	type ReservedXcmpWeight = ();
384	type CheckAssociatedRelayNumber =
385		cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
386	type ConsensusHook = ConsensusHook;
387	type RelayParentOffset = ConstU32<RELAY_PARENT_OFFSET>;
388}
389
390impl parachain_info::Config for Runtime {}
391
392impl pallet_aura::Config for Runtime {
393	type AuthorityId = AuraId;
394	type DisabledValidators = ();
395	type MaxAuthorities = ConstU32<32>;
396	#[cfg(feature = "sync-backing")]
397	type AllowMultipleBlocksPerSlot = ConstBool<false>;
398	#[cfg(not(feature = "sync-backing"))]
399	type AllowMultipleBlocksPerSlot = ConstBool<true>;
400	type SlotDuration = ConstU64<SLOT_DURATION>;
401}
402
403impl test_pallet::Config for Runtime {}
404
405construct_runtime! {
406	pub enum Runtime
407	{
408		System: frame_system,
409		ParachainSystem: cumulus_pallet_parachain_system,
410		Timestamp: pallet_timestamp,
411		ParachainInfo: parachain_info,
412		Balances: pallet_balances,
413		Sudo: pallet_sudo,
414		TransactionPayment: pallet_transaction_payment,
415		TestPallet: test_pallet,
416		Glutton: pallet_glutton,
417		Aura: pallet_aura,
418		AuraExt: cumulus_pallet_aura_ext,
419		WeightReclaim: cumulus_pallet_weight_reclaim,
420	}
421}
422
423/// Index of a transaction in the chain.
424pub type Nonce = u32;
425/// A hash of some data used by the chain.
426pub type Hash = sp_core::H256;
427/// Balance of an account.
428pub type Balance = u128;
429/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
430pub type Signature = MultiSignature;
431/// An index to a block.
432pub type BlockNumber = u32;
433/// Some way of identifying an account on the chain. We intentionally make it equivalent
434/// to the public key of our transaction signing scheme.
435pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
436/// Opaque block type.
437pub type NodeBlock = generic::Block<Header, sp_runtime::OpaqueExtrinsic>;
438
439/// The address format for describing accounts.
440pub type Address = MultiAddress<AccountId, ()>;
441/// Block header type as expected by this runtime.
442pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
443/// Block type as expected by this runtime.
444pub type Block = generic::Block<Header, UncheckedExtrinsic>;
445/// A Block signed with a Justification
446pub type SignedBlock = generic::SignedBlock<Block>;
447/// BlockId type as expected by this runtime.
448pub type BlockId = generic::BlockId<Block>;
449/// The extension to the basic transaction logic.
450pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
451	Runtime,
452	(
453		frame_system::AuthorizeCall<Runtime>,
454		frame_system::CheckNonZeroSender<Runtime>,
455		frame_system::CheckSpecVersion<Runtime>,
456		frame_system::CheckGenesis<Runtime>,
457		frame_system::CheckEra<Runtime>,
458		frame_system::CheckNonce<Runtime>,
459		frame_system::CheckWeight<Runtime>,
460		pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
461	),
462>;
463/// Unchecked extrinsic type as expected by this runtime.
464pub type UncheckedExtrinsic =
465	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
466/// Executive: handles dispatch to the various modules.
467pub type Executive = frame_executive::Executive<
468	Runtime,
469	Block,
470	frame_system::ChainContext<Runtime>,
471	Runtime,
472	AllPalletsWithSystem,
473>;
474
475/// The payload being signed in transactions.
476pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
477
478pub struct SingleBlockMigrations;
479
480impl OnRuntimeUpgrade for SingleBlockMigrations {
481	fn on_runtime_upgrade() -> frame_support::weights::Weight {
482		assert_eq!(
483			sp_io::storage::get(test_pallet::TEST_RUNTIME_UPGRADE_KEY),
484			Some(vec![1, 2, 3, 4].into())
485		);
486		Weight::from_parts(1, 0)
487	}
488}
489
490decl_runtime_apis! {
491	pub trait GetLastTimestamp {
492		/// Returns the last timestamp of a runtime.
493		fn get_last_timestamp() -> u64;
494	}
495}
496
497impl_runtime_apis! {
498	impl sp_api::Core<Block> for Runtime {
499		fn version() -> RuntimeVersion {
500			VERSION
501		}
502
503		fn execute_block(block: <Block as BlockT>::LazyBlock) {
504			Executive::execute_block(block)
505		}
506
507		fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
508			Executive::initialize_block(header)
509		}
510	}
511
512
513	impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
514		fn can_build_upon(
515			included_hash: <Block as BlockT>::Hash,
516			slot: cumulus_primitives_aura::Slot,
517		) -> bool {
518			ConsensusHook::can_build_upon(included_hash, slot)
519		}
520	}
521
522	impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
523		fn relay_parent_offset() -> u32 {
524			RELAY_PARENT_OFFSET
525		}
526	}
527
528	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
529		fn slot_duration() -> sp_consensus_aura::SlotDuration {
530			sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
531		}
532
533		fn authorities() -> Vec<AuraId> {
534			pallet_aura::Authorities::<Runtime>::get().into_inner()
535		}
536	}
537
538	impl sp_api::Metadata<Block> for Runtime {
539		fn metadata() -> OpaqueMetadata {
540			OpaqueMetadata::new(Runtime::metadata().into())
541		}
542
543		fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
544			Runtime::metadata_at_version(version)
545		}
546
547		fn metadata_versions() -> Vec<u32> {
548			Runtime::metadata_versions()
549		}
550	}
551
552	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
553		fn account_nonce(account: AccountId) -> Nonce {
554			System::account_nonce(account)
555		}
556	}
557
558	impl sp_block_builder::BlockBuilder<Block> for Runtime {
559		fn apply_extrinsic(
560			extrinsic: <Block as BlockT>::Extrinsic,
561		) -> ApplyExtrinsicResult {
562			Executive::apply_extrinsic(extrinsic)
563		}
564
565		fn finalize_block() -> <Block as BlockT>::Header {
566			Executive::finalize_block()
567		}
568
569		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
570			data.create_extrinsics()
571		}
572
573		fn check_inherents(block: <Block as BlockT>::LazyBlock, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult {
574			data.check_extrinsics(&block)
575		}
576	}
577
578	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
579		fn validate_transaction(
580			source: TransactionSource,
581			tx: <Block as BlockT>::Extrinsic,
582			block_hash: <Block as BlockT>::Hash,
583		) -> TransactionValidity {
584			Executive::validate_transaction(source, tx, block_hash)
585		}
586	}
587
588	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
589		fn offchain_worker(header: &<Block as BlockT>::Header) {
590			Executive::offchain_worker(header)
591		}
592	}
593
594	impl sp_session::SessionKeys<Block> for Runtime {
595		fn decode_session_keys(
596			encoded: Vec<u8>,
597		) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
598			SessionKeys::decode_into_raw_public_keys(&encoded)
599		}
600
601		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
602			SessionKeys::generate(seed)
603		}
604	}
605
606	impl crate::GetLastTimestamp<Block> for Runtime {
607		fn get_last_timestamp() -> u64 {
608			Now::<Runtime>::get()
609		}
610	}
611
612	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
613		fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
614			ParachainSystem::collect_collation_info(header)
615		}
616	}
617
618	impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
619		fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
620			build_state::<RuntimeGenesisConfig>(config)
621		}
622
623		fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
624			get_preset::<RuntimeGenesisConfig>(id, genesis_config_presets::get_preset)
625		}
626
627		fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
628			genesis_config_presets::preset_names()
629		}
630	}
631
632	impl cumulus_primitives_core::GetParachainInfo<Block> for Runtime {
633		fn parachain_id() -> ParaId {
634			ParachainInfo::parachain_id()
635		}
636
637	}
638
639	impl cumulus_primitives_core::TargetBlockRate<Block> for Runtime {
640		fn target_block_rate() -> u32 {
641			1
642		}
643	}
644}
645
646cumulus_pallet_parachain_system::register_validate_block! {
647	Runtime = Runtime,
648	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
649}