git.delta.rocks / unique-network / refs/commits / e4d3792751ad

difftreelog

feat add benchmarks for burn_from

Yaroslav Bolyukin2021-11-05parent: #3d14ec5.patch.diff
in: master

12 files changed

modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -54,7 +54,6 @@
 		variable_on_chain_schema,
 		const_on_chain_schema,
 		meta_update_permission: Default::default(),
-		transfers_enabled: true,
 	})
 	.and_then(CollectionHandle::try_get)
 	.map(cast)
modifiedpallets/fungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -58,4 +58,13 @@
 		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200))?;
 		<Pallet<T>>::set_allowance(&collection, &sender, &spender, 200)?;
 	}: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, 100)?}
+
+	burn_from {
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			owner: cross_from_sub; sender: cross_sub; burner: cross_sub;
+		};
+		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200))?;
+		<Pallet<T>>::set_allowance(&collection, &sender, &burner, 200)?;
+	}: {<Pallet<T>>::burn_from(&collection, &burner, &sender, 100)?}
 }
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -37,7 +37,7 @@
 	}
 
 	fn burn_from() -> Weight {
-		0
+		<SelfWeightOf<T>>::burn_from()
 	}
 
 	fn set_variable_metadata(_bytes: u32) -> Weight {
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -75,6 +75,14 @@
 			.saturating_add(T::DbWeight::get().reads(3 as Weight))
 			.saturating_add(T::DbWeight::get().writes(3 as Weight))
 	}
+	// Storage: Fungible Allowance (r:1 w:1)
+	// Storage: Fungible TotalSupply (r:1 w:1)
+	// Storage: Fungible Balance (r:1 w:1)
+	fn burn_from() -> Weight {
+		(55_874_000 as Weight)
+			.saturating_add(T::DbWeight::get().reads(3 as Weight))
+			.saturating_add(T::DbWeight::get().writes(3 as Weight))
+	}
 }
 
 // For backwards compatibility and tests
@@ -113,4 +121,12 @@
 			.saturating_add(RocksDbWeight::get().reads(3 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(3 as Weight))
 	}
+	// Storage: Fungible Allowance (r:1 w:1)
+	// Storage: Fungible TotalSupply (r:1 w:1)
+	// Storage: Fungible Balance (r:1 w:1)
+	fn burn_from() -> Weight {
+		(55_874_000 as Weight)
+			.saturating_add(RocksDbWeight::get().reads(3 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(3 as Weight))
+	}
 }
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -89,6 +89,15 @@
 		<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?;
 	}: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item)?}
 
+	burn_from {
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			owner: cross_from_sub; sender: cross_sub; burner: cross_sub;
+		};
+		let item = create_max_item(&collection, &owner, sender.clone())?;
+		<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&burner))?;
+	}: {<Pallet<T>>::burn_from(&collection, &burner, &sender, item)?}
+
 	set_variable_metadata {
 		let b in 0..CUSTOM_DATA_LIMIT;
 		bench_init!{
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -38,7 +38,7 @@
 	}
 
 	fn burn_from() -> Weight {
-		0
+		<SelfWeightOf<T>>::burn_from()
 	}
 
 	fn set_variable_metadata(bytes: u32) -> Weight {
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
before · pallets/nonfungible/src/weights.rs
1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_nonfungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2021-10-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 12889// Executed Command:10// target/release/nft11// benchmark12// --pallet13// pallet-nonfungible14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=2022// --output=./pallets/nonfungible/src/weights.rs232425#![cfg_attr(rustfmt, rustfmt_skip)]26#![allow(unused_parens)]27#![allow(unused_imports)]2829use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};30use sp_std::marker::PhantomData;3132/// Weight functions needed for pallet_nonfungible.33pub trait WeightInfo {34	fn create_item() -> Weight;35	fn create_multiple_items(b: u32, ) -> Weight;36	fn burn_item() -> Weight;37	fn transfer() -> Weight;38	fn approve() -> Weight;39	fn transfer_from() -> Weight;40	fn set_variable_metadata(b: u32, ) -> Weight;41}4243/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.44pub struct SubstrateWeight<T>(PhantomData<T>);45impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {46	// Storage: Nonfungible TokensMinted (r:1 w:1)47	// Storage: Nonfungible AccountBalance (r:1 w:1)48	// Storage: Nonfungible TokenData (r:0 w:1)49	// Storage: Nonfungible Owned (r:0 w:1)50	fn create_item() -> Weight {51		(16_902_000 as Weight)52			.saturating_add(T::DbWeight::get().reads(2 as Weight))53			.saturating_add(T::DbWeight::get().writes(4 as Weight))54	}55	// Storage: Nonfungible TokensMinted (r:1 w:1)56	// Storage: Nonfungible AccountBalance (r:1 w:1)57	// Storage: Nonfungible TokenData (r:0 w:4)58	// Storage: Nonfungible Owned (r:0 w:4)59	fn create_multiple_items(b: u32, ) -> Weight {60		(15_860_000 as Weight)61			// Standard Error: 5_00062			.saturating_add((3_916_000 as Weight).saturating_mul(b as Weight))63			.saturating_add(T::DbWeight::get().reads(2 as Weight))64			.saturating_add(T::DbWeight::get().writes(2 as Weight))65			.saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))66	}67	// Storage: Nonfungible TokenData (r:1 w:1)68	// Storage: Nonfungible TokensBurnt (r:1 w:1)69	// Storage: Nonfungible Allowance (r:1 w:0)70	// Storage: Nonfungible Owned (r:0 w:1)71	fn burn_item() -> Weight {72		(17_966_000 as Weight)73			.saturating_add(T::DbWeight::get().reads(3 as Weight))74			.saturating_add(T::DbWeight::get().writes(3 as Weight))75	}76	// Storage: Nonfungible TokenData (r:1 w:1)77	// Storage: Nonfungible AccountBalance (r:2 w:2)78	// Storage: Nonfungible Allowance (r:1 w:0)79	// Storage: Nonfungible Owned (r:0 w:2)80	fn transfer() -> Weight {81		(23_886_000 as Weight)82			.saturating_add(T::DbWeight::get().reads(4 as Weight))83			.saturating_add(T::DbWeight::get().writes(5 as Weight))84	}85	// Storage: Nonfungible TokenData (r:1 w:0)86	// Storage: Nonfungible Allowance (r:1 w:1)87	fn approve() -> Weight {88		(14_697_000 as Weight)89			.saturating_add(T::DbWeight::get().reads(2 as Weight))90			.saturating_add(T::DbWeight::get().writes(1 as Weight))91	}92	// Storage: Nonfungible Allowance (r:1 w:1)93	// Storage: Nonfungible TokenData (r:1 w:1)94	// Storage: Nonfungible AccountBalance (r:2 w:2)95	// Storage: Nonfungible Owned (r:0 w:2)96	fn transfer_from() -> Weight {97		(28_001_000 as Weight)98			.saturating_add(T::DbWeight::get().reads(4 as Weight))99			.saturating_add(T::DbWeight::get().writes(6 as Weight))100	}101	// Storage: Nonfungible TokenData (r:1 w:1)102	fn set_variable_metadata(_b: u32, ) -> Weight {103		(6_380_000 as Weight)104			.saturating_add(T::DbWeight::get().reads(1 as Weight))105			.saturating_add(T::DbWeight::get().writes(1 as Weight))106	}107}108109// For backwards compatibility and tests110impl WeightInfo for () {111	// Storage: Nonfungible TokensMinted (r:1 w:1)112	// Storage: Nonfungible AccountBalance (r:1 w:1)113	// Storage: Nonfungible TokenData (r:0 w:1)114	// Storage: Nonfungible Owned (r:0 w:1)115	fn create_item() -> Weight {116		(16_902_000 as Weight)117			.saturating_add(RocksDbWeight::get().reads(2 as Weight))118			.saturating_add(RocksDbWeight::get().writes(4 as Weight))119	}120	// Storage: Nonfungible TokensMinted (r:1 w:1)121	// Storage: Nonfungible AccountBalance (r:1 w:1)122	// Storage: Nonfungible TokenData (r:0 w:4)123	// Storage: Nonfungible Owned (r:0 w:4)124	fn create_multiple_items(b: u32, ) -> Weight {125		(15_860_000 as Weight)126			// Standard Error: 5_000127			.saturating_add((3_916_000 as Weight).saturating_mul(b as Weight))128			.saturating_add(RocksDbWeight::get().reads(2 as Weight))129			.saturating_add(RocksDbWeight::get().writes(2 as Weight))130			.saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))131	}132	// Storage: Nonfungible TokenData (r:1 w:1)133	// Storage: Nonfungible TokensBurnt (r:1 w:1)134	// Storage: Nonfungible Allowance (r:1 w:0)135	// Storage: Nonfungible Owned (r:0 w:1)136	fn burn_item() -> Weight {137		(17_966_000 as Weight)138			.saturating_add(RocksDbWeight::get().reads(3 as Weight))139			.saturating_add(RocksDbWeight::get().writes(3 as Weight))140	}141	// Storage: Nonfungible TokenData (r:1 w:1)142	// Storage: Nonfungible AccountBalance (r:2 w:2)143	// Storage: Nonfungible Allowance (r:1 w:0)144	// Storage: Nonfungible Owned (r:0 w:2)145	fn transfer() -> Weight {146		(23_886_000 as Weight)147			.saturating_add(RocksDbWeight::get().reads(4 as Weight))148			.saturating_add(RocksDbWeight::get().writes(5 as Weight))149	}150	// Storage: Nonfungible TokenData (r:1 w:0)151	// Storage: Nonfungible Allowance (r:1 w:1)152	fn approve() -> Weight {153		(14_697_000 as Weight)154			.saturating_add(RocksDbWeight::get().reads(2 as Weight))155			.saturating_add(RocksDbWeight::get().writes(1 as Weight))156	}157	// Storage: Nonfungible Allowance (r:1 w:1)158	// Storage: Nonfungible TokenData (r:1 w:1)159	// Storage: Nonfungible AccountBalance (r:2 w:2)160	// Storage: Nonfungible Owned (r:0 w:2)161	fn transfer_from() -> Weight {162		(28_001_000 as Weight)163			.saturating_add(RocksDbWeight::get().reads(4 as Weight))164			.saturating_add(RocksDbWeight::get().writes(6 as Weight))165	}166	// Storage: Nonfungible TokenData (r:1 w:1)167	fn set_variable_metadata(_b: u32, ) -> Weight {168		(6_380_000 as Weight)169			.saturating_add(RocksDbWeight::get().reads(1 as Weight))170			.saturating_add(RocksDbWeight::get().writes(1 as Weight))171	}172}
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -149,6 +149,16 @@
 		<Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 200)?;
 	}: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item, 200)?}
 
+	// Both source account and token is destroyed
+	burn_from {
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			owner: cross_from_sub; sender: cross_sub; burner: cross_sub;
+		};
+		let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;
+		<Pallet<T>>::set_allowance(&collection, &sender, &burner, item, 200)?;
+	}: {<Pallet<T>>::burn_from(&collection, &burner, &sender, item, 200)?}
+
 	set_variable_metadata {
 		let b in 0..CUSTOM_DATA_LIMIT;
 		bench_init!{
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -166,6 +166,18 @@
 			.saturating_add(T::DbWeight::get().reads(5 as Weight))
 			.saturating_add(T::DbWeight::get().writes(7 as Weight))
 	}
+	// Storage: Refungible Allowance (r:1 w:1)
+	// Storage: Refungible TotalSupply (r:1 w:1)
+	// Storage: Refungible Balance (r:1 w:1)
+	// Storage: Refungible AccountBalance (r:1 w:1)
+	// Storage: Refungible TokensBurnt (r:1 w:1)
+	// Storage: Refungible TokenData (r:0 w:1)
+	// Storage: Refungible Owned (r:0 w:1)
+	fn burn_from() -> Weight {
+		(60_903_000 as Weight)
+			.saturating_add(T::DbWeight::get().reads(5 as Weight))
+			.saturating_add(T::DbWeight::get().writes(7 as Weight))
+	}
 	// Storage: Refungible TokenData (r:1 w:1)
 	fn set_variable_metadata(_b: u32, ) -> Weight {
 		(6_801_000 as Weight)
@@ -292,6 +304,18 @@
 			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(7 as Weight))
 	}
+	// Storage: Refungible Allowance (r:1 w:1)
+	// Storage: Refungible TotalSupply (r:1 w:1)
+	// Storage: Refungible Balance (r:1 w:1)
+	// Storage: Refungible AccountBalance (r:1 w:1)
+	// Storage: Refungible TokensBurnt (r:1 w:1)
+	// Storage: Refungible TokenData (r:0 w:1)
+	// Storage: Refungible Owned (r:0 w:1)
+	fn burn_from() -> Weight {
+		(60_903_000 as Weight)
+			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(7 as Weight))
+	}
 	// Storage: Refungible TokenData (r:1 w:1)
 	fn set_variable_metadata(_b: u32, ) -> Weight {
 		(6_801_000 as Weight)
modifiedpallets/scheduler/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/scheduler/src/benchmarking.rs
+++ b/pallets/scheduler/src/benchmarking.rs
@@ -33,7 +33,7 @@
 // Add `n` named items to the schedule
 fn fill_schedule<T: Config>(when: T::BlockNumber, n: u32) -> Result<(), &'static str> {
 	// Essentially a no-op call.
-	let call = frame_system::Call::set_storage(vec![]);
+	let call = frame_system::Call::set_storage { items: vec![] };
 	for i in 0..n {
 		// Named schedule is strictly heavier than anonymous
 		Scheduler::<T>::do_schedule_named(
@@ -61,7 +61,7 @@
 		let periodic = Some((T::BlockNumber::one(), 100));
 		let priority = 0;
 		// Essentially a no-op call.
-		let call = Box::new(frame_system::Call::set_storage(vec![]).into());
+		let call = Box::new(frame_system::Call::set_storage { items: vec![] }.into());
 
 		fill_schedule::<T>(when, s)?;
 	}: _(RawOrigin::Root, when, periodic, priority, call)
@@ -98,7 +98,7 @@
 		let periodic = Some((T::BlockNumber::one(), 100));
 		let priority = 0;
 		// Essentially a no-op call.
-		let call = Box::new(frame_system::Call::set_storage(vec![]).into());
+		let call = Box::new(frame_system::Call::set_storage { items: vec![] }.into());
 
 		fill_schedule::<T>(when, s)?;
 	}: _(RawOrigin::Root, id, when, periodic, priority, call)
modifiedruntime/Cargo.tomldiffbeforeafterboth
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -23,7 +23,9 @@
     'frame-support/runtime-benchmarks',
     'frame-system-benchmarking',
     'frame-system/runtime-benchmarks',
+    'pallet-ethereum/runtime-benchmarks',
     'pallet-evm-migration/runtime-benchmarks',
+    'pallet-evm-coder-substrate/runtime-benchmarks',
     'pallet-balances/runtime-benchmarks',
     'pallet-timestamp/runtime-benchmarks',
     'pallet-common/runtime-benchmarks',
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -1327,6 +1327,7 @@
 			list_benchmark!(list, extra, pallet_fungible, Fungible);
 			list_benchmark!(list, extra, pallet_refungible, Refungible);
 			list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
+			// list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
 
 			let storage_info = AllPalletsWithSystem::storage_info();
 
@@ -1360,6 +1361,7 @@
 			add_benchmark!(params, batches, pallet_fungible, Fungible);
 			add_benchmark!(params, batches, pallet_refungible, Refungible);
 			add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
+			// add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
 
 			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
 			Ok(batches)