git.delta.rocks / unique-network / refs/commits / 008833a7ebae

difftreelog

refactor(weight) bench rename `transfer` to `transfer_raw`

PraetorP2023-03-31parent: #c35b923.patch.diff
in: master

8 files changed

modifiedpallets/fungible/src/benchmarking.rsdiffbeforeafterboth
after · pallets/fungible/src/benchmarking.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/>.1617use super::*;18use crate::{Pallet, Config, FungibleHandle};1920use sp_std::prelude::*;21use pallet_common::benchmarking::create_collection_raw;22use frame_benchmarking::{benchmarks, account};23use up_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH, budget::Unlimited};24use pallet_common::bench_init;2526const SEED: u32 = 1;2728fn create_collection<T: Config>(29	owner: T::CrossAccountId,30) -> Result<FungibleHandle<T>, DispatchError> {31	create_collection_raw(32		owner,33		CollectionMode::Fungible(0),34		|owner: T::CrossAccountId, data| {35			<Pallet<T>>::init_collection(owner.clone(), owner, data, Default::default())36		},37		FungibleHandle::cast,38	)39}4041benchmarks! {42	create_item {43		bench_init!{44			owner: sub; collection: collection(owner);45			sender: cross_from_sub(owner); to: cross_sub;46		};47	}: {<Pallet<T>>::create_item(&collection, &sender, (to, 200), &Unlimited)?}4849	create_multiple_items_ex {50		let b in 0..MAX_ITEMS_PER_BATCH;51		bench_init!{52			owner: sub; collection: collection(owner);53			sender: cross_from_sub(owner);54		};55		let data = (0..b).map(|i| {56			bench_init!(to: cross_sub(i););57			(to, 200)58		}).collect::<BTreeMap<_, _>>().try_into().unwrap();59	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}6061	burn_item {62		bench_init!{63			owner: sub; collection: collection(owner);64			owner: cross_from_sub; burner: cross_sub;65		};66		<Pallet<T>>::create_item(&collection, &owner, (burner.clone(), 200), &Unlimited)?;67	}: {<Pallet<T>>::burn(&collection, &burner, 100)?}6869	transfer_raw {70		bench_init!{71			owner: sub; collection: collection(owner);72			owner: cross_from_sub; sender: cross_sub; to: cross_sub;73		};74		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;75	}: {<Pallet<T>>::transfer(&collection, &sender, &to, 200, &Unlimited)?}7677	approve {78		bench_init!{79			owner: sub; collection: collection(owner);80			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;81		};82		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;83	}: {<Pallet<T>>::set_allowance(&collection, &sender, &spender, 100)?}8485	approve_from {86		bench_init!{87			owner: sub; collection: collection(owner);88			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;8990		};91		let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());92		<Pallet<T>>::create_item(&collection, &owner, (owner_eth.clone(), 200), &Unlimited)?;93	}: {<Pallet<T>>::set_allowance_from(&collection, &sender, &owner_eth, &spender, 100)?}9495	 check_allowed_raw {96		bench_init!{97			owner: sub; collection: collection(owner);98			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;99		};100		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;101		<Pallet<T>>::set_allowance(&collection, &sender, &spender, 200)?;102	}: {<Pallet<T>>::check_allowed(&collection, &spender, &sender, 200, &Unlimited)?;}103104	set_allowance_unchecked_raw {105		bench_init!{106			owner: sub; collection: collection(owner);107			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;108		};109		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;110	}: {<Pallet<T>>::set_allowance_unchecked(&collection, &sender, &spender, 200);}111112	burn_from {113		bench_init!{114			owner: sub; collection: collection(owner);115			owner: cross_from_sub; sender: cross_sub; burner: cross_sub;116		};117		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;118		<Pallet<T>>::set_allowance(&collection, &sender, &burner, 200)?;119	}: {<Pallet<T>>::burn_from(&collection, &burner, &sender, 100, &Unlimited)?}120}
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -78,7 +78,7 @@
 	}
 
 	fn transfer() -> Weight {
-		<SelfWeightOf<T>>::transfer() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
+		<SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
 	}
 
 	fn approve() -> Weight {
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -400,7 +400,7 @@
 			<CommonError<T>>::TransferNotAllowed,
 		);
 
-		let mut actual_weight = <SelfWeightOf<T>>::transfer();
+		let mut actual_weight = <SelfWeightOf<T>>::transfer_raw();
 
 		if collection.permissions.access() == AccessMode::AllowList {
 			collection.check_allowlist(from)?;
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -37,7 +37,7 @@
 	fn create_item() -> Weight;
 	fn create_multiple_items_ex(b: u32, ) -> Weight;
 	fn burn_item() -> Weight;
-	fn transfer() -> Weight;
+	fn transfer_raw() -> Weight;
 	fn approve() -> Weight;
 	fn approve_from() -> Weight;
 	fn check_allowed_raw() -> Weight;
@@ -93,16 +93,11 @@
 			.saturating_add(T::DbWeight::get().reads(2_u64))
 			.saturating_add(T::DbWeight::get().writes(2_u64))
 	}
-	/// Storage: Fungible Balance (r:2 w:2)
-	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)
-	fn transfer() -> Weight {
-		// Proof Size summary in bytes:
-		//  Measured:  `182`
-		//  Estimated: `5104`
-		// Minimum execution time: 13_832_000 picoseconds.
-		Weight::from_parts(14_064_000, 5104)
-			.saturating_add(T::DbWeight::get().reads(2_u64))
-			.saturating_add(T::DbWeight::get().writes(2_u64))
+	// Storage: Fungible Balance (r:2 w:2)
+	fn transfer_raw() -> Weight {
+		Weight::from_ref_time(12_041_000 as u64)
+			.saturating_add(T::DbWeight::get().reads(2 as u64))
+			.saturating_add(T::DbWeight::get().writes(2 as u64))
 	}
 	/// Storage: Fungible Balance (r:1 w:0)
 	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)
@@ -205,16 +200,11 @@
 			.saturating_add(RocksDbWeight::get().reads(2_u64))
 			.saturating_add(RocksDbWeight::get().writes(2_u64))
 	}
-	/// Storage: Fungible Balance (r:2 w:2)
-	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)
-	fn transfer() -> Weight {
-		// Proof Size summary in bytes:
-		//  Measured:  `182`
-		//  Estimated: `5104`
-		// Minimum execution time: 13_832_000 picoseconds.
-		Weight::from_parts(14_064_000, 5104)
-			.saturating_add(RocksDbWeight::get().reads(2_u64))
-			.saturating_add(RocksDbWeight::get().writes(2_u64))
+	// Storage: Fungible Balance (r:2 w:2)
+	fn transfer_raw() -> Weight {
+		Weight::from_ref_time(12_041_000 as u64)
+			.saturating_add(RocksDbWeight::get().reads(2 as u64))
+			.saturating_add(RocksDbWeight::get().writes(2 as u64))
 	}
 	/// Storage: Fungible Balance (r:1 w:0)
 	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -121,7 +121,7 @@
 		}
 	}: {<Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)?}
 
-	transfer {
+	transfer_raw {
 		bench_init!{
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub; sender: cross_sub; receiver: cross_sub;
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -91,7 +91,7 @@
 	}
 
 	fn transfer() -> Weight {
-		<SelfWeightOf<T>>::transfer() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
+		<SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
 	}
 
 	fn approve() -> Weight {
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -809,7 +809,7 @@
 			<CommonError<T>>::TransferNotAllowed
 		);
 
-		let mut actual_weight = <SelfWeightOf<T>>::transfer();
+		let mut actual_weight = <SelfWeightOf<T>>::transfer_raw();
 		let token_data =
 			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;
 		ensure!(&token_data.owner == from, <CommonError<T>>::NoPermission);
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -40,7 +40,7 @@
 	fn burn_item() -> Weight;
 	fn burn_recursively_self_raw() -> Weight;
 	fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight;
-	fn transfer() -> Weight;
+	fn transfer_raw() -> Weight;
 	fn approve() -> Weight;
 	fn approve_from() -> Weight;
 	fn checks_allowed_raw() -> Weight;
@@ -209,22 +209,14 @@
 			.saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(b.into())))
 			.saturating_add(Weight::from_parts(0, 10097).saturating_mul(b.into()))
 	}
-	/// Storage: Nonfungible TokenData (r:1 w:1)
-	/// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
-	/// Storage: Nonfungible AccountBalance (r:2 w:2)
-	/// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
-	/// Storage: Nonfungible Allowance (r:1 w:0)
-	/// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
-	/// Storage: Nonfungible Owned (r:0 w:2)
-	/// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
-	fn transfer() -> Weight {
-		// Proof Size summary in bytes:
-		//  Measured:  `412`
-		//  Estimated: `10144`
-		// Minimum execution time: 18_629_000 picoseconds.
-		Weight::from_parts(18_997_000, 10144)
-			.saturating_add(T::DbWeight::get().reads(4_u64))
-			.saturating_add(T::DbWeight::get().writes(5_u64))
+	// Storage: Nonfungible TokenData (r:1 w:1)
+	// Storage: Nonfungible AccountBalance (r:2 w:2)
+	// Storage: Nonfungible Allowance (r:1 w:0)
+	// Storage: Nonfungible Owned (r:0 w:2)
+	fn transfer_raw() -> Weight {
+		Weight::from_ref_time(14_909_000 as u64)
+			.saturating_add(T::DbWeight::get().reads(4 as u64))
+			.saturating_add(T::DbWeight::get().writes(5 as u64))
 	}
 	/// Storage: Nonfungible TokenData (r:1 w:0)
 	/// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
@@ -523,22 +515,14 @@
 			.saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(b.into())))
 			.saturating_add(Weight::from_parts(0, 10097).saturating_mul(b.into()))
 	}
-	/// Storage: Nonfungible TokenData (r:1 w:1)
-	/// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
-	/// Storage: Nonfungible AccountBalance (r:2 w:2)
-	/// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
-	/// Storage: Nonfungible Allowance (r:1 w:0)
-	/// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
-	/// Storage: Nonfungible Owned (r:0 w:2)
-	/// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
-	fn transfer() -> Weight {
-		// Proof Size summary in bytes:
-		//  Measured:  `412`
-		//  Estimated: `10144`
-		// Minimum execution time: 18_629_000 picoseconds.
-		Weight::from_parts(18_997_000, 10144)
-			.saturating_add(RocksDbWeight::get().reads(4_u64))
-			.saturating_add(RocksDbWeight::get().writes(5_u64))
+	// Storage: Nonfungible TokenData (r:1 w:1)
+	// Storage: Nonfungible AccountBalance (r:2 w:2)
+	// Storage: Nonfungible Allowance (r:1 w:0)
+	// Storage: Nonfungible Owned (r:0 w:2)
+	fn transfer_raw() -> Weight {
+		Weight::from_ref_time(14_909_000 as u64)
+			.saturating_add(RocksDbWeight::get().reads(4 as u64))
+			.saturating_add(RocksDbWeight::get().writes(5 as u64))
 	}
 	/// Storage: Nonfungible TokenData (r:1 w:0)
 	/// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)