git.delta.rocks / unique-network / refs/commits / 60b6dbd39371

difftreelog

feat(rmrk) benchmark burn_nft

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

3 files changed

modifiedpallets/proxy-rmrk-core/src/benchmarking.rsdiffbeforeafterboth
149 Ok((root_nft_id, deepest_nft_id))149 Ok((root_nft_id, deepest_nft_id))
150 }150 }
151
152 fn build_wide_tree<T: Config>(
153 &mut self,
154 owner: &T::AccountId,
155 width: u32,
156 ) -> Result<RmrkNftId, DispatchError> {
157 self.build::<T>(owner)?;
158
159 let root_nft_id = self.current_nft_id;
160
161 let root_owner =
162 <RmrkAccountIdOrCollectionNftTuple<T::AccountId>>::CollectionAndNftTuple(
163 self.collection_id,
164 root_nft_id,
165 );
166
167 for _ in 0..width {
168 self.build::<T>(owner)?;
169
170 <Pallet<T>>::send(
171 RawOrigin::Signed(owner.clone()).into(),
172 self.collection_id,
173 self.current_nft_id,
174 root_owner.clone(),
175 )?;
176 }
177
178 Ok(root_nft_id)
179 }
151}180}
152181
153benchmarks! {182benchmarks! {
205 transferable234 transferable
206 )235 )
236
237 burn_nft {
238 let b in 0..200;
239
240 let caller: T::AccountId = account("caller", 0, SEED);
241 create_max_collection::<T>(&caller)?;
242 let collection_id = 0;
243
244 let mut nft_builder = NftBuilder::new(collection_id);
245 let root_nft_id = nft_builder.build_wide_tree::<T>(&caller, b)?;
246 let max_burns = b + 1;
247 }: _(
248 RawOrigin::Signed(caller),
249 collection_id,
250 root_nft_id,
251 max_burns
252 )
207253
208 send {254 send {
209 let caller: T::AccountId = account("caller", 0, SEED);255 let caller: T::AccountId = account("caller", 0, SEED);
modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -400,8 +400,8 @@
 		}
 
 		/// burn nft
-		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
+		#[pallet::weight(<SelfWeightOf<T>>::burn_nft(*max_burns))]
 		pub fn burn_nft(
 			origin: OriginFor<T>,
 			collection_id: RmrkCollectionId,
modifiedpallets/proxy-rmrk-core/src/weights.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/weights.rs
+++ b/pallets/proxy-rmrk-core/src/weights.rs
@@ -38,6 +38,7 @@
 	fn change_collection_issuer() -> Weight;
 	fn lock_collection() -> Weight;
 	fn mint_nft() -> Weight;
+	fn burn_nft(b: u32, ) -> Weight;
 	fn send() -> Weight;
 	fn accept_nft() -> Weight;
 	fn reject_nft() -> Weight;
@@ -63,7 +64,7 @@
 	// Storage: Common CollectionById (r:0 w:1)
 	// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
 	fn create_collection() -> Weight {
-		(40_456_000 as Weight)
+		(40_837_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(5 as Weight))
 			.saturating_add(T::DbWeight::get().writes(8 as Weight))
 	}
@@ -76,7 +77,7 @@
 	// Storage: Nonfungible TokensBurnt (r:0 w:1)
 	// Storage: Common AdminAmount (r:0 w:1)
 	fn destroy_collection() -> Weight {
-		(43_812_000 as Weight)
+		(44_544_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(5 as Weight))
 			.saturating_add(T::DbWeight::get().writes(6 as Weight))
 	}
@@ -84,7 +85,7 @@
 	// Storage: Common CollectionById (r:1 w:1)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	fn change_collection_issuer() -> Weight {
-		(22_032_000 as Weight)
+		(22_151_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(3 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -94,7 +95,7 @@
 	// Storage: Nonfungible TokensMinted (r:1 w:0)
 	// Storage: Nonfungible TokensBurnt (r:1 w:0)
 	fn lock_collection() -> Weight {
-		(23_314_000 as Weight)
+		(23_766_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(5 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -107,13 +108,32 @@
 	// Storage: Nonfungible TokenData (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn mint_nft() -> Weight {
-		(40_075_000 as Weight)
+		(40_237_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(6 as Weight))
 			.saturating_add(T::DbWeight::get().writes(5 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:1 w:1)
+	// Storage: Nonfungible TokenChildren (r:1 w:0)
+	// Storage: Nonfungible TokensBurnt (r:1 w:1)
+	// Storage: Nonfungible AccountBalance (r:1 w:1)
+	// Storage: Nonfungible Allowance (r:1 w:0)
+	// Storage: Nonfungible Owned (r:0 w:1)
+	// Storage: Nonfungible TokenProperties (r:0 w:1)
+	fn burn_nft(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 1_023_000
+			.saturating_add((318_424_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(T::DbWeight::get().reads(9 as Weight))
+			.saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
+			.saturating_add(T::DbWeight::get().writes(6 as Weight))
+			.saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))
+	}
+	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
 	// Storage: Nonfungible TokenData (r:5 w:1)
 	// Storage: Nonfungible TokenProperties (r:1 w:0)
 	// Storage: Nonfungible AccountBalance (r:2 w:2)
@@ -121,7 +141,7 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn send() -> Weight {
-		(71_474_000 as Weight)
+		(71_055_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(12 as Weight))
 			.saturating_add(T::DbWeight::get().writes(6 as Weight))
 	}
@@ -135,7 +155,7 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn accept_nft() -> Weight {
-		(79_890_000 as Weight)
+		(79_098_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(15 as Weight))
 			.saturating_add(T::DbWeight::get().writes(7 as Weight))
 	}
@@ -150,7 +170,7 @@
 	// Storage: Nonfungible Allowance (r:5 w:0)
 	// Storage: Nonfungible Owned (r:0 w:5)
 	fn reject_nft() -> Weight {
-		(236_754_000 as Weight)
+		(237_777_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(29 as Weight))
 			.saturating_add(T::DbWeight::get().writes(25 as Weight))
 	}
@@ -160,7 +180,7 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_property() -> Weight {
-		(48_370_000 as Weight)
+		(47_359_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(9 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -170,7 +190,7 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_priority() -> Weight {
-		(47_128_000 as Weight)
+		(46_537_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(9 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -187,7 +207,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_basic_resource() -> Weight {
-		(101_501_000 as Weight)
+		(100_939_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(16 as Weight))
 			.saturating_add(T::DbWeight::get().writes(12 as Weight))
 	}
@@ -204,7 +224,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_composable_resource() -> Weight {
-		(103_004_000 as Weight)
+		(101_821_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(16 as Weight))
 			.saturating_add(T::DbWeight::get().writes(12 as Weight))
 	}
@@ -221,7 +241,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_slot_resource() -> Weight {
-		(102_613_000 as Weight)
+		(100_880_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(16 as Weight))
 			.saturating_add(T::DbWeight::get().writes(12 as Weight))
 	}
@@ -236,7 +256,7 @@
 	// Storage: Nonfungible Allowance (r:1 w:0)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn remove_resource() -> Weight {
-		(82_084_000 as Weight)
+		(79_831_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(16 as Weight))
 			.saturating_add(T::DbWeight::get().writes(5 as Weight))
 	}
@@ -246,7 +266,7 @@
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	// Storage: Nonfungible TokenProperties (r:2 w:1)
 	fn accept_resource() -> Weight {
-		(56_426_000 as Weight)
+		(54_573_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(10 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -261,7 +281,7 @@
 	// Storage: Nonfungible Allowance (r:1 w:0)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn accept_resource_removal() -> Weight {
-		(85_631_000 as Weight)
+		(83_426_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(17 as Weight))
 			.saturating_add(T::DbWeight::get().writes(5 as Weight))
 	}
@@ -278,7 +298,7 @@
 	// Storage: Common CollectionById (r:0 w:1)
 	// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
 	fn create_collection() -> Weight {
-		(40_456_000 as Weight)
+		(40_837_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(8 as Weight))
 	}
@@ -291,7 +311,7 @@
 	// Storage: Nonfungible TokensBurnt (r:0 w:1)
 	// Storage: Common AdminAmount (r:0 w:1)
 	fn destroy_collection() -> Weight {
-		(43_812_000 as Weight)
+		(44_544_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
 	}
@@ -299,7 +319,7 @@
 	// Storage: Common CollectionById (r:1 w:1)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	fn change_collection_issuer() -> Weight {
-		(22_032_000 as Weight)
+		(22_151_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(3 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -309,7 +329,7 @@
 	// Storage: Nonfungible TokensMinted (r:1 w:0)
 	// Storage: Nonfungible TokensBurnt (r:1 w:0)
 	fn lock_collection() -> Weight {
-		(23_314_000 as Weight)
+		(23_766_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -322,13 +342,32 @@
 	// Storage: Nonfungible TokenData (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn mint_nft() -> Weight {
-		(40_075_000 as Weight)
+		(40_237_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(6 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(5 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:1 w:1)
+	// Storage: Nonfungible TokenChildren (r:1 w:0)
+	// Storage: Nonfungible TokensBurnt (r:1 w:1)
+	// Storage: Nonfungible AccountBalance (r:1 w:1)
+	// Storage: Nonfungible Allowance (r:1 w:0)
+	// Storage: Nonfungible Owned (r:0 w:1)
+	// Storage: Nonfungible TokenProperties (r:0 w:1)
+	fn burn_nft(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 1_023_000
+			.saturating_add((318_424_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
+			.saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
+			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
+			.saturating_add(RocksDbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))
+	}
+	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
 	// Storage: Nonfungible TokenData (r:5 w:1)
 	// Storage: Nonfungible TokenProperties (r:1 w:0)
 	// Storage: Nonfungible AccountBalance (r:2 w:2)
@@ -336,7 +375,7 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn send() -> Weight {
-		(71_474_000 as Weight)
+		(71_055_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(12 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
 	}
@@ -350,7 +389,7 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn accept_nft() -> Weight {
-		(79_890_000 as Weight)
+		(79_098_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(15 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(7 as Weight))
 	}
@@ -365,7 +404,7 @@
 	// Storage: Nonfungible Allowance (r:5 w:0)
 	// Storage: Nonfungible Owned (r:0 w:5)
 	fn reject_nft() -> Weight {
-		(236_754_000 as Weight)
+		(237_777_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(29 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(25 as Weight))
 	}
@@ -375,7 +414,7 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_property() -> Weight {
-		(48_370_000 as Weight)
+		(47_359_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -385,7 +424,7 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_priority() -> Weight {
-		(47_128_000 as Weight)
+		(46_537_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -402,7 +441,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_basic_resource() -> Weight {
-		(101_501_000 as Weight)
+		(100_939_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
 	}
@@ -419,7 +458,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_composable_resource() -> Weight {
-		(103_004_000 as Weight)
+		(101_821_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
 	}
@@ -436,7 +475,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_slot_resource() -> Weight {
-		(102_613_000 as Weight)
+		(100_880_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
 	}
@@ -451,7 +490,7 @@
 	// Storage: Nonfungible Allowance (r:1 w:0)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn remove_resource() -> Weight {
-		(82_084_000 as Weight)
+		(79_831_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(5 as Weight))
 	}
@@ -461,7 +500,7 @@
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	// Storage: Nonfungible TokenProperties (r:2 w:1)
 	fn accept_resource() -> Weight {
-		(56_426_000 as Weight)
+		(54_573_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(10 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -476,7 +515,7 @@
 	// Storage: Nonfungible Allowance (r:1 w:0)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn accept_resource_removal() -> Weight {
-		(85_631_000 as Weight)
+		(83_426_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(17 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(5 as Weight))
 	}