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 const RUNTIME_NAME: &'static str = "Opal";127128pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;129130131132133134pub mod opaque {135 use sp_std::prelude::*;136 use sp_runtime::impl_opaque_keys;137 use super::Aura;138139 pub use unique_runtime_common::types::*;140 pub use super::CrossAccountId;141142 impl_opaque_keys! {143 pub struct SessionKeys {144 pub aura: Aura,145 }146 }147}148149150pub const VERSION: RuntimeVersion = RuntimeVersion {151 spec_name: create_runtime_str!("opal"),152 impl_name: create_runtime_str!("opal"),153 authoring_version: 1,154 spec_version: 917004,155 impl_version: 0,156 apis: RUNTIME_API_VERSIONS,157 transaction_version: 1,158 state_version: 0,159};160161#[derive(codec::Encode, codec::Decode)]162pub enum XCMPMessage<XAccountId, XBalance> {163 164 TransferToken(XAccountId, XBalance),165}166167168#[cfg(feature = "std")]169pub fn native_version() -> NativeVersion {170 NativeVersion {171 runtime_version: VERSION,172 can_author_with: Default::default(),173 }174}175176type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;177178pub struct DealWithFees;179impl OnUnbalanced<NegativeImbalance> for DealWithFees {180 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {181 if let Some(fees) = fees_then_tips.next() {182 183 let mut split = fees.ration(100, 0);184 if let Some(tips) = fees_then_tips.next() {185 186 tips.ration_merge_into(100, 0, &mut split);187 }188 Treasury::on_unbalanced(split.0);189 190 }191 }192}193194parameter_types! {195 pub const BlockHashCount: BlockNumber = 2400;196 pub RuntimeBlockLength: BlockLength =197 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);198 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);199 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;200 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()201 .base_block(BlockExecutionWeight::get())202 .for_class(DispatchClass::all(), |weights| {203 weights.base_extrinsic = ExtrinsicBaseWeight::get();204 })205 .for_class(DispatchClass::Normal, |weights| {206 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);207 })208 .for_class(DispatchClass::Operational, |weights| {209 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);210 211 212 weights.reserved = Some(213 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT214 );215 })216 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)217 .build_or_panic();218 pub const Version: RuntimeVersion = VERSION;219 pub const SS58Prefix: u8 = 42;220}221222223224225226227parameter_types! {228 pub const ChainId: u64 = 8882;229}230231pub struct FixedFee;232impl FeeCalculator for FixedFee {233 fn min_gas_price() -> U256 {234 235 1_018_751_825_264u64.into()236 }237}238239240241242parameter_types! {243 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;244 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;245 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();246}247248249250251const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);252parameter_types! {253 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());254}255256pub enum FixedGasWeightMapping {}257impl GasWeightMapping for FixedGasWeightMapping {258 fn gas_to_weight(gas: u64) -> Weight {259 gas.saturating_mul(WeightPerGas::get())260 }261 fn weight_to_gas(weight: Weight) -> u64 {262 weight / WeightPerGas::get()263 }264}265266impl pallet_evm::Config for Runtime {267 type BlockGasLimit = BlockGasLimit;268 type FeeCalculator = FixedFee;269 type GasWeightMapping = FixedGasWeightMapping;270 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;271 type CallOrigin = EnsureAddressTruncated;272 type WithdrawOrigin = EnsureAddressTruncated;273 type AddressMapping = HashedAddressMapping<Self::Hashing>;274 type PrecompilesType = ();275 type PrecompilesValue = ();276 type Currency = Balances;277 type Event = Event;278 type OnMethodCall = (279 pallet_evm_migration::OnMethodCall<Self>,280 pallet_unique::UniqueErcSupport<Self>,281 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,282 );283 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;284 type ChainId = ChainId;285 type Runner = pallet_evm::runner::stack::Runner<Self>;286 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;287 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;288 type FindAuthor = EthereumFindAuthor<Aura>;289}290291impl pallet_evm_migration::Config for Runtime {292 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;293}294295pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);296impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {297 fn find_author<'a, I>(digests: I) -> Option<H160>298 where299 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,300 {301 if let Some(author_index) = F::find_author(digests) {302 let authority_id = Aura::authorities()[author_index as usize].clone();303 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));304 }305 None306 }307}308309impl pallet_ethereum::Config for Runtime {310 type Event = Event;311 type StateRoot = pallet_ethereum::IntermediateStateRoot;312}313314impl pallet_randomness_collective_flip::Config for Runtime {}315316impl frame_system::Config for Runtime {317 318 type AccountData = pallet_balances::AccountData<Balance>;319 320 type AccountId = AccountId;321 322 type BaseCallFilter = Everything;323 324 type BlockHashCount = BlockHashCount;325 326 type BlockLength = RuntimeBlockLength;327 328 type BlockNumber = BlockNumber;329 330 type BlockWeights = RuntimeBlockWeights;331 332 type Call = Call;333 334 type DbWeight = RocksDbWeight;335 336 type Event = Event;337 338 type Hash = Hash;339 340 type Hashing = BlakeTwo256;341 342 type Header = generic::Header<BlockNumber, BlakeTwo256>;343 344 type Index = Index;345 346 type Lookup = AccountIdLookup<AccountId, ()>;347 348 type OnKilledAccount = ();349 350 type OnNewAccount = ();351 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;352 353 type Origin = Origin;354 355 type PalletInfo = PalletInfo;356 357 type SS58Prefix = SS58Prefix;358 359 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;360 361 type Version = Version;362 type MaxConsumers = ConstU32<16>;363}364365parameter_types! {366 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;367}368369impl pallet_timestamp::Config for Runtime {370 371 type Moment = u64;372 type OnTimestampSet = ();373 type MinimumPeriod = MinimumPeriod;374 type WeightInfo = ();375}376377parameter_types! {378 379 pub const ExistentialDeposit: u128 = 0;380 pub const MaxLocks: u32 = 50;381}382383impl pallet_balances::Config for Runtime {384 type MaxLocks = MaxLocks;385 type MaxReserves = ();386 type ReserveIdentifier = [u8; 8];387 388 type Balance = Balance;389 390 type Event = Event;391 type DustRemoval = Treasury;392 type ExistentialDeposit = ExistentialDeposit;393 type AccountStore = System;394 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;395}396397pub const MICROUNIQUE: Balance = 1_000_000_000_000;398pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;399pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;400pub const UNIQUE: Balance = 100 * CENTIUNIQUE;401402pub const fn deposit(items: u32, bytes: u32) -> Balance {403 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE404}405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456parameter_types! {457 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; 458 459 460 pub const OperationalFeeMultiplier: u8 = 5;461}462463464pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);465466impl<T> WeightToFeePolynomial for LinearFee<T>467where468 T: BaseArithmetic + From<u32> + Copy + Unsigned,469{470 type Balance = T;471472 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {473 smallvec!(WeightToFeeCoefficient {474 475 coeff_integer: 142_688_000u32.into(),476 coeff_frac: Perbill::zero(),477 negative: false,478 degree: 1,479 })480 }481}482483impl pallet_transaction_payment::Config for Runtime {484 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;485 type TransactionByteFee = TransactionByteFee;486 type OperationalFeeMultiplier = OperationalFeeMultiplier;487 type WeightToFee = LinearFee<Balance>;488 type FeeMultiplierUpdate = ();489}490491parameter_types! {492 pub const ProposalBond: Permill = Permill::from_percent(5);493 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;494 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;495 pub const SpendPeriod: BlockNumber = 5 * MINUTES;496 pub const Burn: Permill = Permill::from_percent(0);497 pub const TipCountdown: BlockNumber = 1 * DAYS;498 pub const TipFindersFee: Percent = Percent::from_percent(20);499 pub const TipReportDepositBase: Balance = 1 * UNIQUE;500 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;501 pub const BountyDepositBase: Balance = 1 * UNIQUE;502 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;503 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");504 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;505 pub const MaximumReasonLength: u32 = 16384;506 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);507 pub const BountyValueMinimum: Balance = 5 * UNIQUE;508 pub const MaxApprovals: u32 = 100;509}510511impl pallet_treasury::Config for Runtime {512 type PalletId = TreasuryModuleId;513 type Currency = Balances;514 type ApproveOrigin = EnsureRoot<AccountId>;515 type RejectOrigin = EnsureRoot<AccountId>;516 type Event = Event;517 type OnSlash = ();518 type ProposalBond = ProposalBond;519 type ProposalBondMinimum = ProposalBondMinimum;520 type ProposalBondMaximum = ProposalBondMaximum;521 type SpendPeriod = SpendPeriod;522 type Burn = Burn;523 type BurnDestination = ();524 type SpendFunds = ();525 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;526 type MaxApprovals = MaxApprovals;527}528529impl pallet_sudo::Config for Runtime {530 type Event = Event;531 type Call = Call;532}533534pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);535536impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider537 for RelayChainBlockNumberProvider<T>538{539 type BlockNumber = BlockNumber;540541 fn current_block_number() -> Self::BlockNumber {542 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()543 .map(|d| d.relay_parent_number)544 .unwrap_or_default()545 }546}547548parameter_types! {549 pub const MinVestedTransfer: Balance = 10 * UNIQUE;550 pub const MaxVestingSchedules: u32 = 28;551}552553impl orml_vesting::Config for Runtime {554 type Event = Event;555 type Currency = pallet_balances::Pallet<Runtime>;556 type MinVestedTransfer = MinVestedTransfer;557 type VestedTransferOrigin = EnsureSigned<AccountId>;558 type WeightInfo = ();559 type MaxVestingSchedules = MaxVestingSchedules;560 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;561}562563parameter_types! {564 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;565 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;566}567568impl cumulus_pallet_parachain_system::Config for Runtime {569 type Event = Event;570 type SelfParaId = parachain_info::Pallet<Self>;571 type OnSystemEvent = ();572 573 574 575 576 577 type OutboundXcmpMessageSource = XcmpQueue;578 type DmpMessageHandler = DmpQueue;579 type ReservedDmpWeight = ReservedDmpWeight;580 type ReservedXcmpWeight = ReservedXcmpWeight;581 type XcmpMessageHandler = XcmpQueue;582}583584impl parachain_info::Config for Runtime {}585586impl cumulus_pallet_aura_ext::Config for Runtime {}587588parameter_types! {589 pub const RelayLocation: MultiLocation = MultiLocation::parent();590 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;591 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();592 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();593}594595596597598pub type LocationToAccountId = (599 600 ParentIsPreset<AccountId>,601 602 SiblingParachainConvertsVia<Sibling, AccountId>,603 604 AccountId32Aliases<RelayNetwork, AccountId>,605);606607pub struct OnlySelfCurrency;608impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {609 fn matches_fungible(a: &MultiAsset) -> Option<B> {610 match (&a.id, &a.fun) {611 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),612 _ => None,613 }614 }615}616617618pub type LocalAssetTransactor = CurrencyAdapter<619 620 Balances,621 622 OnlySelfCurrency,623 624 LocationToAccountId,625 626 AccountId,627 628 (),629>;630631632633634pub type XcmOriginToTransactDispatchOrigin = (635 636 637 638 SovereignSignedViaLocation<LocationToAccountId, Origin>,639 640 641 RelayChainAsNative<RelayOrigin, Origin>,642 643 644 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,645 646 647 ParentAsSuperuser<Origin>,648 649 650 SignedAccountId32AsNative<RelayNetwork, Origin>,651 652 XcmPassthrough<Origin>,653);654655parameter_types! {656 657 pub UnitWeightCost: Weight = 1_000_000;658 659 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);660 pub const MaxInstructions: u32 = 100;661 pub const MaxAuthorities: u32 = 100_000;662}663664match_type! {665 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {666 MultiLocation { parents: 1, interior: Here } |667 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }668 };669}670671pub type Barrier = (672 TakeWeightCredit,673 AllowTopLevelPaidExecutionFrom<Everything>,674 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,675 676);677678pub struct UsingOnlySelfCurrencyComponents<679 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,680 AssetId: Get<MultiLocation>,681 AccountId,682 Currency: CurrencyT<AccountId>,683 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,684>(685 Weight,686 Currency::Balance,687 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,688);689impl<690 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,691 AssetId: Get<MultiLocation>,692 AccountId,693 Currency: CurrencyT<AccountId>,694 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,695 > WeightTrader696 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>697{698 fn new() -> Self {699 Self(0, Zero::zero(), PhantomData)700 }701702 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {703 let amount = WeightToFee::calc(&weight);704 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;705706 707 let option1: xcm::v1::AssetId = Concrete(MultiLocation {708 parents: 1,709 interior: X1(Parachain(ParachainInfo::parachain_id().into())),710 });711 712 let option2: xcm::v1::AssetId = Concrete(MultiLocation {713 parents: 0,714 interior: Here,715 });716717 let required = if payment.fungible.contains_key(&option1) {718 (option1, u128_amount).into()719 } else if payment.fungible.contains_key(&option2) {720 (option2, u128_amount).into()721 } else {722 (Concrete(MultiLocation::default()), u128_amount).into()723 };724725 let unused = payment726 .checked_sub(required)727 .map_err(|_| XcmError::TooExpensive)?;728 self.0 = self.0.saturating_add(weight);729 self.1 = self.1.saturating_add(amount);730 Ok(unused)731 }732733 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {734 let weight = weight.min(self.0);735 let amount = WeightToFee::calc(&weight);736 self.0 -= weight;737 self.1 = self.1.saturating_sub(amount);738 let amount: u128 = amount.saturated_into();739 if amount > 0 {740 Some((AssetId::get(), amount).into())741 } else {742 None743 }744 }745}746impl<747 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,748 AssetId: Get<MultiLocation>,749 AccountId,750 Currency: CurrencyT<AccountId>,751 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,752 > Drop753 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>754{755 fn drop(&mut self) {756 OnUnbalanced::on_unbalanced(Currency::issue(self.1));757 }758}759760pub struct XcmConfig;761impl Config for XcmConfig {762 type Call = Call;763 type XcmSender = XcmRouter;764 765 type AssetTransactor = LocalAssetTransactor;766 type OriginConverter = XcmOriginToTransactDispatchOrigin;767 type IsReserve = NativeAsset;768 type IsTeleporter = (); 769 type LocationInverter = LocationInverter<Ancestry>;770 type Barrier = Barrier;771 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;772 type Trader = UsingOnlySelfCurrencyComponents<773 IdentityFee<Balance>,774 RelayLocation,775 AccountId,776 Balances,777 (),778 >;779 type ResponseHandler = (); 780 type SubscriptionService = PolkadotXcm;781782 type AssetTrap = PolkadotXcm;783 type AssetClaims = PolkadotXcm;784}785786787788789790791pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);792793794795pub type XcmRouter = (796 797 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,798 799 XcmpQueue,800);801802impl pallet_evm_coder_substrate::Config for Runtime {803 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;804 type GasWeightMapping = FixedGasWeightMapping;805}806807impl pallet_xcm::Config for Runtime {808 type Event = Event;809 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;810 type XcmRouter = XcmRouter;811 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;812 type XcmExecuteFilter = Everything;813 type XcmExecutor = XcmExecutor<XcmConfig>;814 type XcmTeleportFilter = Everything;815 type XcmReserveTransferFilter = Everything;816 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;817 type LocationInverter = LocationInverter<Ancestry>;818 type Origin = Origin;819 type Call = Call;820 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;821 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;822}823824impl cumulus_pallet_xcm::Config for Runtime {825 type Event = Event;826 type XcmExecutor = XcmExecutor<XcmConfig>;827}828829impl cumulus_pallet_xcmp_queue::Config for Runtime {830 type Event = Event;831 type XcmExecutor = XcmExecutor<XcmConfig>;832 type ChannelInfo = ParachainSystem;833 type VersionWrapper = ();834 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;835 type ControllerOrigin = EnsureRoot<AccountId>;836 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;837}838839impl cumulus_pallet_dmp_queue::Config for Runtime {840 type Event = Event;841 type XcmExecutor = XcmExecutor<XcmConfig>;842 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;843}844845impl pallet_aura::Config for Runtime {846 type AuthorityId = AuraId;847 type DisabledValidators = ();848 type MaxAuthorities = MaxAuthorities;849}850851parameter_types! {852 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();853 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;854}855856impl pallet_common::Config for Runtime {857 type Event = Event;858 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;859 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;860 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;861862 type Currency = Balances;863 type CollectionCreationPrice = CollectionCreationPrice;864 type TreasuryAccountId = TreasuryAccountId;865}866867impl pallet_fungible::Config for Runtime {868 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;869}870impl pallet_refungible::Config for Runtime {871 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;872}873impl pallet_nonfungible::Config for Runtime {874 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;875}876877impl pallet_unique::Config for Runtime {878 type Event = Event;879 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;880}881882parameter_types! {883 pub const InflationBlockInterval: BlockNumber = 100; 884}885886887impl pallet_inflation::Config for Runtime {888 type Currency = Balances;889 type TreasuryAccountId = TreasuryAccountId;890 type InflationBlockInterval = InflationBlockInterval;891 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;892}893894895896897898899900type EvmSponsorshipHandler = (901 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,902 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,903);904type SponsorshipHandler = (905 pallet_unique::UniqueSponsorshipHandler<Runtime>,906 907 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,908);909910911912913914915916917918919920921922impl pallet_evm_transaction_payment::Config for Runtime {923 type EvmSponsorshipHandler = EvmSponsorshipHandler;924 type Currency = Balances;925 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;926 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;927}928929impl pallet_charge_transaction::Config for Runtime {930 type SponsorshipHandler = SponsorshipHandler;931}932933934935936937parameter_types! {938 939 pub const HelpersContractAddress: H160 = H160([940 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,941 ]);942}943944impl pallet_evm_contract_helpers::Config for Runtime {945 type ContractAddress = HelpersContractAddress;946 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;947}948949construct_runtime!(950 pub enum Runtime where951 Block = Block,952 NodeBlock = opaque::Block,953 UncheckedExtrinsic = UncheckedExtrinsic954 {955 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,956 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,957958 Aura: pallet_aura::{Pallet, Config<T>} = 22,959 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,960961 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,962 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,963 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,964 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,965 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,966 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,967 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,968 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,969 970 971972 973 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,974 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,975 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,976 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,977978 979 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,980 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,981 982 983 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,984 985 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,986 Fungible: pallet_fungible::{Pallet, Storage} = 67,987 Refungible: pallet_refungible::{Pallet, Storage} = 68,988 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,989990 991 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,992 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,993994 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,995 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,996 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,997 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,998 }999);10001001pub struct TransactionConverter;10021003impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1004 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1005 UncheckedExtrinsic::new_unsigned(1006 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1007 )1008 }1009}10101011impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1012 fn convert_transaction(1013 &self,1014 transaction: pallet_ethereum::Transaction,1015 ) -> opaque::UncheckedExtrinsic {1016 let extrinsic = UncheckedExtrinsic::new_unsigned(1017 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1018 );1019 let encoded = extrinsic.encode();1020 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1021 .expect("Encoded extrinsic is always valid")1022 }1023}102410251026pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10271028pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10291030pub type Block = generic::Block<Header, UncheckedExtrinsic>;10311032pub type SignedBlock = generic::SignedBlock<Block>;10331034pub type BlockId = generic::BlockId<Block>;10351036pub type SignedExtra = (1037 frame_system::CheckSpecVersion<Runtime>,1038 1039 frame_system::CheckGenesis<Runtime>,1040 frame_system::CheckEra<Runtime>,1041 frame_system::CheckNonce<Runtime>,1042 frame_system::CheckWeight<Runtime>,1043 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1044 1045);10461047pub type UncheckedExtrinsic =1048 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10491050pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10511052pub type Executive = frame_executive::Executive<1053 Runtime,1054 Block,1055 frame_system::ChainContext<Runtime>,1056 Runtime,1057 AllPalletsReversedWithSystemFirst,1058>;10591060impl_opaque_keys! {1061 pub struct SessionKeys {1062 pub aura: Aura,1063 }1064}10651066impl fp_self_contained::SelfContainedCall for Call {1067 type SignedInfo = H160;10681069 fn is_self_contained(&self) -> bool {1070 match self {1071 Call::Ethereum(call) => call.is_self_contained(),1072 _ => false,1073 }1074 }10751076 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1077 match self {1078 Call::Ethereum(call) => call.check_self_contained(),1079 _ => None,1080 }1081 }10821083 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1084 match self {1085 Call::Ethereum(call) => call.validate_self_contained(info),1086 _ => None,1087 }1088 }10891090 fn pre_dispatch_self_contained(1091 &self,1092 info: &Self::SignedInfo,1093 ) -> Option<Result<(), TransactionValidityError>> {1094 match self {1095 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1096 _ => None,1097 }1098 }10991100 fn apply_self_contained(1101 self,1102 info: Self::SignedInfo,1103 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1104 match self {1105 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1106 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1107 )),1108 _ => None,1109 }1110 }1111}11121113macro_rules! dispatch_unique_runtime {1114 ($collection:ident.$method:ident($($name:ident),*)) => {{1115 use pallet_unique::dispatch::Dispatched;11161117 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1118 let dispatch = collection.as_dyn();11191120 Ok(dispatch.$method($($name),*))1121 }};1122}1123impl_runtime_apis! {1124 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>1125 for Runtime1126 {1127 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {1128 dispatch_unique_runtime!(collection.account_tokens(account))1129 }1130 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {1131 dispatch_unique_runtime!(collection.token_exists(token))1132 }11331134 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {1135 dispatch_unique_runtime!(collection.token_owner(token))1136 }1137 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {1138 dispatch_unique_runtime!(collection.const_metadata(token))1139 }1140 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {1141 dispatch_unique_runtime!(collection.variable_metadata(token))1142 }11431144 fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {1145 dispatch_unique_runtime!(collection.collection_tokens())1146 }1147 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {1148 dispatch_unique_runtime!(collection.account_balance(account))1149 }1150 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {1151 dispatch_unique_runtime!(collection.balance(account, token))1152 }1153 fn allowance(1154 collection: CollectionId,1155 sender: CrossAccountId,1156 spender: CrossAccountId,1157 token: TokenId,1158 ) -> Result<u128, DispatchError> {1159 dispatch_unique_runtime!(collection.allowance(sender, spender, token))1160 }11611162 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {1163 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)1164 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))1165 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))1166 }1167 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {1168 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))1169 }1170 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {1171 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))1172 }1173 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {1174 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))1175 }1176 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {1177 dispatch_unique_runtime!(collection.last_token_id())1178 }1179 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {1180 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))1181 }1182 fn collection_stats() -> Result<CollectionStats, DispatchError> {1183 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())1184 }1185 }11861187 impl sp_api::Core<Block> for Runtime {1188 fn version() -> RuntimeVersion {1189 VERSION1190 }11911192 fn execute_block(block: Block) {1193 Executive::execute_block(block)1194 }11951196 fn initialize_block(header: &<Block as BlockT>::Header) {1197 Executive::initialize_block(header)1198 }1199 }12001201 impl sp_api::Metadata<Block> for Runtime {1202 fn metadata() -> OpaqueMetadata {1203 OpaqueMetadata::new(Runtime::metadata().into())1204 }1205 }12061207 impl sp_block_builder::BlockBuilder<Block> for Runtime {1208 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {1209 Executive::apply_extrinsic(extrinsic)1210 }12111212 fn finalize_block() -> <Block as BlockT>::Header {1213 Executive::finalize_block()1214 }12151216 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {1217 data.create_extrinsics()1218 }12191220 fn check_inherents(1221 block: Block,1222 data: sp_inherents::InherentData,1223 ) -> sp_inherents::CheckInherentsResult {1224 data.check_extrinsics(&block)1225 }12261227 1228 1229 1230 }12311232 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {1233 fn validate_transaction(1234 source: TransactionSource,1235 tx: <Block as BlockT>::Extrinsic,1236 hash: <Block as BlockT>::Hash,1237 ) -> TransactionValidity {1238 Executive::validate_transaction(source, tx, hash)1239 }1240 }12411242 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {1243 fn offchain_worker(header: &<Block as BlockT>::Header) {1244 Executive::offchain_worker(header)1245 }1246 }12471248 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {1249 fn chain_id() -> u64 {1250 <Runtime as pallet_evm::Config>::ChainId::get()1251 }12521253 fn account_basic(address: H160) -> EVMAccount {1254 EVM::account_basic(&address)1255 }12561257 fn gas_price() -> U256 {1258 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()1259 }12601261 fn account_code_at(address: H160) -> Vec<u8> {1262 EVM::account_codes(address)1263 }12641265 fn author() -> H160 {1266 <pallet_evm::Pallet<Runtime>>::find_author()1267 }12681269 fn storage_at(address: H160, index: U256) -> H256 {1270 let mut tmp = [0u8; 32];1271 index.to_big_endian(&mut tmp);1272 EVM::account_storages(address, H256::from_slice(&tmp[..]))1273 }12741275 #[allow(clippy::redundant_closure)]1276 fn call(1277 from: H160,1278 to: H160,1279 data: Vec<u8>,1280 value: U256,1281 gas_limit: U256,1282 max_fee_per_gas: Option<U256>,1283 max_priority_fee_per_gas: Option<U256>,1284 nonce: Option<U256>,1285 estimate: bool,1286 access_list: Option<Vec<(H160, Vec<H256>)>>,1287 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1288 let config = if estimate {1289 let mut config = <Runtime as pallet_evm::Config>::config().clone();1290 config.estimate = true;1291 Some(config)1292 } else {1293 None1294 };12951296 <Runtime as pallet_evm::Config>::Runner::call(1297 from,1298 to,1299 data,1300 value,1301 gas_limit.low_u64(),1302 max_fee_per_gas,1303 max_priority_fee_per_gas,1304 nonce,1305 access_list.unwrap_or_default(),1306 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1307 ).map_err(|err| err.into())1308 }13091310 #[allow(clippy::redundant_closure)]1311 fn create(1312 from: H160,1313 data: Vec<u8>,1314 value: U256,1315 gas_limit: U256,1316 max_fee_per_gas: Option<U256>,1317 max_priority_fee_per_gas: Option<U256>,1318 nonce: Option<U256>,1319 estimate: bool,1320 access_list: Option<Vec<(H160, Vec<H256>)>>,1321 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1322 let config = if estimate {1323 let mut config = <Runtime as pallet_evm::Config>::config().clone();1324 config.estimate = true;1325 Some(config)1326 } else {1327 None1328 };13291330 <Runtime as pallet_evm::Config>::Runner::create(1331 from,1332 data,1333 value,1334 gas_limit.low_u64(),1335 max_fee_per_gas,1336 max_priority_fee_per_gas,1337 nonce,1338 access_list.unwrap_or_default(),1339 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1340 ).map_err(|err| err.into())1341 }13421343 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1344 Ethereum::current_transaction_statuses()1345 }13461347 fn current_block() -> Option<pallet_ethereum::Block> {1348 Ethereum::current_block()1349 }13501351 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1352 Ethereum::current_receipts()1353 }13541355 fn current_all() -> (1356 Option<pallet_ethereum::Block>,1357 Option<Vec<pallet_ethereum::Receipt>>,1358 Option<Vec<TransactionStatus>>1359 ) {1360 (1361 Ethereum::current_block(),1362 Ethereum::current_receipts(),1363 Ethereum::current_transaction_statuses()1364 )1365 }13661367 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1368 xts.into_iter().filter_map(|xt| match xt.0.function {1369 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),1370 _ => None1371 }).collect()1372 }13731374 fn elasticity() -> Option<Permill> {1375 None1376 }1377 }13781379 impl sp_session::SessionKeys<Block> for Runtime {1380 fn decode_session_keys(1381 encoded: Vec<u8>,1382 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1383 SessionKeys::decode_into_raw_public_keys(&encoded)1384 }13851386 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1387 SessionKeys::generate(seed)1388 }1389 }13901391 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1392 fn slot_duration() -> sp_consensus_aura::SlotDuration {1393 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1394 }13951396 fn authorities() -> Vec<AuraId> {1397 Aura::authorities().to_vec()1398 }1399 }14001401 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1402 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {1403 ParachainSystem::collect_collation_info(header)1404 }1405 }14061407 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1408 fn account_nonce(account: AccountId) -> Index {1409 System::account_nonce(account)1410 }1411 }14121413 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1414 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1415 TransactionPayment::query_info(uxt, len)1416 }1417 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1418 TransactionPayment::query_fee_details(uxt, len)1419 }1420 }14211422 14231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463 #[cfg(feature = "runtime-benchmarks")]1464 impl frame_benchmarking::Benchmark<Block> for Runtime {1465 fn benchmark_metadata(extra: bool) -> (1466 Vec<frame_benchmarking::BenchmarkList>,1467 Vec<frame_support::traits::StorageInfo>,1468 ) {1469 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};1470 use frame_support::traits::StorageInfoTrait;14711472 let mut list = Vec::<BenchmarkList>::new();14731474 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);1475 list_benchmark!(list, extra, pallet_unique, Unique);1476 list_benchmark!(list, extra, pallet_inflation, Inflation);1477 list_benchmark!(list, extra, pallet_fungible, Fungible);1478 list_benchmark!(list, extra, pallet_refungible, Refungible);1479 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);1480 14811482 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();14831484 return (list, storage_info)1485 }14861487 fn dispatch_benchmark(1488 config: frame_benchmarking::BenchmarkConfig1489 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1490 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};14911492 let allowlist: Vec<TrackedStorageKey> = vec![1493 1494 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),1495 1496 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),1497 1498 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),1499 1500 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),1501 1502 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),1503 ];15041505 let mut batches = Vec::<BenchmarkBatch>::new();1506 let params = (&config, &allowlist);15071508 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1509 add_benchmark!(params, batches, pallet_unique, Unique);1510 add_benchmark!(params, batches, pallet_inflation, Inflation);1511 add_benchmark!(params, batches, pallet_fungible, Fungible);1512 add_benchmark!(params, batches, pallet_refungible, Refungible);1513 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);1514 15151516 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1517 Ok(batches)1518 }1519 }1520}15211522struct CheckInherents;15231524impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1525 fn check_inherents(1526 block: &Block,1527 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1528 ) -> sp_inherents::CheckInherentsResult {1529 let relay_chain_slot = relay_state_proof1530 .read_slot()1531 .expect("Could not read the relay chain slot from the proof");15321533 let inherent_data =1534 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1535 relay_chain_slot,1536 sp_std::time::Duration::from_secs(6),1537 )1538 .create_inherent_data()1539 .expect("Could not create the timestamp inherent data");15401541 inherent_data.check_extrinsics(block)1542 }1543}15441545cumulus_pallet_parachain_system::register_validate_block!(1546 Runtime = Runtime,1547 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1548 CheckInherents = CheckInherents,1549);