git.delta.rocks / unique-network / refs/commits / 5f8748ceb660

difftreelog

feat(rmrk) set benchmark generated weights

Daniel Shiposha2022-06-10parent: #e62a25f.patch.diff
in: master

2 files changed

modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -238,8 +238,8 @@
 		}
 
 		/// destroy collection
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::destroy_collection())]
 		pub fn destroy_collection(
 			origin: OriginFor<T>,
 			collection_id: RmrkCollectionId,
@@ -270,8 +270,8 @@
 		/// - `origin`: sender of the transaction
 		/// - `collection_id`: collection id of the nft to change issuer of
 		/// - `new_issuer`: Collection's new issuer
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::change_collection_issuer())]
 		pub fn change_collection_issuer(
 			origin: OriginFor<T>,
 			collection_id: RmrkCollectionId,
@@ -301,8 +301,8 @@
 		}
 
 		/// lock collection
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::lock_collection())]
 		pub fn lock_collection(
 			origin: OriginFor<T>,
 			collection_id: RmrkCollectionId,
@@ -342,8 +342,8 @@
 		/// - `royalty`: Permillage reward from each trade for the Recipient
 		/// - `metadata`: Arbitrary data about an nft, e.g. IPFS hash
 		/// - `transferable`: Ability to transfer this NFT
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::mint_nft())]
 		pub fn mint_nft(
 			origin: OriginFor<T>,
 			owner: T::AccountId,
@@ -440,8 +440,8 @@
 		/// - `rmrk_collection_id`: collection id of the nft to be transferred
 		/// - `rmrk_nft_id`: nft id of the nft to be transferred
 		/// - `new_owner`: new owner of the nft which can be either an account or a NFT
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::send())]
 		pub fn send(
 			origin: OriginFor<T>,
 			rmrk_collection_id: RmrkCollectionId,
@@ -552,8 +552,8 @@
 		/// - `rmrk_nft_id`: nft id of the nft to be accepted
 		/// - `new_owner`: either origin's account ID or origin-owned NFT, whichever the NFT was
 		///   sent to
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::accept_nft())]
 		pub fn accept_nft(
 			origin: OriginFor<T>,
 			rmrk_collection_id: RmrkCollectionId,
@@ -664,8 +664,8 @@
 		}
 
 		/// accept the addition of a new resource to an existing NFT
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::accept_resource())]
 		pub fn accept_resource(
 			origin: OriginFor<T>,
 			rmrk_collection_id: RmrkCollectionId,
@@ -723,8 +723,8 @@
 		}
 
 		/// accept the removal of a resource of an existing NFT
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::accept_resource_removal())]
 		pub fn accept_resource_removal(
 			origin: OriginFor<T>,
 			rmrk_collection_id: RmrkCollectionId,
@@ -788,8 +788,8 @@
 		}
 
 		/// set a custom value on an NFT
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::set_property())]
 		pub fn set_property(
 			origin: OriginFor<T>,
 			#[pallet::compact] rmrk_collection_id: RmrkCollectionId,
@@ -848,8 +848,8 @@
 		}
 
 		/// set a different order of resource priority
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::set_priority())]
 		pub fn set_priority(
 			origin: OriginFor<T>,
 			rmrk_collection_id: RmrkCollectionId,
@@ -887,8 +887,8 @@
 		}
 
 		/// Create basic resource
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::add_basic_resource())]
 		pub fn add_basic_resource(
 			origin: OriginFor<T>,
 			rmrk_collection_id: RmrkCollectionId,
@@ -925,8 +925,8 @@
 		}
 
 		/// Create composable resource
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::add_composable_resource())]
 		pub fn add_composable_resource(
 			origin: OriginFor<T>,
 			rmrk_collection_id: RmrkCollectionId,
@@ -965,8 +965,8 @@
 		}
 
 		/// Create slot resource
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::add_slot_resource())]
 		pub fn add_slot_resource(
 			origin: OriginFor<T>,
 			rmrk_collection_id: RmrkCollectionId,
@@ -1005,8 +1005,8 @@
 		}
 
 		/// remove resource
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::remove_resource())]
 		pub fn remove_resource(
 			origin: OriginFor<T>,
 			rmrk_collection_id: RmrkCollectionId,
modifiedpallets/proxy-rmrk-core/src/weights.rsdiffbeforeafterboth
before · pallets/proxy-rmrk-core/src/weights.rs
1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_proxy_rmrk_core4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2022-06-09, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 102489// Executed Command:10// target/release/unique-collator11// benchmark12// pallet13// --pallet14// pallet-proxy-rmrk-core15// --wasm-execution16// compiled17// --extrinsic18// *19// --template20// .maintain/frame-weight-template.hbs21// --steps=5022// --repeat=20023// --heap-pages=409624// --output=./pallets/proxy-rmrk-core/src/weights.rs2526#![cfg_attr(rustfmt, rustfmt_skip)]27#![allow(unused_parens)]28#![allow(unused_imports)]29#![allow(clippy::unnecessary_cast)]3031use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};32use sp_std::marker::PhantomData;3334/// Weight functions needed for pallet_proxy_rmrk_core.35pub trait WeightInfo {36	fn create_collection() -> Weight;37}3839/// Weights for pallet_proxy_rmrk_core using the Substrate node and recommended hardware.40pub struct SubstrateWeight<T>(PhantomData<T>);41impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {42	// Storage: Common CreatedCollectionCount (r:1 w:1)43	// Storage: Common DestroyedCollectionCount (r:1 w:0)44	// Storage: System Account (r:2 w:2)45	// Storage: RmrkCore CollectionIndex (r:1 w:1)46	// Storage: Common CollectionPropertyPermissions (r:0 w:1)47	// Storage: Common CollectionProperties (r:0 w:1)48	// Storage: Common CollectionById (r:0 w:1)49	// Storage: RmrkCore UniqueCollectionId (r:0 w:1)50	// Storage: RmrkCore RmrkInernalCollectionId (r:0 w:1)51	fn create_collection() -> Weight {52		(76_647_000 as Weight)53			.saturating_add(T::DbWeight::get().reads(5 as Weight))54			.saturating_add(T::DbWeight::get().writes(9 as Weight))55	}56}5758// For backwards compatibility and tests59impl WeightInfo for () {60	// Storage: Common CreatedCollectionCount (r:1 w:1)61	// Storage: Common DestroyedCollectionCount (r:1 w:0)62	// Storage: System Account (r:2 w:2)63	// Storage: RmrkCore CollectionIndex (r:1 w:1)64	// Storage: Common CollectionPropertyPermissions (r:0 w:1)65	// Storage: Common CollectionProperties (r:0 w:1)66	// Storage: Common CollectionById (r:0 w:1)67	// Storage: RmrkCore UniqueCollectionId (r:0 w:1)68	// Storage: RmrkCore RmrkInernalCollectionId (r:0 w:1)69	fn create_collection() -> Weight {70		(76_647_000 as Weight)71			.saturating_add(RocksDbWeight::get().reads(5 as Weight))72			.saturating_add(RocksDbWeight::get().writes(9 as Weight))73	}74}