difftreelog
fix inverted filter direction
in: master
1 file changed
runtime/src/lib.rsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.78#![cfg_attr(not(feature = "std"), no_std)]9// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.10#![recursion_limit = "1024"]11#![allow(clippy::from_over_into, clippy::identity_op)]12#![allow(clippy::fn_to_numeric_cast_with_truncation)]13// Make the WASM binary available.14#[cfg(feature = "std")]15include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1617use sp_api::impl_runtime_apis;18use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};19// #[cfg(any(feature = "std", test))]20// pub use sp_runtime::BuildStorage;2122use sp_runtime::{23 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,24 traits::{25 AccountIdLookup, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify,26 AccountIdConversion,27 },28 transaction_validity::{TransactionSource, TransactionValidity},29 ApplyExtrinsicResult, MultiSignature,30};3132use sp_std::prelude::*;3334#[cfg(feature = "std")]35use sp_version::NativeVersion;36use sp_version::RuntimeVersion;37pub use pallet_transaction_payment::{38 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,39};40// A few exports that help ease life for downstream crates.41pub use pallet_balances::Call as BalancesCall;42pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};43pub use frame_support::{44 construct_runtime, match_type,45 dispatch::DispatchResult,46 PalletId, parameter_types, StorageValue, ConsensusEngineId,47 traits::{48 Nothing, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,49 OnUnbalanced, Randomness, FindAuthor,50 },51 weights::{52 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},53 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,54 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,55 },56};57use xcm_executor::traits::InvertLocation;58use nft_data_structs::*;59// use pallet_contracts::weights::WeightInfo;60// #[cfg(any(feature = "std", test))]61use frame_system::{62 self as system, EnsureRoot, EnsureSigned,63 limits::{BlockWeights, BlockLength},64};65use sp_arithmetic::{66 traits::{BaseArithmetic, Unsigned},67};68use smallvec::smallvec;69use codec::{Encode, Decode};70use pallet_evm::{Account as EVMAccount, FeeCalculator, OnMethodCall};71use fp_rpc::TransactionStatus;72use sp_core::crypto::Public;73use sp_runtime::{74 traits::{Dispatchable},75};7677// pub use pallet_timestamp::Call as TimestampCall;78pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;7980// Polkadot imports81use pallet_xcm::XcmPassthrough;82use polkadot_parachain::primitives::Sibling;83use xcm::v0::Xcm;84use xcm::v0::{BodyId, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId};85use xcm_builder::{86 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,87 EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,88 ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,89 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,90 SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,91};92use xcm_executor::{Config, XcmExecutor};9394// mod chain_extension;95// use crate::chain_extension::{NFTExtension, Imbalance};9697/// An index to a block.98pub type BlockNumber = u32;99100/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.101pub type Signature = MultiSignature;102103/// Some way of identifying an account on the chain. We intentionally make it equivalent104/// to the public key of our transaction signing scheme.105pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;106107/// The type for looking up accounts. We don't expect more than 4 billion of them, but you108/// never know...109pub type AccountIndex = u32;110111/// Balance of an account.112pub type Balance = u128;113114/// Index of a transaction in the chain.115pub type Index = u32;116117/// A hash of some data used by the chain.118pub type Hash = sp_core::H256;119120/// Digest item type.121pub type DigestItem = generic::DigestItem<Hash>;122123/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know124/// the specifics of the runtime. They can then be made to be agnostic over specific formats125/// of data like extrinsics, allowing for them to continue syncing the network through upgrades126/// to even the core data structures.127pub mod opaque {128 use super::*;129130 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;131132 /// Opaque block type.133 pub type Block = generic::Block<Header, UncheckedExtrinsic>;134135 pub type SessionHandlers = ();136137 impl_opaque_keys! {138 pub struct SessionKeys {139 pub aura: Aura,140 }141 }142}143144/// This runtime version.145pub const VERSION: RuntimeVersion = RuntimeVersion {146 spec_name: create_runtime_str!("nft"),147 impl_name: create_runtime_str!("nft"),148 authoring_version: 1,149 spec_version: 3,150 impl_version: 1,151 apis: RUNTIME_API_VERSIONS,152 transaction_version: 1,153};154155pub const MILLISECS_PER_BLOCK: u64 = 12000;156157pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;158159// These time units are defined in number of blocks.160pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);161pub const HOURS: BlockNumber = MINUTES * 60;162pub const DAYS: BlockNumber = HOURS * 24;163164parameter_types! {165 pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;166}167168#[derive(codec::Encode, codec::Decode)]169pub enum XCMPMessage<XAccountId, XBalance> {170 /// Transfer tokens to the given account from the Parachain account.171 TransferToken(XAccountId, XBalance),172}173174/// The version information used to identify this runtime when compiled natively.175#[cfg(feature = "std")]176pub fn native_version() -> NativeVersion {177 NativeVersion {178 runtime_version: VERSION,179 can_author_with: Default::default(),180 }181}182183type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;184185pub struct DealWithFees;186impl OnUnbalanced<NegativeImbalance> for DealWithFees {187 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {188 if let Some(fees) = fees_then_tips.next() {189 // for fees, 100% to treasury190 let mut split = fees.ration(100, 0);191 if let Some(tips) = fees_then_tips.next() {192 // for tips, if any, 100% to treasury193 tips.ration_merge_into(100, 0, &mut split);194 }195 Treasury::on_unbalanced(split.0);196 // Author::on_unbalanced(split.1);197 }198 }199}200201/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.202/// This is used to limit the maximal weight of a single extrinsic.203const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);204/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used205/// by Operational extrinsics.206const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);207/// We allow for 2 seconds of compute with a 6 second average block time.208const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;209210parameter_types! {211 pub const BlockHashCount: BlockNumber = 2400;212 pub RuntimeBlockLength: BlockLength =213 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);214 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);215 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;216 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()217 .base_block(BlockExecutionWeight::get())218 .for_class(DispatchClass::all(), |weights| {219 weights.base_extrinsic = ExtrinsicBaseWeight::get();220 })221 .for_class(DispatchClass::Normal, |weights| {222 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);223 })224 .for_class(DispatchClass::Operational, |weights| {225 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);226 // Operational transactions have some extra reserved space, so that they227 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.228 weights.reserved = Some(229 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT230 );231 })232 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)233 .build_or_panic();234 pub const Version: RuntimeVersion = VERSION;235 pub const SS58Prefix: u8 = 42;236}237238parameter_types! {239 pub const ChainId: u64 = 8888;240}241242impl pallet_evm::Config for Runtime {243 type BlockGasLimit = BlockGasLimit;244 type FeeCalculator = ();245 type GasWeightMapping = ();246 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;247 type CallOrigin = EnsureAddressTruncated;248 type WithdrawOrigin = EnsureAddressTruncated;249 type AddressMapping = HashedAddressMapping<Self::Hashing>;250 type Precompiles = ();251 type Currency = Balances;252 type Event = Event;253 type OnMethodCall = (254 pallet_evm_migration::OnMethodCall<Self>,255 pallet_nft::NftErcSupport<Self>,256 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,257 );258 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;259 type ChainId = ChainId;260 type Runner = pallet_evm::runner::stack::Runner<Self>;261 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;262 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;263 type FindAuthor = EthereumFindAuthor<Aura>;264}265266impl pallet_evm_migration::Config for Runtime {267 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;268}269270pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);271impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {272 fn find_author<'a, I>(digests: I) -> Option<H160>273 where274 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,275 {276 if let Some(author_index) = F::find_author(digests) {277 let authority_id = Aura::authorities()[author_index as usize].clone();278 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));279 }280 None281 }282}283284parameter_types! {285 pub BlockGasLimit: U256 = U256::from(u32::max_value());286}287288impl pallet_ethereum::Config for Runtime {289 type Event = Event;290 type StateRoot = pallet_ethereum::IntermediateStateRoot;291 type EvmSubmitLog = pallet_evm::Pallet<Self>;292}293294impl pallet_randomness_collective_flip::Config for Runtime {}295296impl system::Config for Runtime {297 /// The data to be stored in an account.298 type AccountData = pallet_balances::AccountData<Balance>;299 /// The identifier used to distinguish between accounts.300 type AccountId = AccountId;301 /// The basic call filter to use in dispatchable.302 type BaseCallFilter = ();303 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).304 type BlockHashCount = BlockHashCount;305 /// The maximum length of a block (in bytes).306 type BlockLength = RuntimeBlockLength;307 /// The index type for blocks.308 type BlockNumber = BlockNumber;309 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.310 type BlockWeights = RuntimeBlockWeights;311 /// The aggregated dispatch type that is available for extrinsics.312 type Call = Call;313 /// The weight of database operations that the runtime can invoke.314 type DbWeight = RocksDbWeight;315 /// The ubiquitous event type.316 type Event = Event;317 /// The type for hashing blocks and tries.318 type Hash = Hash;319 /// The hashing algorithm used.320 type Hashing = BlakeTwo256;321 /// The header type.322 type Header = generic::Header<BlockNumber, BlakeTwo256>;323 /// The index type for storing how many extrinsics an account has signed.324 type Index = Index;325 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.326 type Lookup = AccountIdLookup<AccountId, ()>;327 /// What to do if an account is fully reaped from the system.328 type OnKilledAccount = ();329 /// What to do if a new account is created.330 type OnNewAccount = ();331 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;332 /// The ubiquitous origin type.333 type Origin = Origin;334 /// This type is being generated by `construct_runtime!`.335 type PalletInfo = PalletInfo;336 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.337 type SS58Prefix = SS58Prefix;338 /// Weight information for the extrinsics of this pallet.339 type SystemWeightInfo = system::weights::SubstrateWeight<Self>;340 /// Version of the runtime.341 type Version = Version;342}343344parameter_types! {345 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;346}347348impl pallet_timestamp::Config for Runtime {349 /// A timestamp: milliseconds since the unix epoch.350 type Moment = u64;351 type OnTimestampSet = ();352 type MinimumPeriod = MinimumPeriod;353 type WeightInfo = ();354}355356parameter_types! {357 // pub const ExistentialDeposit: u128 = 500;358 pub const ExistentialDeposit: u128 = 0;359 pub const MaxLocks: u32 = 50;360}361362impl pallet_balances::Config for Runtime {363 type MaxLocks = MaxLocks;364 type MaxReserves = ();365 type ReserveIdentifier = [u8; 8];366 /// The type for recording an account's balance.367 type Balance = Balance;368 /// The ubiquitous event type.369 type Event = Event;370 type DustRemoval = Treasury;371 type ExistentialDeposit = ExistentialDeposit;372 type AccountStore = System;373 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;374}375376pub const MICROUNIQUE: Balance = 1_000_000_000;377pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;378pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;379pub const UNIQUE: Balance = 100 * CENTIUNIQUE;380381pub const fn deposit(items: u32, bytes: u32) -> Balance {382 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE383}384385/*386parameter_types! {387 pub TombstoneDeposit: Balance = deposit(388 1,389 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,390 );391 pub DepositPerContract: Balance = TombstoneDeposit::get();392 pub const DepositPerStorageByte: Balance = deposit(0, 1);393 pub const DepositPerStorageItem: Balance = deposit(1, 0);394 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);395 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;396 pub const SignedClaimHandicap: u32 = 2;397 pub const MaxDepth: u32 = 32;398 pub const MaxValueSize: u32 = 16 * 1024;399 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb400 // The lazy deletion runs inside on_initialize.401 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *402 RuntimeBlockWeights::get().max_block;403 // The weight needed for decoding the queue should be less or equal than a fifth404 // of the overall weight dedicated to the lazy deletion.405 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (406 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -407 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)408 )) / 5) as u32;409 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();410}411412impl pallet_contracts::Config for Runtime {413 type Time = Timestamp;414 type Randomness = RandomnessCollectiveFlip;415 type Currency = Balances;416 type Event = Event;417 type RentPayment = ();418 type SignedClaimHandicap = SignedClaimHandicap;419 type TombstoneDeposit = TombstoneDeposit;420 type DepositPerContract = DepositPerContract;421 type DepositPerStorageByte = DepositPerStorageByte;422 type DepositPerStorageItem = DepositPerStorageItem;423 type RentFraction = RentFraction;424 type SurchargeReward = SurchargeReward;425 type WeightPrice = pallet_transaction_payment::Pallet<Self>;426 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;427 type ChainExtension = NFTExtension;428 type DeletionQueueDepth = DeletionQueueDepth;429 type DeletionWeightLimit = DeletionWeightLimit;430 type Schedule = Schedule;431 type CallStack = [pallet_contracts::Frame<Self>; 31];432}433*/434435parameter_types! {436 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer437}438439/// Linear implementor of `WeightToFeePolynomial`440pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);441442impl<T> WeightToFeePolynomial for LinearFee<T>443where444 T: BaseArithmetic + From<u32> + Copy + Unsigned,445{446 type Balance = T;447448 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {449 smallvec!(WeightToFeeCoefficient {450 coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer451 coeff_frac: Perbill::zero(),452 negative: false,453 degree: 1,454 })455 }456}457458impl pallet_transaction_payment::Config for Runtime {459 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;460 type TransactionByteFee = TransactionByteFee;461 type WeightToFee = LinearFee<Balance>;462 type FeeMultiplierUpdate = ();463}464465parameter_types! {466 pub const ProposalBond: Permill = Permill::from_percent(5);467 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;468 pub const SpendPeriod: BlockNumber = 5 * MINUTES;469 pub const Burn: Permill = Permill::from_percent(0);470 pub const TipCountdown: BlockNumber = 1 * DAYS;471 pub const TipFindersFee: Percent = Percent::from_percent(20);472 pub const TipReportDepositBase: Balance = 1 * UNIQUE;473 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;474 pub const BountyDepositBase: Balance = 1 * UNIQUE;475 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;476 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");477 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;478 pub const MaximumReasonLength: u32 = 16384;479 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);480 pub const BountyValueMinimum: Balance = 5 * UNIQUE;481 pub const MaxApprovals: u32 = 100;482}483484impl pallet_treasury::Config for Runtime {485 type PalletId = TreasuryModuleId;486 type Currency = Balances;487 type ApproveOrigin = EnsureRoot<AccountId>;488 type RejectOrigin = EnsureRoot<AccountId>;489 type Event = Event;490 type OnSlash = ();491 type ProposalBond = ProposalBond;492 type ProposalBondMinimum = ProposalBondMinimum;493 type SpendPeriod = SpendPeriod;494 type Burn = Burn;495 type BurnDestination = ();496 type SpendFunds = ();497 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;498 type MaxApprovals = MaxApprovals;499}500501impl pallet_sudo::Config for Runtime {502 type Event = Event;503 type Call = Call;504}505506parameter_types! {507 pub const MinVestedTransfer: Balance = 10 * UNIQUE;508}509510impl pallet_vesting::Config for Runtime {511 type Event = Event;512 type Currency = Balances;513 type BlockNumberToBalance = ConvertInto;514 type MinVestedTransfer = MinVestedTransfer;515 type WeightInfo = ();516}517518parameter_types! {519 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;520 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;521}522523impl cumulus_pallet_parachain_system::Config for Runtime {524 type Event = Event;525 type OnValidationData = ();526 type SelfParaId = parachain_info::Pallet<Self>;527 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<528 // MaxDownwardMessageWeight,529 // XcmExecutor<XcmConfig>,530 // Call,531 // >;532 type OutboundXcmpMessageSource = XcmpQueue;533 type DmpMessageHandler = DmpQueue;534 type ReservedDmpWeight = ReservedDmpWeight;535 type ReservedXcmpWeight = ReservedXcmpWeight;536 type XcmpMessageHandler = XcmpQueue;537}538539impl parachain_info::Config for Runtime {}540541impl cumulus_pallet_aura_ext::Config for Runtime {}542543parameter_types! {544 pub const RelayLocation: MultiLocation = X1(Parent);545 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;546 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();547 pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));548}549550/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used551/// when determining ownership of accounts for asset transacting and when attempting to use XCM552/// `Transact` in order to determine the dispatch Origin.553pub type LocationToAccountId = (554 // The parent (Relay-chain) origin converts to the default `AccountId`.555 ParentIsDefault<AccountId>,556 // Sibling parachain origins convert to AccountId via the `ParaId::into`.557 SiblingParachainConvertsVia<Sibling, AccountId>,558 // Straight up local `AccountId32` origins just alias directly to `AccountId`.559 AccountId32Aliases<RelayNetwork, AccountId>,560);561562/// Means for transacting assets on this chain.563pub type LocalAssetTransactor = CurrencyAdapter<564 // Use this currency:565 Balances,566 // Use this currency when it is a fungible asset matching the given location or name:567 IsConcrete<RelayLocation>,568 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:569 LocationToAccountId,570 // Our chain's account ID type (we can't get away without mentioning it explicitly):571 AccountId,572 // We don't track any teleports.573 (),574>;575576/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,577/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can578/// biases the kind of local `Origin` it will become.579pub type XcmOriginToTransactDispatchOrigin = (580 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location581 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for582 // foreign chains who want to have a local sovereign account on this chain which they control.583 SovereignSignedViaLocation<LocationToAccountId, Origin>,584 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when585 // recognised.586 RelayChainAsNative<RelayOrigin, Origin>,587 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when588 // recognised.589 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,590 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a591 // transaction from the Root origin.592 ParentAsSuperuser<Origin>,593 // Native signed account converter; this just converts an `AccountId32` origin into a normal594 // `Origin::Signed` origin of the same 32-byte value.595 SignedAccountId32AsNative<RelayNetwork, Origin>,596 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.597 XcmPassthrough<Origin>,598);599600parameter_types! {601 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.602 pub UnitWeightCost: Weight = 1_000_000;603 // 1200 UNIQUEs buy 1 second of weight.604 pub const WeightPrice: (MultiLocation, u128) = (X1(Parent), 1_200 * UNIQUE);605}606607match_type! {608 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {609 X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. })610 };611}612613pub type Barrier = (614 TakeWeightCredit,615 AllowTopLevelPaidExecutionFrom<Nothing>,616 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,617 // ^^^ Parent & its unit plurality gets free execution618);619620pub struct XcmConfig;621impl Config for XcmConfig {622 type Call = Call;623 type XcmSender = XcmRouter;624 // How to withdraw and deposit an asset.625 type AssetTransactor = LocalAssetTransactor;626 type OriginConverter = XcmOriginToTransactDispatchOrigin;627 type IsReserve = NativeAsset;628 type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of ROC629 type LocationInverter = LocationInverter<Ancestry>;630 type Barrier = Barrier;631 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;632 type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;633 type ResponseHandler = (); // Don't handle responses for now.634}635636// parameter_types! {637// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;638// }639640/// No local origins on this chain are allowed to dispatch XCM sends/executions.641pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);642643/// The means for routing XCM messages which are not for local execution into the right message644/// queues.645pub type XcmRouter = (646 // Two routers - use UMP to communicate with the relay chain:647 cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,648 // ..and XCMP to communicate with the sibling chains.649 XcmpQueue,650);651652impl pallet_evm_coder_substrate::Config for Runtime {653 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;654}655656impl pallet_xcm::Config for Runtime {657 type Event = Event;658 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;659 type XcmRouter = XcmRouter;660 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;661 type XcmExecuteFilter = Nothing;662 type XcmExecutor = XcmExecutor<XcmConfig>;663 type XcmTeleportFilter = Nothing;664 type XcmReserveTransferFilter = ();665 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;666 type LocationInverter = LocationInverter<Ancestry>;667}668669impl cumulus_pallet_xcm::Config for Runtime {670 type Event = Event;671 type XcmExecutor = XcmExecutor<XcmConfig>;672}673674impl cumulus_pallet_xcmp_queue::Config for Runtime {675 type Event = Event;676 type XcmExecutor = XcmExecutor<XcmConfig>;677 type ChannelInfo = ParachainSystem;678}679680impl cumulus_pallet_dmp_queue::Config for Runtime {681 type Event = Event;682 type XcmExecutor = XcmExecutor<XcmConfig>;683 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;684}685686impl pallet_aura::Config for Runtime {687 type AuthorityId = AuraId;688 type DisabledValidators = ();689}690691parameter_types! {692 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();693 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;694}695696/// Used for the pallet nft in `./nft.rs`697impl pallet_nft::Config for Runtime {698 type Event = Event;699 type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;700701 type EvmBackwardsAddressMapping = pallet_nft::MapBackwardsAddressTruncated;702 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;703 type CrossAccountId = pallet_nft::BasicCrossAccountId<Self>;704705 type Currency = Balances;706 type CollectionCreationPrice = CollectionCreationPrice;707 type TreasuryAccountId = TreasuryAccountId;708}709710parameter_types! {711 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied712}713714/// Used for the pallet inflation715impl pallet_inflation::Config for Runtime {716 type Currency = Balances;717 type TreasuryAccountId = TreasuryAccountId;718 type InflationBlockInterval = InflationBlockInterval;719}720721parameter_types! {722 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *723 RuntimeBlockWeights::get().max_block;724 pub const MaxScheduledPerBlock: u32 = 50;725}726727pub struct Sponsoring;728impl SponsoringResolve<AccountId, Call> for Sponsoring {729 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>730 where731 Call: Dispatchable<Info = DispatchInfo>,732 AccountId: AsRef<[u8]>,733 {734 pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)735 }736}737738type SponsorshipHandler = (739 pallet_nft::NftSponsorshipHandler<Runtime>,740 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,741);742743impl pallet_scheduler::Config for Runtime {744 type Event = Event;745 type Origin = Origin;746 type PalletsOrigin = OriginCaller;747 type Call = Call;748 type MaximumWeight = MaximumSchedulerWeight;749 type ScheduleOrigin = EnsureSigned<AccountId>;750 type MaxScheduledPerBlock = MaxScheduledPerBlock;751 type SponsorshipHandler = SponsorshipHandler;752 type WeightInfo = ();753}754755impl pallet_nft_transaction_payment::Config for Runtime {756 type SponsorshipHandler = SponsorshipHandler;757}758759impl pallet_evm_transaction_payment::Config for Runtime {760 type SponsorshipHandler = (761 pallet_nft::NftEthSponsorshipHandler<Self>,762 pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,763 );764 type Currency = Balances;765}766767impl pallet_nft_charge_transaction::Config for Runtime {}768769// impl pallet_contract_helpers::Config for Runtime {770// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;771// }772773parameter_types! {774 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049775 pub const HelpersContractAddress: H160 = H160([776 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,777 ]);778}779780impl pallet_evm_contract_helpers::Config for Runtime {781 type ContractAddress = HelpersContractAddress;782 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;783}784785construct_runtime!(786 pub enum Runtime where787 Block = Block,788 NodeBlock = opaque::Block,789 UncheckedExtrinsic = UncheckedExtrinsic790 {791 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>} = 20,792 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,793794 Aura: pallet_aura::{Pallet, Config<T>} = 22,795 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,796797 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,798 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,799 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,800 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,801 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,802 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,803 System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,804 Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,805 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,806807 // XCM helpers.808 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,809 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,810 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,811 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,812813 // Unique Pallets814 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,815 Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>} = 61,816 Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 62,817 NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,818 Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,819 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,820821 // Frontier822 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,823 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, ValidateUnsigned} = 101,824825 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,826 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,827 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,828 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,829 }830);831832pub struct TransactionConverter;833834impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {835 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {836 UncheckedExtrinsic::new_unsigned(837 pallet_ethereum::Call::<Runtime>::transact(transaction).into(),838 )839 }840}841842impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {843 fn convert_transaction(844 &self,845 transaction: pallet_ethereum::Transaction,846 ) -> opaque::UncheckedExtrinsic {847 let extrinsic = UncheckedExtrinsic::new_unsigned(848 pallet_ethereum::Call::<Runtime>::transact(transaction).into(),849 );850 let encoded = extrinsic.encode();851 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])852 .expect("Encoded extrinsic is always valid")853 }854}855856/// The address format for describing accounts.857pub type Address = sp_runtime::MultiAddress<AccountId, ()>;858/// Block header type as expected by this runtime.859pub type Header = generic::Header<BlockNumber, BlakeTwo256>;860/// Block type as expected by this runtime.861pub type Block = generic::Block<Header, UncheckedExtrinsic>;862/// A Block signed with a Justification863pub type SignedBlock = generic::SignedBlock<Block>;864/// BlockId type as expected by this runtime.865pub type BlockId = generic::BlockId<Block>;866/// The SignedExtension to the basic transaction logic.867pub type SignedExtra = (868 system::CheckSpecVersion<Runtime>,869 // system::CheckTxVersion<Runtime>,870 system::CheckGenesis<Runtime>,871 system::CheckEra<Runtime>,872 system::CheckNonce<Runtime>,873 system::CheckWeight<Runtime>,874 pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,875 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,876);877/// Unchecked extrinsic type as expected by this runtime.878pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;879/// Extrinsic type that has already been checked.880pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;881/// Executive: handles dispatch to the various modules.882pub type Executive = frame_executive::Executive<883 Runtime,884 Block,885 frame_system::ChainContext<Runtime>,886 Runtime,887 AllPallets,888>;889890impl_opaque_keys! {891 pub struct SessionKeys {892 pub aura: Aura,893 }894}895896impl_runtime_apis! {897 impl pallet_nft::NftApi<Block>898 for Runtime899 {900 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {901 <pallet_nft::NftErcSupport<Runtime>>::get_code(&account)902 }903 }904905 impl sp_api::Core<Block> for Runtime {906 fn version() -> RuntimeVersion {907 VERSION908 }909910 fn execute_block(block: Block) {911 Executive::execute_block(block)912 }913914 fn initialize_block(header: &<Block as BlockT>::Header) {915 Executive::initialize_block(header)916 }917 }918919 impl sp_api::Metadata<Block> for Runtime {920 fn metadata() -> OpaqueMetadata {921 Runtime::metadata().into()922 }923 }924925 impl sp_block_builder::BlockBuilder<Block> for Runtime {926 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {927 Executive::apply_extrinsic(extrinsic)928 }929930 fn finalize_block() -> <Block as BlockT>::Header {931 Executive::finalize_block()932 }933934 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {935 data.create_extrinsics()936 }937938 fn check_inherents(939 block: Block,940 data: sp_inherents::InherentData,941 ) -> sp_inherents::CheckInherentsResult {942 data.check_extrinsics(&block)943 }944945 // fn random_seed() -> <Block as BlockT>::Hash {946 // RandomnessCollectiveFlip::random_seed().0947 // }948 }949950 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {951 fn validate_transaction(952 source: TransactionSource,953 tx: <Block as BlockT>::Extrinsic,954 hash: <Block as BlockT>::Hash,955 ) -> TransactionValidity {956 Executive::validate_transaction(source, tx, hash)957 }958 }959960 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {961 fn offchain_worker(header: &<Block as BlockT>::Header) {962 Executive::offchain_worker(header)963 }964 }965966 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {967 fn chain_id() -> u64 {968 <Runtime as pallet_evm::Config>::ChainId::get()969 }970971 fn account_basic(address: H160) -> EVMAccount {972 EVM::account_basic(&address)973 }974975 fn gas_price() -> U256 {976 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()977 }978979 fn account_code_at(address: H160) -> Vec<u8> {980 EVM::account_codes(address)981 }982983 fn author() -> H160 {984 <pallet_evm::Pallet<Runtime>>::find_author()985 }986987 fn storage_at(address: H160, index: U256) -> H256 {988 let mut tmp = [0u8; 32];989 index.to_big_endian(&mut tmp);990 EVM::account_storages(address, H256::from_slice(&tmp[..]))991 }992993 fn call(994 from: H160,995 to: H160,996 data: Vec<u8>,997 value: U256,998 gas_limit: U256,999 gas_price: Option<U256>,1000 nonce: Option<U256>,1001 estimate: bool,1002 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1003 let config = if estimate {1004 let mut config = <Runtime as pallet_evm::Config>::config().clone();1005 config.estimate = true;1006 Some(config)1007 } else {1008 None1009 };10101011 <Runtime as pallet_evm::Config>::Runner::call(1012 from,1013 to,1014 data,1015 value,1016 gas_limit.low_u64(),1017 gas_price,1018 nonce,1019 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1020 ).map_err(|err| err.into())1021 }10221023 fn create(1024 from: H160,1025 data: Vec<u8>,1026 value: U256,1027 gas_limit: U256,1028 gas_price: Option<U256>,1029 nonce: Option<U256>,1030 estimate: bool,1031 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1032 let config = if estimate {1033 let mut config = <Runtime as pallet_evm::Config>::config().clone();1034 config.estimate = true;1035 Some(config)1036 } else {1037 None1038 };10391040 <Runtime as pallet_evm::Config>::Runner::create(1041 from,1042 data,1043 value,1044 gas_limit.low_u64(),1045 gas_price,1046 nonce,1047 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1048 ).map_err(|err| err.into())1049 }10501051 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1052 Ethereum::current_transaction_statuses()1053 }10541055 fn current_block() -> Option<pallet_ethereum::Block> {1056 Ethereum::current_block()1057 }10581059 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1060 Ethereum::current_receipts()1061 }10621063 fn current_all() -> (1064 Option<pallet_ethereum::Block>,1065 Option<Vec<pallet_ethereum::Receipt>>,1066 Option<Vec<TransactionStatus>>1067 ) {1068 (1069 Ethereum::current_block(),1070 Ethereum::current_receipts(),1071 Ethereum::current_transaction_statuses()1072 )1073 }10741075 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1076 xts.into_iter().filter_map(|xt| match xt.function {1077 Call::Ethereum(pallet_ethereum::Call::transact(t)) => Some(t),1078 _ => None1079 }).collect()1080 }1081 }10821083 impl sp_session::SessionKeys<Block> for Runtime {1084 fn decode_session_keys(1085 encoded: Vec<u8>,1086 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1087 SessionKeys::decode_into_raw_public_keys(&encoded)1088 }10891090 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1091 SessionKeys::generate(seed)1092 }1093 }10941095 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1096 fn slot_duration() -> sp_consensus_aura::SlotDuration {1097 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1098 }10991100 fn authorities() -> Vec<AuraId> {1101 Aura::authorities()1102 }1103 }11041105 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1106 fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {1107 ParachainSystem::collect_collation_info()1108 }1109 }11101111 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1112 fn account_nonce(account: AccountId) -> Index {1113 System::account_nonce(account)1114 }1115 }11161117 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1118 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1119 TransactionPayment::query_info(uxt, len)1120 }1121 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1122 TransactionPayment::query_fee_details(uxt, len)1123 }1124 }11251126 /*1127 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>1128 for Runtime1129 {1130 fn call(1131 origin: AccountId,1132 dest: AccountId,1133 value: Balance,1134 gas_limit: u64,1135 input_data: Vec<u8>,1136 ) -> pallet_contracts_primitives::ContractExecResult {1137 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)1138 }11391140 fn instantiate(1141 origin: AccountId,1142 endowment: Balance,1143 gas_limit: u64,1144 code: pallet_contracts_primitives::Code<Hash>,1145 data: Vec<u8>,1146 salt: Vec<u8>,1147 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>1148 {1149 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)1150 }11511152 fn get_storage(1153 address: AccountId,1154 key: [u8; 32],1155 ) -> pallet_contracts_primitives::GetStorageResult {1156 Contracts::get_storage(address, key)1157 }11581159 fn rent_projection(1160 address: AccountId,1161 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {1162 Contracts::rent_projection(address)1163 }1164 }1165 */11661167 #[cfg(feature = "runtime-benchmarks")]1168 impl frame_benchmarking::Benchmark<Block> for Runtime {1169 fn dispatch_benchmark(1170 config: frame_benchmarking::BenchmarkConfig1171 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1172 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};11731174 let whitelist: Vec<TrackedStorageKey> = vec![1175 // Alice account1176 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),1177 // // Total Issuance1178 // hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),1179 // // Execution Phase1180 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),1181 // // Event Count1182 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),1183 // // System Events1184 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),1185 ];11861187 let mut batches = Vec::<BenchmarkBatch>::new();1188 let params = (&config, &whitelist);11891190 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1191 add_benchmark!(params, batches, pallet_nft, Nft);1192 add_benchmark!(params, batches, pallet_inflation, Inflation);11931194 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1195 Ok(batches)1196 }1197 }1198}11991200struct CheckInherents;12011202impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1203 fn check_inherents(1204 block: &Block,1205 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1206 ) -> sp_inherents::CheckInherentsResult {1207 let relay_chain_slot = relay_state_proof1208 .read_slot()1209 .expect("Could not read the relay chain slot from the proof");12101211 let inherent_data =1212 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1213 relay_chain_slot,1214 sp_std::time::Duration::from_secs(6),1215 )1216 .create_inherent_data()1217 .expect("Could not create the timestamp inherent data");12181219 inherent_data.check_extrinsics(block)1220 }1221}12221223cumulus_pallet_parachain_system::register_validate_block!(1224 Runtime = Runtime,1225 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1226 CheckInherents = CheckInherents,1227);1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.78#![cfg_attr(not(feature = "std"), no_std)]9// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.10#![recursion_limit = "1024"]11#![allow(clippy::from_over_into, clippy::identity_op)]12#![allow(clippy::fn_to_numeric_cast_with_truncation)]13// Make the WASM binary available.14#[cfg(feature = "std")]15include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1617use sp_api::impl_runtime_apis;18use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};19// #[cfg(any(feature = "std", test))]20// pub use sp_runtime::BuildStorage;2122use sp_runtime::{23 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,24 traits::{25 AccountIdLookup, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify,26 AccountIdConversion,27 },28 transaction_validity::{TransactionSource, TransactionValidity},29 ApplyExtrinsicResult, MultiSignature,30};3132use sp_std::prelude::*;3334#[cfg(feature = "std")]35use sp_version::NativeVersion;36use sp_version::RuntimeVersion;37pub use pallet_transaction_payment::{38 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,39};40// A few exports that help ease life for downstream crates.41pub use pallet_balances::Call as BalancesCall;42pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};43pub use frame_support::{44 construct_runtime, match_type,45 dispatch::DispatchResult,46 PalletId, parameter_types, StorageValue, ConsensusEngineId,47 traits::{48 Everything, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem,49 LockIdentifier, OnUnbalanced, Randomness, FindAuthor,50 },51 weights::{52 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},53 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,54 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,55 },56};57use xcm_executor::traits::InvertLocation;58use nft_data_structs::*;59// use pallet_contracts::weights::WeightInfo;60// #[cfg(any(feature = "std", test))]61use frame_system::{62 self as system, EnsureRoot, EnsureSigned,63 limits::{BlockWeights, BlockLength},64};65use sp_arithmetic::{66 traits::{BaseArithmetic, Unsigned},67};68use smallvec::smallvec;69use codec::{Encode, Decode};70use pallet_evm::{Account as EVMAccount, FeeCalculator, OnMethodCall};71use fp_rpc::TransactionStatus;72use sp_core::crypto::Public;73use sp_runtime::{74 traits::{Dispatchable},75};7677// pub use pallet_timestamp::Call as TimestampCall;78pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;7980// Polkadot imports81use pallet_xcm::XcmPassthrough;82use polkadot_parachain::primitives::Sibling;83use xcm::v0::Xcm;84use xcm::v0::{BodyId, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId};85use xcm_builder::{86 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,87 EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,88 ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,89 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,90 SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,91};92use xcm_executor::{Config, XcmExecutor};9394// mod chain_extension;95// use crate::chain_extension::{NFTExtension, Imbalance};9697/// An index to a block.98pub type BlockNumber = u32;99100/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.101pub type Signature = MultiSignature;102103/// Some way of identifying an account on the chain. We intentionally make it equivalent104/// to the public key of our transaction signing scheme.105pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;106107/// The type for looking up accounts. We don't expect more than 4 billion of them, but you108/// never know...109pub type AccountIndex = u32;110111/// Balance of an account.112pub type Balance = u128;113114/// Index of a transaction in the chain.115pub type Index = u32;116117/// A hash of some data used by the chain.118pub type Hash = sp_core::H256;119120/// Digest item type.121pub type DigestItem = generic::DigestItem<Hash>;122123/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know124/// the specifics of the runtime. They can then be made to be agnostic over specific formats125/// of data like extrinsics, allowing for them to continue syncing the network through upgrades126/// to even the core data structures.127pub mod opaque {128 use super::*;129130 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;131132 /// Opaque block type.133 pub type Block = generic::Block<Header, UncheckedExtrinsic>;134135 pub type SessionHandlers = ();136137 impl_opaque_keys! {138 pub struct SessionKeys {139 pub aura: Aura,140 }141 }142}143144/// This runtime version.145pub const VERSION: RuntimeVersion = RuntimeVersion {146 spec_name: create_runtime_str!("nft"),147 impl_name: create_runtime_str!("nft"),148 authoring_version: 1,149 spec_version: 3,150 impl_version: 1,151 apis: RUNTIME_API_VERSIONS,152 transaction_version: 1,153};154155pub const MILLISECS_PER_BLOCK: u64 = 12000;156157pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;158159// These time units are defined in number of blocks.160pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);161pub const HOURS: BlockNumber = MINUTES * 60;162pub const DAYS: BlockNumber = HOURS * 24;163164parameter_types! {165 pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;166}167168#[derive(codec::Encode, codec::Decode)]169pub enum XCMPMessage<XAccountId, XBalance> {170 /// Transfer tokens to the given account from the Parachain account.171 TransferToken(XAccountId, XBalance),172}173174/// The version information used to identify this runtime when compiled natively.175#[cfg(feature = "std")]176pub fn native_version() -> NativeVersion {177 NativeVersion {178 runtime_version: VERSION,179 can_author_with: Default::default(),180 }181}182183type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;184185pub struct DealWithFees;186impl OnUnbalanced<NegativeImbalance> for DealWithFees {187 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {188 if let Some(fees) = fees_then_tips.next() {189 // for fees, 100% to treasury190 let mut split = fees.ration(100, 0);191 if let Some(tips) = fees_then_tips.next() {192 // for tips, if any, 100% to treasury193 tips.ration_merge_into(100, 0, &mut split);194 }195 Treasury::on_unbalanced(split.0);196 // Author::on_unbalanced(split.1);197 }198 }199}200201/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.202/// This is used to limit the maximal weight of a single extrinsic.203const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);204/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used205/// by Operational extrinsics.206const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);207/// We allow for 2 seconds of compute with a 6 second average block time.208const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;209210parameter_types! {211 pub const BlockHashCount: BlockNumber = 2400;212 pub RuntimeBlockLength: BlockLength =213 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);214 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);215 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;216 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()217 .base_block(BlockExecutionWeight::get())218 .for_class(DispatchClass::all(), |weights| {219 weights.base_extrinsic = ExtrinsicBaseWeight::get();220 })221 .for_class(DispatchClass::Normal, |weights| {222 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);223 })224 .for_class(DispatchClass::Operational, |weights| {225 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);226 // Operational transactions have some extra reserved space, so that they227 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.228 weights.reserved = Some(229 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT230 );231 })232 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)233 .build_or_panic();234 pub const Version: RuntimeVersion = VERSION;235 pub const SS58Prefix: u8 = 42;236}237238parameter_types! {239 pub const ChainId: u64 = 8888;240}241242impl pallet_evm::Config for Runtime {243 type BlockGasLimit = BlockGasLimit;244 type FeeCalculator = ();245 type GasWeightMapping = ();246 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;247 type CallOrigin = EnsureAddressTruncated;248 type WithdrawOrigin = EnsureAddressTruncated;249 type AddressMapping = HashedAddressMapping<Self::Hashing>;250 type Precompiles = ();251 type Currency = Balances;252 type Event = Event;253 type OnMethodCall = (254 pallet_evm_migration::OnMethodCall<Self>,255 pallet_nft::NftErcSupport<Self>,256 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,257 );258 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;259 type ChainId = ChainId;260 type Runner = pallet_evm::runner::stack::Runner<Self>;261 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;262 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;263 type FindAuthor = EthereumFindAuthor<Aura>;264}265266impl pallet_evm_migration::Config for Runtime {267 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;268}269270pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);271impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {272 fn find_author<'a, I>(digests: I) -> Option<H160>273 where274 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,275 {276 if let Some(author_index) = F::find_author(digests) {277 let authority_id = Aura::authorities()[author_index as usize].clone();278 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));279 }280 None281 }282}283284parameter_types! {285 pub BlockGasLimit: U256 = U256::from(u32::max_value());286}287288impl pallet_ethereum::Config for Runtime {289 type Event = Event;290 type StateRoot = pallet_ethereum::IntermediateStateRoot;291 type EvmSubmitLog = pallet_evm::Pallet<Self>;292}293294impl pallet_randomness_collective_flip::Config for Runtime {}295296impl system::Config for Runtime {297 /// The data to be stored in an account.298 type AccountData = pallet_balances::AccountData<Balance>;299 /// The identifier used to distinguish between accounts.300 type AccountId = AccountId;301 /// The basic call filter to use in dispatchable.302 type BaseCallFilter = Everything;303 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).304 type BlockHashCount = BlockHashCount;305 /// The maximum length of a block (in bytes).306 type BlockLength = RuntimeBlockLength;307 /// The index type for blocks.308 type BlockNumber = BlockNumber;309 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.310 type BlockWeights = RuntimeBlockWeights;311 /// The aggregated dispatch type that is available for extrinsics.312 type Call = Call;313 /// The weight of database operations that the runtime can invoke.314 type DbWeight = RocksDbWeight;315 /// The ubiquitous event type.316 type Event = Event;317 /// The type for hashing blocks and tries.318 type Hash = Hash;319 /// The hashing algorithm used.320 type Hashing = BlakeTwo256;321 /// The header type.322 type Header = generic::Header<BlockNumber, BlakeTwo256>;323 /// The index type for storing how many extrinsics an account has signed.324 type Index = Index;325 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.326 type Lookup = AccountIdLookup<AccountId, ()>;327 /// What to do if an account is fully reaped from the system.328 type OnKilledAccount = ();329 /// What to do if a new account is created.330 type OnNewAccount = ();331 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;332 /// The ubiquitous origin type.333 type Origin = Origin;334 /// This type is being generated by `construct_runtime!`.335 type PalletInfo = PalletInfo;336 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.337 type SS58Prefix = SS58Prefix;338 /// Weight information for the extrinsics of this pallet.339 type SystemWeightInfo = system::weights::SubstrateWeight<Self>;340 /// Version of the runtime.341 type Version = Version;342}343344parameter_types! {345 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;346}347348impl pallet_timestamp::Config for Runtime {349 /// A timestamp: milliseconds since the unix epoch.350 type Moment = u64;351 type OnTimestampSet = ();352 type MinimumPeriod = MinimumPeriod;353 type WeightInfo = ();354}355356parameter_types! {357 // pub const ExistentialDeposit: u128 = 500;358 pub const ExistentialDeposit: u128 = 0;359 pub const MaxLocks: u32 = 50;360}361362impl pallet_balances::Config for Runtime {363 type MaxLocks = MaxLocks;364 type MaxReserves = ();365 type ReserveIdentifier = [u8; 8];366 /// The type for recording an account's balance.367 type Balance = Balance;368 /// The ubiquitous event type.369 type Event = Event;370 type DustRemoval = Treasury;371 type ExistentialDeposit = ExistentialDeposit;372 type AccountStore = System;373 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;374}375376pub const MICROUNIQUE: Balance = 1_000_000_000;377pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;378pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;379pub const UNIQUE: Balance = 100 * CENTIUNIQUE;380381pub const fn deposit(items: u32, bytes: u32) -> Balance {382 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE383}384385/*386parameter_types! {387 pub TombstoneDeposit: Balance = deposit(388 1,389 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,390 );391 pub DepositPerContract: Balance = TombstoneDeposit::get();392 pub const DepositPerStorageByte: Balance = deposit(0, 1);393 pub const DepositPerStorageItem: Balance = deposit(1, 0);394 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);395 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;396 pub const SignedClaimHandicap: u32 = 2;397 pub const MaxDepth: u32 = 32;398 pub const MaxValueSize: u32 = 16 * 1024;399 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb400 // The lazy deletion runs inside on_initialize.401 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *402 RuntimeBlockWeights::get().max_block;403 // The weight needed for decoding the queue should be less or equal than a fifth404 // of the overall weight dedicated to the lazy deletion.405 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (406 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -407 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)408 )) / 5) as u32;409 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();410}411412impl pallet_contracts::Config for Runtime {413 type Time = Timestamp;414 type Randomness = RandomnessCollectiveFlip;415 type Currency = Balances;416 type Event = Event;417 type RentPayment = ();418 type SignedClaimHandicap = SignedClaimHandicap;419 type TombstoneDeposit = TombstoneDeposit;420 type DepositPerContract = DepositPerContract;421 type DepositPerStorageByte = DepositPerStorageByte;422 type DepositPerStorageItem = DepositPerStorageItem;423 type RentFraction = RentFraction;424 type SurchargeReward = SurchargeReward;425 type WeightPrice = pallet_transaction_payment::Pallet<Self>;426 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;427 type ChainExtension = NFTExtension;428 type DeletionQueueDepth = DeletionQueueDepth;429 type DeletionWeightLimit = DeletionWeightLimit;430 type Schedule = Schedule;431 type CallStack = [pallet_contracts::Frame<Self>; 31];432}433*/434435parameter_types! {436 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer437}438439/// Linear implementor of `WeightToFeePolynomial`440pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);441442impl<T> WeightToFeePolynomial for LinearFee<T>443where444 T: BaseArithmetic + From<u32> + Copy + Unsigned,445{446 type Balance = T;447448 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {449 smallvec!(WeightToFeeCoefficient {450 coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer451 coeff_frac: Perbill::zero(),452 negative: false,453 degree: 1,454 })455 }456}457458impl pallet_transaction_payment::Config for Runtime {459 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;460 type TransactionByteFee = TransactionByteFee;461 type WeightToFee = LinearFee<Balance>;462 type FeeMultiplierUpdate = ();463}464465parameter_types! {466 pub const ProposalBond: Permill = Permill::from_percent(5);467 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;468 pub const SpendPeriod: BlockNumber = 5 * MINUTES;469 pub const Burn: Permill = Permill::from_percent(0);470 pub const TipCountdown: BlockNumber = 1 * DAYS;471 pub const TipFindersFee: Percent = Percent::from_percent(20);472 pub const TipReportDepositBase: Balance = 1 * UNIQUE;473 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;474 pub const BountyDepositBase: Balance = 1 * UNIQUE;475 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;476 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");477 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;478 pub const MaximumReasonLength: u32 = 16384;479 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);480 pub const BountyValueMinimum: Balance = 5 * UNIQUE;481 pub const MaxApprovals: u32 = 100;482}483484impl pallet_treasury::Config for Runtime {485 type PalletId = TreasuryModuleId;486 type Currency = Balances;487 type ApproveOrigin = EnsureRoot<AccountId>;488 type RejectOrigin = EnsureRoot<AccountId>;489 type Event = Event;490 type OnSlash = ();491 type ProposalBond = ProposalBond;492 type ProposalBondMinimum = ProposalBondMinimum;493 type SpendPeriod = SpendPeriod;494 type Burn = Burn;495 type BurnDestination = ();496 type SpendFunds = ();497 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;498 type MaxApprovals = MaxApprovals;499}500501impl pallet_sudo::Config for Runtime {502 type Event = Event;503 type Call = Call;504}505506parameter_types! {507 pub const MinVestedTransfer: Balance = 10 * UNIQUE;508}509510impl pallet_vesting::Config for Runtime {511 type Event = Event;512 type Currency = Balances;513 type BlockNumberToBalance = ConvertInto;514 type MinVestedTransfer = MinVestedTransfer;515 type WeightInfo = ();516}517518parameter_types! {519 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;520 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;521}522523impl cumulus_pallet_parachain_system::Config for Runtime {524 type Event = Event;525 type OnValidationData = ();526 type SelfParaId = parachain_info::Pallet<Self>;527 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<528 // MaxDownwardMessageWeight,529 // XcmExecutor<XcmConfig>,530 // Call,531 // >;532 type OutboundXcmpMessageSource = XcmpQueue;533 type DmpMessageHandler = DmpQueue;534 type ReservedDmpWeight = ReservedDmpWeight;535 type ReservedXcmpWeight = ReservedXcmpWeight;536 type XcmpMessageHandler = XcmpQueue;537}538539impl parachain_info::Config for Runtime {}540541impl cumulus_pallet_aura_ext::Config for Runtime {}542543parameter_types! {544 pub const RelayLocation: MultiLocation = X1(Parent);545 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;546 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();547 pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));548}549550/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used551/// when determining ownership of accounts for asset transacting and when attempting to use XCM552/// `Transact` in order to determine the dispatch Origin.553pub type LocationToAccountId = (554 // The parent (Relay-chain) origin converts to the default `AccountId`.555 ParentIsDefault<AccountId>,556 // Sibling parachain origins convert to AccountId via the `ParaId::into`.557 SiblingParachainConvertsVia<Sibling, AccountId>,558 // Straight up local `AccountId32` origins just alias directly to `AccountId`.559 AccountId32Aliases<RelayNetwork, AccountId>,560);561562/// Means for transacting assets on this chain.563pub type LocalAssetTransactor = CurrencyAdapter<564 // Use this currency:565 Balances,566 // Use this currency when it is a fungible asset matching the given location or name:567 IsConcrete<RelayLocation>,568 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:569 LocationToAccountId,570 // Our chain's account ID type (we can't get away without mentioning it explicitly):571 AccountId,572 // We don't track any teleports.573 (),574>;575576/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,577/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can578/// biases the kind of local `Origin` it will become.579pub type XcmOriginToTransactDispatchOrigin = (580 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location581 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for582 // foreign chains who want to have a local sovereign account on this chain which they control.583 SovereignSignedViaLocation<LocationToAccountId, Origin>,584 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when585 // recognised.586 RelayChainAsNative<RelayOrigin, Origin>,587 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when588 // recognised.589 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,590 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a591 // transaction from the Root origin.592 ParentAsSuperuser<Origin>,593 // Native signed account converter; this just converts an `AccountId32` origin into a normal594 // `Origin::Signed` origin of the same 32-byte value.595 SignedAccountId32AsNative<RelayNetwork, Origin>,596 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.597 XcmPassthrough<Origin>,598);599600parameter_types! {601 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.602 pub UnitWeightCost: Weight = 1_000_000;603 // 1200 UNIQUEs buy 1 second of weight.604 pub const WeightPrice: (MultiLocation, u128) = (X1(Parent), 1_200 * UNIQUE);605}606607match_type! {608 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {609 X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. })610 };611}612613pub type Barrier = (614 TakeWeightCredit,615 AllowTopLevelPaidExecutionFrom<Everything>,616 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,617 // ^^^ Parent & its unit plurality gets free execution618);619620pub struct XcmConfig;621impl Config for XcmConfig {622 type Call = Call;623 type XcmSender = XcmRouter;624 // How to withdraw and deposit an asset.625 type AssetTransactor = LocalAssetTransactor;626 type OriginConverter = XcmOriginToTransactDispatchOrigin;627 type IsReserve = NativeAsset;628 type IsTeleporter = (); // Teleportation is disabled629 type LocationInverter = LocationInverter<Ancestry>;630 type Barrier = Barrier;631 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;632 type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;633 type ResponseHandler = (); // Don't handle responses for now.634}635636// parameter_types! {637// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;638// }639640/// No local origins on this chain are allowed to dispatch XCM sends/executions.641pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);642643/// The means for routing XCM messages which are not for local execution into the right message644/// queues.645pub type XcmRouter = (646 // Two routers - use UMP to communicate with the relay chain:647 cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,648 // ..and XCMP to communicate with the sibling chains.649 XcmpQueue,650);651652impl pallet_evm_coder_substrate::Config for Runtime {653 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;654}655656impl pallet_xcm::Config for Runtime {657 type Event = Event;658 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;659 type XcmRouter = XcmRouter;660 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;661 type XcmExecuteFilter = Everything;662 type XcmExecutor = XcmExecutor<XcmConfig>;663 type XcmTeleportFilter = Everything;664 type XcmReserveTransferFilter = ();665 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;666 type LocationInverter = LocationInverter<Ancestry>;667}668669impl cumulus_pallet_xcm::Config for Runtime {670 type Event = Event;671 type XcmExecutor = XcmExecutor<XcmConfig>;672}673674impl cumulus_pallet_xcmp_queue::Config for Runtime {675 type Event = Event;676 type XcmExecutor = XcmExecutor<XcmConfig>;677 type ChannelInfo = ParachainSystem;678}679680impl cumulus_pallet_dmp_queue::Config for Runtime {681 type Event = Event;682 type XcmExecutor = XcmExecutor<XcmConfig>;683 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;684}685686impl pallet_aura::Config for Runtime {687 type AuthorityId = AuraId;688 type DisabledValidators = ();689}690691parameter_types! {692 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();693 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;694}695696/// Used for the pallet nft in `./nft.rs`697impl pallet_nft::Config for Runtime {698 type Event = Event;699 type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;700701 type EvmBackwardsAddressMapping = pallet_nft::MapBackwardsAddressTruncated;702 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;703 type CrossAccountId = pallet_nft::BasicCrossAccountId<Self>;704705 type Currency = Balances;706 type CollectionCreationPrice = CollectionCreationPrice;707 type TreasuryAccountId = TreasuryAccountId;708}709710parameter_types! {711 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied712}713714/// Used for the pallet inflation715impl pallet_inflation::Config for Runtime {716 type Currency = Balances;717 type TreasuryAccountId = TreasuryAccountId;718 type InflationBlockInterval = InflationBlockInterval;719}720721parameter_types! {722 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *723 RuntimeBlockWeights::get().max_block;724 pub const MaxScheduledPerBlock: u32 = 50;725}726727pub struct Sponsoring;728impl SponsoringResolve<AccountId, Call> for Sponsoring {729 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>730 where731 Call: Dispatchable<Info = DispatchInfo>,732 AccountId: AsRef<[u8]>,733 {734 pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)735 }736}737738type SponsorshipHandler = (739 pallet_nft::NftSponsorshipHandler<Runtime>,740 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,741);742743impl pallet_scheduler::Config for Runtime {744 type Event = Event;745 type Origin = Origin;746 type PalletsOrigin = OriginCaller;747 type Call = Call;748 type MaximumWeight = MaximumSchedulerWeight;749 type ScheduleOrigin = EnsureSigned<AccountId>;750 type MaxScheduledPerBlock = MaxScheduledPerBlock;751 type SponsorshipHandler = SponsorshipHandler;752 type WeightInfo = ();753}754755impl pallet_nft_transaction_payment::Config for Runtime {756 type SponsorshipHandler = SponsorshipHandler;757}758759impl pallet_evm_transaction_payment::Config for Runtime {760 type SponsorshipHandler = (761 pallet_nft::NftEthSponsorshipHandler<Self>,762 pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,763 );764 type Currency = Balances;765}766767impl pallet_nft_charge_transaction::Config for Runtime {}768769// impl pallet_contract_helpers::Config for Runtime {770// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;771// }772773parameter_types! {774 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049775 pub const HelpersContractAddress: H160 = H160([776 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,777 ]);778}779780impl pallet_evm_contract_helpers::Config for Runtime {781 type ContractAddress = HelpersContractAddress;782 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;783}784785construct_runtime!(786 pub enum Runtime where787 Block = Block,788 NodeBlock = opaque::Block,789 UncheckedExtrinsic = UncheckedExtrinsic790 {791 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>} = 20,792 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,793794 Aura: pallet_aura::{Pallet, Config<T>} = 22,795 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,796797 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,798 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,799 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,800 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,801 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,802 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,803 System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,804 Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,805 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,806807 // XCM helpers.808 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,809 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,810 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,811 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,812813 // Unique Pallets814 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,815 Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>} = 61,816 Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 62,817 NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,818 Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,819 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,820821 // Frontier822 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,823 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, ValidateUnsigned} = 101,824825 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,826 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,827 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,828 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,829 }830);831832pub struct TransactionConverter;833834impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {835 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {836 UncheckedExtrinsic::new_unsigned(837 pallet_ethereum::Call::<Runtime>::transact(transaction).into(),838 )839 }840}841842impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {843 fn convert_transaction(844 &self,845 transaction: pallet_ethereum::Transaction,846 ) -> opaque::UncheckedExtrinsic {847 let extrinsic = UncheckedExtrinsic::new_unsigned(848 pallet_ethereum::Call::<Runtime>::transact(transaction).into(),849 );850 let encoded = extrinsic.encode();851 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])852 .expect("Encoded extrinsic is always valid")853 }854}855856/// The address format for describing accounts.857pub type Address = sp_runtime::MultiAddress<AccountId, ()>;858/// Block header type as expected by this runtime.859pub type Header = generic::Header<BlockNumber, BlakeTwo256>;860/// Block type as expected by this runtime.861pub type Block = generic::Block<Header, UncheckedExtrinsic>;862/// A Block signed with a Justification863pub type SignedBlock = generic::SignedBlock<Block>;864/// BlockId type as expected by this runtime.865pub type BlockId = generic::BlockId<Block>;866/// The SignedExtension to the basic transaction logic.867pub type SignedExtra = (868 system::CheckSpecVersion<Runtime>,869 // system::CheckTxVersion<Runtime>,870 system::CheckGenesis<Runtime>,871 system::CheckEra<Runtime>,872 system::CheckNonce<Runtime>,873 system::CheckWeight<Runtime>,874 pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,875 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,876);877/// Unchecked extrinsic type as expected by this runtime.878pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;879/// Extrinsic type that has already been checked.880pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;881/// Executive: handles dispatch to the various modules.882pub type Executive = frame_executive::Executive<883 Runtime,884 Block,885 frame_system::ChainContext<Runtime>,886 Runtime,887 AllPallets,888>;889890impl_opaque_keys! {891 pub struct SessionKeys {892 pub aura: Aura,893 }894}895896impl_runtime_apis! {897 impl pallet_nft::NftApi<Block>898 for Runtime899 {900 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {901 <pallet_nft::NftErcSupport<Runtime>>::get_code(&account)902 }903 }904905 impl sp_api::Core<Block> for Runtime {906 fn version() -> RuntimeVersion {907 VERSION908 }909910 fn execute_block(block: Block) {911 Executive::execute_block(block)912 }913914 fn initialize_block(header: &<Block as BlockT>::Header) {915 Executive::initialize_block(header)916 }917 }918919 impl sp_api::Metadata<Block> for Runtime {920 fn metadata() -> OpaqueMetadata {921 Runtime::metadata().into()922 }923 }924925 impl sp_block_builder::BlockBuilder<Block> for Runtime {926 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {927 Executive::apply_extrinsic(extrinsic)928 }929930 fn finalize_block() -> <Block as BlockT>::Header {931 Executive::finalize_block()932 }933934 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {935 data.create_extrinsics()936 }937938 fn check_inherents(939 block: Block,940 data: sp_inherents::InherentData,941 ) -> sp_inherents::CheckInherentsResult {942 data.check_extrinsics(&block)943 }944945 // fn random_seed() -> <Block as BlockT>::Hash {946 // RandomnessCollectiveFlip::random_seed().0947 // }948 }949950 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {951 fn validate_transaction(952 source: TransactionSource,953 tx: <Block as BlockT>::Extrinsic,954 hash: <Block as BlockT>::Hash,955 ) -> TransactionValidity {956 Executive::validate_transaction(source, tx, hash)957 }958 }959960 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {961 fn offchain_worker(header: &<Block as BlockT>::Header) {962 Executive::offchain_worker(header)963 }964 }965966 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {967 fn chain_id() -> u64 {968 <Runtime as pallet_evm::Config>::ChainId::get()969 }970971 fn account_basic(address: H160) -> EVMAccount {972 EVM::account_basic(&address)973 }974975 fn gas_price() -> U256 {976 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()977 }978979 fn account_code_at(address: H160) -> Vec<u8> {980 EVM::account_codes(address)981 }982983 fn author() -> H160 {984 <pallet_evm::Pallet<Runtime>>::find_author()985 }986987 fn storage_at(address: H160, index: U256) -> H256 {988 let mut tmp = [0u8; 32];989 index.to_big_endian(&mut tmp);990 EVM::account_storages(address, H256::from_slice(&tmp[..]))991 }992993 fn call(994 from: H160,995 to: H160,996 data: Vec<u8>,997 value: U256,998 gas_limit: U256,999 gas_price: Option<U256>,1000 nonce: Option<U256>,1001 estimate: bool,1002 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1003 let config = if estimate {1004 let mut config = <Runtime as pallet_evm::Config>::config().clone();1005 config.estimate = true;1006 Some(config)1007 } else {1008 None1009 };10101011 <Runtime as pallet_evm::Config>::Runner::call(1012 from,1013 to,1014 data,1015 value,1016 gas_limit.low_u64(),1017 gas_price,1018 nonce,1019 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1020 ).map_err(|err| err.into())1021 }10221023 fn create(1024 from: H160,1025 data: Vec<u8>,1026 value: U256,1027 gas_limit: U256,1028 gas_price: Option<U256>,1029 nonce: Option<U256>,1030 estimate: bool,1031 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1032 let config = if estimate {1033 let mut config = <Runtime as pallet_evm::Config>::config().clone();1034 config.estimate = true;1035 Some(config)1036 } else {1037 None1038 };10391040 <Runtime as pallet_evm::Config>::Runner::create(1041 from,1042 data,1043 value,1044 gas_limit.low_u64(),1045 gas_price,1046 nonce,1047 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1048 ).map_err(|err| err.into())1049 }10501051 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1052 Ethereum::current_transaction_statuses()1053 }10541055 fn current_block() -> Option<pallet_ethereum::Block> {1056 Ethereum::current_block()1057 }10581059 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1060 Ethereum::current_receipts()1061 }10621063 fn current_all() -> (1064 Option<pallet_ethereum::Block>,1065 Option<Vec<pallet_ethereum::Receipt>>,1066 Option<Vec<TransactionStatus>>1067 ) {1068 (1069 Ethereum::current_block(),1070 Ethereum::current_receipts(),1071 Ethereum::current_transaction_statuses()1072 )1073 }10741075 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1076 xts.into_iter().filter_map(|xt| match xt.function {1077 Call::Ethereum(pallet_ethereum::Call::transact(t)) => Some(t),1078 _ => None1079 }).collect()1080 }1081 }10821083 impl sp_session::SessionKeys<Block> for Runtime {1084 fn decode_session_keys(1085 encoded: Vec<u8>,1086 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1087 SessionKeys::decode_into_raw_public_keys(&encoded)1088 }10891090 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1091 SessionKeys::generate(seed)1092 }1093 }10941095 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1096 fn slot_duration() -> sp_consensus_aura::SlotDuration {1097 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1098 }10991100 fn authorities() -> Vec<AuraId> {1101 Aura::authorities()1102 }1103 }11041105 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1106 fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {1107 ParachainSystem::collect_collation_info()1108 }1109 }11101111 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1112 fn account_nonce(account: AccountId) -> Index {1113 System::account_nonce(account)1114 }1115 }11161117 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1118 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1119 TransactionPayment::query_info(uxt, len)1120 }1121 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1122 TransactionPayment::query_fee_details(uxt, len)1123 }1124 }11251126 /*1127 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>1128 for Runtime1129 {1130 fn call(1131 origin: AccountId,1132 dest: AccountId,1133 value: Balance,1134 gas_limit: u64,1135 input_data: Vec<u8>,1136 ) -> pallet_contracts_primitives::ContractExecResult {1137 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)1138 }11391140 fn instantiate(1141 origin: AccountId,1142 endowment: Balance,1143 gas_limit: u64,1144 code: pallet_contracts_primitives::Code<Hash>,1145 data: Vec<u8>,1146 salt: Vec<u8>,1147 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>1148 {1149 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)1150 }11511152 fn get_storage(1153 address: AccountId,1154 key: [u8; 32],1155 ) -> pallet_contracts_primitives::GetStorageResult {1156 Contracts::get_storage(address, key)1157 }11581159 fn rent_projection(1160 address: AccountId,1161 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {1162 Contracts::rent_projection(address)1163 }1164 }1165 */11661167 #[cfg(feature = "runtime-benchmarks")]1168 impl frame_benchmarking::Benchmark<Block> for Runtime {1169 fn dispatch_benchmark(1170 config: frame_benchmarking::BenchmarkConfig1171 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1172 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};11731174 let whitelist: Vec<TrackedStorageKey> = vec![1175 // Alice account1176 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),1177 // // Total Issuance1178 // hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),1179 // // Execution Phase1180 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),1181 // // Event Count1182 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),1183 // // System Events1184 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),1185 ];11861187 let mut batches = Vec::<BenchmarkBatch>::new();1188 let params = (&config, &whitelist);11891190 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1191 add_benchmark!(params, batches, pallet_nft, Nft);1192 add_benchmark!(params, batches, pallet_inflation, Inflation);11931194 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1195 Ok(batches)1196 }1197 }1198}11991200struct CheckInherents;12011202impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1203 fn check_inherents(1204 block: &Block,1205 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1206 ) -> sp_inherents::CheckInherentsResult {1207 let relay_chain_slot = relay_state_proof1208 .read_slot()1209 .expect("Could not read the relay chain slot from the proof");12101211 let inherent_data =1212 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1213 relay_chain_slot,1214 sp_std::time::Duration::from_secs(6),1215 )1216 .create_inherent_data()1217 .expect("Could not create the timestamp inherent data");12181219 inherent_data.check_extrinsics(block)1220 }1221}12221223cumulus_pallet_parachain_system::register_validate_block!(1224 Runtime = Runtime,1225 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1226 CheckInherents = CheckInherents,1227);