12345678#![cfg_attr(not(feature = "std"), no_std)]910#![recursion_limit = "1024"]11#![allow(clippy::from_over_into, clippy::identity_op)]12#![allow(clippy::fn_to_numeric_cast_with_truncation)]1314#[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};19use sp_runtime::DispatchError;20212223use sp_runtime::{24 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,25 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},26 transaction_validity::{TransactionSource, TransactionValidity},27 ApplyExtrinsicResult, RuntimeAppPublic,28};2930use sp_std::prelude::*;3132#[cfg(feature = "std")]33use sp_version::NativeVersion;34use sp_version::RuntimeVersion;35pub use pallet_transaction_payment::{36 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,37};3839pub use pallet_balances::Call as BalancesCall;40pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};41pub use frame_support::{42 construct_runtime, match_type,43 dispatch::DispatchResult,44 PalletId, parameter_types, StorageValue, ConsensusEngineId,45 traits::{46 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,47 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,48 OnUnbalanced, Randomness, FindAuthor,49 },50 weights::{51 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},52 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,53 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,54 },55};56use up_data_structs::*;575859use frame_system::{60 self as frame_system, EnsureRoot, EnsureSigned,61 limits::{BlockWeights, BlockLength},62};63use sp_arithmetic::{64 traits::{BaseArithmetic, Unsigned},65};66use smallvec::smallvec;67use codec::{Encode, Decode};68use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};69use fp_rpc::TransactionStatus;70use sp_runtime::{71 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},72 transaction_validity::TransactionValidityError,73 SaturatedConversion,74};757677pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;787980use pallet_xcm::XcmPassthrough;81use polkadot_parachain::primitives::Sibling;82use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};83use xcm_builder::{84 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,85 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,86 ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,87 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,88};89use xcm_executor::{Config, XcmExecutor, Assets};90use sp_std::{marker::PhantomData};9192use xcm::latest::{93 94 AssetId::{Concrete},95 Fungibility::Fungible as XcmFungible,96 MultiAsset,97 Error as XcmError,98};99use xcm_executor::traits::{MatchesFungible, WeightTrader};100101use sp_runtime::traits::CheckedConversion;102103use unique_runtime_common::{types::*, constants::*};104105106107108pub const RUNTIME_NAME: &'static str = "Unique";109110pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;111112113114115116pub mod opaque {117 use sp_std::prelude::*;118 use sp_runtime::impl_opaque_keys;119 use super::Aura;120121 pub use unique_runtime_common::types::*;122 pub use super::CrossAccountId;123124 impl_opaque_keys! {125 pub struct SessionKeys {126 pub aura: Aura,127 }128 }129}130131132pub const VERSION: RuntimeVersion = RuntimeVersion {133 spec_name: create_runtime_str!(RUNTIME_NAME),134 impl_name: create_runtime_str!(RUNTIME_NAME),135 authoring_version: 1,136 spec_version: 916001,137 impl_version: 0,138 apis: RUNTIME_API_VERSIONS,139 transaction_version: 1,140 state_version: 0,141};142143#[derive(codec::Encode, codec::Decode)]144pub enum XCMPMessage<XAccountId, XBalance> {145 146 TransferToken(XAccountId, XBalance),147}148149150#[cfg(feature = "std")]151pub fn native_version() -> NativeVersion {152 NativeVersion {153 runtime_version: VERSION,154 can_author_with: Default::default(),155 }156}157158type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;159160pub struct DealWithFees;161impl OnUnbalanced<NegativeImbalance> for DealWithFees {162 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {163 if let Some(fees) = fees_then_tips.next() {164 165 let mut split = fees.ration(100, 0);166 if let Some(tips) = fees_then_tips.next() {167 168 tips.ration_merge_into(100, 0, &mut split);169 }170 Treasury::on_unbalanced(split.0);171 172 }173 }174}175176parameter_types! {177 pub const BlockHashCount: BlockNumber = 2400;178 pub RuntimeBlockLength: BlockLength =179 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);180 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);181 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;182 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()183 .base_block(BlockExecutionWeight::get())184 .for_class(DispatchClass::all(), |weights| {185 weights.base_extrinsic = ExtrinsicBaseWeight::get();186 })187 .for_class(DispatchClass::Normal, |weights| {188 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);189 })190 .for_class(DispatchClass::Operational, |weights| {191 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);192 193 194 weights.reserved = Some(195 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT196 );197 })198 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)199 .build_or_panic();200 pub const Version: RuntimeVersion = VERSION;201 pub const SS58Prefix: u8 = 255;202}203204parameter_types! {205 pub const ChainId: u64 = 8888;206}207208pub struct FixedFee;209impl FeeCalculator for FixedFee {210 fn min_gas_price() -> U256 {211 212 1_024_947_215_000u64.into()213 }214}215216217218219parameter_types! {220 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;221 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;222 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();223}224225226227228const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);229parameter_types! {230 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());231}232233pub enum FixedGasWeightMapping {}234impl GasWeightMapping for FixedGasWeightMapping {235 fn gas_to_weight(gas: u64) -> Weight {236 gas.saturating_mul(WeightPerGas::get())237 }238 fn weight_to_gas(weight: Weight) -> u64 {239 weight / WeightPerGas::get()240 }241}242243impl pallet_evm::Config for Runtime {244 type BlockGasLimit = BlockGasLimit;245 type FeeCalculator = FixedFee;246 type GasWeightMapping = FixedGasWeightMapping;247 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;248 type CallOrigin = EnsureAddressTruncated;249 type WithdrawOrigin = EnsureAddressTruncated;250 type AddressMapping = HashedAddressMapping<Self::Hashing>;251 type PrecompilesType = ();252 type PrecompilesValue = ();253 type Currency = Balances;254 type Event = Event;255 type OnMethodCall = (256 pallet_evm_migration::OnMethodCall<Self>,257 pallet_unique::UniqueErcSupport<Self>,258 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,259 );260 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;261 type ChainId = ChainId;262 type Runner = pallet_evm::runner::stack::Runner<Self>;263 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;264 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;265 type FindAuthor = EthereumFindAuthor<Aura>;266}267268impl pallet_evm_migration::Config for Runtime {269 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;270}271272pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);273impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {274 fn find_author<'a, I>(digests: I) -> Option<H160>275 where276 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,277 {278 if let Some(author_index) = F::find_author(digests) {279 let authority_id = Aura::authorities()[author_index as usize].clone();280 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));281 }282 None283 }284}285286impl pallet_ethereum::Config for Runtime {287 type Event = Event;288 type StateRoot = pallet_ethereum::IntermediateStateRoot;289}290291impl pallet_randomness_collective_flip::Config for Runtime {}292293impl frame_system::Config for Runtime {294 295 type AccountData = pallet_balances::AccountData<Balance>;296 297 type AccountId = AccountId;298 299 type BaseCallFilter = Everything;300 301 type BlockHashCount = BlockHashCount;302 303 type BlockLength = RuntimeBlockLength;304 305 type BlockNumber = BlockNumber;306 307 type BlockWeights = RuntimeBlockWeights;308 309 type Call = Call;310 311 type DbWeight = RocksDbWeight;312 313 type Event = Event;314 315 type Hash = Hash;316 317 type Hashing = BlakeTwo256;318 319 type Header = generic::Header<BlockNumber, BlakeTwo256>;320 321 type Index = Index;322 323 type Lookup = AccountIdLookup<AccountId, ()>;324 325 type OnKilledAccount = ();326 327 type OnNewAccount = ();328 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;329 330 type Origin = Origin;331 332 type PalletInfo = PalletInfo;333 334 type SS58Prefix = SS58Prefix;335 336 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;337 338 type Version = Version;339 type MaxConsumers = ConstU32<16>;340}341342parameter_types! {343 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;344}345346impl pallet_timestamp::Config for Runtime {347 348 type Moment = u64;349 type OnTimestampSet = ();350 type MinimumPeriod = MinimumPeriod;351 type WeightInfo = ();352}353354parameter_types! {355 356 pub const ExistentialDeposit: u128 = 0;357 pub const MaxLocks: u32 = 50;358}359360impl pallet_balances::Config for Runtime {361 type MaxLocks = MaxLocks;362 type MaxReserves = ();363 type ReserveIdentifier = [u8; 8];364 365 type Balance = Balance;366 367 type Event = Event;368 type DustRemoval = Treasury;369 type ExistentialDeposit = ExistentialDeposit;370 type AccountStore = System;371 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;372}373374pub const MICROUNIQUE: Balance = 1_000_000_000_000;375pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;376pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;377pub const UNIQUE: Balance = 100 * CENTIUNIQUE;378379pub const fn deposit(items: u32, bytes: u32) -> Balance {380 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE381}382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433parameter_types! {434 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; 435 436 437 pub const OperationalFeeMultiplier: u8 = 5;438}439440441pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);442443impl<T> WeightToFeePolynomial for LinearFee<T>444where445 T: BaseArithmetic + From<u32> + Copy + Unsigned,446{447 type Balance = T;448449 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {450 smallvec!(WeightToFeeCoefficient {451 452 coeff_integer: 142_688_000u32.into(),453 coeff_frac: Perbill::zero(),454 negative: false,455 degree: 1,456 })457 }458}459460impl pallet_transaction_payment::Config for Runtime {461 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;462 type TransactionByteFee = TransactionByteFee;463 type OperationalFeeMultiplier = OperationalFeeMultiplier;464 type WeightToFee = LinearFee<Balance>;465 type FeeMultiplierUpdate = ();466}467468parameter_types! {469 pub const ProposalBond: Permill = Permill::from_percent(5);470 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;471 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;472 pub const SpendPeriod: BlockNumber = 5 * MINUTES;473 pub const Burn: Permill = Permill::from_percent(0);474 pub const TipCountdown: BlockNumber = 1 * DAYS;475 pub const TipFindersFee: Percent = Percent::from_percent(20);476 pub const TipReportDepositBase: Balance = 1 * UNIQUE;477 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;478 pub const BountyDepositBase: Balance = 1 * UNIQUE;479 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;480 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");481 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;482 pub const MaximumReasonLength: u32 = 16384;483 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);484 pub const BountyValueMinimum: Balance = 5 * UNIQUE;485 pub const MaxApprovals: u32 = 100;486}487488impl pallet_treasury::Config for Runtime {489 type PalletId = TreasuryModuleId;490 type Currency = Balances;491 type ApproveOrigin = EnsureRoot<AccountId>;492 type RejectOrigin = EnsureRoot<AccountId>;493 type Event = Event;494 type OnSlash = ();495 type ProposalBond = ProposalBond;496 type ProposalBondMinimum = ProposalBondMinimum;497 type ProposalBondMaximum = ProposalBondMaximum;498 type SpendPeriod = SpendPeriod;499 type Burn = Burn;500 type BurnDestination = ();501 type SpendFunds = ();502 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;503 type MaxApprovals = MaxApprovals;504}505506impl pallet_sudo::Config for Runtime {507 type Event = Event;508 type Call = Call;509}510511pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);512513impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider514 for RelayChainBlockNumberProvider<T>515{516 type BlockNumber = BlockNumber;517518 fn current_block_number() -> Self::BlockNumber {519 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()520 .map(|d| d.relay_parent_number)521 .unwrap_or_default()522 }523}524525parameter_types! {526 pub const MinVestedTransfer: Balance = 10 * UNIQUE;527 pub const MaxVestingSchedules: u32 = 28;528}529530impl orml_vesting::Config for Runtime {531 type Event = Event;532 type Currency = pallet_balances::Pallet<Runtime>;533 type MinVestedTransfer = MinVestedTransfer;534 type VestedTransferOrigin = EnsureSigned<AccountId>;535 type WeightInfo = ();536 type MaxVestingSchedules = MaxVestingSchedules;537 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;538}539540parameter_types! {541 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;542 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;543}544545impl cumulus_pallet_parachain_system::Config for Runtime {546 type Event = Event;547 type SelfParaId = parachain_info::Pallet<Self>;548 type OnSystemEvent = ();549 550 551 552 553 554 type OutboundXcmpMessageSource = XcmpQueue;555 type DmpMessageHandler = DmpQueue;556 type ReservedDmpWeight = ReservedDmpWeight;557 type ReservedXcmpWeight = ReservedXcmpWeight;558 type XcmpMessageHandler = XcmpQueue;559}560561impl parachain_info::Config for Runtime {}562563impl cumulus_pallet_aura_ext::Config for Runtime {}564565parameter_types! {566 pub const RelayLocation: MultiLocation = MultiLocation::parent();567 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;568 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();569 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();570}571572573574575pub type LocationToAccountId = (576 577 ParentIsDefault<AccountId>,578 579 SiblingParachainConvertsVia<Sibling, AccountId>,580 581 AccountId32Aliases<RelayNetwork, AccountId>,582);583584pub struct OnlySelfCurrency;585impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {586 fn matches_fungible(a: &MultiAsset) -> Option<B> {587 match (&a.id, &a.fun) {588 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),589 _ => None,590 }591 }592}593594595pub type LocalAssetTransactor = CurrencyAdapter<596 597 Balances,598 599 OnlySelfCurrency,600 601 LocationToAccountId,602 603 AccountId,604 605 (),606>;607608609610611pub type XcmOriginToTransactDispatchOrigin = (612 613 614 615 SovereignSignedViaLocation<LocationToAccountId, Origin>,616 617 618 RelayChainAsNative<RelayOrigin, Origin>,619 620 621 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,622 623 624 ParentAsSuperuser<Origin>,625 626 627 SignedAccountId32AsNative<RelayNetwork, Origin>,628 629 XcmPassthrough<Origin>,630);631632parameter_types! {633 634 pub UnitWeightCost: Weight = 1_000_000;635 636 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);637 pub const MaxInstructions: u32 = 100;638 pub const MaxAuthorities: u32 = 100_000;639}640641match_type! {642 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {643 MultiLocation { parents: 1, interior: Here } |644 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }645 };646}647648pub type Barrier = (649 TakeWeightCredit,650 AllowTopLevelPaidExecutionFrom<Everything>,651 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,652 653);654655pub struct UsingOnlySelfCurrencyComponents<656 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,657 AssetId: Get<MultiLocation>,658 AccountId,659 Currency: CurrencyT<AccountId>,660 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,661>(662 Weight,663 Currency::Balance,664 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,665);666impl<667 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,668 AssetId: Get<MultiLocation>,669 AccountId,670 Currency: CurrencyT<AccountId>,671 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,672 > WeightTrader673 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>674{675 fn new() -> Self {676 Self(0, Zero::zero(), PhantomData)677 }678679 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {680 let amount = WeightToFee::calc(&weight);681 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;682683 684 let option1: xcm::v1::AssetId = Concrete(MultiLocation {685 parents: 1,686 interior: X1(Parachain(ParachainInfo::parachain_id().into())),687 });688 689 let option2: xcm::v1::AssetId = Concrete(MultiLocation {690 parents: 0,691 interior: Here,692 });693694 let required = if payment.fungible.contains_key(&option1) {695 (option1, u128_amount).into()696 } else if payment.fungible.contains_key(&option2) {697 (option2, u128_amount).into()698 } else {699 (Concrete(MultiLocation::default()), u128_amount).into()700 };701702 let unused = payment703 .checked_sub(required)704 .map_err(|_| XcmError::TooExpensive)?;705 self.0 = self.0.saturating_add(weight);706 self.1 = self.1.saturating_add(amount);707 Ok(unused)708 }709710 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {711 let weight = weight.min(self.0);712 let amount = WeightToFee::calc(&weight);713 self.0 -= weight;714 self.1 = self.1.saturating_sub(amount);715 let amount: u128 = amount.saturated_into();716 if amount > 0 {717 Some((AssetId::get(), amount).into())718 } else {719 None720 }721 }722}723impl<724 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,725 AssetId: Get<MultiLocation>,726 AccountId,727 Currency: CurrencyT<AccountId>,728 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,729 > Drop730 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>731{732 fn drop(&mut self) {733 OnUnbalanced::on_unbalanced(Currency::issue(self.1));734 }735}736737pub struct XcmConfig;738impl Config for XcmConfig {739 type Call = Call;740 type XcmSender = XcmRouter;741 742 type AssetTransactor = LocalAssetTransactor;743 type OriginConverter = XcmOriginToTransactDispatchOrigin;744 type IsReserve = NativeAsset;745 type IsTeleporter = (); 746 type LocationInverter = LocationInverter<Ancestry>;747 type Barrier = Barrier;748 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;749 type Trader = UsingOnlySelfCurrencyComponents<750 IdentityFee<Balance>,751 RelayLocation,752 AccountId,753 Balances,754 (),755 >;756 type ResponseHandler = (); 757 type SubscriptionService = PolkadotXcm;758759 type AssetTrap = PolkadotXcm;760 type AssetClaims = PolkadotXcm;761}762763764765766767768pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);769770771772pub type XcmRouter = (773 774 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,775 776 XcmpQueue,777);778779impl pallet_evm_coder_substrate::Config for Runtime {780 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;781 type GasWeightMapping = FixedGasWeightMapping;782}783784impl pallet_xcm::Config for Runtime {785 type Event = Event;786 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;787 type XcmRouter = XcmRouter;788 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;789 type XcmExecuteFilter = Everything;790 type XcmExecutor = XcmExecutor<XcmConfig>;791 type XcmTeleportFilter = Everything;792 type XcmReserveTransferFilter = Everything;793 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;794 type LocationInverter = LocationInverter<Ancestry>;795 type Origin = Origin;796 type Call = Call;797 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;798 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;799}800801impl cumulus_pallet_xcm::Config for Runtime {802 type Event = Event;803 type XcmExecutor = XcmExecutor<XcmConfig>;804}805806impl cumulus_pallet_xcmp_queue::Config for Runtime {807 type Event = Event;808 type XcmExecutor = XcmExecutor<XcmConfig>;809 type ChannelInfo = ParachainSystem;810 type VersionWrapper = ();811 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;812}813814impl cumulus_pallet_dmp_queue::Config for Runtime {815 type Event = Event;816 type XcmExecutor = XcmExecutor<XcmConfig>;817 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;818}819820impl pallet_aura::Config for Runtime {821 type AuthorityId = AuraId;822 type DisabledValidators = ();823 type MaxAuthorities = MaxAuthorities;824}825826parameter_types! {827 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();828 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;829}830831impl pallet_common::Config for Runtime {832 type Event = Event;833 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;834 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;835 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;836837 type Currency = Balances;838 type CollectionCreationPrice = CollectionCreationPrice;839 type TreasuryAccountId = TreasuryAccountId;840}841842impl pallet_fungible::Config for Runtime {843 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;844}845impl pallet_refungible::Config for Runtime {846 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;847}848impl pallet_nonfungible::Config for Runtime {849 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;850}851852impl pallet_unique::Config for Runtime {853 type Event = Event;854 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;855}856857parameter_types! {858 pub const InflationBlockInterval: BlockNumber = 100; 859}860861862impl pallet_inflation::Config for Runtime {863 type Currency = Balances;864 type TreasuryAccountId = TreasuryAccountId;865 type InflationBlockInterval = InflationBlockInterval;866 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;867}868869870871872873874875type EvmSponsorshipHandler = (876 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,877 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,878);879type SponsorshipHandler = (880 pallet_unique::UniqueSponsorshipHandler<Runtime>,881 882 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,883);884885886887888889890891892893894895896897impl pallet_evm_transaction_payment::Config for Runtime {898 type EvmSponsorshipHandler = EvmSponsorshipHandler;899 type Currency = Balances;900 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;901 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;902}903904impl pallet_charge_transaction::Config for Runtime {905 type SponsorshipHandler = SponsorshipHandler;906}907908909910911912parameter_types! {913 914 pub const HelpersContractAddress: H160 = H160([915 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,916 ]);917}918919impl pallet_evm_contract_helpers::Config for Runtime {920 type ContractAddress = HelpersContractAddress;921 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;922}923924construct_runtime!(925 pub enum Runtime where926 Block = Block,927 NodeBlock = opaque::Block,928 UncheckedExtrinsic = UncheckedExtrinsic929 {930 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,931 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,932933 Aura: pallet_aura::{Pallet, Config<T>} = 22,934 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,935936 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,937 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,938 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,939 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,940 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,941 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,942 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,943 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,944 945 946947 948 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,949 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,950 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,951 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,952953 954 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,955 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,956 957 958 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,959 960 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,961 Fungible: pallet_fungible::{Pallet, Storage} = 67,962 Refungible: pallet_refungible::{Pallet, Storage} = 68,963 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,964965 966 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,967 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,968969 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,970 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,971 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,972 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,973 }974);975976pub struct TransactionConverter;977978impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {979 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {980 UncheckedExtrinsic::new_unsigned(981 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),982 )983 }984}985986impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {987 fn convert_transaction(988 &self,989 transaction: pallet_ethereum::Transaction,990 ) -> opaque::UncheckedExtrinsic {991 let extrinsic = UncheckedExtrinsic::new_unsigned(992 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),993 );994 let encoded = extrinsic.encode();995 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])996 .expect("Encoded extrinsic is always valid")997 }998}99910001001pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10021003pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10041005pub type Block = generic::Block<Header, UncheckedExtrinsic>;10061007pub type SignedBlock = generic::SignedBlock<Block>;10081009pub type BlockId = generic::BlockId<Block>;10101011pub type SignedExtra = (1012 frame_system::CheckSpecVersion<Runtime>,1013 1014 frame_system::CheckGenesis<Runtime>,1015 frame_system::CheckEra<Runtime>,1016 frame_system::CheckNonce<Runtime>,1017 frame_system::CheckWeight<Runtime>,1018 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1019 1020);10211022pub type UncheckedExtrinsic =1023 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10241025pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10261027pub type Executive = frame_executive::Executive<1028 Runtime,1029 Block,1030 frame_system::ChainContext<Runtime>,1031 Runtime,1032 AllPalletsReversedWithSystemFirst,1033>;10341035impl_opaque_keys! {1036 pub struct SessionKeys {1037 pub aura: Aura,1038 }1039}10401041impl fp_self_contained::SelfContainedCall for Call {1042 type SignedInfo = H160;10431044 fn is_self_contained(&self) -> bool {1045 match self {1046 Call::Ethereum(call) => call.is_self_contained(),1047 _ => false,1048 }1049 }10501051 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1052 match self {1053 Call::Ethereum(call) => call.check_self_contained(),1054 _ => None,1055 }1056 }10571058 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1059 match self {1060 Call::Ethereum(call) => call.validate_self_contained(info),1061 _ => None,1062 }1063 }10641065 fn pre_dispatch_self_contained(1066 &self,1067 info: &Self::SignedInfo,1068 ) -> Option<Result<(), TransactionValidityError>> {1069 match self {1070 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1071 _ => None,1072 }1073 }10741075 fn apply_self_contained(1076 self,1077 info: Self::SignedInfo,1078 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1079 match self {1080 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1081 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1082 )),1083 _ => None,1084 }1085 }1086}10871088macro_rules! dispatch_unique_runtime {1089 ($collection:ident.$method:ident($($name:ident),*)) => {{1090 use pallet_unique::dispatch::Dispatched;10911092 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1093 let dispatch = collection.as_dyn();10941095 Ok(dispatch.$method($($name),*))1096 }};1097}1098impl_runtime_apis! {1099 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>1100 for Runtime1101 {1102 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {1103 dispatch_unique_runtime!(collection.account_tokens(account))1104 }1105 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {1106 dispatch_unique_runtime!(collection.token_exists(token))1107 }11081109 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {1110 dispatch_unique_runtime!(collection.token_owner(token))1111 }1112 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {1113 dispatch_unique_runtime!(collection.const_metadata(token))1114 }1115 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {1116 dispatch_unique_runtime!(collection.variable_metadata(token))1117 }11181119 fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {1120 dispatch_unique_runtime!(collection.collection_tokens())1121 }1122 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {1123 dispatch_unique_runtime!(collection.account_balance(account))1124 }1125 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {1126 dispatch_unique_runtime!(collection.balance(account, token))1127 }1128 fn allowance(1129 collection: CollectionId,1130 sender: CrossAccountId,1131 spender: CrossAccountId,1132 token: TokenId,1133 ) -> Result<u128, DispatchError> {1134 dispatch_unique_runtime!(collection.allowance(sender, spender, token))1135 }11361137 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {1138 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)1139 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))1140 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))1141 }1142 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {1143 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))1144 }1145 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {1146 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))1147 }1148 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {1149 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))1150 }1151 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {1152 dispatch_unique_runtime!(collection.last_token_id())1153 }1154 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {1155 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))1156 }1157 fn collection_stats() -> Result<CollectionStats, DispatchError> {1158 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())1159 }1160 }11611162 impl sp_api::Core<Block> for Runtime {1163 fn version() -> RuntimeVersion {1164 VERSION1165 }11661167 fn execute_block(block: Block) {1168 Executive::execute_block(block)1169 }11701171 fn initialize_block(header: &<Block as BlockT>::Header) {1172 Executive::initialize_block(header)1173 }1174 }11751176 impl sp_api::Metadata<Block> for Runtime {1177 fn metadata() -> OpaqueMetadata {1178 OpaqueMetadata::new(Runtime::metadata().into())1179 }1180 }11811182 impl sp_block_builder::BlockBuilder<Block> for Runtime {1183 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {1184 Executive::apply_extrinsic(extrinsic)1185 }11861187 fn finalize_block() -> <Block as BlockT>::Header {1188 Executive::finalize_block()1189 }11901191 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {1192 data.create_extrinsics()1193 }11941195 fn check_inherents(1196 block: Block,1197 data: sp_inherents::InherentData,1198 ) -> sp_inherents::CheckInherentsResult {1199 data.check_extrinsics(&block)1200 }12011202 1203 1204 1205 }12061207 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {1208 fn validate_transaction(1209 source: TransactionSource,1210 tx: <Block as BlockT>::Extrinsic,1211 hash: <Block as BlockT>::Hash,1212 ) -> TransactionValidity {1213 Executive::validate_transaction(source, tx, hash)1214 }1215 }12161217 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {1218 fn offchain_worker(header: &<Block as BlockT>::Header) {1219 Executive::offchain_worker(header)1220 }1221 }12221223 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {1224 fn chain_id() -> u64 {1225 <Runtime as pallet_evm::Config>::ChainId::get()1226 }12271228 fn account_basic(address: H160) -> EVMAccount {1229 EVM::account_basic(&address)1230 }12311232 fn gas_price() -> U256 {1233 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()1234 }12351236 fn account_code_at(address: H160) -> Vec<u8> {1237 EVM::account_codes(address)1238 }12391240 fn author() -> H160 {1241 <pallet_evm::Pallet<Runtime>>::find_author()1242 }12431244 fn storage_at(address: H160, index: U256) -> H256 {1245 let mut tmp = [0u8; 32];1246 index.to_big_endian(&mut tmp);1247 EVM::account_storages(address, H256::from_slice(&tmp[..]))1248 }12491250 #[allow(clippy::redundant_closure)]1251 fn call(1252 from: H160,1253 to: H160,1254 data: Vec<u8>,1255 value: U256,1256 gas_limit: U256,1257 max_fee_per_gas: Option<U256>,1258 max_priority_fee_per_gas: Option<U256>,1259 nonce: Option<U256>,1260 estimate: bool,1261 access_list: Option<Vec<(H160, Vec<H256>)>>,1262 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1263 let config = if estimate {1264 let mut config = <Runtime as pallet_evm::Config>::config().clone();1265 config.estimate = true;1266 Some(config)1267 } else {1268 None1269 };12701271 <Runtime as pallet_evm::Config>::Runner::call(1272 from,1273 to,1274 data,1275 value,1276 gas_limit.low_u64(),1277 max_fee_per_gas,1278 max_priority_fee_per_gas,1279 nonce,1280 access_list.unwrap_or_default(),1281 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1282 ).map_err(|err| err.into())1283 }12841285 #[allow(clippy::redundant_closure)]1286 fn create(1287 from: H160,1288 data: Vec<u8>,1289 value: U256,1290 gas_limit: U256,1291 max_fee_per_gas: Option<U256>,1292 max_priority_fee_per_gas: Option<U256>,1293 nonce: Option<U256>,1294 estimate: bool,1295 access_list: Option<Vec<(H160, Vec<H256>)>>,1296 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1297 let config = if estimate {1298 let mut config = <Runtime as pallet_evm::Config>::config().clone();1299 config.estimate = true;1300 Some(config)1301 } else {1302 None1303 };13041305 <Runtime as pallet_evm::Config>::Runner::create(1306 from,1307 data,1308 value,1309 gas_limit.low_u64(),1310 max_fee_per_gas,1311 max_priority_fee_per_gas,1312 nonce,1313 access_list.unwrap_or_default(),1314 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1315 ).map_err(|err| err.into())1316 }13171318 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1319 Ethereum::current_transaction_statuses()1320 }13211322 fn current_block() -> Option<pallet_ethereum::Block> {1323 Ethereum::current_block()1324 }13251326 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1327 Ethereum::current_receipts()1328 }13291330 fn current_all() -> (1331 Option<pallet_ethereum::Block>,1332 Option<Vec<pallet_ethereum::Receipt>>,1333 Option<Vec<TransactionStatus>>1334 ) {1335 (1336 Ethereum::current_block(),1337 Ethereum::current_receipts(),1338 Ethereum::current_transaction_statuses()1339 )1340 }13411342 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1343 xts.into_iter().filter_map(|xt| match xt.0.function {1344 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),1345 _ => None1346 }).collect()1347 }13481349 fn elasticity() -> Option<Permill> {1350 None1351 }1352 }13531354 impl sp_session::SessionKeys<Block> for Runtime {1355 fn decode_session_keys(1356 encoded: Vec<u8>,1357 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1358 SessionKeys::decode_into_raw_public_keys(&encoded)1359 }13601361 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1362 SessionKeys::generate(seed)1363 }1364 }13651366 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1367 fn slot_duration() -> sp_consensus_aura::SlotDuration {1368 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1369 }13701371 fn authorities() -> Vec<AuraId> {1372 Aura::authorities().to_vec()1373 }1374 }13751376 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1377 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {1378 ParachainSystem::collect_collation_info(header)1379 }1380 }13811382 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1383 fn account_nonce(account: AccountId) -> Index {1384 System::account_nonce(account)1385 }1386 }13871388 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1389 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1390 TransactionPayment::query_info(uxt, len)1391 }1392 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1393 TransactionPayment::query_fee_details(uxt, len)1394 }1395 }13961397 13981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438 #[cfg(feature = "runtime-benchmarks")]1439 impl frame_benchmarking::Benchmark<Block> for Runtime {1440 fn benchmark_metadata(extra: bool) -> (1441 Vec<frame_benchmarking::BenchmarkList>,1442 Vec<frame_support::traits::StorageInfo>,1443 ) {1444 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};1445 use frame_support::traits::StorageInfoTrait;14461447 let mut list = Vec::<BenchmarkList>::new();14481449 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);1450 list_benchmark!(list, extra, pallet_unique, Unique);1451 list_benchmark!(list, extra, pallet_inflation, Inflation);1452 list_benchmark!(list, extra, pallet_fungible, Fungible);1453 list_benchmark!(list, extra, pallet_refungible, Refungible);1454 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);1455 14561457 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();14581459 return (list, storage_info)1460 }14611462 fn dispatch_benchmark(1463 config: frame_benchmarking::BenchmarkConfig1464 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1465 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};14661467 let allowlist: Vec<TrackedStorageKey> = vec![1468 1469 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),1470 1471 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),1472 1473 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),1474 1475 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),1476 1477 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),1478 ];14791480 let mut batches = Vec::<BenchmarkBatch>::new();1481 let params = (&config, &allowlist);14821483 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1484 add_benchmark!(params, batches, pallet_unique, Unique);1485 add_benchmark!(params, batches, pallet_inflation, Inflation);1486 add_benchmark!(params, batches, pallet_fungible, Fungible);1487 add_benchmark!(params, batches, pallet_refungible, Refungible);1488 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);1489 14901491 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1492 Ok(batches)1493 }1494 }1495}14961497struct CheckInherents;14981499impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1500 fn check_inherents(1501 block: &Block,1502 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1503 ) -> sp_inherents::CheckInherentsResult {1504 let relay_chain_slot = relay_state_proof1505 .read_slot()1506 .expect("Could not read the relay chain slot from the proof");15071508 let inherent_data =1509 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1510 relay_chain_slot,1511 sp_std::time::Duration::from_secs(6),1512 )1513 .create_inherent_data()1514 .expect("Could not create the timestamp inherent data");15151516 inherent_data.check_extrinsics(block)1517 }1518}15191520cumulus_pallet_parachain_system::register_validate_block!(1521 Runtime = Runtime,1522 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1523 CheckInherents = CheckInherents,1524);