git.delta.rocks / unique-network / refs/commits / 1563a47f4047

difftreelog

source

runtime/opal/src/lib.rs44.3 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.1819#![cfg_attr(not(feature = "std"), no_std)]20// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.21#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]24// Make the WASM binary available.25#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31use fp_self_contained::*;32use sp_runtime::traits::{Member};33// #[cfg(any(feature = "std", test))]34// pub use sp_runtime::BuildStorage;3536use sp_runtime::{37	Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,38	traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},39	transaction_validity::{TransactionSource, TransactionValidity},40	ApplyExtrinsicResult, RuntimeAppPublic,41};4243use sp_std::prelude::*;4445#[cfg(feature = "std")]46use sp_version::NativeVersion;47use sp_version::RuntimeVersion;48pub use pallet_transaction_payment::{49	Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,50};51// A few exports that help ease life for downstream crates.52pub use pallet_balances::Call as BalancesCall;53pub use pallet_evm::{54	EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,55};56pub use frame_support::{57	construct_runtime, match_types,58	dispatch::DispatchResult,59	PalletId, parameter_types, StorageValue, ConsensusEngineId,60	traits::{61		tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,62		Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,63		OnUnbalanced, Randomness, FindAuthor, PrivilegeCmp,64	},65	weights::{66		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},67		DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,68		WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,69	},70};71use pallet_unq_scheduler::DispatchCall;72use up_data_structs::*;73// use pallet_contracts::weights::WeightInfo;74// #[cfg(any(feature = "std", test))]75use frame_system::{76	self as frame_system, EnsureRoot, EnsureSigned,77	limits::{BlockWeights, BlockLength},78};79use sp_arithmetic::{80	traits::{BaseArithmetic, Unsigned},81};82use smallvec::smallvec;83// use scale_info::TypeInfo;84use codec::{Encode, Decode};85use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};86use fp_rpc::TransactionStatus;87use sp_runtime::{88	traits::{89		Applyable, BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating,90		CheckedConversion,91	},92	generic::Era,93	transaction_validity::TransactionValidityError,94	DispatchErrorWithPostInfo, SaturatedConversion,95};9697// pub use pallet_timestamp::Call as TimestampCall;98pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;99100// Polkadot imports101use pallet_xcm::XcmPassthrough;102use polkadot_parachain::primitives::Sibling;103use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};104use xcm_builder::{105	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,106	EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,107	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,108	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,109	ParentIsPreset,110};111use xcm_executor::{Config, XcmExecutor, Assets};112use sp_std::{cmp::Ordering, marker::PhantomData};113114use xcm::latest::{115	//	Xcm,116	AssetId::{Concrete},117	Fungibility::Fungible as XcmFungible,118	MultiAsset,119	Error as XcmError,120};121use xcm_executor::traits::{MatchesFungible, WeightTrader};122//use xcm_executor::traits::MatchesFungible;123124use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};125126pub const RUNTIME_NAME: &str = "opal";127pub const TOKEN_SYMBOL: &str = "OPL";128129type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;130131impl RuntimeInstance for Runtime {132	type CrossAccountId = self::CrossAccountId;133	type TransactionConverter = self::TransactionConverter;134135	fn get_transaction_converter() -> TransactionConverter {136		TransactionConverter137	}138}139140/// The type for looking up accounts. We don't expect more than 4 billion of them, but you141/// never know...142pub type AccountIndex = u32;143144/// Balance of an account.145pub type Balance = u128;146147/// Index of a transaction in the chain.148pub type Index = u32;149150/// A hash of some data used by the chain.151pub type Hash = sp_core::H256;152153/// Digest item type.154pub type DigestItem = generic::DigestItem;155156/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know157/// the specifics of the runtime. They can then be made to be agnostic over specific formats158/// of data like extrinsics, allowing for them to continue syncing the network through upgrades159/// to even the core data structures.160pub mod opaque {161	use sp_std::prelude::*;162	use sp_runtime::impl_opaque_keys;163	use super::Aura;164165	pub use unique_runtime_common::types::*;166167	impl_opaque_keys! {168		pub struct SessionKeys {169			pub aura: Aura,170		}171	}172}173174/// This runtime version.175pub const VERSION: RuntimeVersion = RuntimeVersion {176	spec_name: create_runtime_str!(RUNTIME_NAME),177	impl_name: create_runtime_str!(RUNTIME_NAME),178	authoring_version: 1,179	spec_version: 921000,180	impl_version: 0,181	apis: RUNTIME_API_VERSIONS,182	transaction_version: 1,183	state_version: 0,184};185186#[derive(codec::Encode, codec::Decode)]187pub enum XCMPMessage<XAccountId, XBalance> {188	/// Transfer tokens to the given account from the Parachain account.189	TransferToken(XAccountId, XBalance),190}191192/// The version information used to identify this runtime when compiled natively.193#[cfg(feature = "std")]194pub fn native_version() -> NativeVersion {195	NativeVersion {196		runtime_version: VERSION,197		can_author_with: Default::default(),198	}199}200201type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;202203pub struct DealWithFees;204impl OnUnbalanced<NegativeImbalance> for DealWithFees {205	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {206		if let Some(fees) = fees_then_tips.next() {207			// for fees, 100% to treasury208			let mut split = fees.ration(100, 0);209			if let Some(tips) = fees_then_tips.next() {210				// for tips, if any, 100% to treasury211				tips.ration_merge_into(100, 0, &mut split);212			}213			Treasury::on_unbalanced(split.0);214			// Author::on_unbalanced(split.1);215		}216	}217}218219parameter_types! {220	pub const BlockHashCount: BlockNumber = 2400;221	pub RuntimeBlockLength: BlockLength =222		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);223	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);224	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;225	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()226		.base_block(BlockExecutionWeight::get())227		.for_class(DispatchClass::all(), |weights| {228			weights.base_extrinsic = ExtrinsicBaseWeight::get();229		})230		.for_class(DispatchClass::Normal, |weights| {231			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);232		})233		.for_class(DispatchClass::Operational, |weights| {234			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);235			// Operational transactions have some extra reserved space, so that they236			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.237			weights.reserved = Some(238				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT239			);240		})241		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)242		.build_or_panic();243	pub const Version: RuntimeVersion = VERSION;244	pub const SS58Prefix: u8 = 42;245}246247parameter_types! {248	pub const ChainId: u64 = 8882;249}250251pub struct FixedFee;252impl FeeCalculator for FixedFee {253	fn min_gas_price() -> U256 {254		MIN_GAS_PRICE.into()255	}256}257258// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case259// (contract, which only writes a lot of data),260// approximating on top of our real store write weight261parameter_types! {262	pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;263	pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;264	pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();265}266267/// Limiting EVM execution to 50% of block for substrate users and management tasks268/// EVM transaction consumes more weight than substrate's, so we can't rely on them being269/// scheduled fairly270const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);271parameter_types! {272	pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());273}274275pub enum FixedGasWeightMapping {}276impl GasWeightMapping for FixedGasWeightMapping {277	fn gas_to_weight(gas: u64) -> Weight {278		gas.saturating_mul(WeightPerGas::get())279	}280	fn weight_to_gas(weight: Weight) -> u64 {281		weight / WeightPerGas::get()282	}283}284285impl pallet_evm::account::Config for Runtime {286	type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;287	type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;288	type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;289}290291impl pallet_evm::Config for Runtime {292	type BlockGasLimit = BlockGasLimit;293	type FeeCalculator = FixedFee;294	type GasWeightMapping = FixedGasWeightMapping;295	type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;296	type CallOrigin = EnsureAddressTruncated<Self>;297	type WithdrawOrigin = EnsureAddressTruncated<Self>;298	type AddressMapping = HashedAddressMapping<Self::Hashing>;299	type PrecompilesType = ();300	type PrecompilesValue = ();301	type Currency = Balances;302	type Event = Event;303	type OnMethodCall = (304		pallet_evm_migration::OnMethodCall<Self>,305		pallet_unique::UniqueErcSupport<Self>,306		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,307	);308	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;309	type ChainId = ChainId;310	type Runner = pallet_evm::runner::stack::Runner<Self>;311	type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;312	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;313	type FindAuthor = EthereumFindAuthor<Aura>;314}315316impl pallet_evm_migration::Config for Runtime {317	type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;318}319320pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);321impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {322	fn find_author<'a, I>(digests: I) -> Option<H160>323	where324		I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,325	{326		if let Some(author_index) = F::find_author(digests) {327			let authority_id = Aura::authorities()[author_index as usize].clone();328			return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));329		}330		None331	}332}333334impl pallet_ethereum::Config for Runtime {335	type Event = Event;336	type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;337}338339impl pallet_randomness_collective_flip::Config for Runtime {}340341impl frame_system::Config for Runtime {342	/// The data to be stored in an account.343	type AccountData = pallet_balances::AccountData<Balance>;344	/// The identifier used to distinguish between accounts.345	type AccountId = AccountId;346	/// The basic call filter to use in dispatchable.347	type BaseCallFilter = Everything;348	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).349	type BlockHashCount = BlockHashCount;350	/// The maximum length of a block (in bytes).351	type BlockLength = RuntimeBlockLength;352	/// The index type for blocks.353	type BlockNumber = BlockNumber;354	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.355	type BlockWeights = RuntimeBlockWeights;356	/// The aggregated dispatch type that is available for extrinsics.357	type Call = Call;358	/// The weight of database operations that the runtime can invoke.359	type DbWeight = RocksDbWeight;360	/// The ubiquitous event type.361	type Event = Event;362	/// The type for hashing blocks and tries.363	type Hash = Hash;364	/// The hashing algorithm used.365	type Hashing = BlakeTwo256;366	/// The header type.367	type Header = generic::Header<BlockNumber, BlakeTwo256>;368	/// The index type for storing how many extrinsics an account has signed.369	type Index = Index;370	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.371	type Lookup = AccountIdLookup<AccountId, ()>;372	/// What to do if an account is fully reaped from the system.373	type OnKilledAccount = ();374	/// What to do if a new account is created.375	type OnNewAccount = ();376	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;377	/// The ubiquitous origin type.378	type Origin = Origin;379	/// This type is being generated by `construct_runtime!`.380	type PalletInfo = PalletInfo;381	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.382	type SS58Prefix = SS58Prefix;383	/// Weight information for the extrinsics of this pallet.384	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;385	/// Version of the runtime.386	type Version = Version;387	type MaxConsumers = ConstU32<16>;388}389390parameter_types! {391	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;392}393394impl pallet_timestamp::Config for Runtime {395	/// A timestamp: milliseconds since the unix epoch.396	type Moment = u64;397	type OnTimestampSet = ();398	type MinimumPeriod = MinimumPeriod;399	type WeightInfo = ();400}401402parameter_types! {403	// pub const ExistentialDeposit: u128 = 500;404	pub const ExistentialDeposit: u128 = 0;405	pub const MaxLocks: u32 = 50;406	pub const MaxReserves: u32 = 50;407}408409impl pallet_balances::Config for Runtime {410	type MaxLocks = MaxLocks;411	type MaxReserves = MaxReserves;412	type ReserveIdentifier = [u8; 16];413	/// The type for recording an account's balance.414	type Balance = Balance;415	/// The ubiquitous event type.416	type Event = Event;417	type DustRemoval = Treasury;418	type ExistentialDeposit = ExistentialDeposit;419	type AccountStore = System;420	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;421}422423pub const fn deposit(items: u32, bytes: u32) -> Balance {424	items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE425}426427/*428parameter_types! {429	pub TombstoneDeposit: Balance = deposit(430		1,431		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,432	);433	pub DepositPerContract: Balance = TombstoneDeposit::get();434	pub const DepositPerStorageByte: Balance = deposit(0, 1);435	pub const DepositPerStorageItem: Balance = deposit(1, 0);436	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);437	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;438	pub const SignedClaimHandicap: u32 = 2;439	pub const MaxDepth: u32 = 32;440	pub const MaxValueSize: u32 = 16 * 1024;441	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb442	// The lazy deletion runs inside on_initialize.443	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *444		RuntimeBlockWeights::get().max_block;445	// The weight needed for decoding the queue should be less or equal than a fifth446	// of the overall weight dedicated to the lazy deletion.447	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (448			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -449			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)450		)) / 5) as u32;451	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();452}453454impl pallet_contracts::Config for Runtime {455	type Time = Timestamp;456	type Randomness = RandomnessCollectiveFlip;457	type Currency = Balances;458	type Event = Event;459	type RentPayment = ();460	type SignedClaimHandicap = SignedClaimHandicap;461	type TombstoneDeposit = TombstoneDeposit;462	type DepositPerContract = DepositPerContract;463	type DepositPerStorageByte = DepositPerStorageByte;464	type DepositPerStorageItem = DepositPerStorageItem;465	type RentFraction = RentFraction;466	type SurchargeReward = SurchargeReward;467	type WeightPrice = pallet_transaction_payment::Pallet<Self>;468	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;469	type ChainExtension = NFTExtension;470	type DeletionQueueDepth = DeletionQueueDepth;471	type DeletionWeightLimit = DeletionWeightLimit;472	type Schedule = Schedule;473	type CallStack = [pallet_contracts::Frame<Self>; 31];474}475*/476477parameter_types! {478	/// This value increases the priority of `Operational` transactions by adding479	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.480	pub const OperationalFeeMultiplier: u8 = 5;481}482483/// Linear implementor of `WeightToFeePolynomial`484pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);485486impl<T> WeightToFeePolynomial for LinearFee<T>487where488	T: BaseArithmetic + From<u32> + Copy + Unsigned,489{490	type Balance = T;491492	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {493		smallvec!(WeightToFeeCoefficient {494			// Targeting 0.1 Unique per NFT transfer495			coeff_integer: WEIGHT_TO_FEE_COEFF.into(),496			coeff_frac: Perbill::zero(),497			negative: false,498			degree: 1,499		})500	}501}502503impl pallet_transaction_payment::Config for Runtime {504	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;505	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;506	type OperationalFeeMultiplier = OperationalFeeMultiplier;507	type WeightToFee = LinearFee<Balance>;508	type FeeMultiplierUpdate = ();509}510511parameter_types! {512	pub const ProposalBond: Permill = Permill::from_percent(5);513	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;514	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;515	pub const SpendPeriod: BlockNumber = 5 * MINUTES;516	pub const Burn: Permill = Permill::from_percent(0);517	pub const TipCountdown: BlockNumber = 1 * DAYS;518	pub const TipFindersFee: Percent = Percent::from_percent(20);519	pub const TipReportDepositBase: Balance = 1 * UNIQUE;520	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;521	pub const BountyDepositBase: Balance = 1 * UNIQUE;522	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;523	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");524	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;525	pub const MaximumReasonLength: u32 = 16384;526	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);527	pub const BountyValueMinimum: Balance = 5 * UNIQUE;528	pub const MaxApprovals: u32 = 100;529}530531impl pallet_treasury::Config for Runtime {532	type PalletId = TreasuryModuleId;533	type Currency = Balances;534	type ApproveOrigin = EnsureRoot<AccountId>;535	type RejectOrigin = EnsureRoot<AccountId>;536	type Event = Event;537	type OnSlash = ();538	type ProposalBond = ProposalBond;539	type ProposalBondMinimum = ProposalBondMinimum;540	type ProposalBondMaximum = ProposalBondMaximum;541	type SpendPeriod = SpendPeriod;542	type Burn = Burn;543	type BurnDestination = ();544	type SpendFunds = ();545	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;546	type MaxApprovals = MaxApprovals;547}548549impl pallet_sudo::Config for Runtime {550	type Event = Event;551	type Call = Call;552}553554pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);555556impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider557	for RelayChainBlockNumberProvider<T>558{559	type BlockNumber = BlockNumber;560561	fn current_block_number() -> Self::BlockNumber {562		cumulus_pallet_parachain_system::Pallet::<T>::validation_data()563			.map(|d| d.relay_parent_number)564			.unwrap_or_default()565	}566}567568parameter_types! {569	pub const MinVestedTransfer: Balance = 10 * UNIQUE;570	pub const MaxVestingSchedules: u32 = 28;571}572573impl orml_vesting::Config for Runtime {574	type Event = Event;575	type Currency = pallet_balances::Pallet<Runtime>;576	type MinVestedTransfer = MinVestedTransfer;577	type VestedTransferOrigin = EnsureSigned<AccountId>;578	type WeightInfo = ();579	type MaxVestingSchedules = MaxVestingSchedules;580	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;581}582583parameter_types! {584	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;585	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;586}587588impl cumulus_pallet_parachain_system::Config for Runtime {589	type Event = Event;590	type SelfParaId = parachain_info::Pallet<Self>;591	type OnSystemEvent = ();592	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<593	// 	MaxDownwardMessageWeight,594	// 	XcmExecutor<XcmConfig>,595	// 	Call,596	// >;597	type OutboundXcmpMessageSource = XcmpQueue;598	type DmpMessageHandler = DmpQueue;599	type ReservedDmpWeight = ReservedDmpWeight;600	type ReservedXcmpWeight = ReservedXcmpWeight;601	type XcmpMessageHandler = XcmpQueue;602}603604impl parachain_info::Config for Runtime {}605606impl cumulus_pallet_aura_ext::Config for Runtime {}607608parameter_types! {609	pub const RelayLocation: MultiLocation = MultiLocation::parent();610	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;611	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();612	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();613}614615/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used616/// when determining ownership of accounts for asset transacting and when attempting to use XCM617/// `Transact` in order to determine the dispatch Origin.618pub type LocationToAccountId = (619	// The parent (Relay-chain) origin converts to the default `AccountId`.620	ParentIsPreset<AccountId>,621	// Sibling parachain origins convert to AccountId via the `ParaId::into`.622	SiblingParachainConvertsVia<Sibling, AccountId>,623	// Straight up local `AccountId32` origins just alias directly to `AccountId`.624	AccountId32Aliases<RelayNetwork, AccountId>,625);626627pub struct OnlySelfCurrency;628impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {629	fn matches_fungible(a: &MultiAsset) -> Option<B> {630		match (&a.id, &a.fun) {631			(Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),632			_ => None,633		}634	}635}636637/// Means for transacting assets on this chain.638pub type LocalAssetTransactor = CurrencyAdapter<639	// Use this currency:640	Balances,641	// Use this currency when it is a fungible asset matching the given location or name:642	OnlySelfCurrency,643	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:644	LocationToAccountId,645	// Our chain's account ID type (we can't get away without mentioning it explicitly):646	AccountId,647	// We don't track any teleports.648	(),649>;650651/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,652/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can653/// biases the kind of local `Origin` it will become.654pub type XcmOriginToTransactDispatchOrigin = (655	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location656	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for657	// foreign chains who want to have a local sovereign account on this chain which they control.658	SovereignSignedViaLocation<LocationToAccountId, Origin>,659	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when660	// recognised.661	RelayChainAsNative<RelayOrigin, Origin>,662	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when663	// recognised.664	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,665	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a666	// transaction from the Root origin.667	ParentAsSuperuser<Origin>,668	// Native signed account converter; this just converts an `AccountId32` origin into a normal669	// `Origin::Signed` origin of the same 32-byte value.670	SignedAccountId32AsNative<RelayNetwork, Origin>,671	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.672	XcmPassthrough<Origin>,673);674675parameter_types! {676	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.677	pub UnitWeightCost: Weight = 1_000_000;678	// 1200 UNIQUEs buy 1 second of weight.679	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);680	pub const MaxInstructions: u32 = 100;681	pub const MaxAuthorities: u32 = 100_000;682}683684match_types! {685	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {686		MultiLocation { parents: 1, interior: Here } |687		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }688	};689}690691pub type Barrier = (692	TakeWeightCredit,693	AllowTopLevelPaidExecutionFrom<Everything>,694	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,695	// ^^^ Parent & its unit plurality gets free execution696);697698pub struct UsingOnlySelfCurrencyComponents<699	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,700	AssetId: Get<MultiLocation>,701	AccountId,702	Currency: CurrencyT<AccountId>,703	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,704>(705	Weight,706	Currency::Balance,707	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,708);709impl<710		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,711		AssetId: Get<MultiLocation>,712		AccountId,713		Currency: CurrencyT<AccountId>,714		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,715	> WeightTrader716	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>717{718	fn new() -> Self {719		Self(0, Zero::zero(), PhantomData)720	}721722	fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {723		let amount = WeightToFee::calc(&weight);724		let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;725726		// location to this parachain through relay chain727		let option1: xcm::v1::AssetId = Concrete(MultiLocation {728			parents: 1,729			interior: X1(Parachain(ParachainInfo::parachain_id().into())),730		});731		// direct location732		let option2: xcm::v1::AssetId = Concrete(MultiLocation {733			parents: 0,734			interior: Here,735		});736737		let required = if payment.fungible.contains_key(&option1) {738			(option1, u128_amount).into()739		} else if payment.fungible.contains_key(&option2) {740			(option2, u128_amount).into()741		} else {742			(Concrete(MultiLocation::default()), u128_amount).into()743		};744745		let unused = payment746			.checked_sub(required)747			.map_err(|_| XcmError::TooExpensive)?;748		self.0 = self.0.saturating_add(weight);749		self.1 = self.1.saturating_add(amount);750		Ok(unused)751	}752753	fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {754		let weight = weight.min(self.0);755		let amount = WeightToFee::calc(&weight);756		self.0 -= weight;757		self.1 = self.1.saturating_sub(amount);758		let amount: u128 = amount.saturated_into();759		if amount > 0 {760			Some((AssetId::get(), amount).into())761		} else {762			None763		}764	}765}766impl<767		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,768		AssetId: Get<MultiLocation>,769		AccountId,770		Currency: CurrencyT<AccountId>,771		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,772	> Drop773	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>774{775	fn drop(&mut self) {776		OnUnbalanced::on_unbalanced(Currency::issue(self.1));777	}778}779780pub struct XcmConfig;781impl Config for XcmConfig {782	type Call = Call;783	type XcmSender = XcmRouter;784	// How to withdraw and deposit an asset.785	type AssetTransactor = LocalAssetTransactor;786	type OriginConverter = XcmOriginToTransactDispatchOrigin;787	type IsReserve = NativeAsset;788	type IsTeleporter = (); // Teleportation is disabled789	type LocationInverter = LocationInverter<Ancestry>;790	type Barrier = Barrier;791	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;792	type Trader = UsingOnlySelfCurrencyComponents<793		IdentityFee<Balance>,794		RelayLocation,795		AccountId,796		Balances,797		(),798	>;799	type ResponseHandler = (); // Don't handle responses for now.800	type SubscriptionService = PolkadotXcm;801802	type AssetTrap = PolkadotXcm;803	type AssetClaims = PolkadotXcm;804}805806// parameter_types! {807// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;808// }809810/// No local origins on this chain are allowed to dispatch XCM sends/executions.811pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);812813/// The means for routing XCM messages which are not for local execution into the right message814/// queues.815pub type XcmRouter = (816	// Two routers - use UMP to communicate with the relay chain:817	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,818	// ..and XCMP to communicate with the sibling chains.819	XcmpQueue,820);821822impl pallet_evm_coder_substrate::Config for Runtime {823	type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;824	type GasWeightMapping = FixedGasWeightMapping;825}826827impl pallet_xcm::Config for Runtime {828	type Event = Event;829	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;830	type XcmRouter = XcmRouter;831	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;832	type XcmExecuteFilter = Everything;833	type XcmExecutor = XcmExecutor<XcmConfig>;834	type XcmTeleportFilter = Everything;835	type XcmReserveTransferFilter = Everything;836	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;837	type LocationInverter = LocationInverter<Ancestry>;838	type Origin = Origin;839	type Call = Call;840	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;841	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;842}843844impl cumulus_pallet_xcm::Config for Runtime {845	type Event = Event;846	type XcmExecutor = XcmExecutor<XcmConfig>;847}848849impl cumulus_pallet_xcmp_queue::Config for Runtime {850	type WeightInfo = ();851	type Event = Event;852	type XcmExecutor = XcmExecutor<XcmConfig>;853	type ChannelInfo = ParachainSystem;854	type VersionWrapper = ();855	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;856	type ControllerOrigin = EnsureRoot<AccountId>;857	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;858}859860impl cumulus_pallet_dmp_queue::Config for Runtime {861	type Event = Event;862	type XcmExecutor = XcmExecutor<XcmConfig>;863	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;864}865866impl pallet_aura::Config for Runtime {867	type AuthorityId = AuraId;868	type DisabledValidators = ();869	type MaxAuthorities = MaxAuthorities;870}871872parameter_types! {873	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();874	pub const CollectionCreationPrice: Balance = 2 * UNIQUE;875}876877impl pallet_common::Config for Runtime {878	type Event = Event;879	type Currency = Balances;880	type CollectionCreationPrice = CollectionCreationPrice;881	type TreasuryAccountId = TreasuryAccountId;882}883884impl pallet_fungible::Config for Runtime {885	type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;886}887impl pallet_refungible::Config for Runtime {888	type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;889}890impl pallet_nonfungible::Config for Runtime {891	type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;892}893894impl pallet_unique::Config for Runtime {895	type Event = Event;896	type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;897}898899parameter_types! {900	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied901}902903/// Used for the pallet inflation904impl pallet_inflation::Config for Runtime {905	type Currency = Balances;906	type TreasuryAccountId = TreasuryAccountId;907	type InflationBlockInterval = InflationBlockInterval;908	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;909}910911parameter_types! {912	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *913		RuntimeBlockWeights::get().max_block;914	pub const MaxScheduledPerBlock: u32 = 50;915}916917type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;918use frame_support::traits::NamedReservableCurrency;919920fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {921	(922		frame_system::CheckSpecVersion::<Runtime>::new(),923		frame_system::CheckGenesis::<Runtime>::new(),924		frame_system::CheckEra::<Runtime>::from(Era::Immortal),925		frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(926			from,927		)),928		frame_system::CheckWeight::<Runtime>::new(),929		// sponsoring transaction logic930		// pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),931	)932}933934pub struct SchedulerPaymentExecutor;935impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>936	DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor937where938	<T as frame_system::Config>::Call: Member939		+ Dispatchable<Origin = Origin, Info = DispatchInfo>940		+ SelfContainedCall<SignedInfo = SelfContainedSignedInfo>941		+ GetDispatchInfo942		+ From<frame_system::Call<Runtime>>,943	SelfContainedSignedInfo: Send + Sync + 'static,944	Call: From<<T as frame_system::Config>::Call>945		+ From<<T as pallet_unq_scheduler::Config>::Call>946		+ SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,947	sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,948{949	fn dispatch_call(950		signer: <T as frame_system::Config>::AccountId,951		call: <T as pallet_unq_scheduler::Config>::Call,952	) -> Result<953		Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,954		TransactionValidityError,955	> {956		let dispatch_info = call.get_dispatch_info();957		let extrinsic = fp_self_contained::CheckedExtrinsic::<958			AccountId,959			Call,960			SignedExtraScheduler,961			SelfContainedSignedInfo,962		> {963			signed:964				CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(965					signer.clone().into(),966					get_signed_extras(signer.into()),967				),968			function: call.into(),969		};970971		extrinsic.apply::<Runtime>(&dispatch_info, 0)972	}973974	fn reserve_balance(975		id: [u8; 16],976		sponsor: <T as frame_system::Config>::AccountId,977		call: <T as pallet_unq_scheduler::Config>::Call,978		count: u32,979	) -> Result<(), DispatchError> {980		let dispatch_info = call.get_dispatch_info();981		let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)982			.saturating_mul(count.into());983984		<Balances as NamedReservableCurrency<AccountId>>::reserve_named(985			&id,986			&(sponsor.into()),987			weight,988		)989	}990991	fn pay_for_call(992		id: [u8; 16],993		sponsor: <T as frame_system::Config>::AccountId,994		call: <T as pallet_unq_scheduler::Config>::Call,995	) -> Result<u128, DispatchError> {996		let dispatch_info = call.get_dispatch_info();997		let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);998		Ok(999			<Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1000				&id,1001				&(sponsor.into()),1002				weight,1003			),1004		)1005	}10061007	fn cancel_reserve(1008		id: [u8; 16],1009		sponsor: <T as frame_system::Config>::AccountId,1010	) -> Result<u128, DispatchError> {1011		Ok(1012			<Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1013				&id,1014				&(sponsor.into()),1015				u128::MAX,1016			),1017		)1018	}1019}10201021parameter_types! {1022	pub const NoPreimagePostponement: Option<u32> = Some(10);1023	pub const Preimage: Option<u32> = Some(10);1024}10251026/// Used the compare the privilege of an origin inside the scheduler.1027pub struct OriginPrivilegeCmp;10281029impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {1030	fn cmp_privilege(_left: &OriginCaller, _right: &OriginCaller) -> Option<Ordering> {1031		Some(Ordering::Equal)1032	}1033}10341035impl pallet_unq_scheduler::Config for Runtime {1036	type Event = Event;1037	type Origin = Origin;1038	type Currency = Balances;1039	type PalletsOrigin = OriginCaller;1040	type Call = Call;1041	type MaximumWeight = MaximumSchedulerWeight;1042	type ScheduleOrigin = EnsureSigned<AccountId>;1043	type MaxScheduledPerBlock = MaxScheduledPerBlock;1044	type WeightInfo = ();1045	type CallExecutor = SchedulerPaymentExecutor;1046	type OriginPrivilegeCmp = OriginPrivilegeCmp;1047	type PreimageProvider = ();1048	type NoPreimagePostponement = NoPreimagePostponement;1049}10501051type EvmSponsorshipHandler = (1052	pallet_unique::UniqueEthSponsorshipHandler<Runtime>,1053	pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,1054);10551056type SponsorshipHandler = (1057	pallet_unique::UniqueSponsorshipHandler<Runtime>,1058	//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,1059	pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,1060);10611062impl pallet_evm_transaction_payment::Config for Runtime {1063	type EvmSponsorshipHandler = EvmSponsorshipHandler;1064	type Currency = Balances;1065}10661067impl pallet_charge_transaction::Config for Runtime {1068	type SponsorshipHandler = SponsorshipHandler;1069}10701071// impl pallet_contract_helpers::Config for Runtime {1072//	 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;1073// }10741075parameter_types! {1076	// 0x842899ECF380553E8a4de75bF534cdf6fBF640491077	pub const HelpersContractAddress: H160 = H160([1078		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,1079	]);1080}10811082impl pallet_evm_contract_helpers::Config for Runtime {1083	type ContractAddress = HelpersContractAddress;1084	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;1085}10861087construct_runtime!(1088	pub enum Runtime where1089		Block = Block,1090		NodeBlock = opaque::Block,1091		UncheckedExtrinsic = UncheckedExtrinsic1092	{1093		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,1094		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,10951096		Aura: pallet_aura::{Pallet, Config<T>} = 22,1097		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,10981099		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,1100		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,1101		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,1102		TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,1103		Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,1104		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,1105		System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,1106		Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,1107		// Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,1108		// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,11091110		// XCM helpers.1111		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1112		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1113		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1114		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,11151116		// Unique Pallets1117		Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1118		Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1119		Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1120		// free = 631121		Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1122		// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1123		Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1124		Fungible: pallet_fungible::{Pallet, Storage} = 67,1125		Refungible: pallet_refungible::{Pallet, Storage} = 68,1126		Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,11271128		// Frontier1129		EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1130		Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,11311132		EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1133		EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1134		EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1135		EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1136	}1137);11381139pub struct TransactionConverter;11401141impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1142	fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1143		UncheckedExtrinsic::new_unsigned(1144			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1145		)1146	}1147}11481149impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1150	fn convert_transaction(1151		&self,1152		transaction: pallet_ethereum::Transaction,1153	) -> opaque::UncheckedExtrinsic {1154		let extrinsic = UncheckedExtrinsic::new_unsigned(1155			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1156		);1157		let encoded = extrinsic.encode();1158		opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1159			.expect("Encoded extrinsic is always valid")1160	}1161}11621163/// The address format for describing accounts.1164pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1165/// Block header type as expected by this runtime.1166pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1167/// Block type as expected by this runtime.1168pub type Block = generic::Block<Header, UncheckedExtrinsic>;1169/// A Block signed with a Justification1170pub type SignedBlock = generic::SignedBlock<Block>;1171/// BlockId type as expected by this runtime.1172pub type BlockId = generic::BlockId<Block>;1173/// The SignedExtension to the basic transaction logic.1174pub type SignedExtra = (1175	frame_system::CheckSpecVersion<Runtime>,1176	// system::CheckTxVersion<Runtime>,1177	frame_system::CheckGenesis<Runtime>,1178	frame_system::CheckEra<Runtime>,1179	frame_system::CheckNonce<Runtime>,1180	frame_system::CheckWeight<Runtime>,1181	ChargeTransactionPayment,1182	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,1183);1184pub type SignedExtraScheduler = (1185	frame_system::CheckSpecVersion<Runtime>,1186	frame_system::CheckGenesis<Runtime>,1187	frame_system::CheckEra<Runtime>,1188	frame_system::CheckNonce<Runtime>,1189	frame_system::CheckWeight<Runtime>,1190);1191/// Unchecked extrinsic type as expected by this runtime.1192pub type UncheckedExtrinsic =1193	fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1194/// Extrinsic type that has already been checked.1195pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1196/// Executive: handles dispatch to the various modules.1197pub type Executive = frame_executive::Executive<1198	Runtime,1199	Block,1200	frame_system::ChainContext<Runtime>,1201	Runtime,1202	AllPalletsReversedWithSystemFirst,1203>;12041205impl_opaque_keys! {1206	pub struct SessionKeys {1207		pub aura: Aura,1208	}1209}12101211impl fp_self_contained::SelfContainedCall for Call {1212	type SignedInfo = H160;12131214	fn is_self_contained(&self) -> bool {1215		match self {1216			Call::Ethereum(call) => call.is_self_contained(),1217			_ => false,1218		}1219	}12201221	fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1222		match self {1223			Call::Ethereum(call) => call.check_self_contained(),1224			_ => None,1225		}1226	}12271228	fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1229		match self {1230			Call::Ethereum(call) => call.validate_self_contained(info),1231			_ => None,1232		}1233	}12341235	fn pre_dispatch_self_contained(1236		&self,1237		info: &Self::SignedInfo,1238	) -> Option<Result<(), TransactionValidityError>> {1239		match self {1240			Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1241			_ => None,1242		}1243	}12441245	fn apply_self_contained(1246		self,1247		info: Self::SignedInfo,1248	) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1249		match self {1250			call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1251				Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1252			)),1253			_ => None,1254		}1255	}1256}12571258macro_rules! dispatch_unique_runtime {1259	($collection:ident.$method:ident($($name:ident),*)) => {{1260		use pallet_unique::dispatch::Dispatched;12611262		let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1263		let dispatch = collection.as_dyn();12641265		Ok(dispatch.$method($($name),*))1266	}};1267}12681269impl_common_runtime_apis!();12701271struct CheckInherents;12721273impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1274	fn check_inherents(1275		block: &Block,1276		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1277	) -> sp_inherents::CheckInherentsResult {1278		let relay_chain_slot = relay_state_proof1279			.read_slot()1280			.expect("Could not read the relay chain slot from the proof");12811282		let inherent_data =1283			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1284				relay_chain_slot,1285				sp_std::time::Duration::from_secs(6),1286			)1287			.create_inherent_data()1288			.expect("Could not create the timestamp inherent data");12891290		inherent_data.check_extrinsics(block)1291	}1292}12931294cumulus_pallet_parachain_system::register_validate_block!(1295	Runtime = Runtime,1296	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1297	CheckInherents = CheckInherents,1298);