--- a/pallets/proxy-rmrk-core/src/benchmarking.rs +++ b/pallets/proxy-rmrk-core/src/benchmarking.rs @@ -53,6 +53,10 @@ } } +fn create_max_resource_types_array>(num: usize) -> BoundedVec { + vec![RmrkResourceTypes::Composable(create_composable_resource()); num].try_into().expect("num <= S") +} + fn create_max_collection(owner: &T::AccountId) -> DispatchResult { ::Currency::deposit_creating( owner, @@ -71,7 +75,7 @@ ) } -fn create_max_nft( +fn create_nft( owner: &T::AccountId, collection_id: RmrkCollectionId, ) -> DispatchResult { @@ -88,6 +92,7 @@ royalty_amount, metadata, transferable, + None ) } @@ -109,7 +114,7 @@ } fn build(&mut self, owner: &T::AccountId) -> Result { - create_max_nft::(owner, self.collection_id)?; + create_nft::(owner, self.collection_id)?; self.current_nft_id += 1; Ok(self.current_nft_id) @@ -213,7 +218,10 @@ }: _(RawOrigin::Signed(caller), collection_id) mint_nft { + let b in 0..100; + let caller: T::AccountId = account("caller", 0, SEED); + ::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get()); create_max_collection::(&caller)?; let collection_id = 0; @@ -230,7 +238,8 @@ royalty_recipient, royalty_amount, metadata, - transferable + transferable, + Some(create_max_resource_types_array(b as usize)) ) burn_nft { --- a/pallets/proxy-rmrk-core/src/lib.rs +++ b/pallets/proxy-rmrk-core/src/lib.rs @@ -344,7 +344,7 @@ /// - `metadata`: Arbitrary data about an nft, e.g. IPFS hash /// - `transferable`: Ability to transfer this NFT #[transactional] - #[pallet::weight(>::mint_nft())] + #[pallet::weight(>::mint_nft(resources.as_ref().map(|r| r.len() as u32).unwrap_or(0)))] pub fn mint_nft( origin: OriginFor, owner: T::AccountId, --- a/pallets/proxy-rmrk-core/src/weights.rs +++ b/pallets/proxy-rmrk-core/src/weights.rs @@ -3,7 +3,7 @@ //! Autogenerated weights for pallet_proxy_rmrk_core //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-06-10, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-06-14, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -37,7 +37,7 @@ fn destroy_collection() -> Weight; fn change_collection_issuer() -> Weight; fn lock_collection() -> Weight; - fn mint_nft() -> Weight; + fn mint_nft(b: u32, ) -> Weight; fn burn_nft(b: u32, ) -> Weight; fn send() -> Weight; fn accept_nft() -> Weight; @@ -64,7 +64,7 @@ // Storage: Common CollectionById (r:0 w:1) // Storage: RmrkCore UniqueCollectionId (r:0 w:1) fn create_collection() -> Weight { - (40_837_000 as Weight) + (41_277_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) } @@ -77,7 +77,7 @@ // Storage: Nonfungible TokensBurnt (r:0 w:1) // Storage: Common AdminAmount (r:0 w:1) fn destroy_collection() -> Weight { - (44_544_000 as Weight) + (43_371_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) } @@ -85,7 +85,7 @@ // Storage: Common CollectionById (r:1 w:1) // Storage: Common CollectionProperties (r:1 w:0) fn change_collection_issuer() -> Weight { - (22_151_000 as Weight) + (21_891_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -95,7 +95,7 @@ // Storage: Nonfungible TokensMinted (r:1 w:0) // Storage: Nonfungible TokensBurnt (r:1 w:0) fn lock_collection() -> Weight { - (23_766_000 as Weight) + (23_144_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -107,10 +107,18 @@ // Storage: Nonfungible TokenProperties (r:1 w:1) // Storage: Nonfungible TokenData (r:0 w:1) // Storage: Nonfungible Owned (r:0 w:1) - fn mint_nft() -> 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: Common CreatedCollectionCount (r:1 w:1) + // Storage: Common DestroyedCollectionCount (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Common CollectionPropertyPermissions (r:0 w:1) + fn mint_nft(b: u32, ) -> Weight { + (68_329_000 as Weight) + // Standard Error: 3_000 + .saturating_add((21_470_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(T::DbWeight::get().reads(12 as Weight)) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight))) + .saturating_add(T::DbWeight::get().writes(12 as Weight)) + .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight))) } // Storage: RmrkCore UniqueCollectionId (r:1 w:0) // Storage: Common CollectionProperties (r:1 w:0) @@ -124,8 +132,8 @@ // 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)) + // Standard Error: 959_000 + .saturating_add((305_872_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)) @@ -141,7 +149,7 @@ // Storage: Nonfungible TokenChildren (r:0 w:1) // Storage: Nonfungible Owned (r:0 w:2) fn send() -> Weight { - (71_055_000 as Weight) + (71_405_000 as Weight) .saturating_add(T::DbWeight::get().reads(12 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) } @@ -155,7 +163,7 @@ // Storage: Nonfungible TokenChildren (r:0 w:1) // Storage: Nonfungible Owned (r:0 w:2) fn accept_nft() -> Weight { - (79_098_000 as Weight) + (79_159_000 as Weight) .saturating_add(T::DbWeight::get().reads(15 as Weight)) .saturating_add(T::DbWeight::get().writes(7 as Weight)) } @@ -170,7 +178,7 @@ // Storage: Nonfungible Allowance (r:5 w:0) // Storage: Nonfungible Owned (r:0 w:5) fn reject_nft() -> Weight { - (237_777_000 as Weight) + (238_179_000 as Weight) .saturating_add(T::DbWeight::get().reads(29 as Weight)) .saturating_add(T::DbWeight::get().writes(25 as Weight)) } @@ -180,7 +188,7 @@ // Storage: Nonfungible TokenProperties (r:1 w:1) // Storage: Nonfungible TokenData (r:5 w:0) fn set_property() -> Weight { - (47_359_000 as Weight) + (47_770_000 as Weight) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -190,7 +198,7 @@ // Storage: Nonfungible TokenProperties (r:1 w:1) // Storage: Nonfungible TokenData (r:5 w:0) fn set_priority() -> Weight { - (46_537_000 as Weight) + (46_679_000 as Weight) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -207,7 +215,7 @@ // Storage: Nonfungible Owned (r:0 w:1) // Storage: Common CollectionPropertyPermissions (r:0 w:1) fn add_basic_resource() -> Weight { - (100_939_000 as Weight) + (100_770_000 as Weight) .saturating_add(T::DbWeight::get().reads(16 as Weight)) .saturating_add(T::DbWeight::get().writes(12 as Weight)) } @@ -224,7 +232,7 @@ // Storage: Nonfungible Owned (r:0 w:1) // Storage: Common CollectionPropertyPermissions (r:0 w:1) fn add_composable_resource() -> Weight { - (101_821_000 as Weight) + (101_791_000 as Weight) .saturating_add(T::DbWeight::get().reads(16 as Weight)) .saturating_add(T::DbWeight::get().writes(12 as Weight)) } @@ -241,7 +249,7 @@ // Storage: Nonfungible Owned (r:0 w:1) // Storage: Common CollectionPropertyPermissions (r:0 w:1) fn add_slot_resource() -> Weight { - (100_880_000 as Weight) + (101_610_000 as Weight) .saturating_add(T::DbWeight::get().reads(16 as Weight)) .saturating_add(T::DbWeight::get().writes(12 as Weight)) } @@ -256,7 +264,7 @@ // Storage: Nonfungible Allowance (r:1 w:0) // Storage: Nonfungible Owned (r:0 w:1) fn remove_resource() -> Weight { - (79_831_000 as Weight) + (80_571_000 as Weight) .saturating_add(T::DbWeight::get().reads(16 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } @@ -266,7 +274,7 @@ // Storage: Nonfungible TokenData (r:5 w:0) // Storage: Nonfungible TokenProperties (r:2 w:1) fn accept_resource() -> Weight { - (54_573_000 as Weight) + (54_733_000 as Weight) .saturating_add(T::DbWeight::get().reads(10 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -281,7 +289,7 @@ // Storage: Nonfungible Allowance (r:1 w:0) // Storage: Nonfungible Owned (r:0 w:1) fn accept_resource_removal() -> Weight { - (83_426_000 as Weight) + (84_138_000 as Weight) .saturating_add(T::DbWeight::get().reads(17 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } @@ -298,7 +306,7 @@ // Storage: Common CollectionById (r:0 w:1) // Storage: RmrkCore UniqueCollectionId (r:0 w:1) fn create_collection() -> Weight { - (40_837_000 as Weight) + (41_277_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) } @@ -311,7 +319,7 @@ // Storage: Nonfungible TokensBurnt (r:0 w:1) // Storage: Common AdminAmount (r:0 w:1) fn destroy_collection() -> Weight { - (44_544_000 as Weight) + (43_371_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(6 as Weight)) } @@ -319,7 +327,7 @@ // Storage: Common CollectionById (r:1 w:1) // Storage: Common CollectionProperties (r:1 w:0) fn change_collection_issuer() -> Weight { - (22_151_000 as Weight) + (21_891_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -329,7 +337,7 @@ // Storage: Nonfungible TokensMinted (r:1 w:0) // Storage: Nonfungible TokensBurnt (r:1 w:0) fn lock_collection() -> Weight { - (23_766_000 as Weight) + (23_144_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -341,10 +349,18 @@ // Storage: Nonfungible TokenProperties (r:1 w:1) // Storage: Nonfungible TokenData (r:0 w:1) // Storage: Nonfungible Owned (r:0 w:1) - fn mint_nft() -> Weight { - (40_237_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + // Storage: Common CreatedCollectionCount (r:1 w:1) + // Storage: Common DestroyedCollectionCount (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Common CollectionPropertyPermissions (r:0 w:1) + fn mint_nft(b: u32, ) -> Weight { + (68_329_000 as Weight) + // Standard Error: 3_000 + .saturating_add((21_470_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(RocksDbWeight::get().reads(12 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight))) + .saturating_add(RocksDbWeight::get().writes(12 as Weight)) + .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight))) } // Storage: RmrkCore UniqueCollectionId (r:1 w:0) // Storage: Common CollectionProperties (r:1 w:0) @@ -358,8 +374,8 @@ // 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)) + // Standard Error: 959_000 + .saturating_add((305_872_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)) @@ -375,7 +391,7 @@ // Storage: Nonfungible TokenChildren (r:0 w:1) // Storage: Nonfungible Owned (r:0 w:2) fn send() -> Weight { - (71_055_000 as Weight) + (71_405_000 as Weight) .saturating_add(RocksDbWeight::get().reads(12 as Weight)) .saturating_add(RocksDbWeight::get().writes(6 as Weight)) } @@ -389,7 +405,7 @@ // Storage: Nonfungible TokenChildren (r:0 w:1) // Storage: Nonfungible Owned (r:0 w:2) fn accept_nft() -> Weight { - (79_098_000 as Weight) + (79_159_000 as Weight) .saturating_add(RocksDbWeight::get().reads(15 as Weight)) .saturating_add(RocksDbWeight::get().writes(7 as Weight)) } @@ -404,7 +420,7 @@ // Storage: Nonfungible Allowance (r:5 w:0) // Storage: Nonfungible Owned (r:0 w:5) fn reject_nft() -> Weight { - (237_777_000 as Weight) + (238_179_000 as Weight) .saturating_add(RocksDbWeight::get().reads(29 as Weight)) .saturating_add(RocksDbWeight::get().writes(25 as Weight)) } @@ -414,7 +430,7 @@ // Storage: Nonfungible TokenProperties (r:1 w:1) // Storage: Nonfungible TokenData (r:5 w:0) fn set_property() -> Weight { - (47_359_000 as Weight) + (47_770_000 as Weight) .saturating_add(RocksDbWeight::get().reads(9 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -424,7 +440,7 @@ // Storage: Nonfungible TokenProperties (r:1 w:1) // Storage: Nonfungible TokenData (r:5 w:0) fn set_priority() -> Weight { - (46_537_000 as Weight) + (46_679_000 as Weight) .saturating_add(RocksDbWeight::get().reads(9 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -441,7 +457,7 @@ // Storage: Nonfungible Owned (r:0 w:1) // Storage: Common CollectionPropertyPermissions (r:0 w:1) fn add_basic_resource() -> Weight { - (100_939_000 as Weight) + (100_770_000 as Weight) .saturating_add(RocksDbWeight::get().reads(16 as Weight)) .saturating_add(RocksDbWeight::get().writes(12 as Weight)) } @@ -458,7 +474,7 @@ // Storage: Nonfungible Owned (r:0 w:1) // Storage: Common CollectionPropertyPermissions (r:0 w:1) fn add_composable_resource() -> Weight { - (101_821_000 as Weight) + (101_791_000 as Weight) .saturating_add(RocksDbWeight::get().reads(16 as Weight)) .saturating_add(RocksDbWeight::get().writes(12 as Weight)) } @@ -475,7 +491,7 @@ // Storage: Nonfungible Owned (r:0 w:1) // Storage: Common CollectionPropertyPermissions (r:0 w:1) fn add_slot_resource() -> Weight { - (100_880_000 as Weight) + (101_610_000 as Weight) .saturating_add(RocksDbWeight::get().reads(16 as Weight)) .saturating_add(RocksDbWeight::get().writes(12 as Weight)) } @@ -490,7 +506,7 @@ // Storage: Nonfungible Allowance (r:1 w:0) // Storage: Nonfungible Owned (r:0 w:1) fn remove_resource() -> Weight { - (79_831_000 as Weight) + (80_571_000 as Weight) .saturating_add(RocksDbWeight::get().reads(16 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } @@ -500,7 +516,7 @@ // Storage: Nonfungible TokenData (r:5 w:0) // Storage: Nonfungible TokenProperties (r:2 w:1) fn accept_resource() -> Weight { - (54_573_000 as Weight) + (54_733_000 as Weight) .saturating_add(RocksDbWeight::get().reads(10 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -515,7 +531,7 @@ // Storage: Nonfungible Allowance (r:1 w:0) // Storage: Nonfungible Owned (r:0 w:1) fn accept_resource_removal() -> Weight { - (83_426_000 as Weight) + (84_138_000 as Weight) .saturating_add(RocksDbWeight::get().reads(17 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) }