git.delta.rocks / unique-network / refs/commits / 37e76bc01ac1

difftreelog

fix make runtime build on 0.9.42

Yaroslav Bolyukin2023-05-22parent: #6f7886b.patch.diff
in: master

11 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -13701,6 +13701,7 @@
 dependencies = [
  "app-promotion-rpc",
  "fc-db",
+ "fc-mapping-sync",
  "fc-rpc",
  "fc-rpc-core",
  "fp-rpc",
modifiedruntime/common/config/ethereum.rsdiffbeforeafterboth
--- a/runtime/common/config/ethereum.rs
+++ b/runtime/common/config/ethereum.rs
@@ -4,7 +4,7 @@
 	traits::{FindAuthor},
 	parameter_types, ConsensusEngineId,
 };
-use sp_runtime::{RuntimeAppPublic, Perbill};
+use sp_runtime::{RuntimeAppPublic, Perbill, traits::ConstU32};
 use crate::{
 	runtime_common::{
 		config::sponsoring::DefaultSponsoringRateLimit,
@@ -84,6 +84,8 @@
 	type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;
 	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;
 	type FindAuthor = EthereumFindAuthor<Aura>;
+	type Timestamp = crate::Timestamp;
+	type WeightInfo = pallet_evm::weights::SubstrateWeight<Self>;
 }
 
 impl pallet_evm_migration::Config for Runtime {
@@ -99,6 +101,9 @@
 	type RuntimeEvent = RuntimeEvent;
 	type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;
 	type PostLogContent = PostBlockAndTxnHashes;
+	// Space for revert reason. Ethereum transactions are not cheap, and overall size is much less
+	// than the substrate tx size, so we can afford this
+	type ExtraDataLength = ConstU32<32>;
 }
 
 parameter_types! {
modifiedruntime/common/config/substrate.rsdiffbeforeafterboth
--- a/runtime/common/config/substrate.rs
+++ b/runtime/common/config/substrate.rs
@@ -36,7 +36,7 @@
 use pallet_transaction_payment::{Multiplier, ConstFeeMultiplier};
 use crate::{
 	runtime_common::DealWithFees, Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, PalletInfo,
-	System, Balances, Treasury, SS58Prefix, Version,
+	System, Balances, SS58Prefix, Version,
 };
 use up_common::{types::*, constants::*};
 
@@ -142,10 +142,15 @@
 	type Balance = Balance;
 	/// The ubiquitous event type.
 	type RuntimeEvent = RuntimeEvent;
-	type DustRemoval = Treasury;
+	// FIXME: Is () the new treasury?
+	type DustRemoval = ();
 	type ExistentialDeposit = ExistentialDeposit;
 	type AccountStore = System;
 	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;
+	type HoldIdentifier = [u8; 16];
+	type FreezeIdentifier = [u8; 16];
+	type MaxHolds = ();
+	type MaxFreezes = ();
 }
 
 parameter_types! {
modifiedruntime/common/config/xcm/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/mod.rs
+++ b/runtime/common/config/xcm/mod.rs
@@ -15,7 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{
-	traits::{Everything, Nothing, Get, ConstU32},
+	traits::{Everything, Nothing, Get, ConstU32, ProcessMessageError},
 	parameter_types,
 };
 use frame_system::EnsureRoot;
@@ -114,26 +114,18 @@
 );
 
 pub trait TryPass {
-<<<<<<< HEAD
-	fn try_pass<Call>(origin: &MultiLocation, message: &mut [Instruction<Call>]) -> Result<(), ()>;
-=======
 	fn try_pass<Call>(
 		origin: &MultiLocation,
 		message: &mut [Instruction<Call>],
 	) -> Result<(), ProcessMessageError>;
->>>>>>> fd33b0ac (fixup pallets)
 }
 
 #[impl_trait_for_tuples::impl_for_tuples(30)]
 impl TryPass for Tuple {
-<<<<<<< HEAD
-	fn try_pass<Call>(origin: &MultiLocation, message: &mut [Instruction<Call>]) -> Result<(), ()> {
-=======
 	fn try_pass<Call>(
 		origin: &MultiLocation,
 		message: &mut [Instruction<Call>],
 	) -> Result<(), ProcessMessageError> {
->>>>>>> fd33b0ac (fixup pallets)
 		for_tuples!( #(
 			Tuple::try_pass(origin, message)?;
 		)* );
@@ -159,7 +151,7 @@
 		message: &mut [Instruction<Call>],
 		max_weight: Weight,
 		weight_credit: &mut Weight,
-	) -> Result<(), ()> {
+	) -> Result<(), ProcessMessageError> {
 		Deny::try_pass(origin, message)?;
 		Allow::should_execute(origin, message, max_weight, weight_credit)
 	}
@@ -227,6 +219,7 @@
 	type SovereignAccountOf = LocationToAccountId;
 	type MaxLockers = ConstU32<8>;
 	type WeightInfo = crate::weights::xcm::SubstrateWeight<Runtime>;
+	type AdminOrigin = EnsureRoot<AccountId>;
 	#[cfg(feature = "runtime-benchmarks")]
 	type ReachableDest = ReachableDest;
 }
modifiedruntime/common/config/xcm/nativeassets.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/nativeassets.rs
+++ b/runtime/common/config/xcm/nativeassets.rs
@@ -102,7 +102,8 @@
 	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
 {
 	fn new() -> Self {
-		Self(0, Zero::zero(), PhantomData)
+		// FIXME: benchmark
+		Self(Weight::from_parts(0, 0), Zero::zero(), PhantomData)
 	}
 
 	fn buy_weight(&mut self, _weight: Weight, payment: Assets) -> Result<Assets, XcmError> {
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
before · runtime/common/runtime_apis.rs
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(<pallet_common::CollectionHandle<Runtime>>::try_get($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, Bytes};39        use sp_runtime::{40            Permill,41            traits::Block as BlockT,42            transaction_validity::{TransactionSource, TransactionValidity},43            ApplyExtrinsicResult, DispatchError,44        };45        use frame_support::pallet_prelude::Weight;46        use fp_rpc::TransactionStatus;47        use pallet_transaction_payment::{48            FeeDetails, RuntimeDispatchInfo,49        };50        use pallet_evm::{51            Runner, account::CrossAccountId as _,52            Account as EVMAccount, FeeCalculator,53        };54        use runtime_common::{55            sponsoring::{SponsorshipPredict, UniqueSponsorshipPredict},56            dispatch::CollectionDispatch,57            config::ethereum::CrossAccountId,58        };59        use up_data_structs::*;606162        impl_runtime_apis! {63            $($($custom_apis)+)?6465            impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {66                fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {67                    dispatch_unique_runtime!(collection.account_tokens(account))68                }69                fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {70                    dispatch_unique_runtime!(collection.collection_tokens())71                }72                fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {73                    dispatch_unique_runtime!(collection.token_exists(token))74                }7576                fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {77                    dispatch_unique_runtime!(collection.token_owner(token).ok())78                }7980                fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec::<CrossAccountId>, DispatchError>  {81                   dispatch_unique_runtime!(collection.token_owners(token))82                }8384                fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {85                    let budget = up_data_structs::budget::Value::new(10);8687                    Ok(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?)88                }89                fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>, DispatchError> {90                    Ok(<pallet_nonfungible::Pallet<Runtime>>::token_children_ids(collection, token))91                }92                fn collection_properties(93                    collection: CollectionId,94                    keys: Option<Vec<Vec<u8>>>95                ) -> Result<Vec<Property>, DispatchError> {96                    let keys = keys.map(97                        |keys| Common::bytes_keys_to_property_keys(keys)98                    ).transpose()?;99100                    Common::filter_collection_properties(collection, keys)101                }102103                fn token_properties(104                    collection: CollectionId,105                    token_id: TokenId,106                    keys: Option<Vec<Vec<u8>>>107                ) -> Result<Vec<Property>, DispatchError> {108                    let keys = keys.map(109                        |keys| Common::bytes_keys_to_property_keys(keys)110                    ).transpose()?;111112                    dispatch_unique_runtime!(collection.token_properties(token_id, keys))113                }114115                fn property_permissions(116                    collection: CollectionId,117                    keys: Option<Vec<Vec<u8>>>118                ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {119                    let keys = keys.map(120                        |keys| Common::bytes_keys_to_property_keys(keys)121                    ).transpose()?;122123                    Common::filter_property_permissions(collection, keys)124                }125126                fn token_data(127                    collection: CollectionId,128                    token_id: TokenId,129                    keys: Option<Vec<Vec<u8>>>130                ) -> Result<TokenData<CrossAccountId>, DispatchError> {131                    let token_data = TokenData {132                        properties: Self::token_properties(collection, token_id, keys)?,133                        owner: Self::token_owner(collection, token_id)?,134                        pieces: Self::total_pieces(collection, token_id)?.unwrap_or(0),135                    };136137                    Ok(token_data)138                }139140                fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {141                    dispatch_unique_runtime!(collection.total_supply())142                }143                fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {144                    dispatch_unique_runtime!(collection.account_balance(account))145                }146                fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {147                    dispatch_unique_runtime!(collection.balance(account, token))148                }149                fn allowance(150                    collection: CollectionId,151                    sender: CrossAccountId,152                    spender: CrossAccountId,153                    token: TokenId,154                ) -> Result<u128, DispatchError> {155                    dispatch_unique_runtime!(collection.allowance(sender, spender, token))156                }157158                fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {159                    Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))160                }161                fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {162                    Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))163                }164                fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {165                    Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))166                }167                fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {168                    dispatch_unique_runtime!(collection.last_token_id())169                }170                fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {171                    Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))172                }173                fn collection_stats() -> Result<CollectionStats, DispatchError> {174                    Ok(<pallet_common::Pallet<Runtime>>::collection_stats())175                }176                fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {177                    Ok(<UniqueSponsorshipPredict<Runtime> as SponsorshipPredict<Runtime>>::predict(178                        collection,179                        account,180                        token181                    ))182                }183184                fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {185                    Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))186                }187188                fn total_pieces(collection: CollectionId, token_id: TokenId) -> Result<Option<u128>, DispatchError> {189                    dispatch_unique_runtime!(collection.total_pieces(token_id))190                }191192		        fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool, DispatchError> {193                    dispatch_unique_runtime!(collection.allowance_for_all(owner, operator))194                }195            }196197            impl app_promotion_rpc::AppPromotionApi<Block, BlockNumber, CrossAccountId, AccountId> for Runtime {198                #[allow(unused_variables)]199                fn total_staked(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {200                    #[cfg(not(feature = "app-promotion"))]201                    return unsupported!();202203                    #[cfg(feature = "app-promotion")]204                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked(staker).unwrap_or_default());205                }206207                #[allow(unused_variables)]208                fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {209                    #[cfg(not(feature = "app-promotion"))]210                    return unsupported!();211212                    #[cfg(feature = "app-promotion")]213                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked_per_block(staker));214                }215216                #[allow(unused_variables)]217                fn pending_unstake(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {218                    #[cfg(not(feature = "app-promotion"))]219                    return unsupported!();220221                    #[cfg(feature = "app-promotion")]222                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake(staker));223                }224225                #[allow(unused_variables)]226                fn pending_unstake_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {227                    #[cfg(not(feature = "app-promotion"))]228                    return unsupported!();229230                    #[cfg(feature = "app-promotion")]231                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake_per_block(staker))232                }233            }234235            impl sp_api::Core<Block> for Runtime {236                fn version() -> RuntimeVersion {237                    VERSION238                }239240                fn execute_block(block: Block) {241                    Executive::execute_block(block)242                }243244                fn initialize_block(header: &<Block as BlockT>::Header) {245                    Executive::initialize_block(header)246                }247            }248249            impl sp_api::Metadata<Block> for Runtime {250                fn metadata() -> OpaqueMetadata {251                    OpaqueMetadata::new(Runtime::metadata().into())252                }253            }254255            impl sp_block_builder::BlockBuilder<Block> for Runtime {256                fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {257                    Executive::apply_extrinsic(extrinsic)258                }259260                fn finalize_block() -> <Block as BlockT>::Header {261                    Executive::finalize_block()262                }263264                fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {265                    data.create_extrinsics()266                }267268                fn check_inherents(269                    block: Block,270                    data: sp_inherents::InherentData,271                ) -> sp_inherents::CheckInherentsResult {272                    data.check_extrinsics(&block)273                }274275                // fn random_seed() -> <Block as BlockT>::Hash {276                //     RandomnessCollectiveFlip::random_seed().0277                // }278            }279280            impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {281                fn validate_transaction(282                    source: TransactionSource,283                    tx: <Block as BlockT>::Extrinsic,284                    hash: <Block as BlockT>::Hash,285                ) -> TransactionValidity {286                    Executive::validate_transaction(source, tx, hash)287                }288            }289290            impl sp_offchain::OffchainWorkerApi<Block> for Runtime {291                fn offchain_worker(header: &<Block as BlockT>::Header) {292                    Executive::offchain_worker(header)293                }294            }295296            impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {297                fn chain_id() -> u64 {298                    <Runtime as pallet_evm::Config>::ChainId::get()299                }300301                fn account_basic(address: H160) -> EVMAccount {302                    let (account, _) = EVM::account_basic(&address);303                    account304                }305306                fn gas_price() -> U256 {307                    let (price, _) = <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price();308                    price309                }310311                fn account_code_at(address: H160) -> Vec<u8> {312                    use pallet_evm::OnMethodCall;313                    <Runtime as pallet_evm::Config>::OnMethodCall::get_code(&address)314                        .unwrap_or_else(|| EVM::account_codes(address))315                }316317                fn author() -> H160 {318                    <pallet_evm::Pallet<Runtime>>::find_author()319                }320321                fn storage_at(address: H160, index: U256) -> H256 {322                    let mut tmp = [0u8; 32];323                    index.to_big_endian(&mut tmp);324                    EVM::account_storages(address, H256::from_slice(&tmp[..]))325                }326327                #[allow(clippy::redundant_closure)]328                fn call(329                    from: H160,330                    to: H160,331                    data: Vec<u8>,332                    value: U256,333                    gas_limit: U256,334                    max_fee_per_gas: Option<U256>,335                    max_priority_fee_per_gas: Option<U256>,336                    nonce: Option<U256>,337                    estimate: bool,338                    access_list: Option<Vec<(H160, Vec<H256>)>>,339                ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {340                    let config = if estimate {341                        let mut config = <Runtime as pallet_evm::Config>::config().clone();342                        config.estimate = true;343                        Some(config)344                    } else {345                        None346                    };347348                    let is_transactional = false;349                    let validate = false;350                    <Runtime as pallet_evm::Config>::Runner::call(351                        CrossAccountId::from_eth(from),352                        to,353                        data,354                        value,355                        gas_limit.low_u64(),356                        max_fee_per_gas,357                        max_priority_fee_per_gas,358                        nonce,359                        access_list.unwrap_or_default(),360                        is_transactional,361                        validate,362                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),363                    ).map_err(|err| err.error.into())364                }365366                #[allow(clippy::redundant_closure)]367                fn create(368                    from: H160,369                    data: Vec<u8>,370                    value: U256,371                    gas_limit: U256,372                    max_fee_per_gas: Option<U256>,373                    max_priority_fee_per_gas: Option<U256>,374                    nonce: Option<U256>,375                    estimate: bool,376                    access_list: Option<Vec<(H160, Vec<H256>)>>,377                ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {378                    let config = if estimate {379                        let mut config = <Runtime as pallet_evm::Config>::config().clone();380                        config.estimate = true;381                        Some(config)382                    } else {383                        None384                    };385386                    let is_transactional = false;387                    let validate = false;388                    <Runtime as pallet_evm::Config>::Runner::create(389                        CrossAccountId::from_eth(from),390                        data,391                        value,392                        gas_limit.low_u64(),393                        max_fee_per_gas,394                        max_priority_fee_per_gas,395                        nonce,396                        access_list.unwrap_or_default(),397                        is_transactional,398                        validate,399                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),400                    ).map_err(|err| err.error.into())401                }402403                fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {404                    Ethereum::current_transaction_statuses()405                }406407                fn current_block() -> Option<pallet_ethereum::Block> {408                    Ethereum::current_block()409                }410411                fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {412                    Ethereum::current_receipts()413                }414415                fn current_all() -> (416                    Option<pallet_ethereum::Block>,417                    Option<Vec<pallet_ethereum::Receipt>>,418                    Option<Vec<TransactionStatus>>419                ) {420                    (421                        Ethereum::current_block(),422                        Ethereum::current_receipts(),423                        Ethereum::current_transaction_statuses()424                    )425                }426427                fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {428                    xts.into_iter().filter_map(|xt| match xt.0.function {429                        RuntimeCall::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),430                        _ => None431                    }).collect()432                }433434                fn elasticity() -> Option<Permill> {435                    None436                }437438                fn gas_limit_multiplier_support() {}439            }440441            impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {442                fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic  {443                    UncheckedExtrinsic::new_unsigned(444                        pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),445                    )446                }447            }448449            impl sp_session::SessionKeys<Block> for Runtime {450                fn decode_session_keys(451                    encoded: Vec<u8>,452                ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {453                    SessionKeys::decode_into_raw_public_keys(&encoded)454                }455456                fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {457                    SessionKeys::generate(seed)458                }459            }460461            impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {462                fn slot_duration() -> sp_consensus_aura::SlotDuration {463                    sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())464                }465466                fn authorities() -> Vec<AuraId> {467                    Aura::authorities().to_vec()468                }469            }470471            impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {472                fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {473                    ParachainSystem::collect_collation_info(header)474                }475            }476477            impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {478                fn account_nonce(account: AccountId) -> Index {479                    System::account_nonce(account)480                }481            }482483            impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {484                fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {485                    TransactionPayment::query_info(uxt, len)486                }487                fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {488                    TransactionPayment::query_fee_details(uxt, len)489                }490                fn query_weight_to_fee(weight: Weight) -> Balance {491                    TransactionPayment::weight_to_fee(weight)492                }493                fn query_length_to_fee(length: u32) -> Balance {494                    TransactionPayment::length_to_fee(length)495                }496            }497498            /*499            impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>500                for Runtime501            {502                fn call(503                    origin: AccountId,504                    dest: AccountId,505                    value: Balance,506                    gas_limit: u64,507                    input_data: Vec<u8>,508                ) -> pallet_contracts_primitives::ContractExecResult {509                    Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)510                }511512                fn instantiate(513                    origin: AccountId,514                    endowment: Balance,515                    gas_limit: u64,516                    code: pallet_contracts_primitives::Code<Hash>,517                    data: Vec<u8>,518                    salt: Vec<u8>,519                ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>520                {521                    Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)522                }523524                fn get_storage(525                    address: AccountId,526                    key: [u8; 32],527                ) -> pallet_contracts_primitives::GetStorageResult {528                    Contracts::get_storage(address, key)529                }530531                fn rent_projection(532                    address: AccountId,533                ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {534                    Contracts::rent_projection(address)535                }536            }537            */538539            #[cfg(feature = "runtime-benchmarks")]540            impl frame_benchmarking::Benchmark<Block> for Runtime {541                fn benchmark_metadata(extra: bool) -> (542                    Vec<frame_benchmarking::BenchmarkList>,543                    Vec<frame_support::traits::StorageInfo>,544                ) {545                    use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};546                    use frame_support::traits::StorageInfoTrait;547548                    let mut list = Vec::<BenchmarkList>::new();549                    list_benchmark!(list, extra, pallet_xcm, PolkadotXcm);550551                    list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);552                    list_benchmark!(list, extra, pallet_common, Common);553                    list_benchmark!(list, extra, pallet_unique, Unique);554                    list_benchmark!(list, extra, pallet_structure, Structure);555                    list_benchmark!(list, extra, pallet_inflation, Inflation);556                    list_benchmark!(list, extra, pallet_configuration, Configuration);557558                    #[cfg(feature = "app-promotion")]559                    list_benchmark!(list, extra, pallet_app_promotion, AppPromotion);560561                    list_benchmark!(list, extra, pallet_fungible, Fungible);562                    list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);563564                    #[cfg(feature = "refungible")]565                    list_benchmark!(list, extra, pallet_refungible, Refungible);566567                    #[cfg(feature = "scheduler")]568                    list_benchmark!(list, extra, pallet_unique_scheduler_v2, Scheduler);569570                    #[cfg(feature = "collator-selection")]571                    list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);572573                    #[cfg(feature = "collator-selection")]574                    list_benchmark!(list, extra, pallet_identity, Identity);575576                    #[cfg(feature = "foreign-assets")]577                    list_benchmark!(list, extra, pallet_foreign_assets, ForeignAssets);578579                    list_benchmark!(list, extra, pallet_maintenance, Maintenance);580581                    // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);582583                    let storage_info = AllPalletsWithSystem::storage_info();584585                    return (list, storage_info)586                }587588                fn dispatch_benchmark(589                    config: frame_benchmarking::BenchmarkConfig590                ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {591                    use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};592593                    let allowlist: Vec<TrackedStorageKey> = vec![594                        // Total Issuance595                        hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),596597                        // Block Number598                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),599                        // Execution Phase600                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),601                        // Event Count602                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),603                        // System Events604                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),605606                        // Evm CurrentLogs607                        hex_literal::hex!("1da53b775b270400e7e61ed5cbc5a146547f210cec367e9af919603343b9cb56").to_vec().into(),608609                        // Transactional depth610                        hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),611                    ];612613                    let mut batches = Vec::<BenchmarkBatch>::new();614                    let params = (&config, &allowlist);615                    add_benchmark!(params, batches, pallet_xcm, PolkadotXcm);616617                    add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);618                    add_benchmark!(params, batches, pallet_common, Common);619                    add_benchmark!(params, batches, pallet_unique, Unique);620                    add_benchmark!(params, batches, pallet_structure, Structure);621                    add_benchmark!(params, batches, pallet_inflation, Inflation);622                    add_benchmark!(params, batches, pallet_configuration, Configuration);623624                    #[cfg(feature = "app-promotion")]625                    add_benchmark!(params, batches, pallet_app_promotion, AppPromotion);626627                    add_benchmark!(params, batches, pallet_fungible, Fungible);628                    add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);629630                    #[cfg(feature = "refungible")]631                    add_benchmark!(params, batches, pallet_refungible, Refungible);632633                    #[cfg(feature = "scheduler")]634                    add_benchmark!(params, batches, pallet_unique_scheduler_v2, Scheduler);635636                    #[cfg(feature = "collator-selection")]637                    add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);638639                    #[cfg(feature = "collator-selection")]640                    add_benchmark!(params, batches, pallet_identity, Identity);641642                    #[cfg(feature = "foreign-assets")]643                    add_benchmark!(params, batches, pallet_foreign_assets, ForeignAssets);644645                    add_benchmark!(params, batches, pallet_maintenance, Maintenance);646647                    // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);648649                    if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }650                    Ok(batches)651                }652            }653654            impl up_pov_estimate_rpc::PovEstimateApi<Block> for Runtime {655                #[allow(unused_variables)]656                fn pov_estimate(uxt: Bytes) -> ApplyExtrinsicResult {657                    #[cfg(feature = "pov-estimate")]658                    {659                        use codec::Decode;660661                        let uxt_decode = <<Block as BlockT>::Extrinsic as Decode>::decode(&mut &*uxt)662                            .map_err(|_| DispatchError::Other("failed to decode the extrinsic"));663664                        let uxt = match uxt_decode {665                            Ok(uxt) => uxt,666                            Err(err) => return Ok(err.into()),667                        };668669                        Executive::apply_extrinsic(uxt)670                    }671672                    #[cfg(not(feature = "pov-estimate"))]673                    return Ok(unsupported!());674                }675            }676677            #[cfg(feature = "try-runtime")]678            impl frame_try_runtime::TryRuntime<Block> for Runtime {679                fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {680                    log::info!("try-runtime::on_runtime_upgrade unique-chain.");681                    let weight = Executive::try_runtime_upgrade(checks).unwrap();682                    (weight, crate::config::substrate::RuntimeBlockWeights::get().max_block)683                }684685                fn execute_block(686                    block: Block,687                    state_root_check: bool,688                    signature_check: bool,689                    select: frame_try_runtime::TryStateSelect690                ) -> Weight {691                    log::info!(692                        target: "node-runtime",693                        "try-runtime: executing block {:?} / root checks: {:?} / try-state-select: {:?}",694                        block.header.hash(),695                        state_root_check,696                        select,697                    );698699                    Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()700                }701            }702        }703    }704}
after · runtime/common/runtime_apis.rs
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(<pallet_common::CollectionHandle<Runtime>>::try_get($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::pallet_prelude::Weight;46        use fp_rpc::TransactionStatus;47        use pallet_transaction_payment::{48            FeeDetails, RuntimeDispatchInfo,49        };50        use pallet_evm::{51            Runner, account::CrossAccountId as _,52            Account as EVMAccount, FeeCalculator,53        };54        use runtime_common::{55            sponsoring::{SponsorshipPredict, UniqueSponsorshipPredict},56            dispatch::CollectionDispatch,57            config::ethereum::CrossAccountId,58        };59        use up_data_structs::*;606162        impl_runtime_apis! {63            $($($custom_apis)+)?6465            impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {66                fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {67                    dispatch_unique_runtime!(collection.account_tokens(account))68                }69                fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {70                    dispatch_unique_runtime!(collection.collection_tokens())71                }72                fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {73                    dispatch_unique_runtime!(collection.token_exists(token))74                }7576                fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {77                    dispatch_unique_runtime!(collection.token_owner(token).ok())78                }7980                fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec::<CrossAccountId>, DispatchError>  {81                   dispatch_unique_runtime!(collection.token_owners(token))82                }8384                fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {85                    let budget = up_data_structs::budget::Value::new(10);8687                    Ok(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?)88                }89                fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>, DispatchError> {90                    Ok(<pallet_nonfungible::Pallet<Runtime>>::token_children_ids(collection, token))91                }92                fn collection_properties(93                    collection: CollectionId,94                    keys: Option<Vec<Vec<u8>>>95                ) -> Result<Vec<Property>, DispatchError> {96                    let keys = keys.map(97                        |keys| Common::bytes_keys_to_property_keys(keys)98                    ).transpose()?;99100                    Common::filter_collection_properties(collection, keys)101                }102103                fn token_properties(104                    collection: CollectionId,105                    token_id: TokenId,106                    keys: Option<Vec<Vec<u8>>>107                ) -> Result<Vec<Property>, DispatchError> {108                    let keys = keys.map(109                        |keys| Common::bytes_keys_to_property_keys(keys)110                    ).transpose()?;111112                    dispatch_unique_runtime!(collection.token_properties(token_id, keys))113                }114115                fn property_permissions(116                    collection: CollectionId,117                    keys: Option<Vec<Vec<u8>>>118                ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {119                    let keys = keys.map(120                        |keys| Common::bytes_keys_to_property_keys(keys)121                    ).transpose()?;122123                    Common::filter_property_permissions(collection, keys)124                }125126                fn token_data(127                    collection: CollectionId,128                    token_id: TokenId,129                    keys: Option<Vec<Vec<u8>>>130                ) -> Result<TokenData<CrossAccountId>, DispatchError> {131                    let token_data = TokenData {132                        properties: Self::token_properties(collection, token_id, keys)?,133                        owner: Self::token_owner(collection, token_id)?,134                        pieces: Self::total_pieces(collection, token_id)?.unwrap_or(0),135                    };136137                    Ok(token_data)138                }139140                fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {141                    dispatch_unique_runtime!(collection.total_supply())142                }143                fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {144                    dispatch_unique_runtime!(collection.account_balance(account))145                }146                fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {147                    dispatch_unique_runtime!(collection.balance(account, token))148                }149                fn allowance(150                    collection: CollectionId,151                    sender: CrossAccountId,152                    spender: CrossAccountId,153                    token: TokenId,154                ) -> Result<u128, DispatchError> {155                    dispatch_unique_runtime!(collection.allowance(sender, spender, token))156                }157158                fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {159                    Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))160                }161                fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {162                    Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))163                }164                fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {165                    Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))166                }167                fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {168                    dispatch_unique_runtime!(collection.last_token_id())169                }170                fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {171                    Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))172                }173                fn collection_stats() -> Result<CollectionStats, DispatchError> {174                    Ok(<pallet_common::Pallet<Runtime>>::collection_stats())175                }176                fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {177                    Ok(<UniqueSponsorshipPredict<Runtime> as SponsorshipPredict<Runtime>>::predict(178                        collection,179                        account,180                        token181                    ))182                }183184                fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {185                    Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))186                }187188                fn total_pieces(collection: CollectionId, token_id: TokenId) -> Result<Option<u128>, DispatchError> {189                    dispatch_unique_runtime!(collection.total_pieces(token_id))190                }191192		        fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool, DispatchError> {193                    dispatch_unique_runtime!(collection.allowance_for_all(owner, operator))194                }195            }196197            impl app_promotion_rpc::AppPromotionApi<Block, BlockNumber, CrossAccountId, AccountId> for Runtime {198                #[allow(unused_variables)]199                fn total_staked(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {200                    #[cfg(not(feature = "app-promotion"))]201                    return unsupported!();202203                    #[cfg(feature = "app-promotion")]204                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked(staker).unwrap_or_default());205                }206207                #[allow(unused_variables)]208                fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {209                    #[cfg(not(feature = "app-promotion"))]210                    return unsupported!();211212                    #[cfg(feature = "app-promotion")]213                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked_per_block(staker));214                }215216                #[allow(unused_variables)]217                fn pending_unstake(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {218                    #[cfg(not(feature = "app-promotion"))]219                    return unsupported!();220221                    #[cfg(feature = "app-promotion")]222                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake(staker));223                }224225                #[allow(unused_variables)]226                fn pending_unstake_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {227                    #[cfg(not(feature = "app-promotion"))]228                    return unsupported!();229230                    #[cfg(feature = "app-promotion")]231                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake_per_block(staker))232                }233            }234235            impl sp_api::Core<Block> for Runtime {236                fn version() -> RuntimeVersion {237                    VERSION238                }239240                fn execute_block(block: Block) {241                    Executive::execute_block(block)242                }243244                fn initialize_block(header: &<Block as BlockT>::Header) {245                    Executive::initialize_block(header)246                }247            }248249            impl sp_api::Metadata<Block> for Runtime {250                fn metadata() -> OpaqueMetadata {251                    OpaqueMetadata::new(Runtime::metadata().into())252                }253254                fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {255                    Runtime::metadata_at_version(version)256                }257258                fn metadata_versions() -> sp_std::vec::Vec<u32> {259                    Runtime::metadata_versions()260                }261            }262263            impl sp_block_builder::BlockBuilder<Block> for Runtime {264                fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {265                    Executive::apply_extrinsic(extrinsic)266                }267268                fn finalize_block() -> <Block as BlockT>::Header {269                    Executive::finalize_block()270                }271272                fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {273                    data.create_extrinsics()274                }275276                fn check_inherents(277                    block: Block,278                    data: sp_inherents::InherentData,279                ) -> sp_inherents::CheckInherentsResult {280                    data.check_extrinsics(&block)281                }282283                // fn random_seed() -> <Block as BlockT>::Hash {284                //     RandomnessCollectiveFlip::random_seed().0285                // }286            }287288            impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {289                fn validate_transaction(290                    source: TransactionSource,291                    tx: <Block as BlockT>::Extrinsic,292                    hash: <Block as BlockT>::Hash,293                ) -> TransactionValidity {294                    Executive::validate_transaction(source, tx, hash)295                }296            }297298            impl sp_offchain::OffchainWorkerApi<Block> for Runtime {299                fn offchain_worker(header: &<Block as BlockT>::Header) {300                    Executive::offchain_worker(header)301                }302            }303304            impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {305                fn chain_id() -> u64 {306                    <Runtime as pallet_evm::Config>::ChainId::get()307                }308309                fn account_basic(address: H160) -> EVMAccount {310                    let (account, _) = EVM::account_basic(&address);311                    account312                }313314                fn gas_price() -> U256 {315                    let (price, _) = <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price();316                    price317                }318319                fn account_code_at(address: H160) -> Vec<u8> {320                    use pallet_evm::OnMethodCall;321                    <Runtime as pallet_evm::Config>::OnMethodCall::get_code(&address)322                        .unwrap_or_else(|| pallet_evm::AccountCodes::<Runtime>::get(address))323                }324325                fn author() -> H160 {326                    <pallet_evm::Pallet<Runtime>>::find_author()327                }328329                fn storage_at(address: H160, index: U256) -> H256 {330                    let mut tmp = [0u8; 32];331                    index.to_big_endian(&mut tmp);332                    pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))333                }334335                #[allow(clippy::redundant_closure)]336                fn call(337                    from: H160,338                    to: H160,339                    data: Vec<u8>,340                    value: U256,341                    gas_limit: U256,342                    max_fee_per_gas: Option<U256>,343                    max_priority_fee_per_gas: Option<U256>,344                    nonce: Option<U256>,345                    estimate: bool,346                    access_list: Option<Vec<(H160, Vec<H256>)>>,347                ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {348                    let config = if estimate {349                        let mut config = <Runtime as pallet_evm::Config>::config().clone();350                        config.estimate = true;351                        Some(config)352                    } else {353                        None354                    };355356                    let is_transactional = false;357                    let validate = false;358                    <Runtime as pallet_evm::Config>::Runner::call(359                        CrossAccountId::from_eth(from),360                        to,361                        data,362                        value,363                        gas_limit.low_u64(),364                        max_fee_per_gas,365                        max_priority_fee_per_gas,366                        nonce,367                        access_list.unwrap_or_default(),368                        is_transactional,369                        validate,370                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),371                    ).map_err(|err| err.error.into())372                }373374                #[allow(clippy::redundant_closure)]375                fn create(376                    from: H160,377                    data: Vec<u8>,378                    value: U256,379                    gas_limit: U256,380                    max_fee_per_gas: Option<U256>,381                    max_priority_fee_per_gas: Option<U256>,382                    nonce: Option<U256>,383                    estimate: bool,384                    access_list: Option<Vec<(H160, Vec<H256>)>>,385                ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {386                    let config = if estimate {387                        let mut config = <Runtime as pallet_evm::Config>::config().clone();388                        config.estimate = true;389                        Some(config)390                    } else {391                        None392                    };393394                    let is_transactional = false;395                    let validate = false;396                    <Runtime as pallet_evm::Config>::Runner::create(397                        CrossAccountId::from_eth(from),398                        data,399                        value,400                        gas_limit.low_u64(),401                        max_fee_per_gas,402                        max_priority_fee_per_gas,403                        nonce,404                        access_list.unwrap_or_default(),405                        is_transactional,406                        validate,407                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),408                    ).map_err(|err| err.error.into())409                }410411                fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {412                    pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()413                }414415                fn current_block() -> Option<pallet_ethereum::Block> {416                    pallet_ethereum::CurrentBlock::<Runtime>::get()417                }418419                fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {420                    pallet_ethereum::CurrentReceipts::<Runtime>::get()421                }422423                fn current_all() -> (424                    Option<pallet_ethereum::Block>,425                    Option<Vec<pallet_ethereum::Receipt>>,426                    Option<Vec<TransactionStatus>>427                ) {428                    (429                        pallet_ethereum::CurrentBlock::<Runtime>::get(),430                        pallet_ethereum::CurrentReceipts::<Runtime>::get(),431                        pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()432                    )433                }434435                fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {436                    xts.into_iter().filter_map(|xt| match xt.0.function {437                        RuntimeCall::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),438                        _ => None439                    }).collect()440                }441442                fn elasticity() -> Option<Permill> {443                    None444                }445446                fn gas_limit_multiplier_support() {}447            }448449            impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {450                fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic  {451                    UncheckedExtrinsic::new_unsigned(452                        pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),453                    )454                }455            }456457            impl sp_session::SessionKeys<Block> for Runtime {458                fn decode_session_keys(459                    encoded: Vec<u8>,460                ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {461                    SessionKeys::decode_into_raw_public_keys(&encoded)462                }463464                fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {465                    SessionKeys::generate(seed)466                }467            }468469            impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {470                fn slot_duration() -> sp_consensus_aura::SlotDuration {471                    sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())472                }473474                fn authorities() -> Vec<AuraId> {475                    Aura::authorities().to_vec()476                }477            }478479            impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {480                fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {481                    ParachainSystem::collect_collation_info(header)482                }483            }484485            impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {486                fn account_nonce(account: AccountId) -> Index {487                    System::account_nonce(account)488                }489            }490491            impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {492                fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {493                    TransactionPayment::query_info(uxt, len)494                }495                fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {496                    TransactionPayment::query_fee_details(uxt, len)497                }498                fn query_weight_to_fee(weight: Weight) -> Balance {499                    TransactionPayment::weight_to_fee(weight)500                }501                fn query_length_to_fee(length: u32) -> Balance {502                    TransactionPayment::length_to_fee(length)503                }504            }505506            /*507            impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>508                for Runtime509            {510                fn call(511                    origin: AccountId,512                    dest: AccountId,513                    value: Balance,514                    gas_limit: u64,515                    input_data: Vec<u8>,516                ) -> pallet_contracts_primitives::ContractExecResult {517                    Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)518                }519520                fn instantiate(521                    origin: AccountId,522                    endowment: Balance,523                    gas_limit: u64,524                    code: pallet_contracts_primitives::Code<Hash>,525                    data: Vec<u8>,526                    salt: Vec<u8>,527                ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>528                {529                    Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)530                }531532                fn get_storage(533                    address: AccountId,534                    key: [u8; 32],535                ) -> pallet_contracts_primitives::GetStorageResult {536                    Contracts::get_storage(address, key)537                }538539                fn rent_projection(540                    address: AccountId,541                ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {542                    Contracts::rent_projection(address)543                }544            }545            */546547            #[cfg(feature = "runtime-benchmarks")]548            impl frame_benchmarking::Benchmark<Block> for Runtime {549                fn benchmark_metadata(extra: bool) -> (550                    Vec<frame_benchmarking::BenchmarkList>,551                    Vec<frame_support::traits::StorageInfo>,552                ) {553                    use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};554                    use frame_support::traits::StorageInfoTrait;555556                    let mut list = Vec::<BenchmarkList>::new();557                    list_benchmark!(list, extra, pallet_xcm, PolkadotXcm);558559                    list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);560                    list_benchmark!(list, extra, pallet_common, Common);561                    list_benchmark!(list, extra, pallet_unique, Unique);562                    list_benchmark!(list, extra, pallet_structure, Structure);563                    list_benchmark!(list, extra, pallet_inflation, Inflation);564                    list_benchmark!(list, extra, pallet_configuration, Configuration);565566                    #[cfg(feature = "app-promotion")]567                    list_benchmark!(list, extra, pallet_app_promotion, AppPromotion);568569                    list_benchmark!(list, extra, pallet_fungible, Fungible);570                    list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);571572                    #[cfg(feature = "refungible")]573                    list_benchmark!(list, extra, pallet_refungible, Refungible);574575                    #[cfg(feature = "scheduler")]576                    list_benchmark!(list, extra, pallet_unique_scheduler_v2, Scheduler);577578                    #[cfg(feature = "collator-selection")]579                    list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);580581                    #[cfg(feature = "collator-selection")]582                    list_benchmark!(list, extra, pallet_identity, Identity);583584                    #[cfg(feature = "foreign-assets")]585                    list_benchmark!(list, extra, pallet_foreign_assets, ForeignAssets);586587                    list_benchmark!(list, extra, pallet_maintenance, Maintenance);588589                    // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);590591                    let storage_info = AllPalletsWithSystem::storage_info();592593                    return (list, storage_info)594                }595596                fn dispatch_benchmark(597                    config: frame_benchmarking::BenchmarkConfig598                ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {599                    use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};600601                    let allowlist: Vec<TrackedStorageKey> = vec![602                        // Total Issuance603                        hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),604605                        // Block Number606                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),607                        // Execution Phase608                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),609                        // Event Count610                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),611                        // System Events612                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),613614                        // Evm CurrentLogs615                        hex_literal::hex!("1da53b775b270400e7e61ed5cbc5a146547f210cec367e9af919603343b9cb56").to_vec().into(),616617                        // Transactional depth618                        hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),619                    ];620621                    let mut batches = Vec::<BenchmarkBatch>::new();622                    let params = (&config, &allowlist);623                    add_benchmark!(params, batches, pallet_xcm, PolkadotXcm);624625                    add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);626                    add_benchmark!(params, batches, pallet_common, Common);627                    add_benchmark!(params, batches, pallet_unique, Unique);628                    add_benchmark!(params, batches, pallet_structure, Structure);629                    add_benchmark!(params, batches, pallet_inflation, Inflation);630                    add_benchmark!(params, batches, pallet_configuration, Configuration);631632                    #[cfg(feature = "app-promotion")]633                    add_benchmark!(params, batches, pallet_app_promotion, AppPromotion);634635                    add_benchmark!(params, batches, pallet_fungible, Fungible);636                    add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);637638                    #[cfg(feature = "refungible")]639                    add_benchmark!(params, batches, pallet_refungible, Refungible);640641                    #[cfg(feature = "scheduler")]642                    add_benchmark!(params, batches, pallet_unique_scheduler_v2, Scheduler);643644                    #[cfg(feature = "collator-selection")]645                    add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);646647                    #[cfg(feature = "collator-selection")]648                    add_benchmark!(params, batches, pallet_identity, Identity);649650                    #[cfg(feature = "foreign-assets")]651                    add_benchmark!(params, batches, pallet_foreign_assets, ForeignAssets);652653                    add_benchmark!(params, batches, pallet_maintenance, Maintenance);654655                    // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);656657                    if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }658                    Ok(batches)659                }660            }661662            impl up_pov_estimate_rpc::PovEstimateApi<Block> for Runtime {663                #[allow(unused_variables)]664                fn pov_estimate(uxt: Vec<u8>) -> ApplyExtrinsicResult {665                    #[cfg(feature = "pov-estimate")]666                    {667                        use codec::Decode;668669                        let uxt_decode = <<Block as BlockT>::Extrinsic as Decode>::decode(&mut &uxt)670                            .map_err(|_| DispatchError::Other("failed to decode the extrinsic"));671672                        let uxt = match uxt_decode {673                            Ok(uxt) => uxt,674                            Err(err) => return Ok(err.into()),675                        };676677                        Executive::apply_extrinsic(uxt)678                    }679680                    #[cfg(not(feature = "pov-estimate"))]681                    return Ok(unsupported!());682                }683            }684685            #[cfg(feature = "try-runtime")]686            impl frame_try_runtime::TryRuntime<Block> for Runtime {687                fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {688                    log::info!("try-runtime::on_runtime_upgrade unique-chain.");689                    let weight = Executive::try_runtime_upgrade(checks).unwrap();690                    (weight, crate::config::substrate::RuntimeBlockWeights::get().max_block)691                }692693                fn execute_block(694                    block: Block,695                    state_root_check: bool,696                    signature_check: bool,697                    select: frame_try_runtime::TryStateSelect698                ) -> Weight {699                    log::info!(700                        target: "node-runtime",701                        "try-runtime: executing block {:?} / root checks: {:?} / try-state-select: {:?}",702                        block.header.hash(),703                        state_root_check,704                        select,705                    );706707                    Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()708                }709            }710        }711    }712}
modifiedruntime/common/weights/xcm.rsdiffbeforeafterboth
--- a/runtime/common/weights/xcm.rs
+++ b/runtime/common/weights/xcm.rs
@@ -244,5 +244,9 @@
 			.saturating_add(T::DbWeight::get().reads(9_u64))
 			.saturating_add(T::DbWeight::get().writes(4_u64))
 	}
+
+	fn force_suspension() -> Weight {
+		Default::default()
+	}
 }
 
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -220,7 +220,7 @@
 orml-xcm-support = { workspace = true }
 pallet-aura = { workspace = true }
 pallet-authorship = { workspace = true }
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 pallet-preimage = { workspace = true }
 pallet-session = { workspace = true }
 pallet-sudo = { workspace = true }
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -212,7 +212,7 @@
 orml-xcm-support = { workspace = true }
 pallet-aura = { workspace = true }
 pallet-authorship = { workspace = true }
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 pallet-preimage = { workspace = true }
 pallet-session = { workspace = true }
 pallet-sudo = { workspace = true }
modifiedruntime/tests/Cargo.tomldiffbeforeafterboth
--- a/runtime/tests/Cargo.toml
+++ b/runtime/tests/Cargo.toml
@@ -9,37 +9,37 @@
 refungible = []
 
 [dependencies]
-up-data-structs = { default-features = false, path = "../../primitives/data-structs" }
+up-data-structs = { workspace = true }
 
-sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
+sp-core = { workspace = true }
+sp-io = { workspace = true }
+sp-runtime = { workspace = true }
+sp-std = { workspace = true }
 
-frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
+frame-support = { workspace = true }
+frame-system = { workspace = true }
 
-pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
-pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
+pallet-timestamp = { workspace = true }
+pallet-transaction-payment = { workspace = true }
 
-pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
+pallet-ethereum = { workspace = true }
+pallet-evm = { workspace = true }
 
-pallet-common.path = "../../pallets/common"
-pallet-fungible.path = "../../pallets/fungible"
-pallet-nonfungible.path = "../../pallets/nonfungible"
-pallet-refungible.path = "../../pallets/refungible"
-pallet-structure.path = "../../pallets/structure"
-pallet-unique.path = "../../pallets/unique"
+pallet-common = { workspace = true }
+pallet-fungible = { workspace = true }
+pallet-nonfungible = { workspace = true }
+pallet-refungible = { workspace = true }
+pallet-structure = { workspace = true }
+pallet-unique = { workspace = true }
 
-pallet-evm-coder-substrate.path = "../../pallets/evm-coder-substrate"
+pallet-evm-coder-substrate = { workspace = true }
 
-parity-scale-codec = { version = "3.2.2", default-features = false, features = ["derive"] }
-scale-info = "*"
+codec = { workspace = true }
+scale-info = { workspace = true }
 
 evm-coder = { workspace = true }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.42" }
+up-sponsorship = { workspace = true }
 xcm = { workspace = true }
 pallet-xcm = { workspace = true }
 pallet-configuration = { workspace = true }
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -211,7 +211,7 @@
 orml-xcm-support = { workspace = true }
 pallet-aura = { workspace = true }
 pallet-authorship = { workspace = true }
-pallet-balances = { workspace = true }
+pallet-balances = { features = ["insecure_zero_ed"], workspace = true }
 pallet-preimage = { workspace = true }
 pallet-session = { workspace = true }
 pallet-sudo = { workspace = true }