difftreelog
fix benchmarks
in: master
5 files changed
pallets/common/src/benchmarking.rsdiffbeforeafterboth120 create_collection_raw(120 create_collection_raw(121 owner,121 owner,122 CollectionMode::NFT,122 CollectionMode::NFT,123 |owner: T::CrossAccountId, data| <Pallet<T>>::init_collection(owner.clone(), owner, data),123 |owner: T::CrossAccountId, data| {124 <Pallet<T>>::init_collection(owner.clone(), Some(owner), data)125 },124 |h| h,126 |h| h,125 )127 )126}128}pallets/foreign-assets/src/benchmarking.rsdiffbeforeafterboth161617#![allow(missing_docs)]17#![allow(missing_docs)]181819use frame_benchmarking::{account, v2::*};19use frame_benchmarking::v2::*;20use frame_system::RawOrigin;20use frame_support::traits::Currency;21use pallet_common::benchmarking::create_u16_data;21use frame_system::RawOrigin;22use sp_std::vec;22use sp_std::{boxed::Box, vec, vec::Vec};23use staging_xcm::prelude::*;23use staging_xcm::{opaque::latest::Junction::Parachain, v3::Junctions::X1, VersionedMultiLocation};24use up_data_structs::{CollectionMode, MAX_COLLECTION_NAME_LENGTH};242525use super::{Call, Config, Pallet};26use super::{Call, Config, Pallet};26use crate::AssetMetadata;2728fn bounded<T: TryFrom<Vec<u8>>>(slice: &[u8]) -> T {29 T::try_from(slice.to_vec())30 .map_err(|_| "slice doesn't fit")31 .unwrap()32}332734#[benchmarks]28#[benchmarks]35mod benchmarks {29mod benchmarks {3036 use super::*;31 use super::*;373238 #[benchmark]33 #[benchmark]39 fn register_foreign_asset() -> Result<(), BenchmarkError> {34 fn force_register_foreign_asset() -> Result<(), BenchmarkError> {40 let owner: T::AccountId = account("user", 0, 1);41 let location: VersionedMultiLocation = VersionedMultiLocation::from(X1(Parachain(1000)));35 let location =36 MultiLocation::from(X3(Parachain(1000), PalletInstance(42), GeneralIndex(1)));42 let metadata: AssetMetadata<37 let name = create_u16_data::<MAX_COLLECTION_NAME_LENGTH>();43 <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance,44 > = AssetMetadata {45 name: bounded(b"name"),46 symbol: bounded(b"symbol"),47 decimals: 18,48 minimal_balance: 1u32.into(),49 };50 let mut balance: <<T as Config>::Currency as Currency<38 let mode = CollectionMode::NFT;51 <T as frame_system::Config>::AccountId,52 >>::Balance = 4_000_000_000u32.into();53 balance = balance * balance;54 <T as Config>::Currency::make_free_balance_be(&owner, balance);553956 #[extrinsic_call]40 #[extrinsic_call]57 _(41 _(RawOrigin::Root, location, name, mode);58 RawOrigin::Root,59 owner,60 Box::new(location),61 Box::new(metadata),62 );634264 Ok(())43 Ok(())65 }44 }6667 #[benchmark]68 fn update_foreign_asset() -> Result<(), BenchmarkError> {69 let owner: T::AccountId = account("user", 0, 1);70 let location: VersionedMultiLocation = VersionedMultiLocation::from(X1(Parachain(2000)));71 let metadata: AssetMetadata<72 <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance,73 > = AssetMetadata {74 name: bounded(b"name"),75 symbol: bounded(b"symbol"),76 decimals: 18,77 minimal_balance: 1u32.into(),78 };79 let metadata2: AssetMetadata<80 <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance,81 > = AssetMetadata {82 name: bounded(b"name2"),83 symbol: bounded(b"symbol2"),84 decimals: 18,85 minimal_balance: 1u32.into(),86 };87 let mut balance: <<T as Config>::Currency as Currency<88 <T as frame_system::Config>::AccountId,89 >>::Balance = 4_000_000_000u32.into();90 balance = balance * balance;91 <T as Config>::Currency::make_free_balance_be(&owner, balance);92 Pallet::<T>::register_foreign_asset(93 RawOrigin::Root.into(),94 owner,95 Box::new(location.clone()),96 Box::new(metadata),97 )?;9899 #[extrinsic_call]100 _(RawOrigin::Root, 0, Box::new(location), Box::new(metadata2));101102 Ok(())103 }104}45}10546pallets/fungible/src/benchmarking.rsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617use frame_benchmarking::{account, v2::*};17use frame_benchmarking::{account, v2::*};18use pallet_common::{bench_init, benchmarking::create_collection_raw};18use pallet_common::{bench_init, benchmarking::create_collection_raw, Pallet as PalletCommon};19use sp_std::prelude::*;19use sp_std::prelude::*;20use up_data_structs::{budget::Unlimited, CollectionMode, MAX_ITEMS_PER_BATCH};20use up_data_structs::{budget::Unlimited, CollectionMode, MAX_ITEMS_PER_BATCH};212130 create_collection_raw(30 create_collection_raw(31 owner,31 owner,32 CollectionMode::Fungible(0),32 CollectionMode::Fungible(0),33 |owner: T::CrossAccountId, data| <Pallet<T>>::init_collection(owner.clone(), owner, data),33 |owner: T::CrossAccountId, data| {34 <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), data)35 },34 FungibleHandle::cast,36 FungibleHandle::cast,35 )37 )36}38}pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth18use pallet_common::{18use pallet_common::{19 bench_init,19 bench_init,20 benchmarking::{create_collection_raw, property_key, property_value},20 benchmarking::{create_collection_raw, property_key, property_value},21 Pallet as PalletCommon,21};22};22use sp_std::prelude::*;23use sp_std::prelude::*;23use up_data_structs::{24use up_data_structs::{56 create_collection_raw(57 create_collection_raw(57 owner,58 owner,58 CollectionMode::NFT,59 CollectionMode::NFT,59 |owner: T::CrossAccountId, data| <Pallet<T>>::init_collection(owner.clone(), owner, data),60 |owner: T::CrossAccountId, data| {61 <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), data)62 },60 NonfungibleHandle::cast,63 NonfungibleHandle::cast,61 )64 )62}65}pallets/structure/src/benchmarking.rsdiffbeforeafterboth44 .unwrap();44 .unwrap();45 T::CollectionDispatch::create(45 T::CollectionDispatch::create(46 caller_cross.clone(),46 caller_cross.clone(),47 caller_cross.clone(),47 Some(caller_cross.clone()),48 CreateCollectionData {48 CreateCollectionData {49 mode: CollectionMode::NFT,49 mode: CollectionMode::NFT,50 ..Default::default()50 ..Default::default()