difftreelog
fix benchmarks
in: master
5 files changed
pallets/common/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -33,7 +33,7 @@
MAX_COLLECTION_NAME_LENGTH, MAX_PROPERTIES_PER_ITEM, MAX_TOKEN_PREFIX_LENGTH,
};
-use crate::{BenchmarkPropertyWriter, CollectionHandle, Config, Pallet};
+use crate::{BenchmarkPropertyWriter, CollectionHandle, CollectionIssuer, Config, Pallet};
const SEED: u32 = 1;
@@ -121,7 +121,7 @@
owner,
CollectionMode::NFT,
|owner: T::CrossAccountId, data| {
- <Pallet<T>>::init_collection(owner.clone(), Some(owner), false, data)
+ <Pallet<T>>::init_collection(owner.clone(), CollectionIssuer::User(owner), data)
},
|h| h,
)
pallets/fungible/src/benchmarking.rsdiffbeforeafterboth1// 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/>.1617use frame_benchmarking::{account, v2::*};18use pallet_common::{19 bench_init, benchmarking::create_collection_raw, CollectionIssuer, Pallet as PalletCommon,20};21use sp_std::prelude::*;22use up_data_structs::{budget::Unlimited, CollectionMode, MAX_ITEMS_PER_BATCH};2324use super::*;25use crate::{Config, FungibleHandle, Pallet};2627const SEED: u32 = 1;2829fn create_collection<T: Config>(30 owner: T::CrossAccountId,31) -> Result<FungibleHandle<T>, DispatchError> {32 create_collection_raw(33 owner,34 CollectionMode::Fungible(0),35 |owner: T::CrossAccountId, data| {36 <PalletCommon<T>>::init_collection(owner.clone(), CollectionIssuer::User(owner), data)37 },38 FungibleHandle::cast,39 )40}4142#[benchmarks]43mod benchmarks {44 use super::*;4546 #[benchmark]47 fn create_item() -> Result<(), BenchmarkError> {48 bench_init! {49 owner: sub; collection: collection(owner);50 sender: cross_from_sub(owner); to: cross_sub;51 };5253 #[block]54 {55 <Pallet<T>>::create_item(&collection, &sender, (to, 200), &Unlimited)?;56 }5758 Ok(())59 }6061 #[benchmark]62 fn create_multiple_items_ex(b: Linear<0, MAX_ITEMS_PER_BATCH>) -> Result<(), BenchmarkError> {63 bench_init! {64 owner: sub; collection: collection(owner);65 sender: cross_from_sub(owner);66 };67 let data = (0..b)68 .map(|i| {69 bench_init!(to: cross_sub(i););70 (to, 200)71 })72 .collect::<BTreeMap<_, _>>();7374 #[block]75 {76 <Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?;77 }7879 Ok(())80 }8182 #[benchmark]83 fn burn_item() -> Result<(), BenchmarkError> {84 bench_init! {85 owner: sub; collection: collection(owner);86 owner: cross_from_sub; burner: cross_sub;87 };88 <Pallet<T>>::create_item(&collection, &owner, (burner.clone(), 200), &Unlimited)?;8990 #[block]91 {92 <Pallet<T>>::burn(&collection, &burner, 100)?;93 }9495 Ok(())96 }9798 #[benchmark]99 fn transfer_raw() -> Result<(), BenchmarkError> {100 bench_init! {101 owner: sub; collection: collection(owner);102 owner: cross_from_sub; sender: cross_sub; to: cross_sub;103 };104 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;105106 #[block]107 {108 <Pallet<T>>::transfer(&collection, &sender, &to, 200, &Unlimited)?;109 }110111 Ok(())112 }113114 #[benchmark]115 fn approve() -> Result<(), BenchmarkError> {116 bench_init! {117 owner: sub; collection: collection(owner);118 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;119 };120 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;121122 #[block]123 {124 <Pallet<T>>::set_allowance(&collection, &sender, &spender, 100)?;125 }126127 Ok(())128 }129130 #[benchmark]131 fn approve_from() -> Result<(), BenchmarkError> {132 bench_init! {133 owner: sub; collection: collection(owner);134 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;135136 };137 let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());138 <Pallet<T>>::create_item(&collection, &owner, (owner_eth.clone(), 200), &Unlimited)?;139140 #[block]141 {142 <Pallet<T>>::set_allowance_from(&collection, &sender, &owner_eth, &spender, 100)?;143 }144145 Ok(())146 }147148 #[benchmark]149 fn check_allowed_raw() -> Result<(), BenchmarkError> {150 bench_init! {151 owner: sub; collection: collection(owner);152 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;153 };154 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;155 <Pallet<T>>::set_allowance(&collection, &sender, &spender, 200)?;156157 #[block]158 {159 <Pallet<T>>::check_allowed(&collection, &spender, &sender, 200, &Unlimited)?;160 }161162 Ok(())163 }164165 #[benchmark]166 fn set_allowance_unchecked_raw() -> Result<(), BenchmarkError> {167 bench_init! {168 owner: sub; collection: collection(owner);169 owner: cross_from_sub; sender: cross_sub; spender: cross_sub;170 };171 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;172173 #[block]174 {175 <Pallet<T>>::set_allowance_unchecked(&collection, &sender, &spender, 200);176 }177178 Ok(())179 }180181 #[benchmark]182 fn burn_from() -> Result<(), BenchmarkError> {183 bench_init! {184 owner: sub; collection: collection(owner);185 owner: cross_from_sub; sender: cross_sub; burner: cross_sub;186 };187 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;188 <Pallet<T>>::set_allowance(&collection, &sender, &burner, 200)?;189190 #[block]191 {192 <Pallet<T>>::burn_from(&collection, &burner, &sender, 100, &Unlimited)?193 }194195 Ok(())196 }197}pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -18,7 +18,7 @@
use pallet_common::{
bench_init,
benchmarking::{create_collection_raw, property_key, property_value},
- Pallet as PalletCommon,
+ CollectionIssuer, Pallet as PalletCommon,
};
use sp_std::prelude::*;
use up_data_structs::{
@@ -58,7 +58,7 @@
owner,
CollectionMode::NFT,
|owner: T::CrossAccountId, data| {
- <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), false, data)
+ <PalletCommon<T>>::init_collection(owner.clone(), CollectionIssuer::User(owner), data)
},
NonfungibleHandle::cast,
)
pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -20,7 +20,7 @@
use pallet_common::{
bench_init,
benchmarking::{create_collection_raw, property_key, property_value},
- Pallet as PalletCommon,
+ CollectionIssuer, Pallet as PalletCommon,
};
use sp_std::prelude::*;
use up_data_structs::{
@@ -63,7 +63,7 @@
owner,
CollectionMode::ReFungible,
|owner: T::CrossAccountId, data| {
- <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), false, data)
+ <PalletCommon<T>>::init_collection(owner.clone(), CollectionIssuer::User(owner), data)
},
RefungibleHandle::cast,
)
pallets/structure/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/structure/src/benchmarking.rs
+++ b/pallets/structure/src/benchmarking.rs
@@ -16,7 +16,7 @@
use frame_benchmarking::v2::{account, benchmarks, BenchmarkError};
use frame_support::traits::{fungible::Balanced, tokens::Precision, Get};
-use pallet_common::Config as CommonConfig;
+use pallet_common::{CollectionIssuer, Config as CommonConfig};
use pallet_evm::account::CrossAccountId;
use sp_std::vec;
use up_data_structs::{
@@ -44,7 +44,7 @@
.unwrap();
T::CollectionDispatch::create(
caller_cross.clone(),
- Some(caller_cross.clone()),
+ CollectionIssuer::User(caller_cross.clone()),
CreateCollectionData {
mode: CollectionMode::NFT,
..Default::default()