git.delta.rocks / unique-network / refs/commits / 448629b28a12

difftreelog

source

runtime/common/runtime_apis.rs32.5 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#[macro_export]18macro_rules! dispatch_unique_runtime {19	($collection:ident.$method:ident($($name:ident),*) $($rest:tt)*) => {{20		let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch($collection)?;21		let dispatch = collection.as_dyn();2223		Ok::<_, DispatchError>(dispatch.$method($($name),*) $($rest)*)24	}};25}2627#[macro_export]28macro_rules! impl_common_runtime_apis {29    (30        $(31            #![custom_apis]3233            $($custom_apis:tt)+34        )?35    ) => {36        use sp_std::prelude::*;37        use sp_api::impl_runtime_apis;38        use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};39        use sp_runtime::{40            Permill,41            traits::{Block as BlockT},42            transaction_validity::{TransactionSource, TransactionValidity},43            ApplyExtrinsicResult, DispatchError,44        };45        use frame_support::{46            pallet_prelude::Weight,47            traits::OnFinalize,48        };49        use fp_rpc::TransactionStatus;50        use pallet_transaction_payment::{51            FeeDetails, RuntimeDispatchInfo,52        };53        use pallet_evm::{54            Runner, account::CrossAccountId as _,55            Account as EVMAccount, FeeCalculator,56        };57        use runtime_common::{58            sponsoring::{SponsorshipPredict, UniqueSponsorshipPredict},59            dispatch::CollectionDispatch,60            config::ethereum::CrossAccountId,61        };62        use up_data_structs::*;636465        impl_runtime_apis! {66            $($($custom_apis)+)?6768            impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {69                fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {70                    dispatch_unique_runtime!(collection.account_tokens(account))71                }72                fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {73                    dispatch_unique_runtime!(collection.collection_tokens())74                }75                fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {76                    dispatch_unique_runtime!(collection.token_exists(token))77                }7879                fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {80                    dispatch_unique_runtime!(collection.token_owner(token).ok())81                }8283                fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec::<CrossAccountId>, DispatchError>  {84                   dispatch_unique_runtime!(collection.token_owners(token))85                }8687                fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {88                    let budget = up_data_structs::budget::Value::new(10);8990                    <pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)91                }92                fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>, DispatchError> {93                    Ok(<pallet_nonfungible::Pallet<Runtime>>::token_children_ids(collection, token))94                }95                fn collection_properties(96                    collection: CollectionId,97                    keys: Option<Vec<Vec<u8>>>98                ) -> Result<Vec<Property>, DispatchError> {99                    let keys = keys.map(100                        |keys| Common::bytes_keys_to_property_keys(keys)101                    ).transpose()?;102103                    Common::filter_collection_properties(collection, keys)104                }105106                fn token_properties(107                    collection: CollectionId,108                    token_id: TokenId,109                    keys: Option<Vec<Vec<u8>>>110                ) -> Result<Vec<Property>, DispatchError> {111                    let keys = keys.map(112                        |keys| Common::bytes_keys_to_property_keys(keys)113                    ).transpose()?;114115                    dispatch_unique_runtime!(collection.token_properties(token_id, keys))116                }117118                fn property_permissions(119                    collection: CollectionId,120                    keys: Option<Vec<Vec<u8>>>121                ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {122                    let keys = keys.map(123                        |keys| Common::bytes_keys_to_property_keys(keys)124                    ).transpose()?;125126                    Common::filter_property_permissions(collection, keys)127                }128129                fn token_data(130                    collection: CollectionId,131                    token_id: TokenId,132                    keys: Option<Vec<Vec<u8>>>133                ) -> Result<TokenData<CrossAccountId>, DispatchError> {134                    let token_data = TokenData {135                        properties: Self::token_properties(collection, token_id, keys)?,136                        owner: Self::token_owner(collection, token_id)?,137                        pieces: Self::total_pieces(collection, token_id)?.unwrap_or(0),138                    };139140                    Ok(token_data)141                }142143                fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {144                    dispatch_unique_runtime!(collection.total_supply())145                }146                fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {147                    dispatch_unique_runtime!(collection.account_balance(account))148                }149                fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {150                    dispatch_unique_runtime!(collection.balance(account, token))151                }152                fn allowance(153                    collection: CollectionId,154                    sender: CrossAccountId,155                    spender: CrossAccountId,156                    token: TokenId,157                ) -> Result<u128, DispatchError> {158                    dispatch_unique_runtime!(collection.allowance(sender, spender, token))159                }160161                fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {162                    Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))163                }164                fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {165                    Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))166                }167                fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {168                    Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))169                }170                fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {171                    dispatch_unique_runtime!(collection.last_token_id())172                }173                fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {174                    Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))175                }176                fn collection_stats() -> Result<CollectionStats, DispatchError> {177                    Ok(<pallet_common::Pallet<Runtime>>::collection_stats())178                }179                fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {180                    Ok(<UniqueSponsorshipPredict<Runtime> as SponsorshipPredict<Runtime>>::predict(181                        collection,182                        account,183                        token184                    ))185                }186187                fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {188                    Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))189                }190191                fn total_pieces(collection: CollectionId, token_id: TokenId) -> Result<Option<u128>, DispatchError> {192                    dispatch_unique_runtime!(collection.total_pieces(token_id))193                }194195		        fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool, DispatchError> {196                    dispatch_unique_runtime!(collection.allowance_for_all(owner, operator))197                }198            }199200            impl app_promotion_rpc::AppPromotionApi<Block, BlockNumber, CrossAccountId, AccountId> for Runtime {201                #[allow(unused_variables)]202                fn total_staked(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {203                    #[cfg(not(feature = "app-promotion"))]204                    return unsupported!();205206                    #[cfg(feature = "app-promotion")]207                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked(staker).unwrap_or_default());208                }209210                #[allow(unused_variables)]211                fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {212                    #[cfg(not(feature = "app-promotion"))]213                    return unsupported!();214215                    #[cfg(feature = "app-promotion")]216                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked_per_block(staker));217                }218219                #[allow(unused_variables)]220                fn pending_unstake(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {221                    #[cfg(not(feature = "app-promotion"))]222                    return unsupported!();223224                    #[cfg(feature = "app-promotion")]225                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake(staker));226                }227228                #[allow(unused_variables)]229                fn pending_unstake_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {230                    #[cfg(not(feature = "app-promotion"))]231                    return unsupported!();232233                    #[cfg(feature = "app-promotion")]234                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake_per_block(staker))235                }236            }237238            impl sp_api::Core<Block> for Runtime {239                fn version() -> RuntimeVersion {240                    VERSION241                }242243                fn execute_block(block: Block) {244                    Executive::execute_block(block)245                }246247                fn initialize_block(header: &<Block as BlockT>::Header) {248                    Executive::initialize_block(header)249                }250            }251252            impl sp_api::Metadata<Block> for Runtime {253                fn metadata() -> OpaqueMetadata {254                    OpaqueMetadata::new(Runtime::metadata().into())255                }256257                fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {258                    Runtime::metadata_at_version(version)259                }260261                fn metadata_versions() -> sp_std::vec::Vec<u32> {262                    Runtime::metadata_versions()263                }264            }265266            impl sp_block_builder::BlockBuilder<Block> for Runtime {267                fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {268                    Executive::apply_extrinsic(extrinsic)269                }270271                fn finalize_block() -> <Block as BlockT>::Header {272                    Executive::finalize_block()273                }274275                fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {276                    data.create_extrinsics()277                }278279                fn check_inherents(280                    block: Block,281                    data: sp_inherents::InherentData,282                ) -> sp_inherents::CheckInherentsResult {283                    data.check_extrinsics(&block)284                }285286                // fn random_seed() -> <Block as BlockT>::Hash {287                //     RandomnessCollectiveFlip::random_seed().0288                // }289            }290291            impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {292                fn validate_transaction(293                    source: TransactionSource,294                    tx: <Block as BlockT>::Extrinsic,295                    hash: <Block as BlockT>::Hash,296                ) -> TransactionValidity {297                    Executive::validate_transaction(source, tx, hash)298                }299            }300301            impl sp_offchain::OffchainWorkerApi<Block> for Runtime {302                fn offchain_worker(header: &<Block as BlockT>::Header) {303                    Executive::offchain_worker(header)304                }305            }306307            impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {308                fn chain_id() -> u64 {309                    <Runtime as pallet_evm::Config>::ChainId::get()310                }311312                fn account_basic(address: H160) -> EVMAccount {313                    let (account, _) = EVM::account_basic(&address);314                    account315                }316317                fn gas_price() -> U256 {318                    let (price, _) = <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price();319                    price320                }321322                fn account_code_at(address: H160) -> Vec<u8> {323                    use pallet_evm::OnMethodCall;324                    <Runtime as pallet_evm::Config>::OnMethodCall::get_code(&address)325                        .unwrap_or_else(|| pallet_evm::AccountCodes::<Runtime>::get(address))326                }327328                fn author() -> H160 {329                    <pallet_evm::Pallet<Runtime>>::find_author()330                }331332                fn storage_at(address: H160, index: U256) -> H256 {333                    let mut tmp = [0u8; 32];334                    index.to_big_endian(&mut tmp);335                    pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))336                }337338                #[allow(clippy::redundant_closure)]339                fn call(340                    from: H160,341                    to: H160,342                    data: Vec<u8>,343                    value: U256,344                    gas_limit: U256,345                    max_fee_per_gas: Option<U256>,346                    max_priority_fee_per_gas: Option<U256>,347                    nonce: Option<U256>,348                    estimate: bool,349                    access_list: Option<Vec<(H160, Vec<H256>)>>,350                ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {351                    let config = if estimate {352                        let mut config = <Runtime as pallet_evm::Config>::config().clone();353                        config.estimate = true;354                        Some(config)355                    } else {356                        None357                    };358359                    let is_transactional = false;360                    let validate = false;361                    <Runtime as pallet_evm::Config>::Runner::call(362                        CrossAccountId::from_eth(from),363                        to,364                        data,365                        value,366                        gas_limit.low_u64(),367                        max_fee_per_gas,368                        max_priority_fee_per_gas,369                        nonce,370                        access_list.unwrap_or_default(),371                        is_transactional,372                        validate,373                        // TODO we probably want to support external cost recording in non-transactional calls374                        None,375                        None,376377                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),378                    ).map_err(|err| err.error.into())379                }380381                #[allow(clippy::redundant_closure)]382                fn create(383                    from: H160,384                    data: Vec<u8>,385                    value: U256,386                    gas_limit: U256,387                    max_fee_per_gas: Option<U256>,388                    max_priority_fee_per_gas: Option<U256>,389                    nonce: Option<U256>,390                    estimate: bool,391                    access_list: Option<Vec<(H160, Vec<H256>)>>,392                ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {393                    let config = if estimate {394                        let mut config = <Runtime as pallet_evm::Config>::config().clone();395                        config.estimate = true;396                        Some(config)397                    } else {398                        None399                    };400401                    let is_transactional = false;402                    let validate = false;403                    <Runtime as pallet_evm::Config>::Runner::create(404                        CrossAccountId::from_eth(from),405                        data,406                        value,407                        gas_limit.low_u64(),408                        max_fee_per_gas,409                        max_priority_fee_per_gas,410                        nonce,411                        access_list.unwrap_or_default(),412                        is_transactional,413                        validate,414                        // TODO we probably want to support external cost recording in non-transactional calls415                        None,416                        None,417418                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),419                    ).map_err(|err| err.error.into())420                }421422                fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {423                    pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()424                }425426                fn current_block() -> Option<pallet_ethereum::Block> {427                    pallet_ethereum::CurrentBlock::<Runtime>::get()428                }429430                fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {431                    pallet_ethereum::CurrentReceipts::<Runtime>::get()432                }433434                fn current_all() -> (435                    Option<pallet_ethereum::Block>,436                    Option<Vec<pallet_ethereum::Receipt>>,437                    Option<Vec<TransactionStatus>>438                ) {439                    (440                        pallet_ethereum::CurrentBlock::<Runtime>::get(),441                        pallet_ethereum::CurrentReceipts::<Runtime>::get(),442                        pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()443                    )444                }445446                fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {447                    xts.into_iter().filter_map(|xt| match xt.0.function {448                        RuntimeCall::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),449                        _ => None450                    }).collect()451                }452453                fn elasticity() -> Option<Permill> {454                    None455                }456457                fn gas_limit_multiplier_support() {}458459                fn pending_block(460                    xts: Vec<<Block as BlockT>::Extrinsic>,461                ) -> (Option<pallet_ethereum::Block>, Option<Vec<TransactionStatus>>) {462                    for ext in xts.into_iter() {463                        let _ = Executive::apply_extrinsic(ext);464                    }465466                    Ethereum::on_finalize(System::block_number() + 1);467468                    (469                        pallet_ethereum::CurrentBlock::<Runtime>::get(),470                        pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()471                    )472                }473            }474475            impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {476                fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic  {477                    UncheckedExtrinsic::new_unsigned(478                        pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),479                    )480                }481            }482483            impl sp_session::SessionKeys<Block> for Runtime {484                fn decode_session_keys(485                    encoded: Vec<u8>,486                ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {487                    SessionKeys::decode_into_raw_public_keys(&encoded)488                }489490                fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {491                    SessionKeys::generate(seed)492                }493            }494495            impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {496                fn slot_duration() -> sp_consensus_aura::SlotDuration {497                    sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())498                }499500                fn authorities() -> Vec<AuraId> {501                    Aura::authorities().to_vec()502                }503            }504505            impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {506                fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {507                    ParachainSystem::collect_collation_info(header)508                }509            }510511            impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {512                fn account_nonce(account: AccountId) -> Index {513                    System::account_nonce(account)514                }515            }516517            impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {518                fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {519                    TransactionPayment::query_info(uxt, len)520                }521                fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {522                    TransactionPayment::query_fee_details(uxt, len)523                }524                fn query_weight_to_fee(weight: Weight) -> Balance {525                    TransactionPayment::weight_to_fee(weight)526                }527                fn query_length_to_fee(length: u32) -> Balance {528                    TransactionPayment::length_to_fee(length)529                }530            }531532            /*533            impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>534                for Runtime535            {536                fn call(537                    origin: AccountId,538                    dest: AccountId,539                    value: Balance,540                    gas_limit: u64,541                    input_data: Vec<u8>,542                ) -> pallet_contracts_primitives::ContractExecResult {543                    Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)544                }545546                fn instantiate(547                    origin: AccountId,548                    endowment: Balance,549                    gas_limit: u64,550                    code: pallet_contracts_primitives::Code<Hash>,551                    data: Vec<u8>,552                    salt: Vec<u8>,553                ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>554                {555                    Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)556                }557558                fn get_storage(559                    address: AccountId,560                    key: [u8; 32],561                ) -> pallet_contracts_primitives::GetStorageResult {562                    Contracts::get_storage(address, key)563                }564565                fn rent_projection(566                    address: AccountId,567                ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {568                    Contracts::rent_projection(address)569                }570            }571            */572573            #[cfg(feature = "runtime-benchmarks")]574            impl frame_benchmarking::Benchmark<Block> for Runtime {575                fn benchmark_metadata(extra: bool) -> (576                    Vec<frame_benchmarking::BenchmarkList>,577                    Vec<frame_support::traits::StorageInfo>,578                ) {579                    use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};580                    use frame_support::traits::StorageInfoTrait;581582                    let mut list = Vec::<BenchmarkList>::new();583                    list_benchmark!(list, extra, pallet_xcm, PolkadotXcm);584585                    list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);586                    list_benchmark!(list, extra, pallet_common, Common);587                    list_benchmark!(list, extra, pallet_unique, Unique);588                    list_benchmark!(list, extra, pallet_structure, Structure);589                    list_benchmark!(list, extra, pallet_inflation, Inflation);590                    list_benchmark!(list, extra, pallet_configuration, Configuration);591592                    #[cfg(feature = "app-promotion")]593                    list_benchmark!(list, extra, pallet_app_promotion, AppPromotion);594595                    list_benchmark!(list, extra, pallet_fungible, Fungible);596                    list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);597598                    #[cfg(feature = "refungible")]599                    list_benchmark!(list, extra, pallet_refungible, Refungible);600601                    #[cfg(feature = "unique-scheduler")]602                    list_benchmark!(list, extra, pallet_unique_scheduler_v2, Scheduler);603604                    #[cfg(feature = "collator-selection")]605                    list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);606607                    #[cfg(feature = "collator-selection")]608                    list_benchmark!(list, extra, pallet_identity, Identity);609610                    #[cfg(feature = "foreign-assets")]611                    list_benchmark!(list, extra, pallet_foreign_assets, ForeignAssets);612613                    list_benchmark!(list, extra, pallet_maintenance, Maintenance);614615                    // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);616617                    let storage_info = AllPalletsWithSystem::storage_info();618619                    return (list, storage_info)620                }621622                fn dispatch_benchmark(623                    config: frame_benchmarking::BenchmarkConfig624                ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {625                    use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};626627                    let allowlist: Vec<TrackedStorageKey> = vec![628                        // Total Issuance629                        hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),630631                        // Block Number632                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),633                        // Execution Phase634                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),635                        // Event Count636                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),637                        // System Events638                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),639640                        // Evm CurrentLogs641                        hex_literal::hex!("1da53b775b270400e7e61ed5cbc5a146547f210cec367e9af919603343b9cb56").to_vec().into(),642643                        // Transactional depth644                        hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),645                    ];646647                    let mut batches = Vec::<BenchmarkBatch>::new();648                    let params = (&config, &allowlist);649                    add_benchmark!(params, batches, pallet_xcm, PolkadotXcm);650651                    add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);652                    add_benchmark!(params, batches, pallet_common, Common);653                    add_benchmark!(params, batches, pallet_unique, Unique);654                    add_benchmark!(params, batches, pallet_structure, Structure);655                    add_benchmark!(params, batches, pallet_inflation, Inflation);656                    add_benchmark!(params, batches, pallet_configuration, Configuration);657658                    #[cfg(feature = "app-promotion")]659                    add_benchmark!(params, batches, pallet_app_promotion, AppPromotion);660661                    add_benchmark!(params, batches, pallet_fungible, Fungible);662                    add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);663664                    #[cfg(feature = "refungible")]665                    add_benchmark!(params, batches, pallet_refungible, Refungible);666667                    #[cfg(feature = "unique-scheduler")]668                    add_benchmark!(params, batches, pallet_unique_scheduler_v2, Scheduler);669670                    #[cfg(feature = "collator-selection")]671                    add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);672673                    #[cfg(feature = "collator-selection")]674                    add_benchmark!(params, batches, pallet_identity, Identity);675676                    #[cfg(feature = "foreign-assets")]677                    add_benchmark!(params, batches, pallet_foreign_assets, ForeignAssets);678679                    add_benchmark!(params, batches, pallet_maintenance, Maintenance);680681                    // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);682683                    if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }684                    Ok(batches)685                }686            }687688            impl up_pov_estimate_rpc::PovEstimateApi<Block> for Runtime {689                #[allow(unused_variables)]690                fn pov_estimate(uxt: Vec<u8>) -> ApplyExtrinsicResult {691                    #[cfg(feature = "pov-estimate")]692                    {693                        use codec::Decode;694695                        let uxt_decode = <<Block as BlockT>::Extrinsic as Decode>::decode(&mut &uxt)696                            .map_err(|_| DispatchError::Other("failed to decode the extrinsic"));697698                        let uxt = match uxt_decode {699                            Ok(uxt) => uxt,700                            Err(err) => return Ok(err.into()),701                        };702703                        Executive::apply_extrinsic(uxt)704                    }705706                    #[cfg(not(feature = "pov-estimate"))]707                    return Ok(unsupported!());708                }709            }710711            #[cfg(feature = "try-runtime")]712            impl frame_try_runtime::TryRuntime<Block> for Runtime {713                fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {714                    log::info!("try-runtime::on_runtime_upgrade unique-chain.");715                    let weight = Executive::try_runtime_upgrade(checks).unwrap();716                    (weight, $crate::config::substrate::RuntimeBlockWeights::get().max_block)717                }718719                fn execute_block(720                    block: Block,721                    state_root_check: bool,722                    signature_check: bool,723                    select: frame_try_runtime::TryStateSelect724                ) -> Weight {725                    log::info!(726                        target: "node-runtime",727                        "try-runtime: executing block {:?} / root checks: {:?} / try-state-select: {:?}",728                        block.header.hash(),729                        state_root_check,730                        select,731                    );732733                    Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()734                }735            }736        }737    }738}