12345678910111213141516171819#![cfg_attr(not(feature = "std"), no_std)]2021#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]2425#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31323334use sp_runtime::{35 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37 transaction_validity::{TransactionSource, TransactionValidity},38 ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};4950pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};52pub use frame_support::{53 construct_runtime, match_type,54 dispatch::DispatchResult,55 PalletId, parameter_types, StorageValue, ConsensusEngineId,56 traits::{57 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,58 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,59 OnUnbalanced, Randomness, FindAuthor,60 },61 weights::{62 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},63 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,64 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,65 },66};67use up_data_structs::*;686970use frame_system::{71 self as frame_system, EnsureRoot, EnsureSigned,72 limits::{BlockWeights, BlockLength},73};74use sp_arithmetic::{75 traits::{BaseArithmetic, Unsigned},76};77use smallvec::smallvec;78use codec::{Encode, Decode};79use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};80use fp_rpc::TransactionStatus;81use sp_runtime::{82 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},83 transaction_validity::TransactionValidityError,84 SaturatedConversion,85};868788pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;899091use pallet_xcm::XcmPassthrough;92use polkadot_parachain::primitives::Sibling;93use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};94use xcm_builder::{95 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,96 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,97 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,98 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,99 ParentIsPreset,100};101use xcm_executor::{Config, XcmExecutor, Assets};102use sp_std::{marker::PhantomData};103104use xcm::latest::{105 106 AssetId::{Concrete},107 Fungibility::Fungible as XcmFungible,108 MultiAsset,109 Error as XcmError,110};111use xcm_executor::traits::{MatchesFungible, WeightTrader};112113use sp_runtime::traits::CheckedConversion;114115use unique_runtime_common::{types::*, constants::*};116117pub const RUNTIME_NAME: &str = "Unique";118119pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120121122123124125pub mod opaque {126 use sp_std::prelude::*;127 use sp_runtime::impl_opaque_keys;128 use super::Aura;129130 pub use unique_runtime_common::types::*;131 pub use super::CrossAccountId;132133 impl_opaque_keys! {134 pub struct SessionKeys {135 pub aura: Aura,136 }137 }138}139140141pub const VERSION: RuntimeVersion = RuntimeVersion {142 spec_name: create_runtime_str!(RUNTIME_NAME),143 impl_name: create_runtime_str!(RUNTIME_NAME),144 authoring_version: 1,145 spec_version: 917004,146 impl_version: 0,147 apis: RUNTIME_API_VERSIONS,148 transaction_version: 1,149 state_version: 0,150};151152#[derive(codec::Encode, codec::Decode)]153pub enum XCMPMessage<XAccountId, XBalance> {154 155 TransferToken(XAccountId, XBalance),156}157158159#[cfg(feature = "std")]160pub fn native_version() -> NativeVersion {161 NativeVersion {162 runtime_version: VERSION,163 can_author_with: Default::default(),164 }165}166167type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;168169pub struct DealWithFees;170impl OnUnbalanced<NegativeImbalance> for DealWithFees {171 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {172 if let Some(fees) = fees_then_tips.next() {173 174 let mut split = fees.ration(100, 0);175 if let Some(tips) = fees_then_tips.next() {176 177 tips.ration_merge_into(100, 0, &mut split);178 }179 Treasury::on_unbalanced(split.0);180 181 }182 }183}184185parameter_types! {186 pub const BlockHashCount: BlockNumber = 2400;187 pub RuntimeBlockLength: BlockLength =188 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);189 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);190 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;191 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()192 .base_block(BlockExecutionWeight::get())193 .for_class(DispatchClass::all(), |weights| {194 weights.base_extrinsic = ExtrinsicBaseWeight::get();195 })196 .for_class(DispatchClass::Normal, |weights| {197 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);198 })199 .for_class(DispatchClass::Operational, |weights| {200 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);201 202 203 weights.reserved = Some(204 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT205 );206 })207 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)208 .build_or_panic();209 pub const Version: RuntimeVersion = VERSION;210 211212213214215 pub const SS58Prefix: u8 = 255; 216}217218219220221222223parameter_types! {224 pub const ChainId: u64 = 8880;225}226227pub struct FixedFee;228impl FeeCalculator for FixedFee {229 fn min_gas_price() -> U256 {230 231 1_018_751_825_264u64.into()232 }233}234235236237238parameter_types! {239 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;240 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;241 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();242}243244245246247const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);248parameter_types! {249 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());250}251252pub enum FixedGasWeightMapping {}253impl GasWeightMapping for FixedGasWeightMapping {254 fn gas_to_weight(gas: u64) -> Weight {255 gas.saturating_mul(WeightPerGas::get())256 }257 fn weight_to_gas(weight: Weight) -> u64 {258 weight / WeightPerGas::get()259 }260}261262impl pallet_evm::Config for Runtime {263 type BlockGasLimit = BlockGasLimit;264 type FeeCalculator = FixedFee;265 type GasWeightMapping = FixedGasWeightMapping;266 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;267 type CallOrigin = EnsureAddressTruncated;268 type WithdrawOrigin = EnsureAddressTruncated;269 type AddressMapping = HashedAddressMapping<Self::Hashing>;270 type PrecompilesType = ();271 type PrecompilesValue = ();272 type Currency = Balances;273 type Event = Event;274 type OnMethodCall = (275 pallet_evm_migration::OnMethodCall<Self>,276 pallet_unique::UniqueErcSupport<Self>,277 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,278 );279 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;280 type ChainId = ChainId;281 type Runner = pallet_evm::runner::stack::Runner<Self>;282 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;283 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;284 type FindAuthor = EthereumFindAuthor<Aura>;285}286287impl pallet_evm_migration::Config for Runtime {288 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;289}290291pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);292impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {293 fn find_author<'a, I>(digests: I) -> Option<H160>294 where295 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,296 {297 if let Some(author_index) = F::find_author(digests) {298 let authority_id = Aura::authorities()[author_index as usize].clone();299 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));300 }301 None302 }303}304305impl pallet_ethereum::Config for Runtime {306 type Event = Event;307 type StateRoot = pallet_ethereum::IntermediateStateRoot;308}309310impl pallet_randomness_collective_flip::Config for Runtime {}311312impl frame_system::Config for Runtime {313 314 type AccountData = pallet_balances::AccountData<Balance>;315 316 type AccountId = AccountId;317 318 type BaseCallFilter = Everything;319 320 type BlockHashCount = BlockHashCount;321 322 type BlockLength = RuntimeBlockLength;323 324 type BlockNumber = BlockNumber;325 326 type BlockWeights = RuntimeBlockWeights;327 328 type Call = Call;329 330 type DbWeight = RocksDbWeight;331 332 type Event = Event;333 334 type Hash = Hash;335 336 type Hashing = BlakeTwo256;337 338 type Header = generic::Header<BlockNumber, BlakeTwo256>;339 340 type Index = Index;341 342 type Lookup = AccountIdLookup<AccountId, ()>;343 344 type OnKilledAccount = ();345 346 type OnNewAccount = ();347 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;348 349 type Origin = Origin;350 351 type PalletInfo = PalletInfo;352 353 type SS58Prefix = SS58Prefix;354 355 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;356 357 type Version = Version;358 type MaxConsumers = ConstU32<16>;359}360361parameter_types! {362 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;363}364365impl pallet_timestamp::Config for Runtime {366 367 type Moment = u64;368 type OnTimestampSet = ();369 type MinimumPeriod = MinimumPeriod;370 type WeightInfo = ();371}372373parameter_types! {374 375 pub const ExistentialDeposit: u128 = 0;376 pub const MaxLocks: u32 = 50;377}378379impl pallet_balances::Config for Runtime {380 type MaxLocks = MaxLocks;381 type MaxReserves = ();382 type ReserveIdentifier = [u8; 8];383 384 type Balance = Balance;385 386 type Event = Event;387 type DustRemoval = Treasury;388 type ExistentialDeposit = ExistentialDeposit;389 type AccountStore = System;390 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;391}392393pub const MICROUNIQUE: Balance = 1_000_000_000_000;394pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;395pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;396pub const UNIQUE: Balance = 100 * CENTIUNIQUE;397398pub const fn deposit(items: u32, bytes: u32) -> Balance {399 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE400}401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452parameter_types! {453 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; 454 455 456 pub const OperationalFeeMultiplier: u8 = 5;457}458459460pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);461462impl<T> WeightToFeePolynomial for LinearFee<T>463where464 T: BaseArithmetic + From<u32> + Copy + Unsigned,465{466 type Balance = T;467468 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {469 smallvec!(WeightToFeeCoefficient {470 471 coeff_integer: 142_688_000u32.into(),472 coeff_frac: Perbill::zero(),473 negative: false,474 degree: 1,475 })476 }477}478479impl pallet_transaction_payment::Config for Runtime {480 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;481 type TransactionByteFee = TransactionByteFee;482 type OperationalFeeMultiplier = OperationalFeeMultiplier;483 type WeightToFee = LinearFee<Balance>;484 type FeeMultiplierUpdate = ();485}486487parameter_types! {488 pub const ProposalBond: Permill = Permill::from_percent(5);489 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;490 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;491 pub const SpendPeriod: BlockNumber = 5 * MINUTES;492 pub const Burn: Permill = Permill::from_percent(0);493 pub const TipCountdown: BlockNumber = 1 * DAYS;494 pub const TipFindersFee: Percent = Percent::from_percent(20);495 pub const TipReportDepositBase: Balance = 1 * UNIQUE;496 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;497 pub const BountyDepositBase: Balance = 1 * UNIQUE;498 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;499 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");500 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;501 pub const MaximumReasonLength: u32 = 16384;502 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);503 pub const BountyValueMinimum: Balance = 5 * UNIQUE;504 pub const MaxApprovals: u32 = 100;505}506507impl pallet_treasury::Config for Runtime {508 type PalletId = TreasuryModuleId;509 type Currency = Balances;510 type ApproveOrigin = EnsureRoot<AccountId>;511 type RejectOrigin = EnsureRoot<AccountId>;512 type Event = Event;513 type OnSlash = ();514 type ProposalBond = ProposalBond;515 type ProposalBondMinimum = ProposalBondMinimum;516 type ProposalBondMaximum = ProposalBondMaximum;517 type SpendPeriod = SpendPeriod;518 type Burn = Burn;519 type BurnDestination = ();520 type SpendFunds = ();521 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;522 type MaxApprovals = MaxApprovals;523}524525impl pallet_sudo::Config for Runtime {526 type Event = Event;527 type Call = Call;528}529530pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);531532impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider533 for RelayChainBlockNumberProvider<T>534{535 type BlockNumber = BlockNumber;536537 fn current_block_number() -> Self::BlockNumber {538 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()539 .map(|d| d.relay_parent_number)540 .unwrap_or_default()541 }542}543544parameter_types! {545 pub const MinVestedTransfer: Balance = 10 * UNIQUE;546 pub const MaxVestingSchedules: u32 = 28;547}548549impl orml_vesting::Config for Runtime {550 type Event = Event;551 type Currency = pallet_balances::Pallet<Runtime>;552 type MinVestedTransfer = MinVestedTransfer;553 type VestedTransferOrigin = EnsureSigned<AccountId>;554 type WeightInfo = ();555 type MaxVestingSchedules = MaxVestingSchedules;556 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;557}558559parameter_types! {560 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;561 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;562}563564impl cumulus_pallet_parachain_system::Config for Runtime {565 type Event = Event;566 type SelfParaId = parachain_info::Pallet<Self>;567 type OnSystemEvent = ();568 569 570 571 572 573 type OutboundXcmpMessageSource = XcmpQueue;574 type DmpMessageHandler = DmpQueue;575 type ReservedDmpWeight = ReservedDmpWeight;576 type ReservedXcmpWeight = ReservedXcmpWeight;577 type XcmpMessageHandler = XcmpQueue;578}579580impl parachain_info::Config for Runtime {}581582impl cumulus_pallet_aura_ext::Config for Runtime {}583584parameter_types! {585 pub const RelayLocation: MultiLocation = MultiLocation::parent();586 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;587 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();588 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();589}590591592593594pub type LocationToAccountId = (595 596 ParentIsPreset<AccountId>,597 598 SiblingParachainConvertsVia<Sibling, AccountId>,599 600 AccountId32Aliases<RelayNetwork, AccountId>,601);602603pub struct OnlySelfCurrency;604impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {605 fn matches_fungible(a: &MultiAsset) -> Option<B> {606 match (&a.id, &a.fun) {607 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),608 _ => None,609 }610 }611}612613614pub type LocalAssetTransactor = CurrencyAdapter<615 616 Balances,617 618 OnlySelfCurrency,619 620 LocationToAccountId,621 622 AccountId,623 624 (),625>;626627628629630pub type XcmOriginToTransactDispatchOrigin = (631 632 633 634 SovereignSignedViaLocation<LocationToAccountId, Origin>,635 636 637 RelayChainAsNative<RelayOrigin, Origin>,638 639 640 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,641 642 643 ParentAsSuperuser<Origin>,644 645 646 SignedAccountId32AsNative<RelayNetwork, Origin>,647 648 XcmPassthrough<Origin>,649);650651parameter_types! {652 653 pub UnitWeightCost: Weight = 1_000_000;654 655 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);656 pub const MaxInstructions: u32 = 100;657 pub const MaxAuthorities: u32 = 100_000;658}659660match_type! {661 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {662 MultiLocation { parents: 1, interior: Here } |663 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }664 };665}666667pub type Barrier = (668 TakeWeightCredit,669 AllowTopLevelPaidExecutionFrom<Everything>,670 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,671 672);673674pub struct UsingOnlySelfCurrencyComponents<675 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,676 AssetId: Get<MultiLocation>,677 AccountId,678 Currency: CurrencyT<AccountId>,679 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,680>(681 Weight,682 Currency::Balance,683 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,684);685impl<686 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,687 AssetId: Get<MultiLocation>,688 AccountId,689 Currency: CurrencyT<AccountId>,690 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,691 > WeightTrader692 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>693{694 fn new() -> Self {695 Self(0, Zero::zero(), PhantomData)696 }697698 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {699 let amount = WeightToFee::calc(&weight);700 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;701702 703 let option1: xcm::v1::AssetId = Concrete(MultiLocation {704 parents: 1,705 interior: X1(Parachain(ParachainInfo::parachain_id().into())),706 });707 708 let option2: xcm::v1::AssetId = Concrete(MultiLocation {709 parents: 0,710 interior: Here,711 });712713 let required = if payment.fungible.contains_key(&option1) {714 (option1, u128_amount).into()715 } else if payment.fungible.contains_key(&option2) {716 (option2, u128_amount).into()717 } else {718 (Concrete(MultiLocation::default()), u128_amount).into()719 };720721 let unused = payment722 .checked_sub(required)723 .map_err(|_| XcmError::TooExpensive)?;724 self.0 = self.0.saturating_add(weight);725 self.1 = self.1.saturating_add(amount);726 Ok(unused)727 }728729 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {730 let weight = weight.min(self.0);731 let amount = WeightToFee::calc(&weight);732 self.0 -= weight;733 self.1 = self.1.saturating_sub(amount);734 let amount: u128 = amount.saturated_into();735 if amount > 0 {736 Some((AssetId::get(), amount).into())737 } else {738 None739 }740 }741}742impl<743 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,744 AssetId: Get<MultiLocation>,745 AccountId,746 Currency: CurrencyT<AccountId>,747 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,748 > Drop749 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>750{751 fn drop(&mut self) {752 OnUnbalanced::on_unbalanced(Currency::issue(self.1));753 }754}755756pub struct XcmConfig;757impl Config for XcmConfig {758 type Call = Call;759 type XcmSender = XcmRouter;760 761 type AssetTransactor = LocalAssetTransactor;762 type OriginConverter = XcmOriginToTransactDispatchOrigin;763 type IsReserve = NativeAsset;764 type IsTeleporter = (); 765 type LocationInverter = LocationInverter<Ancestry>;766 type Barrier = Barrier;767 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;768 type Trader = UsingOnlySelfCurrencyComponents<769 IdentityFee<Balance>,770 RelayLocation,771 AccountId,772 Balances,773 (),774 >;775 type ResponseHandler = (); 776 type SubscriptionService = PolkadotXcm;777778 type AssetTrap = PolkadotXcm;779 type AssetClaims = PolkadotXcm;780}781782783784785786787pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);788789790791pub type XcmRouter = (792 793 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,794 795 XcmpQueue,796);797798impl pallet_evm_coder_substrate::Config for Runtime {799 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;800 type GasWeightMapping = FixedGasWeightMapping;801}802803impl pallet_xcm::Config for Runtime {804 type Event = Event;805 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;806 type XcmRouter = XcmRouter;807 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;808 type XcmExecuteFilter = Everything;809 type XcmExecutor = XcmExecutor<XcmConfig>;810 type XcmTeleportFilter = Everything;811 type XcmReserveTransferFilter = Everything;812 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;813 type LocationInverter = LocationInverter<Ancestry>;814 type Origin = Origin;815 type Call = Call;816 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;817 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;818}819820impl cumulus_pallet_xcm::Config for Runtime {821 type Event = Event;822 type XcmExecutor = XcmExecutor<XcmConfig>;823}824825impl cumulus_pallet_xcmp_queue::Config for Runtime {826 type Event = Event;827 type XcmExecutor = XcmExecutor<XcmConfig>;828 type ChannelInfo = ParachainSystem;829 type VersionWrapper = ();830 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;831 type ControllerOrigin = EnsureRoot<AccountId>;832 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;833}834835impl cumulus_pallet_dmp_queue::Config for Runtime {836 type Event = Event;837 type XcmExecutor = XcmExecutor<XcmConfig>;838 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;839}840841impl pallet_aura::Config for Runtime {842 type AuthorityId = AuraId;843 type DisabledValidators = ();844 type MaxAuthorities = MaxAuthorities;845}846847parameter_types! {848 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();849 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;850}851852impl pallet_common::Config for Runtime {853 type Event = Event;854 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;855 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;856 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;857858 type Currency = Balances;859 type CollectionCreationPrice = CollectionCreationPrice;860 type TreasuryAccountId = TreasuryAccountId;861}862863impl pallet_fungible::Config for Runtime {864 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;865}866impl pallet_refungible::Config for Runtime {867 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;868}869impl pallet_nonfungible::Config for Runtime {870 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;871}872873impl pallet_unique::Config for Runtime {874 type Event = Event;875 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;876}877878parameter_types! {879 pub const InflationBlockInterval: BlockNumber = 100; 880}881882883impl pallet_inflation::Config for Runtime {884 type Currency = Balances;885 type TreasuryAccountId = TreasuryAccountId;886 type InflationBlockInterval = InflationBlockInterval;887 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;888}889890891892893894895896type EvmSponsorshipHandler = (897 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,898 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,899);900type SponsorshipHandler = (901 pallet_unique::UniqueSponsorshipHandler<Runtime>,902 903 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,904);905906907908909910911912913914915916917918impl pallet_evm_transaction_payment::Config for Runtime {919 type EvmSponsorshipHandler = EvmSponsorshipHandler;920 type Currency = Balances;921 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;922 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;923}924925impl pallet_charge_transaction::Config for Runtime {926 type SponsorshipHandler = SponsorshipHandler;927}928929930931932933parameter_types! {934 935 pub const HelpersContractAddress: H160 = H160([936 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,937 ]);938}939940impl pallet_evm_contract_helpers::Config for Runtime {941 type ContractAddress = HelpersContractAddress;942 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;943}944945construct_runtime!(946 pub enum Runtime where947 Block = Block,948 NodeBlock = opaque::Block,949 UncheckedExtrinsic = UncheckedExtrinsic950 {951 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,952 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,953954 Aura: pallet_aura::{Pallet, Config<T>} = 22,955 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,956957 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,958 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,959 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,960 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,961 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,962 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,963 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,964 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,965 966 967968 969 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,970 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,971 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,972 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,973974 975 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,976 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,977 978 979 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,980 981 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,982 Fungible: pallet_fungible::{Pallet, Storage} = 67,983 Refungible: pallet_refungible::{Pallet, Storage} = 68,984 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,985986 987 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,988 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,989990 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,991 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,992 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,993 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,994 }995);996997pub struct TransactionConverter;998999impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1000 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1001 UncheckedExtrinsic::new_unsigned(1002 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1003 )1004 }1005}10061007impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1008 fn convert_transaction(1009 &self,1010 transaction: pallet_ethereum::Transaction,1011 ) -> opaque::UncheckedExtrinsic {1012 let extrinsic = UncheckedExtrinsic::new_unsigned(1013 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1014 );1015 let encoded = extrinsic.encode();1016 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1017 .expect("Encoded extrinsic is always valid")1018 }1019}102010211022pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10231024pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10251026pub type Block = generic::Block<Header, UncheckedExtrinsic>;10271028pub type SignedBlock = generic::SignedBlock<Block>;10291030pub type BlockId = generic::BlockId<Block>;10311032pub type SignedExtra = (1033 frame_system::CheckSpecVersion<Runtime>,1034 1035 frame_system::CheckGenesis<Runtime>,1036 frame_system::CheckEra<Runtime>,1037 frame_system::CheckNonce<Runtime>,1038 frame_system::CheckWeight<Runtime>,1039 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1040 1041);10421043pub type UncheckedExtrinsic =1044 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10451046pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10471048pub type Executive = frame_executive::Executive<1049 Runtime,1050 Block,1051 frame_system::ChainContext<Runtime>,1052 Runtime,1053 AllPalletsReversedWithSystemFirst,1054>;10551056impl_opaque_keys! {1057 pub struct SessionKeys {1058 pub aura: Aura,1059 }1060}10611062impl fp_self_contained::SelfContainedCall for Call {1063 type SignedInfo = H160;10641065 fn is_self_contained(&self) -> bool {1066 match self {1067 Call::Ethereum(call) => call.is_self_contained(),1068 _ => false,1069 }1070 }10711072 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1073 match self {1074 Call::Ethereum(call) => call.check_self_contained(),1075 _ => None,1076 }1077 }10781079 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1080 match self {1081 Call::Ethereum(call) => call.validate_self_contained(info),1082 _ => None,1083 }1084 }10851086 fn pre_dispatch_self_contained(1087 &self,1088 info: &Self::SignedInfo,1089 ) -> Option<Result<(), TransactionValidityError>> {1090 match self {1091 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1092 _ => None,1093 }1094 }10951096 fn apply_self_contained(1097 self,1098 info: Self::SignedInfo,1099 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1100 match self {1101 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1102 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1103 )),1104 _ => None,1105 }1106 }1107}11081109macro_rules! dispatch_unique_runtime {1110 ($collection:ident.$method:ident($($name:ident),*)) => {{1111 use pallet_unique::dispatch::Dispatched;11121113 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1114 let dispatch = collection.as_dyn();11151116 Ok(dispatch.$method($($name),*))1117 }};1118}1119impl_runtime_apis! {1120 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>1121 for Runtime1122 {1123 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {1124 dispatch_unique_runtime!(collection.account_tokens(account))1125 }1126 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {1127 dispatch_unique_runtime!(collection.token_exists(token))1128 }11291130 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {1131 dispatch_unique_runtime!(collection.token_owner(token))1132 }1133 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {1134 dispatch_unique_runtime!(collection.const_metadata(token))1135 }1136 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {1137 dispatch_unique_runtime!(collection.variable_metadata(token))1138 }11391140 fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {1141 dispatch_unique_runtime!(collection.collection_tokens())1142 }1143 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {1144 dispatch_unique_runtime!(collection.account_balance(account))1145 }1146 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {1147 dispatch_unique_runtime!(collection.balance(account, token))1148 }1149 fn allowance(1150 collection: CollectionId,1151 sender: CrossAccountId,1152 spender: CrossAccountId,1153 token: TokenId,1154 ) -> Result<u128, DispatchError> {1155 dispatch_unique_runtime!(collection.allowance(sender, spender, token))1156 }11571158 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {1159 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)1160 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))1161 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))1162 }1163 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {1164 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))1165 }1166 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {1167 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))1168 }1169 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {1170 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))1171 }1172 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {1173 dispatch_unique_runtime!(collection.last_token_id())1174 }1175 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {1176 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))1177 }1178 fn collection_stats() -> Result<CollectionStats, DispatchError> {1179 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())1180 }1181 }11821183 impl sp_api::Core<Block> for Runtime {1184 fn version() -> RuntimeVersion {1185 VERSION1186 }11871188 fn execute_block(block: Block) {1189 Executive::execute_block(block)1190 }11911192 fn initialize_block(header: &<Block as BlockT>::Header) {1193 Executive::initialize_block(header)1194 }1195 }11961197 impl sp_api::Metadata<Block> for Runtime {1198 fn metadata() -> OpaqueMetadata {1199 OpaqueMetadata::new(Runtime::metadata().into())1200 }1201 }12021203 impl sp_block_builder::BlockBuilder<Block> for Runtime {1204 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {1205 Executive::apply_extrinsic(extrinsic)1206 }12071208 fn finalize_block() -> <Block as BlockT>::Header {1209 Executive::finalize_block()1210 }12111212 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {1213 data.create_extrinsics()1214 }12151216 fn check_inherents(1217 block: Block,1218 data: sp_inherents::InherentData,1219 ) -> sp_inherents::CheckInherentsResult {1220 data.check_extrinsics(&block)1221 }12221223 1224 1225 1226 }12271228 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {1229 fn validate_transaction(1230 source: TransactionSource,1231 tx: <Block as BlockT>::Extrinsic,1232 hash: <Block as BlockT>::Hash,1233 ) -> TransactionValidity {1234 Executive::validate_transaction(source, tx, hash)1235 }1236 }12371238 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {1239 fn offchain_worker(header: &<Block as BlockT>::Header) {1240 Executive::offchain_worker(header)1241 }1242 }12431244 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {1245 fn chain_id() -> u64 {1246 <Runtime as pallet_evm::Config>::ChainId::get()1247 }12481249 fn account_basic(address: H160) -> EVMAccount {1250 EVM::account_basic(&address)1251 }12521253 fn gas_price() -> U256 {1254 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()1255 }12561257 fn account_code_at(address: H160) -> Vec<u8> {1258 EVM::account_codes(address)1259 }12601261 fn author() -> H160 {1262 <pallet_evm::Pallet<Runtime>>::find_author()1263 }12641265 fn storage_at(address: H160, index: U256) -> H256 {1266 let mut tmp = [0u8; 32];1267 index.to_big_endian(&mut tmp);1268 EVM::account_storages(address, H256::from_slice(&tmp[..]))1269 }12701271 #[allow(clippy::redundant_closure)]1272 fn call(1273 from: H160,1274 to: H160,1275 data: Vec<u8>,1276 value: U256,1277 gas_limit: U256,1278 max_fee_per_gas: Option<U256>,1279 max_priority_fee_per_gas: Option<U256>,1280 nonce: Option<U256>,1281 estimate: bool,1282 access_list: Option<Vec<(H160, Vec<H256>)>>,1283 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1284 let config = if estimate {1285 let mut config = <Runtime as pallet_evm::Config>::config().clone();1286 config.estimate = true;1287 Some(config)1288 } else {1289 None1290 };12911292 <Runtime as pallet_evm::Config>::Runner::call(1293 from,1294 to,1295 data,1296 value,1297 gas_limit.low_u64(),1298 max_fee_per_gas,1299 max_priority_fee_per_gas,1300 nonce,1301 access_list.unwrap_or_default(),1302 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1303 ).map_err(|err| err.into())1304 }13051306 #[allow(clippy::redundant_closure)]1307 fn create(1308 from: H160,1309 data: Vec<u8>,1310 value: U256,1311 gas_limit: U256,1312 max_fee_per_gas: Option<U256>,1313 max_priority_fee_per_gas: Option<U256>,1314 nonce: Option<U256>,1315 estimate: bool,1316 access_list: Option<Vec<(H160, Vec<H256>)>>,1317 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1318 let config = if estimate {1319 let mut config = <Runtime as pallet_evm::Config>::config().clone();1320 config.estimate = true;1321 Some(config)1322 } else {1323 None1324 };13251326 <Runtime as pallet_evm::Config>::Runner::create(1327 from,1328 data,1329 value,1330 gas_limit.low_u64(),1331 max_fee_per_gas,1332 max_priority_fee_per_gas,1333 nonce,1334 access_list.unwrap_or_default(),1335 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1336 ).map_err(|err| err.into())1337 }13381339 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1340 Ethereum::current_transaction_statuses()1341 }13421343 fn current_block() -> Option<pallet_ethereum::Block> {1344 Ethereum::current_block()1345 }13461347 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1348 Ethereum::current_receipts()1349 }13501351 fn current_all() -> (1352 Option<pallet_ethereum::Block>,1353 Option<Vec<pallet_ethereum::Receipt>>,1354 Option<Vec<TransactionStatus>>1355 ) {1356 (1357 Ethereum::current_block(),1358 Ethereum::current_receipts(),1359 Ethereum::current_transaction_statuses()1360 )1361 }13621363 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1364 xts.into_iter().filter_map(|xt| match xt.0.function {1365 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),1366 _ => None1367 }).collect()1368 }13691370 fn elasticity() -> Option<Permill> {1371 None1372 }1373 }13741375 impl sp_session::SessionKeys<Block> for Runtime {1376 fn decode_session_keys(1377 encoded: Vec<u8>,1378 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1379 SessionKeys::decode_into_raw_public_keys(&encoded)1380 }13811382 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1383 SessionKeys::generate(seed)1384 }1385 }13861387 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1388 fn slot_duration() -> sp_consensus_aura::SlotDuration {1389 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1390 }13911392 fn authorities() -> Vec<AuraId> {1393 Aura::authorities().to_vec()1394 }1395 }13961397 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1398 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {1399 ParachainSystem::collect_collation_info(header)1400 }1401 }14021403 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1404 fn account_nonce(account: AccountId) -> Index {1405 System::account_nonce(account)1406 }1407 }14081409 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1410 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1411 TransactionPayment::query_info(uxt, len)1412 }1413 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1414 TransactionPayment::query_fee_details(uxt, len)1415 }1416 }14171418 14191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459 #[cfg(feature = "runtime-benchmarks")]1460 impl frame_benchmarking::Benchmark<Block> for Runtime {1461 fn benchmark_metadata(extra: bool) -> (1462 Vec<frame_benchmarking::BenchmarkList>,1463 Vec<frame_support::traits::StorageInfo>,1464 ) {1465 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};1466 use frame_support::traits::StorageInfoTrait;14671468 let mut list = Vec::<BenchmarkList>::new();14691470 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);1471 list_benchmark!(list, extra, pallet_unique, Unique);1472 list_benchmark!(list, extra, pallet_inflation, Inflation);1473 list_benchmark!(list, extra, pallet_fungible, Fungible);1474 list_benchmark!(list, extra, pallet_refungible, Refungible);1475 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);1476 14771478 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();14791480 return (list, storage_info)1481 }14821483 fn dispatch_benchmark(1484 config: frame_benchmarking::BenchmarkConfig1485 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1486 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};14871488 let allowlist: Vec<TrackedStorageKey> = vec![1489 1490 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),1491 1492 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),1493 1494 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),1495 1496 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),1497 1498 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),1499 ];15001501 let mut batches = Vec::<BenchmarkBatch>::new();1502 let params = (&config, &allowlist);15031504 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1505 add_benchmark!(params, batches, pallet_unique, Unique);1506 add_benchmark!(params, batches, pallet_inflation, Inflation);1507 add_benchmark!(params, batches, pallet_fungible, Fungible);1508 add_benchmark!(params, batches, pallet_refungible, Refungible);1509 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);1510 15111512 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1513 Ok(batches)1514 }1515 }1516}15171518struct CheckInherents;15191520impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1521 fn check_inherents(1522 block: &Block,1523 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1524 ) -> sp_inherents::CheckInherentsResult {1525 let relay_chain_slot = relay_state_proof1526 .read_slot()1527 .expect("Could not read the relay chain slot from the proof");15281529 let inherent_data =1530 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1531 relay_chain_slot,1532 sp_std::time::Duration::from_secs(6),1533 )1534 .create_inherent_data()1535 .expect("Could not create the timestamp inherent data");15361537 inherent_data.check_extrinsics(block)1538 }1539}15401541cumulus_pallet_parachain_system::register_validate_block!(1542 Runtime = Runtime,1543 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1544 CheckInherents = CheckInherents,1545);