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::{37 AccountIdLookup, BlakeTwo256, Block as BlockT,38 AccountIdConversion, Zero,39 },40 transaction_validity::{TransactionSource, TransactionValidity},41 ApplyExtrinsicResult, RuntimeAppPublic,42};4344use sp_std::prelude::*;4546#[cfg(feature = "std")]47use sp_version::NativeVersion;48use sp_version::RuntimeVersion;49pub use pallet_transaction_payment::{50 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,51};5253pub use pallet_balances::Call as BalancesCall;54pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};55pub use frame_support::{56 construct_runtime, match_type,57 dispatch::DispatchResult,58 PalletId, parameter_types, StorageValue, ConsensusEngineId,59 traits::{60 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,61 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,62 OnUnbalanced, Randomness, FindAuthor,63 },64 weights::{65 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},66 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,67 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,68 },69};70use up_data_structs::*;717273use frame_system::{74 self as frame_system, EnsureRoot, EnsureSigned,75 limits::{BlockWeights, BlockLength},76};77use sp_arithmetic::{78 traits::{BaseArithmetic, Unsigned},79};80use smallvec::smallvec;81use codec::{Encode, Decode};82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};83use fp_rpc::TransactionStatus;84use sp_runtime::{85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86 transaction_validity::TransactionValidityError,87 SaturatedConversion,88};899091pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;929394use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm_builder::{98 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,100 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,101 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,102 ParentIsPreset,103};104use xcm_executor::{Config, XcmExecutor, Assets};105use sp_std::{marker::PhantomData};106107use xcm::latest::{108 109 AssetId::{Concrete},110 Fungibility::Fungible as XcmFungible,111 MultiAsset,112 Error as XcmError,113};114use xcm_executor::traits::{MatchesFungible, WeightTrader};115116use sp_runtime::traits::CheckedConversion;117118use unique_runtime_common::{119 types::*,120 constants::*,121};122123124125126pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;127128129130131132pub mod opaque {133 use sp_std::prelude::*;134 use sp_runtime::impl_opaque_keys;135 use super::Aura;136137 pub use unique_runtime_common::types::*;138 pub use super::CrossAccountId;139140 impl_opaque_keys! {141 pub struct SessionKeys {142 pub aura: Aura,143 }144 }145}146147148pub const VERSION: RuntimeVersion = RuntimeVersion {149 spec_name: create_runtime_str!("opal"),150 impl_name: create_runtime_str!("opal"),151 authoring_version: 1,152 spec_version: 917004,153 impl_version: 0,154 apis: RUNTIME_API_VERSIONS,155 transaction_version: 1,156 state_version: 0,157};158159#[derive(codec::Encode, codec::Decode)]160pub enum XCMPMessage<XAccountId, XBalance> {161 162 TransferToken(XAccountId, XBalance),163}164165166#[cfg(feature = "std")]167pub fn native_version() -> NativeVersion {168 NativeVersion {169 runtime_version: VERSION,170 can_author_with: Default::default(),171 }172}173174type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;175176pub struct DealWithFees;177impl OnUnbalanced<NegativeImbalance> for DealWithFees {178 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {179 if let Some(fees) = fees_then_tips.next() {180 181 let mut split = fees.ration(100, 0);182 if let Some(tips) = fees_then_tips.next() {183 184 tips.ration_merge_into(100, 0, &mut split);185 }186 Treasury::on_unbalanced(split.0);187 188 }189 }190}191192parameter_types! {193 pub const BlockHashCount: BlockNumber = 2400;194 pub RuntimeBlockLength: BlockLength =195 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);196 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);197 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;198 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()199 .base_block(BlockExecutionWeight::get())200 .for_class(DispatchClass::all(), |weights| {201 weights.base_extrinsic = ExtrinsicBaseWeight::get();202 })203 .for_class(DispatchClass::Normal, |weights| {204 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);205 })206 .for_class(DispatchClass::Operational, |weights| {207 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);208 209 210 weights.reserved = Some(211 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT212 );213 })214 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)215 .build_or_panic();216 pub const Version: RuntimeVersion = VERSION;217 pub const SS58Prefix: u8 = 42;218}219220221222223224225parameter_types! {226 pub const ChainId: u64 = 8882;227}228229pub struct FixedFee;230impl FeeCalculator for FixedFee {231 fn min_gas_price() -> U256 {232 233 1_018_751_825_264u64.into()234 }235}236237238239240parameter_types! {241 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;242 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;243 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();244}245246247248249const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);250parameter_types! {251 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());252}253254pub enum FixedGasWeightMapping {}255impl GasWeightMapping for FixedGasWeightMapping {256 fn gas_to_weight(gas: u64) -> Weight {257 gas.saturating_mul(WeightPerGas::get())258 }259 fn weight_to_gas(weight: Weight) -> u64 {260 weight / WeightPerGas::get()261 }262}263264impl pallet_evm::Config for Runtime {265 type BlockGasLimit = BlockGasLimit;266 type FeeCalculator = FixedFee;267 type GasWeightMapping = FixedGasWeightMapping;268 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;269 type CallOrigin = EnsureAddressTruncated;270 type WithdrawOrigin = EnsureAddressTruncated;271 type AddressMapping = HashedAddressMapping<Self::Hashing>;272 type PrecompilesType = ();273 type PrecompilesValue = ();274 type Currency = Balances;275 type Event = Event;276 type OnMethodCall = (277 pallet_evm_migration::OnMethodCall<Self>,278 pallet_unique::UniqueErcSupport<Self>,279 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,280 );281 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;282 type ChainId = ChainId;283 type Runner = pallet_evm::runner::stack::Runner<Self>;284 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;285 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;286 type FindAuthor = EthereumFindAuthor<Aura>;287}288289impl pallet_evm_migration::Config for Runtime {290 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;291}292293pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);294impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {295 fn find_author<'a, I>(digests: I) -> Option<H160>296 where297 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,298 {299 if let Some(author_index) = F::find_author(digests) {300 let authority_id = Aura::authorities()[author_index as usize].clone();301 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));302 }303 None304 }305}306307impl pallet_ethereum::Config for Runtime {308 type Event = Event;309 type StateRoot = pallet_ethereum::IntermediateStateRoot;310}311312impl pallet_randomness_collective_flip::Config for Runtime {}313314impl frame_system::Config for Runtime {315 316 type AccountData = pallet_balances::AccountData<Balance>;317 318 type AccountId = AccountId;319 320 type BaseCallFilter = Everything;321 322 type BlockHashCount = BlockHashCount;323 324 type BlockLength = RuntimeBlockLength;325 326 type BlockNumber = BlockNumber;327 328 type BlockWeights = RuntimeBlockWeights;329 330 type Call = Call;331 332 type DbWeight = RocksDbWeight;333 334 type Event = Event;335 336 type Hash = Hash;337 338 type Hashing = BlakeTwo256;339 340 type Header = generic::Header<BlockNumber, BlakeTwo256>;341 342 type Index = Index;343 344 type Lookup = AccountIdLookup<AccountId, ()>;345 346 type OnKilledAccount = ();347 348 type OnNewAccount = ();349 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;350 351 type Origin = Origin;352 353 type PalletInfo = PalletInfo;354 355 type SS58Prefix = SS58Prefix;356 357 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;358 359 type Version = Version;360 type MaxConsumers = ConstU32<16>;361}362363parameter_types! {364 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;365}366367impl pallet_timestamp::Config for Runtime {368 369 type Moment = u64;370 type OnTimestampSet = ();371 type MinimumPeriod = MinimumPeriod;372 type WeightInfo = ();373}374375parameter_types! {376 377 pub const ExistentialDeposit: u128 = 0;378 pub const MaxLocks: u32 = 50;379}380381impl pallet_balances::Config for Runtime {382 type MaxLocks = MaxLocks;383 type MaxReserves = ();384 type ReserveIdentifier = [u8; 8];385 386 type Balance = Balance;387 388 type Event = Event;389 type DustRemoval = Treasury;390 type ExistentialDeposit = ExistentialDeposit;391 type AccountStore = System;392 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;393}394395pub const MICROUNIQUE: Balance = 1_000_000_000_000;396pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;397pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;398pub const UNIQUE: Balance = 100 * CENTIUNIQUE;399400pub const fn deposit(items: u32, bytes: u32) -> Balance {401 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE402}403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454parameter_types! {455 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; 456 457 458 pub const OperationalFeeMultiplier: u8 = 5;459}460461462pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);463464impl<T> WeightToFeePolynomial for LinearFee<T>465where466 T: BaseArithmetic + From<u32> + Copy + Unsigned,467{468 type Balance = T;469470 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {471 smallvec!(WeightToFeeCoefficient {472 473 coeff_integer: 142_688_000u32.into(),474 coeff_frac: Perbill::zero(),475 negative: false,476 degree: 1,477 })478 }479}480481impl pallet_transaction_payment::Config for Runtime {482 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;483 type TransactionByteFee = TransactionByteFee;484 type OperationalFeeMultiplier = OperationalFeeMultiplier;485 type WeightToFee = LinearFee<Balance>;486 type FeeMultiplierUpdate = ();487}488489parameter_types! {490 pub const ProposalBond: Permill = Permill::from_percent(5);491 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;492 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;493 pub const SpendPeriod: BlockNumber = 5 * MINUTES;494 pub const Burn: Permill = Permill::from_percent(0);495 pub const TipCountdown: BlockNumber = 1 * DAYS;496 pub const TipFindersFee: Percent = Percent::from_percent(20);497 pub const TipReportDepositBase: Balance = 1 * UNIQUE;498 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;499 pub const BountyDepositBase: Balance = 1 * UNIQUE;500 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;501 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");502 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;503 pub const MaximumReasonLength: u32 = 16384;504 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);505 pub const BountyValueMinimum: Balance = 5 * UNIQUE;506 pub const MaxApprovals: u32 = 100;507}508509impl pallet_treasury::Config for Runtime {510 type PalletId = TreasuryModuleId;511 type Currency = Balances;512 type ApproveOrigin = EnsureRoot<AccountId>;513 type RejectOrigin = EnsureRoot<AccountId>;514 type Event = Event;515 type OnSlash = ();516 type ProposalBond = ProposalBond;517 type ProposalBondMinimum = ProposalBondMinimum;518 type ProposalBondMaximum = ProposalBondMaximum;519 type SpendPeriod = SpendPeriod;520 type Burn = Burn;521 type BurnDestination = ();522 type SpendFunds = ();523 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;524 type MaxApprovals = MaxApprovals;525}526527impl pallet_sudo::Config for Runtime {528 type Event = Event;529 type Call = Call;530}531532pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);533534impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider535 for RelayChainBlockNumberProvider<T>536{537 type BlockNumber = BlockNumber;538539 fn current_block_number() -> Self::BlockNumber {540 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()541 .map(|d| d.relay_parent_number)542 .unwrap_or_default()543 }544}545546parameter_types! {547 pub const MinVestedTransfer: Balance = 10 * UNIQUE;548 pub const MaxVestingSchedules: u32 = 28;549}550551impl orml_vesting::Config for Runtime {552 type Event = Event;553 type Currency = pallet_balances::Pallet<Runtime>;554 type MinVestedTransfer = MinVestedTransfer;555 type VestedTransferOrigin = EnsureSigned<AccountId>;556 type WeightInfo = ();557 type MaxVestingSchedules = MaxVestingSchedules;558 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;559}560561parameter_types! {562 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;563 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;564}565566impl cumulus_pallet_parachain_system::Config for Runtime {567 type Event = Event;568 type SelfParaId = parachain_info::Pallet<Self>;569 type OnSystemEvent = ();570 571 572 573 574 575 type OutboundXcmpMessageSource = XcmpQueue;576 type DmpMessageHandler = DmpQueue;577 type ReservedDmpWeight = ReservedDmpWeight;578 type ReservedXcmpWeight = ReservedXcmpWeight;579 type XcmpMessageHandler = XcmpQueue;580}581582impl parachain_info::Config for Runtime {}583584impl cumulus_pallet_aura_ext::Config for Runtime {}585586parameter_types! {587 pub const RelayLocation: MultiLocation = MultiLocation::parent();588 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;589 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();590 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();591}592593594595596pub type LocationToAccountId = (597 598 ParentIsPreset<AccountId>,599 600 SiblingParachainConvertsVia<Sibling, AccountId>,601 602 AccountId32Aliases<RelayNetwork, AccountId>,603);604605pub struct OnlySelfCurrency;606impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {607 fn matches_fungible(a: &MultiAsset) -> Option<B> {608 match (&a.id, &a.fun) {609 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),610 _ => None,611 }612 }613}614615616pub type LocalAssetTransactor = CurrencyAdapter<617 618 Balances,619 620 OnlySelfCurrency,621 622 LocationToAccountId,623 624 AccountId,625 626 (),627>;628629630631632pub type XcmOriginToTransactDispatchOrigin = (633 634 635 636 SovereignSignedViaLocation<LocationToAccountId, Origin>,637 638 639 RelayChainAsNative<RelayOrigin, Origin>,640 641 642 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,643 644 645 ParentAsSuperuser<Origin>,646 647 648 SignedAccountId32AsNative<RelayNetwork, Origin>,649 650 XcmPassthrough<Origin>,651);652653parameter_types! {654 655 pub UnitWeightCost: Weight = 1_000_000;656 657 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);658 pub const MaxInstructions: u32 = 100;659 pub const MaxAuthorities: u32 = 100_000;660}661662match_type! {663 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {664 MultiLocation { parents: 1, interior: Here } |665 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }666 };667}668669pub type Barrier = (670 TakeWeightCredit,671 AllowTopLevelPaidExecutionFrom<Everything>,672 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,673 674);675676pub struct UsingOnlySelfCurrencyComponents<677 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,678 AssetId: Get<MultiLocation>,679 AccountId,680 Currency: CurrencyT<AccountId>,681 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,682>(683 Weight,684 Currency::Balance,685 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,686);687impl<688 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,689 AssetId: Get<MultiLocation>,690 AccountId,691 Currency: CurrencyT<AccountId>,692 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,693 > WeightTrader694 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>695{696 fn new() -> Self {697 Self(0, Zero::zero(), PhantomData)698 }699700 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {701 let amount = WeightToFee::calc(&weight);702 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;703704 705 let option1: xcm::v1::AssetId = Concrete(MultiLocation {706 parents: 1,707 interior: X1(Parachain(ParachainInfo::parachain_id().into())),708 });709 710 let option2: xcm::v1::AssetId = Concrete(MultiLocation {711 parents: 0,712 interior: Here,713 });714715 let required = if payment.fungible.contains_key(&option1) {716 (option1, u128_amount).into()717 } else if payment.fungible.contains_key(&option2) {718 (option2, u128_amount).into()719 } else {720 (Concrete(MultiLocation::default()), u128_amount).into()721 };722723 let unused = payment724 .checked_sub(required)725 .map_err(|_| XcmError::TooExpensive)?;726 self.0 = self.0.saturating_add(weight);727 self.1 = self.1.saturating_add(amount);728 Ok(unused)729 }730731 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {732 let weight = weight.min(self.0);733 let amount = WeightToFee::calc(&weight);734 self.0 -= weight;735 self.1 = self.1.saturating_sub(amount);736 let amount: u128 = amount.saturated_into();737 if amount > 0 {738 Some((AssetId::get(), amount).into())739 } else {740 None741 }742 }743}744impl<745 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,746 AssetId: Get<MultiLocation>,747 AccountId,748 Currency: CurrencyT<AccountId>,749 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,750 > Drop751 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>752{753 fn drop(&mut self) {754 OnUnbalanced::on_unbalanced(Currency::issue(self.1));755 }756}757758pub struct XcmConfig;759impl Config for XcmConfig {760 type Call = Call;761 type XcmSender = XcmRouter;762 763 type AssetTransactor = LocalAssetTransactor;764 type OriginConverter = XcmOriginToTransactDispatchOrigin;765 type IsReserve = NativeAsset;766 type IsTeleporter = (); 767 type LocationInverter = LocationInverter<Ancestry>;768 type Barrier = Barrier;769 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;770 type Trader = UsingOnlySelfCurrencyComponents<771 IdentityFee<Balance>,772 RelayLocation,773 AccountId,774 Balances,775 (),776 >;777 type ResponseHandler = (); 778 type SubscriptionService = PolkadotXcm;779780 type AssetTrap = PolkadotXcm;781 type AssetClaims = PolkadotXcm;782}783784785786787788789pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);790791792793pub type XcmRouter = (794 795 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,796 797 XcmpQueue,798);799800impl pallet_evm_coder_substrate::Config for Runtime {801 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;802 type GasWeightMapping = FixedGasWeightMapping;803}804805impl pallet_xcm::Config for Runtime {806 type Event = Event;807 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;808 type XcmRouter = XcmRouter;809 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;810 type XcmExecuteFilter = Everything;811 type XcmExecutor = XcmExecutor<XcmConfig>;812 type XcmTeleportFilter = Everything;813 type XcmReserveTransferFilter = Everything;814 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;815 type LocationInverter = LocationInverter<Ancestry>;816 type Origin = Origin;817 type Call = Call;818 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;819 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;820}821822impl cumulus_pallet_xcm::Config for Runtime {823 type Event = Event;824 type XcmExecutor = XcmExecutor<XcmConfig>;825}826827impl cumulus_pallet_xcmp_queue::Config for Runtime {828 type Event = Event;829 type XcmExecutor = XcmExecutor<XcmConfig>;830 type ChannelInfo = ParachainSystem;831 type VersionWrapper = ();832 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;833 type ControllerOrigin = EnsureRoot<AccountId>;834 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;835}836837impl cumulus_pallet_dmp_queue::Config for Runtime {838 type Event = Event;839 type XcmExecutor = XcmExecutor<XcmConfig>;840 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;841}842843impl pallet_aura::Config for Runtime {844 type AuthorityId = AuraId;845 type DisabledValidators = ();846 type MaxAuthorities = MaxAuthorities;847}848849parameter_types! {850 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();851 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;852}853854impl pallet_common::Config for Runtime {855 type Event = Event;856 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;857 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;858 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;859860 type Currency = Balances;861 type CollectionCreationPrice = CollectionCreationPrice;862 type TreasuryAccountId = TreasuryAccountId;863}864865impl pallet_fungible::Config for Runtime {866 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;867}868impl pallet_refungible::Config for Runtime {869 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;870}871impl pallet_nonfungible::Config for Runtime {872 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;873}874875impl pallet_unique::Config for Runtime {876 type Event = Event;877 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;878}879880parameter_types! {881 pub const InflationBlockInterval: BlockNumber = 100; 882}883884885impl pallet_inflation::Config for Runtime {886 type Currency = Balances;887 type TreasuryAccountId = TreasuryAccountId;888 type InflationBlockInterval = InflationBlockInterval;889 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;890}891892893894895896897898type EvmSponsorshipHandler = (899 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,900 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,901);902type SponsorshipHandler = (903 pallet_unique::UniqueSponsorshipHandler<Runtime>,904 905 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,906);907908909910911912913914915916917918919920impl pallet_evm_transaction_payment::Config for Runtime {921 type EvmSponsorshipHandler = EvmSponsorshipHandler;922 type Currency = Balances;923 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;924 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;925}926927impl pallet_charge_transaction::Config for Runtime {928 type SponsorshipHandler = SponsorshipHandler;929}930931932933934935parameter_types! {936 937 pub const HelpersContractAddress: H160 = H160([938 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,939 ]);940}941942impl pallet_evm_contract_helpers::Config for Runtime {943 type ContractAddress = HelpersContractAddress;944 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;945}946947construct_runtime!(948 pub enum Runtime where949 Block = Block,950 NodeBlock = opaque::Block,951 UncheckedExtrinsic = UncheckedExtrinsic952 {953 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,954 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,955956 Aura: pallet_aura::{Pallet, Config<T>} = 22,957 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,958959 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,960 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,961 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,962 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,963 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,964 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,965 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,966 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,967 968 969970 971 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,972 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,973 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,974 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,975976 977 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,978 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,979 980 981 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,982 983 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,984 Fungible: pallet_fungible::{Pallet, Storage} = 67,985 Refungible: pallet_refungible::{Pallet, Storage} = 68,986 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,987988 989 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,990 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,991992 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,993 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,994 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,995 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,996 }997);998999pub struct TransactionConverter;10001001impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1002 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1003 UncheckedExtrinsic::new_unsigned(1004 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1005 )1006 }1007}10081009impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1010 fn convert_transaction(1011 &self,1012 transaction: pallet_ethereum::Transaction,1013 ) -> opaque::UncheckedExtrinsic {1014 let extrinsic = UncheckedExtrinsic::new_unsigned(1015 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1016 );1017 let encoded = extrinsic.encode();1018 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1019 .expect("Encoded extrinsic is always valid")1020 }1021}102210231024pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10251026pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10271028pub type Block = generic::Block<Header, UncheckedExtrinsic>;10291030pub type SignedBlock = generic::SignedBlock<Block>;10311032pub type BlockId = generic::BlockId<Block>;10331034pub type SignedExtra = (1035 frame_system::CheckSpecVersion<Runtime>,1036 1037 frame_system::CheckGenesis<Runtime>,1038 frame_system::CheckEra<Runtime>,1039 frame_system::CheckNonce<Runtime>,1040 frame_system::CheckWeight<Runtime>,1041 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1042 1043);10441045pub type UncheckedExtrinsic =1046 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10471048pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10491050pub type Executive = frame_executive::Executive<1051 Runtime,1052 Block,1053 frame_system::ChainContext<Runtime>,1054 Runtime,1055 AllPalletsReversedWithSystemFirst,1056>;10571058impl_opaque_keys! {1059 pub struct SessionKeys {1060 pub aura: Aura,1061 }1062}10631064impl fp_self_contained::SelfContainedCall for Call {1065 type SignedInfo = H160;10661067 fn is_self_contained(&self) -> bool {1068 match self {1069 Call::Ethereum(call) => call.is_self_contained(),1070 _ => false,1071 }1072 }10731074 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1075 match self {1076 Call::Ethereum(call) => call.check_self_contained(),1077 _ => None,1078 }1079 }10801081 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1082 match self {1083 Call::Ethereum(call) => call.validate_self_contained(info),1084 _ => None,1085 }1086 }10871088 fn pre_dispatch_self_contained(1089 &self,1090 info: &Self::SignedInfo,1091 ) -> Option<Result<(), TransactionValidityError>> {1092 match self {1093 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1094 _ => None,1095 }1096 }10971098 fn apply_self_contained(1099 self,1100 info: Self::SignedInfo,1101 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1102 match self {1103 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1104 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1105 )),1106 _ => None,1107 }1108 }1109}11101111macro_rules! dispatch_unique_runtime {1112 ($collection:ident.$method:ident($($name:ident),*)) => {{1113 use pallet_unique::dispatch::Dispatched;11141115 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1116 let dispatch = collection.as_dyn();11171118 Ok(dispatch.$method($($name),*))1119 }};1120}1121impl_runtime_apis! {1122 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>1123 for Runtime1124 {1125 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {1126 dispatch_unique_runtime!(collection.account_tokens(account))1127 }1128 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {1129 dispatch_unique_runtime!(collection.token_exists(token))1130 }11311132 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {1133 dispatch_unique_runtime!(collection.token_owner(token))1134 }1135 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {1136 dispatch_unique_runtime!(collection.const_metadata(token))1137 }1138 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {1139 dispatch_unique_runtime!(collection.variable_metadata(token))1140 }11411142 fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {1143 dispatch_unique_runtime!(collection.collection_tokens())1144 }1145 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {1146 dispatch_unique_runtime!(collection.account_balance(account))1147 }1148 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {1149 dispatch_unique_runtime!(collection.balance(account, token))1150 }1151 fn allowance(1152 collection: CollectionId,1153 sender: CrossAccountId,1154 spender: CrossAccountId,1155 token: TokenId,1156 ) -> Result<u128, DispatchError> {1157 dispatch_unique_runtime!(collection.allowance(sender, spender, token))1158 }11591160 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {1161 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)1162 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))1163 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))1164 }1165 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {1166 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))1167 }1168 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {1169 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))1170 }1171 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {1172 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))1173 }1174 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {1175 dispatch_unique_runtime!(collection.last_token_id())1176 }1177 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {1178 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))1179 }1180 fn collection_stats() -> Result<CollectionStats, DispatchError> {1181 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())1182 }1183 }11841185 impl sp_api::Core<Block> for Runtime {1186 fn version() -> RuntimeVersion {1187 VERSION1188 }11891190 fn execute_block(block: Block) {1191 Executive::execute_block(block)1192 }11931194 fn initialize_block(header: &<Block as BlockT>::Header) {1195 Executive::initialize_block(header)1196 }1197 }11981199 impl sp_api::Metadata<Block> for Runtime {1200 fn metadata() -> OpaqueMetadata {1201 OpaqueMetadata::new(Runtime::metadata().into())1202 }1203 }12041205 impl sp_block_builder::BlockBuilder<Block> for Runtime {1206 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {1207 Executive::apply_extrinsic(extrinsic)1208 }12091210 fn finalize_block() -> <Block as BlockT>::Header {1211 Executive::finalize_block()1212 }12131214 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {1215 data.create_extrinsics()1216 }12171218 fn check_inherents(1219 block: Block,1220 data: sp_inherents::InherentData,1221 ) -> sp_inherents::CheckInherentsResult {1222 data.check_extrinsics(&block)1223 }12241225 1226 1227 1228 }12291230 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {1231 fn validate_transaction(1232 source: TransactionSource,1233 tx: <Block as BlockT>::Extrinsic,1234 hash: <Block as BlockT>::Hash,1235 ) -> TransactionValidity {1236 Executive::validate_transaction(source, tx, hash)1237 }1238 }12391240 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {1241 fn offchain_worker(header: &<Block as BlockT>::Header) {1242 Executive::offchain_worker(header)1243 }1244 }12451246 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {1247 fn chain_id() -> u64 {1248 <Runtime as pallet_evm::Config>::ChainId::get()1249 }12501251 fn account_basic(address: H160) -> EVMAccount {1252 EVM::account_basic(&address)1253 }12541255 fn gas_price() -> U256 {1256 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()1257 }12581259 fn account_code_at(address: H160) -> Vec<u8> {1260 EVM::account_codes(address)1261 }12621263 fn author() -> H160 {1264 <pallet_evm::Pallet<Runtime>>::find_author()1265 }12661267 fn storage_at(address: H160, index: U256) -> H256 {1268 let mut tmp = [0u8; 32];1269 index.to_big_endian(&mut tmp);1270 EVM::account_storages(address, H256::from_slice(&tmp[..]))1271 }12721273 #[allow(clippy::redundant_closure)]1274 fn call(1275 from: H160,1276 to: H160,1277 data: Vec<u8>,1278 value: U256,1279 gas_limit: U256,1280 max_fee_per_gas: Option<U256>,1281 max_priority_fee_per_gas: Option<U256>,1282 nonce: Option<U256>,1283 estimate: bool,1284 access_list: Option<Vec<(H160, Vec<H256>)>>,1285 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1286 let config = if estimate {1287 let mut config = <Runtime as pallet_evm::Config>::config().clone();1288 config.estimate = true;1289 Some(config)1290 } else {1291 None1292 };12931294 <Runtime as pallet_evm::Config>::Runner::call(1295 from,1296 to,1297 data,1298 value,1299 gas_limit.low_u64(),1300 max_fee_per_gas,1301 max_priority_fee_per_gas,1302 nonce,1303 access_list.unwrap_or_default(),1304 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1305 ).map_err(|err| err.into())1306 }13071308 #[allow(clippy::redundant_closure)]1309 fn create(1310 from: H160,1311 data: Vec<u8>,1312 value: U256,1313 gas_limit: U256,1314 max_fee_per_gas: Option<U256>,1315 max_priority_fee_per_gas: Option<U256>,1316 nonce: Option<U256>,1317 estimate: bool,1318 access_list: Option<Vec<(H160, Vec<H256>)>>,1319 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1320 let config = if estimate {1321 let mut config = <Runtime as pallet_evm::Config>::config().clone();1322 config.estimate = true;1323 Some(config)1324 } else {1325 None1326 };13271328 <Runtime as pallet_evm::Config>::Runner::create(1329 from,1330 data,1331 value,1332 gas_limit.low_u64(),1333 max_fee_per_gas,1334 max_priority_fee_per_gas,1335 nonce,1336 access_list.unwrap_or_default(),1337 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1338 ).map_err(|err| err.into())1339 }13401341 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1342 Ethereum::current_transaction_statuses()1343 }13441345 fn current_block() -> Option<pallet_ethereum::Block> {1346 Ethereum::current_block()1347 }13481349 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1350 Ethereum::current_receipts()1351 }13521353 fn current_all() -> (1354 Option<pallet_ethereum::Block>,1355 Option<Vec<pallet_ethereum::Receipt>>,1356 Option<Vec<TransactionStatus>>1357 ) {1358 (1359 Ethereum::current_block(),1360 Ethereum::current_receipts(),1361 Ethereum::current_transaction_statuses()1362 )1363 }13641365 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1366 xts.into_iter().filter_map(|xt| match xt.0.function {1367 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),1368 _ => None1369 }).collect()1370 }13711372 fn elasticity() -> Option<Permill> {1373 None1374 }1375 }13761377 impl sp_session::SessionKeys<Block> for Runtime {1378 fn decode_session_keys(1379 encoded: Vec<u8>,1380 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1381 SessionKeys::decode_into_raw_public_keys(&encoded)1382 }13831384 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1385 SessionKeys::generate(seed)1386 }1387 }13881389 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1390 fn slot_duration() -> sp_consensus_aura::SlotDuration {1391 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1392 }13931394 fn authorities() -> Vec<AuraId> {1395 Aura::authorities().to_vec()1396 }1397 }13981399 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1400 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {1401 ParachainSystem::collect_collation_info(header)1402 }1403 }14041405 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1406 fn account_nonce(account: AccountId) -> Index {1407 System::account_nonce(account)1408 }1409 }14101411 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1412 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1413 TransactionPayment::query_info(uxt, len)1414 }1415 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1416 TransactionPayment::query_fee_details(uxt, len)1417 }1418 }14191420 14211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461 #[cfg(feature = "runtime-benchmarks")]1462 impl frame_benchmarking::Benchmark<Block> for Runtime {1463 fn benchmark_metadata(extra: bool) -> (1464 Vec<frame_benchmarking::BenchmarkList>,1465 Vec<frame_support::traits::StorageInfo>,1466 ) {1467 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};1468 use frame_support::traits::StorageInfoTrait;14691470 let mut list = Vec::<BenchmarkList>::new();14711472 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);1473 list_benchmark!(list, extra, pallet_unique, Unique);1474 list_benchmark!(list, extra, pallet_inflation, Inflation);1475 list_benchmark!(list, extra, pallet_fungible, Fungible);1476 list_benchmark!(list, extra, pallet_refungible, Refungible);1477 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);1478 14791480 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();14811482 return (list, storage_info)1483 }14841485 fn dispatch_benchmark(1486 config: frame_benchmarking::BenchmarkConfig1487 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1488 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};14891490 let allowlist: Vec<TrackedStorageKey> = vec![1491 1492 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),1493 1494 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),1495 1496 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),1497 1498 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),1499 1500 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),1501 ];15021503 let mut batches = Vec::<BenchmarkBatch>::new();1504 let params = (&config, &allowlist);15051506 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1507 add_benchmark!(params, batches, pallet_unique, Unique);1508 add_benchmark!(params, batches, pallet_inflation, Inflation);1509 add_benchmark!(params, batches, pallet_fungible, Fungible);1510 add_benchmark!(params, batches, pallet_refungible, Refungible);1511 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);1512 15131514 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1515 Ok(batches)1516 }1517 }1518}15191520struct CheckInherents;15211522impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1523 fn check_inherents(1524 block: &Block,1525 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1526 ) -> sp_inherents::CheckInherentsResult {1527 let relay_chain_slot = relay_state_proof1528 .read_slot()1529 .expect("Could not read the relay chain slot from the proof");15301531 let inherent_data =1532 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1533 relay_chain_slot,1534 sp_std::time::Duration::from_secs(6),1535 )1536 .create_inherent_data()1537 .expect("Could not create the timestamp inherent data");15381539 inherent_data.check_extrinsics(block)1540 }1541}15421543cumulus_pallet_parachain_system::register_validate_block!(1544 Runtime = Runtime,1545 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1546 CheckInherents = CheckInherents,1547);