git.delta.rocks / unique-network / refs/commits / 908b58f6b381

difftreelog

feat(weight) Changed weight calculation system for transfer & transfer_from (FT)

PraetorP2023-03-30parent: #918595f.patch.diff
in: master

9 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6558,7 +6558,7 @@
 
 [[package]]
 name = "pallet-fungible"
-version = "0.1.10"
+version = "0.1.11"
 dependencies = [
  "evm-coder",
  "frame-benchmarking",
modifiedpallets/foreign-assets/src/impl_fungibles.rsdiffbeforeafterboth
--- a/pallets/foreign-assets/src/impl_fungibles.rs
+++ b/pallets/foreign-assets/src/impl_fungibles.rs
@@ -452,7 +452,8 @@
 					&T::CrossAccountId::from_sub(dest.clone()),
 					amount.into(),
 					&Value::new(0),
-				)?;
+				)
+				.map_err(|e| e.error)?;
 
 				Ok(amount)
 			}
modifiedpallets/fungible/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/fungible/CHANGELOG.md
+++ b/pallets/fungible/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.1.11] - 2023-03-28
+
+### Fixed
+
+- The weight of `transfer` and `transfer_from`.
+
 ## [0.1.10] - 2023-02-01
 
 ### Added
modifiedpallets/fungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/fungible/Cargo.toml
+++ b/pallets/fungible/Cargo.toml
@@ -2,7 +2,7 @@
 edition = "2021"
 license = "GPLv3"
 name = "pallet-fungible"
-version = "0.1.10"
+version = "0.1.11"
 
 [dependencies]
 # Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.
modifiedpallets/fungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -92,14 +92,22 @@
 		<Pallet<T>>::create_item(&collection, &owner, (owner_eth.clone(), 200), &Unlimited)?;
 	}: {<Pallet<T>>::set_allowance_from(&collection, &sender, &owner_eth, &spender, 100)?}
 
-	transfer_from {
+	 check_allowed_raw {
 		bench_init!{
 			owner: sub; collection: collection(owner);
-			owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;
+			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
 		};
 		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
 		<Pallet<T>>::set_allowance(&collection, &sender, &spender, 200)?;
-	}: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, 100, &Unlimited)?}
+	}: {<Pallet<T>>::check_allowed(&collection, &spender, &sender, 200, &Unlimited)?;}
+
+	set_allowance_unchecked_raw {
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
+		};
+		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
+	}: {<Pallet<T>>::set_allowance_unchecked(&collection, &sender, &spender, 200);}
 
 	burn_from {
 		bench_init!{
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -22,7 +22,7 @@
 };
 use pallet_common::{
 	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,
-	weights::WeightInfo as _,
+	weights::WeightInfo as _, SelfWeightOf as PalletCommonWeightOf,
 };
 use pallet_structure::Error as StructureError;
 use sp_runtime::ArithmeticError;
@@ -78,7 +78,7 @@
 	}
 
 	fn transfer() -> Weight {
-		<SelfWeightOf<T>>::transfer()
+		<SelfWeightOf<T>>::transfer() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
 	}
 
 	fn approve() -> Weight {
@@ -90,7 +90,9 @@
 	}
 
 	fn transfer_from() -> Weight {
-		<SelfWeightOf<T>>::transfer_from()
+		<SelfWeightOf<T>>::transfer()
+			+ <SelfWeightOf<T>>::check_allowed_raw()
+			+ <SelfWeightOf<T>>::set_allowance_unchecked_raw()
 	}
 
 	fn burn_from() -> Weight {
@@ -232,10 +234,7 @@
 			<Error<T>>::FungibleItemsHaveNoId
 		);
 
-		with_weight(
-			<Pallet<T>>::transfer(self, &from, &to, amount, nesting_budget),
-			<CommonWeights<T>>::transfer(),
-		)
+		<Pallet<T>>::transfer(self, &from, &to, amount, nesting_budget)
 	}
 
 	fn approve(
@@ -289,10 +288,7 @@
 			<Error<T>>::FungibleItemsHaveNoId
 		);
 
-		with_weight(
-			<Pallet<T>>::transfer_from(self, &sender, &from, &to, amount, nesting_budget),
-			<CommonWeights<T>>::transfer_from(),
-		)
+		<Pallet<T>>::transfer_from(self, &sender, &from, &to, amount, nesting_budget)
 	}
 
 	fn burn_from(
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -26,6 +26,7 @@
 	CollectionHandle,
 	erc::{CommonEvmHandler, PrecompileResult, CollectionCall},
 	eth::CrossAddress,
+	CommonWeightInfo as _,
 };
 use sp_std::vec::Vec;
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
@@ -39,7 +40,7 @@
 
 use crate::{
 	Allowance, Balance, Config, FungibleHandle, Pallet, TotalSupply, SelfWeightOf,
-	weights::WeightInfo,
+	weights::WeightInfo, common::CommonWeights,
 };
 
 frontier_contract! {
@@ -99,7 +100,7 @@
 		let balance = <Balance<T>>::get((self.id, owner));
 		Ok(balance.into())
 	}
-	#[weight(<SelfWeightOf<T>>::transfer())]
+	#[weight(<CommonWeights<T>>::transfer())]
 	fn transfer(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let to = T::CrossAccountId::from_eth(to);
@@ -112,7 +113,7 @@
 		Ok(true)
 	}
 
-	#[weight(<SelfWeightOf<T>>::transfer_from())]
+	#[weight(<CommonWeights<T>>::transfer_from())]
 	fn transfer_from(
 		&mut self,
 		caller: Caller,
@@ -129,7 +130,7 @@
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
 		<Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
-			.map_err(dispatch_to_evm::<T>)?;
+			.map_err(|e| dispatch_to_evm::<T>(e.error))?;
 		Ok(true)
 	}
 	#[weight(<SelfWeightOf<T>>::approve())]
@@ -201,7 +202,7 @@
 		let budget = self
 			.recorder
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
-		<Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)
+		<Pallet<T>>::create_item(self, &caller, (to, amount), &budget)
 			.map_err(dispatch_to_evm::<T>)?;
 		Ok(true)
 	}
@@ -289,7 +290,7 @@
 		Ok(true)
 	}
 
-	#[weight(<SelfWeightOf<T>>::transfer())]
+	#[weight(<CommonWeights<T>>::transfer())]
 	fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let to = to.into_sub_cross_account::<T>()?;
@@ -302,7 +303,7 @@
 		Ok(true)
 	}
 
-	#[weight(<SelfWeightOf<T>>::transfer_from())]
+	#[weight(<CommonWeights<T>>::transfer_from())]
 	fn transfer_from_cross(
 		&mut self,
 		caller: Caller,
@@ -319,7 +320,7 @@
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
 		<Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
-			.map_err(dispatch_to_evm::<T>)?;
+			.map_err(|e| dispatch_to_evm::<T>(e.error))?;
 		Ok(true)
 	}
 
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -80,7 +80,11 @@
 
 use core::ops::Deref;
 use evm_coder::ToLog;
-use frame_support::ensure;
+use frame_support::{
+	ensure,
+	pallet_prelude::{DispatchResultWithPostInfo, Pays},
+	dispatch::PostDispatchInfo,
+};
 use pallet_evm::account::CrossAccountId;
 use up_data_structs::{
 	AccessMode, CollectionId, CollectionFlags, TokenId, CreateCollectionData,
@@ -88,7 +92,8 @@
 };
 use pallet_common::{
 	Error as CommonError, Event as CommonEvent, Pallet as PalletCommon,
-	eth::collection_id_to_address,
+	eth::collection_id_to_address, SelfWeightOf as PalletCommonWeightOf,
+	weights::WeightInfo as CommonWeightInfo, helpers::add_weight_to_post_info,
 };
 use pallet_evm::Pallet as PalletEvm;
 use pallet_structure::Pallet as PalletStructure;
@@ -96,7 +101,7 @@
 use sp_core::H160;
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
 use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
-
+use weights::WeightInfo;
 pub use pallet::*;
 
 use crate::erc::ERC20Events;
@@ -389,18 +394,20 @@
 		to: &T::CrossAccountId,
 		amount: u128,
 		nesting_budget: &dyn Budget,
-	) -> DispatchResult {
+	) -> DispatchResultWithPostInfo {
 		ensure!(
 			collection.limits.transfers_enabled(),
 			<CommonError<T>>::TransferNotAllowed,
 		);
 
+		let mut actual_weight = <SelfWeightOf<T>>::transfer();
+
 		if collection.permissions.access() == AccessMode::AllowList {
 			collection.check_allowlist(from)?;
 			collection.check_allowlist(to)?;
+			actual_weight += <PalletCommonWeightOf<T>>::check_accesslist() * 2;
 		}
 		<PalletCommon<T>>::ensure_correct_receiver(to)?;
-
 		let balance_from = <Balance<T>>::get((collection.id, from))
 			.checked_sub(amount)
 			.ok_or(<CommonError<T>>::TokenValueTooLow)?;
@@ -451,7 +458,11 @@
 			to.clone(),
 			amount,
 		));
-		Ok(())
+
+		Ok(PostDispatchInfo {
+			actual_weight: Some(actual_weight),
+			pays_fee: Pays::Yes,
+		})
 	}
 
 	/// Minting tokens for multiple IDs.
@@ -464,8 +475,8 @@
 		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
 		let total_supply = data
-			.iter()
-			.map(|(_, v)| *v)
+			.values()
+			.copied()
 			.try_fold(<TotalSupply<T>>::get(collection.id), |acc, v| {
 				acc.checked_add(v)
 			})
@@ -718,7 +729,6 @@
 	/// Same as the [`transfer`][`Pallet::transfer`] but spender doesn't needs to be an owner of the token pieces.
 	/// The owner should set allowance for the spender to transfer pieces.
 	///	See [`set_allowance`][`Pallet::set_allowance`] for more details.
-
 	pub fn transfer_from(
 		collection: &FungibleHandle<T>,
 		spender: &T::CrossAccountId,
@@ -726,16 +736,23 @@
 		to: &T::CrossAccountId,
 		amount: u128,
 		nesting_budget: &dyn Budget,
-	) -> DispatchResult {
+	) -> DispatchResultWithPostInfo {
 		let allowance = Self::check_allowed(collection, spender, from, amount, nesting_budget)?;
 
 		// =========
 
-		Self::transfer(collection, from, to, amount, nesting_budget)?;
+		let mut result = Self::transfer(collection, from, to, amount, nesting_budget);
+		add_weight_to_post_info(&mut result, <SelfWeightOf<T>>::check_allowed_raw());
+		result?;
+
 		if let Some(allowance) = allowance {
 			Self::set_allowance_unchecked(collection, from, spender, allowance);
+			add_weight_to_post_info(
+				&mut result,
+				<SelfWeightOf<T>>::set_allowance_unchecked_raw(),
+			)
 		}
-		Ok(())
+		result
 	}
 
 	/// Burn fungible tokens from the account.
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
before · pallets/fungible/src/weights.rs
1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_fungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2023-03-30, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! WORST CASE MAP SIZE: `1000000`8//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024910// Executed Command:11// target/release/unique-collator12// benchmark13// pallet14// --pallet15// pallet-fungible16// --wasm-execution17// compiled18// --extrinsic19// *20// --template=.maintain/frame-weight-template.hbs21// --steps=5022// --repeat=8023// --heap-pages=409624// --output=./pallets/fungible/src/weights.rs2526#![cfg_attr(rustfmt, rustfmt_skip)]27#![allow(unused_parens)]28#![allow(unused_imports)]29#![allow(missing_docs)]30#![allow(clippy::unnecessary_cast)]3132use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};33use sp_std::marker::PhantomData;3435/// Weight functions needed for pallet_fungible.36pub trait WeightInfo {37	fn create_item() -> Weight;38	fn create_multiple_items_ex(b: u32, ) -> Weight;39	fn burn_item() -> Weight;40	fn transfer() -> Weight;41	fn approve() -> Weight;42	fn approve_from() -> Weight;43	fn transfer_from() -> Weight;44	fn burn_from() -> Weight;45}4647/// Weights for pallet_fungible using the Substrate node and recommended hardware.48pub struct SubstrateWeight<T>(PhantomData<T>);49impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {50	/// Storage: Fungible TotalSupply (r:1 w:1)51	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)52	/// Storage: Fungible Balance (r:1 w:1)53	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)54	fn create_item() -> Weight {55		// Proof Size summary in bytes:56		//  Measured:  `42`57		//  Estimated: `5055`58		// Minimum execution time: 10_152_000 picoseconds.59		Weight::from_parts(10_520_000, 5055)60			.saturating_add(T::DbWeight::get().reads(2_u64))61			.saturating_add(T::DbWeight::get().writes(2_u64))62	}63	/// Storage: Fungible TotalSupply (r:1 w:1)64	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)65	/// Storage: Fungible Balance (r:200 w:200)66	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)67	/// The range of component `b` is `[0, 200]`.68	fn create_multiple_items_ex(b: u32, ) -> Weight {69		// Proof Size summary in bytes:70		//  Measured:  `42`71		//  Estimated: `2503 + b * (2552 ±0)`72		// Minimum execution time: 3_437_000 picoseconds.73		Weight::from_parts(13_322_752, 2503)74			// Standard Error: 1_72875			.saturating_add(Weight::from_parts(3_605_522, 0).saturating_mul(b.into()))76			.saturating_add(T::DbWeight::get().reads(1_u64))77			.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))78			.saturating_add(T::DbWeight::get().writes(1_u64))79			.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(b.into())))80			.saturating_add(Weight::from_parts(0, 2552).saturating_mul(b.into()))81	}82	/// Storage: Fungible TotalSupply (r:1 w:1)83	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)84	/// Storage: Fungible Balance (r:1 w:1)85	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)86	fn burn_item() -> Weight {87		// Proof Size summary in bytes:88		//  Measured:  `197`89		//  Estimated: `5055`90		// Minimum execution time: 12_894_000 picoseconds.91		Weight::from_parts(13_347_000, 5055)92			.saturating_add(T::DbWeight::get().reads(2_u64))93			.saturating_add(T::DbWeight::get().writes(2_u64))94	}95	/// Storage: Fungible Balance (r:2 w:2)96	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)97	fn transfer() -> Weight {98		// Proof Size summary in bytes:99		//  Measured:  `182`100		//  Estimated: `5104`101		// Minimum execution time: 13_832_000 picoseconds.102		Weight::from_parts(14_064_000, 5104)103			.saturating_add(T::DbWeight::get().reads(2_u64))104			.saturating_add(T::DbWeight::get().writes(2_u64))105	}106	/// Storage: Fungible Balance (r:1 w:0)107	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)108	/// Storage: Fungible Allowance (r:0 w:1)109	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)110	fn approve() -> Weight {111		// Proof Size summary in bytes:112		//  Measured:  `182`113		//  Estimated: `2552`114		// Minimum execution time: 12_417_000 picoseconds.115		Weight::from_parts(12_658_000, 2552)116			.saturating_add(T::DbWeight::get().reads(1_u64))117			.saturating_add(T::DbWeight::get().writes(1_u64))118	}119	/// Storage: Fungible Balance (r:1 w:0)120	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)121	/// Storage: Fungible Allowance (r:0 w:1)122	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)123	fn approve_from() -> Weight {124		// Proof Size summary in bytes:125		//  Measured:  `170`126		//  Estimated: `2552`127		// Minimum execution time: 12_322_000 picoseconds.128		Weight::from_parts(12_629_000, 2552)129			.saturating_add(T::DbWeight::get().reads(1_u64))130			.saturating_add(T::DbWeight::get().writes(1_u64))131	}132	/// Storage: Fungible Allowance (r:1 w:1)133	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)134	/// Storage: Fungible Balance (r:2 w:2)135	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)136	fn transfer_from() -> Weight {137		// Proof Size summary in bytes:138		//  Measured:  `300`139		//  Estimated: `7672`140		// Minimum execution time: 21_667_000 picoseconds.141		Weight::from_parts(22_166_000, 7672)142			.saturating_add(T::DbWeight::get().reads(3_u64))143			.saturating_add(T::DbWeight::get().writes(3_u64))144	}145	/// Storage: Fungible Allowance (r:1 w:1)146	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)147	/// Storage: Fungible TotalSupply (r:1 w:1)148	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)149	/// Storage: Fungible Balance (r:1 w:1)150	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)151	fn burn_from() -> Weight {152		// Proof Size summary in bytes:153		//  Measured:  `315`154		//  Estimated: `7623`155		// Minimum execution time: 21_271_000 picoseconds.156		Weight::from_parts(21_709_000, 7623)157			.saturating_add(T::DbWeight::get().reads(3_u64))158			.saturating_add(T::DbWeight::get().writes(3_u64))159	}160}161162// For backwards compatibility and tests163impl WeightInfo for () {164	/// Storage: Fungible TotalSupply (r:1 w:1)165	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)166	/// Storage: Fungible Balance (r:1 w:1)167	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)168	fn create_item() -> Weight {169		// Proof Size summary in bytes:170		//  Measured:  `42`171		//  Estimated: `5055`172		// Minimum execution time: 10_152_000 picoseconds.173		Weight::from_parts(10_520_000, 5055)174			.saturating_add(RocksDbWeight::get().reads(2_u64))175			.saturating_add(RocksDbWeight::get().writes(2_u64))176	}177	/// Storage: Fungible TotalSupply (r:1 w:1)178	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)179	/// Storage: Fungible Balance (r:200 w:200)180	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)181	/// The range of component `b` is `[0, 200]`.182	fn create_multiple_items_ex(b: u32, ) -> Weight {183		// Proof Size summary in bytes:184		//  Measured:  `42`185		//  Estimated: `2503 + b * (2552 ±0)`186		// Minimum execution time: 3_437_000 picoseconds.187		Weight::from_parts(13_322_752, 2503)188			// Standard Error: 1_728189			.saturating_add(Weight::from_parts(3_605_522, 0).saturating_mul(b.into()))190			.saturating_add(RocksDbWeight::get().reads(1_u64))191			.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))192			.saturating_add(RocksDbWeight::get().writes(1_u64))193			.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(b.into())))194			.saturating_add(Weight::from_parts(0, 2552).saturating_mul(b.into()))195	}196	/// Storage: Fungible TotalSupply (r:1 w:1)197	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)198	/// Storage: Fungible Balance (r:1 w:1)199	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)200	fn burn_item() -> Weight {201		// Proof Size summary in bytes:202		//  Measured:  `197`203		//  Estimated: `5055`204		// Minimum execution time: 12_894_000 picoseconds.205		Weight::from_parts(13_347_000, 5055)206			.saturating_add(RocksDbWeight::get().reads(2_u64))207			.saturating_add(RocksDbWeight::get().writes(2_u64))208	}209	/// Storage: Fungible Balance (r:2 w:2)210	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)211	fn transfer() -> Weight {212		// Proof Size summary in bytes:213		//  Measured:  `182`214		//  Estimated: `5104`215		// Minimum execution time: 13_832_000 picoseconds.216		Weight::from_parts(14_064_000, 5104)217			.saturating_add(RocksDbWeight::get().reads(2_u64))218			.saturating_add(RocksDbWeight::get().writes(2_u64))219	}220	/// Storage: Fungible Balance (r:1 w:0)221	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)222	/// Storage: Fungible Allowance (r:0 w:1)223	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)224	fn approve() -> Weight {225		// Proof Size summary in bytes:226		//  Measured:  `182`227		//  Estimated: `2552`228		// Minimum execution time: 12_417_000 picoseconds.229		Weight::from_parts(12_658_000, 2552)230			.saturating_add(RocksDbWeight::get().reads(1_u64))231			.saturating_add(RocksDbWeight::get().writes(1_u64))232	}233	/// Storage: Fungible Balance (r:1 w:0)234	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)235	/// Storage: Fungible Allowance (r:0 w:1)236	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)237	fn approve_from() -> Weight {238		// Proof Size summary in bytes:239		//  Measured:  `170`240		//  Estimated: `2552`241		// Minimum execution time: 12_322_000 picoseconds.242		Weight::from_parts(12_629_000, 2552)243			.saturating_add(RocksDbWeight::get().reads(1_u64))244			.saturating_add(RocksDbWeight::get().writes(1_u64))245	}246	/// Storage: Fungible Allowance (r:1 w:1)247	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)248	/// Storage: Fungible Balance (r:2 w:2)249	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)250	fn transfer_from() -> Weight {251		// Proof Size summary in bytes:252		//  Measured:  `300`253		//  Estimated: `7672`254		// Minimum execution time: 21_667_000 picoseconds.255		Weight::from_parts(22_166_000, 7672)256			.saturating_add(RocksDbWeight::get().reads(3_u64))257			.saturating_add(RocksDbWeight::get().writes(3_u64))258	}259	/// Storage: Fungible Allowance (r:1 w:1)260	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)261	/// Storage: Fungible TotalSupply (r:1 w:1)262	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)263	/// Storage: Fungible Balance (r:1 w:1)264	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)265	fn burn_from() -> Weight {266		// Proof Size summary in bytes:267		//  Measured:  `315`268		//  Estimated: `7623`269		// Minimum execution time: 21_271_000 picoseconds.270		Weight::from_parts(21_709_000, 7623)271			.saturating_add(RocksDbWeight::get().reads(3_u64))272			.saturating_add(RocksDbWeight::get().writes(3_u64))273	}274}275
after · pallets/fungible/src/weights.rs
1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_fungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2023-03-30, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! WORST CASE MAP SIZE: `1000000`8//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024910// Executed Command:11// target/release/unique-collator12// benchmark13// pallet14// --pallet15// pallet-fungible16// --wasm-execution17// compiled18// --extrinsic19// *20// --template=.maintain/frame-weight-template.hbs21// --steps=5022// --repeat=8023// --heap-pages=409624// --output=./pallets/fungible/src/weights.rs2526#![cfg_attr(rustfmt, rustfmt_skip)]27#![allow(unused_parens)]28#![allow(unused_imports)]29#![allow(missing_docs)]30#![allow(clippy::unnecessary_cast)]3132use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};33use sp_std::marker::PhantomData;3435/// Weight functions needed for pallet_fungible.36pub trait WeightInfo {37	fn create_item() -> Weight;38	fn create_multiple_items_ex(b: u32, ) -> Weight;39	fn burn_item() -> Weight;40	fn transfer() -> Weight;41	fn approve() -> Weight;42	fn approve_from() -> Weight;43	fn check_allowed_raw() -> Weight;44	fn set_allowance_unchecked_raw() -> Weight;45	fn burn_from() -> Weight;46}4748/// Weights for pallet_fungible using the Substrate node and recommended hardware.49pub struct SubstrateWeight<T>(PhantomData<T>);50impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {51	/// Storage: Fungible TotalSupply (r:1 w:1)52	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)53	/// Storage: Fungible Balance (r:1 w:1)54	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)55	fn create_item() -> Weight {56		// Proof Size summary in bytes:57		//  Measured:  `42`58		//  Estimated: `5055`59		// Minimum execution time: 10_152_000 picoseconds.60		Weight::from_parts(10_520_000, 5055)61			.saturating_add(T::DbWeight::get().reads(2_u64))62			.saturating_add(T::DbWeight::get().writes(2_u64))63	}64	/// Storage: Fungible TotalSupply (r:1 w:1)65	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)66	/// Storage: Fungible Balance (r:200 w:200)67	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)68	/// The range of component `b` is `[0, 200]`.69	fn create_multiple_items_ex(b: u32, ) -> Weight {70		// Proof Size summary in bytes:71		//  Measured:  `42`72		//  Estimated: `2503 + b * (2552 ±0)`73		// Minimum execution time: 3_437_000 picoseconds.74		Weight::from_parts(13_322_752, 2503)75			// Standard Error: 1_72876			.saturating_add(Weight::from_parts(3_605_522, 0).saturating_mul(b.into()))77			.saturating_add(T::DbWeight::get().reads(1_u64))78			.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))79			.saturating_add(T::DbWeight::get().writes(1_u64))80			.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(b.into())))81			.saturating_add(Weight::from_parts(0, 2552).saturating_mul(b.into()))82	}83	/// Storage: Fungible TotalSupply (r:1 w:1)84	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)85	/// Storage: Fungible Balance (r:1 w:1)86	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)87	fn burn_item() -> Weight {88		// Proof Size summary in bytes:89		//  Measured:  `197`90		//  Estimated: `5055`91		// Minimum execution time: 12_894_000 picoseconds.92		Weight::from_parts(13_347_000, 5055)93			.saturating_add(T::DbWeight::get().reads(2_u64))94			.saturating_add(T::DbWeight::get().writes(2_u64))95	}96	/// Storage: Fungible Balance (r:2 w:2)97	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)98	fn transfer() -> Weight {99		// Proof Size summary in bytes:100		//  Measured:  `182`101		//  Estimated: `5104`102		// Minimum execution time: 13_832_000 picoseconds.103		Weight::from_parts(14_064_000, 5104)104			.saturating_add(T::DbWeight::get().reads(2_u64))105			.saturating_add(T::DbWeight::get().writes(2_u64))106	}107	/// Storage: Fungible Balance (r:1 w:0)108	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)109	/// Storage: Fungible Allowance (r:0 w:1)110	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)111	fn approve() -> Weight {112		// Proof Size summary in bytes:113		//  Measured:  `182`114		//  Estimated: `2552`115		// Minimum execution time: 12_417_000 picoseconds.116		Weight::from_parts(12_658_000, 2552)117			.saturating_add(T::DbWeight::get().reads(1_u64))118			.saturating_add(T::DbWeight::get().writes(1_u64))119	}120	/// Storage: Fungible Balance (r:1 w:0)121	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)122	/// Storage: Fungible Allowance (r:0 w:1)123	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)124	fn approve_from() -> Weight {125		// Proof Size summary in bytes:126		//  Measured:  `170`127		//  Estimated: `2552`128		// Minimum execution time: 12_322_000 picoseconds.129		Weight::from_parts(12_629_000, 2552)130			.saturating_add(T::DbWeight::get().reads(1_u64))131			.saturating_add(T::DbWeight::get().writes(1_u64))132	}133	// Storage: Fungible Allowance (r:1 w:0)134	fn check_allowed_raw() -> Weight {135		Weight::from_ref_time(3_550_000 as u64)136			.saturating_add(T::DbWeight::get().reads(1 as u64))137	}138	// Storage: Fungible Allowance (r:1 w:1)139	fn set_allowance_unchecked_raw() -> Weight {140		Weight::from_ref_time(10_682_000 as u64)141			.saturating_add(T::DbWeight::get().reads(1 as u64))142			.saturating_add(T::DbWeight::get().writes(1 as u64))143	}144	/// Storage: Fungible Allowance (r:1 w:1)145	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)146	/// Storage: Fungible TotalSupply (r:1 w:1)147	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)148	/// Storage: Fungible Balance (r:1 w:1)149	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)150	fn burn_from() -> Weight {151		// Proof Size summary in bytes:152		//  Measured:  `315`153		//  Estimated: `7623`154		// Minimum execution time: 21_271_000 picoseconds.155		Weight::from_parts(21_709_000, 7623)156			.saturating_add(T::DbWeight::get().reads(3_u64))157			.saturating_add(T::DbWeight::get().writes(3_u64))158	}159}160161// For backwards compatibility and tests162impl WeightInfo for () {163	/// Storage: Fungible TotalSupply (r:1 w:1)164	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)165	/// Storage: Fungible Balance (r:1 w:1)166	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)167	fn create_item() -> Weight {168		// Proof Size summary in bytes:169		//  Measured:  `42`170		//  Estimated: `5055`171		// Minimum execution time: 10_152_000 picoseconds.172		Weight::from_parts(10_520_000, 5055)173			.saturating_add(RocksDbWeight::get().reads(2_u64))174			.saturating_add(RocksDbWeight::get().writes(2_u64))175	}176	/// Storage: Fungible TotalSupply (r:1 w:1)177	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)178	/// Storage: Fungible Balance (r:200 w:200)179	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)180	/// The range of component `b` is `[0, 200]`.181	fn create_multiple_items_ex(b: u32, ) -> Weight {182		// Proof Size summary in bytes:183		//  Measured:  `42`184		//  Estimated: `2503 + b * (2552 ±0)`185		// Minimum execution time: 3_437_000 picoseconds.186		Weight::from_parts(13_322_752, 2503)187			// Standard Error: 1_728188			.saturating_add(Weight::from_parts(3_605_522, 0).saturating_mul(b.into()))189			.saturating_add(RocksDbWeight::get().reads(1_u64))190			.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))191			.saturating_add(RocksDbWeight::get().writes(1_u64))192			.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(b.into())))193			.saturating_add(Weight::from_parts(0, 2552).saturating_mul(b.into()))194	}195	/// Storage: Fungible TotalSupply (r:1 w:1)196	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)197	/// Storage: Fungible Balance (r:1 w:1)198	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)199	fn burn_item() -> Weight {200		// Proof Size summary in bytes:201		//  Measured:  `197`202		//  Estimated: `5055`203		// Minimum execution time: 12_894_000 picoseconds.204		Weight::from_parts(13_347_000, 5055)205			.saturating_add(RocksDbWeight::get().reads(2_u64))206			.saturating_add(RocksDbWeight::get().writes(2_u64))207	}208	/// Storage: Fungible Balance (r:2 w:2)209	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)210	fn transfer() -> Weight {211		// Proof Size summary in bytes:212		//  Measured:  `182`213		//  Estimated: `5104`214		// Minimum execution time: 13_832_000 picoseconds.215		Weight::from_parts(14_064_000, 5104)216			.saturating_add(RocksDbWeight::get().reads(2_u64))217			.saturating_add(RocksDbWeight::get().writes(2_u64))218	}219	/// Storage: Fungible Balance (r:1 w:0)220	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)221	/// Storage: Fungible Allowance (r:0 w:1)222	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)223	fn approve() -> Weight {224		// Proof Size summary in bytes:225		//  Measured:  `182`226		//  Estimated: `2552`227		// Minimum execution time: 12_417_000 picoseconds.228		Weight::from_parts(12_658_000, 2552)229			.saturating_add(RocksDbWeight::get().reads(1_u64))230			.saturating_add(RocksDbWeight::get().writes(1_u64))231	}232	/// Storage: Fungible Balance (r:1 w:0)233	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)234	/// Storage: Fungible Allowance (r:0 w:1)235	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)236	fn approve_from() -> Weight {237		// Proof Size summary in bytes:238		//  Measured:  `170`239		//  Estimated: `2552`240		// Minimum execution time: 12_322_000 picoseconds.241		Weight::from_parts(12_629_000, 2552)242			.saturating_add(RocksDbWeight::get().reads(1_u64))243			.saturating_add(RocksDbWeight::get().writes(1_u64))244	}245	// Storage: Fungible Allowance (r:1 w:0)246	fn check_allowed_raw() -> Weight {247		Weight::from_ref_time(3_550_000 as u64)248			.saturating_add(RocksDbWeight::get().reads(1 as u64))249	}250	// Storage: Fungible Allowance (r:1 w:1)251	fn set_allowance_unchecked_raw() -> Weight {252		Weight::from_ref_time(10_682_000 as u64)253			.saturating_add(RocksDbWeight::get().reads(1 as u64))254			.saturating_add(RocksDbWeight::get().writes(1 as u64))255	}256	/// Storage: Fungible Allowance (r:1 w:1)257	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)258	/// Storage: Fungible TotalSupply (r:1 w:1)259	/// Proof: Fungible TotalSupply (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)260	/// Storage: Fungible Balance (r:1 w:1)261	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)262	fn burn_from() -> Weight {263		// Proof Size summary in bytes:264		//  Measured:  `315`265		//  Estimated: `7623`266		// Minimum execution time: 21_271_000 picoseconds.267		Weight::from_parts(21_709_000, 7623)268			.saturating_add(RocksDbWeight::get().reads(3_u64))269			.saturating_add(RocksDbWeight::get().writes(3_u64))270	}271}272