From bdf9f7d36e1d01724535f03408fe97475f00d974 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Thu, 12 Jan 2023 15:15:36 +0200 Subject: [PATCH 01/25] Allow to mint with the pre-signed signatures --- bin/node/runtime/src/lib.rs | 2 + frame/nfts/src/common_functions.rs | 8 +++- frame/nfts/src/features/metadata.rs | 7 +++ frame/nfts/src/features/settings.rs | 7 +++ frame/nfts/src/lib.rs | 74 +++++++++++++++++++++++++++-- frame/nfts/src/mock.rs | 2 + frame/nfts/src/tests.rs | 43 ++++++++++++++++- frame/nfts/src/types.rs | 22 ++++++++- 8 files changed, 158 insertions(+), 7 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index a9e93a16f0713..2d6e4b2cdb4d1 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1579,6 +1579,8 @@ impl pallet_nfts::Config for Runtime { type MaxTips = MaxTips; type MaxDeadlineDuration = MaxDeadlineDuration; type Features = Features; + type Signature = Signature; //sp_core::sr25519::Signature; + type PublicKey = ::Signer; //sp_core::sr25519::Public; type WeightInfo = pallet_nfts::weights::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] type Helper = (); diff --git a/frame/nfts/src/common_functions.rs b/frame/nfts/src/common_functions.rs index 9c0faeb6b7c77..8796acecd4821 100644 --- a/frame/nfts/src/common_functions.rs +++ b/frame/nfts/src/common_functions.rs @@ -17,7 +17,8 @@ //! Various pieces of common functionality. -use super::*; +use crate::*; +use frame_support::pallet_prelude::*; impl, I: 'static> Pallet { /// Get the owner of the item, if the item exists. @@ -30,6 +31,11 @@ impl, I: 'static> Pallet { Collection::::get(collection).map(|i| i.owner) } + /// Convert public key to account id. + pub fn public_to_account(public: T::PublicKey) -> Result { + Ok(T::AccountId::decode(&mut public.as_ref()).map_err(|_| Error::::WrongPublic)?) + } + #[cfg(any(test, feature = "runtime-benchmarks"))] pub fn set_next_id(id: T::CollectionId) { NextCollectionId::::set(Some(id)); diff --git a/frame/nfts/src/features/metadata.rs b/frame/nfts/src/features/metadata.rs index 272b2247426d6..39645d7784f08 100644 --- a/frame/nfts/src/features/metadata.rs +++ b/frame/nfts/src/features/metadata.rs @@ -191,4 +191,11 @@ impl, I: 'static> Pallet { Ok(()) }) } + + /// A helper method to construct metadata. + pub fn construct_metadata( + metadata: Vec, + ) -> Result, DispatchError> { + Ok(BoundedVec::try_from(metadata).map_err(|_| Error::::IncorrectMetadata)?) + } } diff --git a/frame/nfts/src/features/settings.rs b/frame/nfts/src/features/settings.rs index 5f408ed183c35..7c29711094112 100644 --- a/frame/nfts/src/features/settings.rs +++ b/frame/nfts/src/features/settings.rs @@ -96,6 +96,13 @@ impl, I: 'static> Pallet { Ok(config) } + pub(crate) fn get_default_item_settings( + collection_id: &T::CollectionId, + ) -> Result { + let collection_config = Self::get_collection_config(collection_id)?; + Ok(collection_config.mint_settings.default_item_settings) + } + pub(crate) fn is_pallet_feature_enabled(feature: PalletFeature) -> bool { let features = T::Features::get(); return features.is_enabled(feature) diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 8f24c8dcd6e98..4731a7952bbb9 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -67,6 +67,7 @@ pub mod pallet { use super::*; use frame_support::{pallet_prelude::*, traits::ExistenceRequirement}; use frame_system::pallet_prelude::*; + use sp_runtime::traits::{IdentifyAccount, Verify}; #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] @@ -171,6 +172,16 @@ pub mod pallet { #[pallet::constant] type Features: Get; + /// A signature used to pre-sign some data. + type Signature: Verify + Encode + Decode + Parameter; + + /// The public key of the signer. + type PublicKey: IdentifyAccount + + AsRef<[u8]> + + Encode + + Decode + + Parameter; + #[cfg(feature = "runtime-benchmarks")] /// A set of helper functions for benchmarking. type Helper: BenchmarkHelper; @@ -591,6 +602,14 @@ pub mod pallet { AlreadyClaimed, /// The provided data is incorrect. IncorrectData, + /// The extrinsic should be sent by another origin. + WrongOrigin, + /// Unable to get the account id from the provided public key. + WrongPublic, + /// The provided signature is incorrect. + WrongSignature, + /// The provided metadata might be too long. + IncorrectMetadata, } #[pallet::call] @@ -742,10 +761,8 @@ pub mod pallet { ) -> DispatchResult { let caller = ensure_signed(origin)?; let mint_to = T::Lookup::lookup(mint_to)?; - - let collection_config = Self::get_collection_config(&collection)?; - let item_settings = collection_config.mint_settings.default_item_settings; - let item_config = ItemConfig { settings: item_settings }; + let item_config = + ItemConfig { settings: Self::get_default_item_settings(&collection)? }; Self::do_mint( collection, @@ -1768,6 +1785,55 @@ pub mod pallet { witness_price, ) } + + #[pallet::call_index(37)] + #[pallet::weight(0)] + pub fn mint_pre_signed( + origin: OriginFor, + data: PreSignedMintOf, + signature: T::Signature, + signer: T::PublicKey, + ) -> DispatchResult { + let origin = ensure_signed(origin)?; + let msg = Encode::encode(&data); + ensure!(signature.verify(&*msg, &signer), Error::::WrongSignature); + + let signer_account = Self::public_to_account(signer)?; + log::info!("signer_account {:?}", &signer_account); + + let PreSignedMint { collection, item, metadata, deadline, only_account } = data; + let metadata = Self::construct_metadata(metadata)?; + + if let Some(account) = only_account { + ensure!(account == origin, Error::::WrongOrigin); + } + + let now = frame_system::Pallet::::block_number(); + ensure!(deadline >= now, Error::::DeadlineExpired); + + let collection_details = + Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; + ensure!(collection_details.owner == signer_account, Error::::NoPermission); + + let item_config = + ItemConfig { settings: Self::get_default_item_settings(&collection)? }; + Self::do_mint( + collection, + item, + Some(origin.clone()), + origin.clone(), + item_config, + |_, _| Ok(()), + )?; + + Self::do_set_item_metadata( + Some(collection_details.owner), + collection, + item, + metadata, + Some(origin), + ) + } } } diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index f814b209d5f78..7e44de9cd3c26 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -109,6 +109,8 @@ impl Config for Test { type MaxTips = ConstU32<10>; type MaxDeadlineDuration = ConstU64<10000>; type Features = Features; + type Signature = sp_core::sr25519::Signature; + type PublicKey = sp_core::sr25519::Public; type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] type Helper = (); diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index ebbba33b04fa2..76a52396b02c3 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -28,7 +28,7 @@ use frame_support::{ }, }; use pallet_balances::Error as BalancesError; -use sp_core::bounded::BoundedVec; +use sp_core::{bounded::BoundedVec, Pair}; use sp_std::prelude::*; fn items() -> Vec<(u64, u32, u32)> { @@ -2498,3 +2498,44 @@ fn add_remove_item_attributes_approval_should_work() { assert_eq!(item_attributes_approvals(collection_id, item_id), vec![user_3]); }) } + +#[test] +fn pre_signed_mints_should_work() { + new_test_ext().execute_with(|| { + let user1_pair = sp_core::sr25519::Pair::from_string("//Alice///password", None).unwrap(); + let user1 = Nfts::public_to_account(user1_pair.public()).unwrap(); + let mint_data = PreSignedMint { + collection: 0, + item: 0, + metadata: bvec![0], + only_account: None, + deadline: 1, + }; + let signature = user1_pair.sign(&Encode::encode(&mint_data)); + dbg!(user1); + + let user2 = 2; + + Balances::make_free_balance_be(&user1, 100); + Balances::make_free_balance_be(&user2, 100); + assert_ok!(Nfts::create( + RuntimeOrigin::signed(user1), + user1, + collection_config_with_all_settings_enabled() + )); + assert_ok!(Nfts::mint_pre_signed( + RuntimeOrigin::signed(user2), + mint_data, + signature, + user1_pair.public() + )); + assert_eq!(items(), vec![(user2, 0, 0)]); + // validate metadata (ok and not ok) + // validate balances + // validate signature + // validate deadline + // validate balance on burn + // validate collection owner + // validate wrong collection's and item's ids + }) +} diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index d8938aab4377a..6cf821d7660a5 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -61,6 +61,12 @@ pub(super) type CollectionConfigFor = CollectionConfig< ::BlockNumber, >::CollectionId, >; +pub(super) type PreSignedMintOf = PreSignedMint< + >::CollectionId, + >::ItemId, + ::AccountId, + ::BlockNumber, +>; pub trait Incrementable { fn increment(&self) -> Self; @@ -187,7 +193,7 @@ pub struct PendingSwap { pub(super) desired_item: Option, /// A price for the desired `item` with the direction. pub(super) price: Option, - /// An optional deadline for the swap. + /// A deadline for the swap. pub(super) deadline: Deadline, } @@ -473,3 +479,17 @@ impl CollectionRoles { } } impl_codec_bitflags!(CollectionRoles, u8, CollectionRole); + +#[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] +pub struct PreSignedMint { + /// A collection of the item to be minted. + pub(super) collection: CollectionId, + /// Item's id. + pub(super) item: ItemId, + /// Additional item's metadata. + pub(super) metadata: Vec, + /// Restrict the claim to a particular account. + pub(super) only_account: Option, + /// A deadline for the signature. + pub(super) deadline: Deadline, +} From 320582d1f9855357ab01a0737b219137412b1e3c Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Thu, 12 Jan 2023 16:31:39 +0200 Subject: [PATCH 02/25] Another try --- bin/node/runtime/src/lib.rs | 2 -- frame/nfts/src/common_functions.rs | 8 +++++--- frame/nfts/src/lib.rs | 23 ++++++++--------------- frame/nfts/src/mock.rs | 5 ++--- frame/nfts/src/tests.rs | 8 +++++--- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 2d6e4b2cdb4d1..a9e93a16f0713 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1579,8 +1579,6 @@ impl pallet_nfts::Config for Runtime { type MaxTips = MaxTips; type MaxDeadlineDuration = MaxDeadlineDuration; type Features = Features; - type Signature = Signature; //sp_core::sr25519::Signature; - type PublicKey = ::Signer; //sp_core::sr25519::Public; type WeightInfo = pallet_nfts::weights::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] type Helper = (); diff --git a/frame/nfts/src/common_functions.rs b/frame/nfts/src/common_functions.rs index 8796acecd4821..a32f3f1127cc0 100644 --- a/frame/nfts/src/common_functions.rs +++ b/frame/nfts/src/common_functions.rs @@ -19,6 +19,7 @@ use crate::*; use frame_support::pallet_prelude::*; +use sp_runtime::traits::IdentifyAccount; impl, I: 'static> Pallet { /// Get the owner of the item, if the item exists. @@ -31,9 +32,10 @@ impl, I: 'static> Pallet { Collection::::get(collection).map(|i| i.owner) } - /// Convert public key to account id. - pub fn public_to_account(public: T::PublicKey) -> Result { - Ok(T::AccountId::decode(&mut public.as_ref()).map_err(|_| Error::::WrongPublic)?) + /// Convert signer into account id. + pub fn signer_to_account(signer: MultiSigner) -> Result { + Ok(T::AccountId::decode(&mut signer.into_account().as_ref()) + .map_err(|_| Error::::WrongPublic)?) } #[cfg(any(test, feature = "runtime-benchmarks"))] diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 4731a7952bbb9..1ddb1f880f554 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -52,7 +52,7 @@ use frame_support::traits::{ use frame_system::Config as SystemConfig; use sp_runtime::{ traits::{Saturating, StaticLookup, Zero}, - RuntimeDebug, + MultiSignature, MultiSigner, RuntimeDebug, }; use sp_std::prelude::*; @@ -172,16 +172,6 @@ pub mod pallet { #[pallet::constant] type Features: Get; - /// A signature used to pre-sign some data. - type Signature: Verify + Encode + Decode + Parameter; - - /// The public key of the signer. - type PublicKey: IdentifyAccount - + AsRef<[u8]> - + Encode - + Decode - + Parameter; - #[cfg(feature = "runtime-benchmarks")] /// A set of helper functions for benchmarking. type Helper: BenchmarkHelper; @@ -1791,14 +1781,17 @@ pub mod pallet { pub fn mint_pre_signed( origin: OriginFor, data: PreSignedMintOf, - signature: T::Signature, - signer: T::PublicKey, + signature: MultiSignature, + signer: MultiSigner, ) -> DispatchResult { let origin = ensure_signed(origin)?; let msg = Encode::encode(&data); - ensure!(signature.verify(&*msg, &signer), Error::::WrongSignature); + ensure!( + signature.verify(&*msg, &signer.clone().into_account()), + Error::::WrongSignature + ); - let signer_account = Self::public_to_account(signer)?; + let signer_account = Self::signer_to_account(signer)?; log::info!("signer_account {:?}", &signer_account); let PreSignedMint { collection, item, metadata, deadline, only_account } = data; diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index 7e44de9cd3c26..912a4d90186e0 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -28,6 +28,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + MultiSignature, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -87,7 +88,7 @@ impl pallet_balances::Config for Test { parameter_types! { pub storage Features: PalletFeatures = PalletFeatures::all_enabled(); } - +pub type Signature = MultiSignature; impl Config for Test { type RuntimeEvent = RuntimeEvent; type CollectionId = u32; @@ -109,8 +110,6 @@ impl Config for Test { type MaxTips = ConstU32<10>; type MaxDeadlineDuration = ConstU64<10000>; type Features = Features; - type Signature = sp_core::sr25519::Signature; - type PublicKey = sp_core::sr25519::Public; type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] type Helper = (); diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index 76a52396b02c3..bf746f49d67b1 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -29,6 +29,7 @@ use frame_support::{ }; use pallet_balances::Error as BalancesError; use sp_core::{bounded::BoundedVec, Pair}; +use sp_runtime::{MultiSignature, MultiSigner}; use sp_std::prelude::*; fn items() -> Vec<(u64, u32, u32)> { @@ -2503,7 +2504,8 @@ fn add_remove_item_attributes_approval_should_work() { fn pre_signed_mints_should_work() { new_test_ext().execute_with(|| { let user1_pair = sp_core::sr25519::Pair::from_string("//Alice///password", None).unwrap(); - let user1 = Nfts::public_to_account(user1_pair.public()).unwrap(); + let user1_signer = MultiSigner::Sr25519(user1_pair.public()); + let user1 = Nfts::signer_to_account(user1_signer.clone()).unwrap(); let mint_data = PreSignedMint { collection: 0, item: 0, @@ -2511,7 +2513,7 @@ fn pre_signed_mints_should_work() { only_account: None, deadline: 1, }; - let signature = user1_pair.sign(&Encode::encode(&mint_data)); + let signature = MultiSignature::Sr25519(user1_pair.sign(&Encode::encode(&mint_data))); dbg!(user1); let user2 = 2; @@ -2527,7 +2529,7 @@ fn pre_signed_mints_should_work() { RuntimeOrigin::signed(user2), mint_data, signature, - user1_pair.public() + user1_signer )); assert_eq!(items(), vec![(user2, 0, 0)]); // validate metadata (ok and not ok) From a92dc15bb06ca41bf224586fd52e629b8591a82e Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Fri, 13 Jan 2023 16:13:51 +0200 Subject: [PATCH 03/25] WIP: test encoder --- Cargo.lock | 1 + frame/nfts/Cargo.toml | 1 + frame/nfts/src/lib.rs | 28 +++++++++++++++---------- frame/nfts/src/tests.rs | 45 ++++++++++++++++++++++++++++++++++------- frame/nfts/src/types.rs | 4 ++-- 5 files changed, 59 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb644202ae382..178887b2cb92b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5902,6 +5902,7 @@ dependencies = [ name = "pallet-nfts" version = "4.0.0-dev" dependencies = [ + "array-bytes", "enumflags2", "frame-benchmarking", "frame-support", diff --git a/frame/nfts/Cargo.toml b/frame/nfts/Cargo.toml index d2cdb48532fd0..d2a5378a6f817 100644 --- a/frame/nfts/Cargo.toml +++ b/frame/nfts/Cargo.toml @@ -25,6 +25,7 @@ sp-runtime = { version = "7.0.0", default-features = false, path = "../../primit sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } [dev-dependencies] +array-bytes = "4.1" pallet-balances = { version = "4.0.0-dev", path = "../balances" } sp-core = { version = "7.0.0", path = "../../primitives/core" } sp-io = { version = "7.0.0", path = "../../primitives/io" } diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 1ddb1f880f554..1cc3d3fb94fdf 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -1786,16 +1786,20 @@ pub mod pallet { ) -> DispatchResult { let origin = ensure_signed(origin)?; let msg = Encode::encode(&data); + use sp_core::hexdisplay::HexDisplay; + log::info!("DDEBUG: msg {:?}", HexDisplay::from(&msg)); + log::info!("DDEBUG: signature {:?}", &signature); + log::info!("DDEBUG: signer {:?}", &signer.clone().into_account()); ensure!( signature.verify(&*msg, &signer.clone().into_account()), Error::::WrongSignature ); let signer_account = Self::signer_to_account(signer)?; - log::info!("signer_account {:?}", &signer_account); + log::info!("DDEBUG: signer_account {:?}", &signer_account); - let PreSignedMint { collection, item, metadata, deadline, only_account } = data; - let metadata = Self::construct_metadata(metadata)?; + let PreSignedMint { collection, item, /* metadata, */ deadline, only_account } = data; + // let metadata = Self::construct_metadata(metadata)?; if let Some(account) = only_account { ensure!(account == origin, Error::::WrongOrigin); @@ -1818,14 +1822,16 @@ pub mod pallet { item_config, |_, _| Ok(()), )?; - - Self::do_set_item_metadata( - Some(collection_details.owner), - collection, - item, - metadata, - Some(origin), - ) + /*if !metadata.len().is_zero() { + Self::do_set_item_metadata( + Some(collection_details.owner), + collection, + item, + metadata, + Some(origin), + )?; + }*/ + Ok(()) } } } diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index bf746f49d67b1..a3bd1f7b01bd2 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -2503,19 +2503,50 @@ fn add_remove_item_attributes_approval_should_work() { #[test] fn pre_signed_mints_should_work() { new_test_ext().execute_with(|| { - let user1_pair = sp_core::sr25519::Pair::from_string("//Alice///password", None).unwrap(); + let user1_pair = sp_core::sr25519::Pair::from_string("//Alice", None).unwrap(); let user1_signer = MultiSigner::Sr25519(user1_pair.public()); let user1 = Nfts::signer_to_account(user1_signer.clone()).unwrap(); - let mint_data = PreSignedMint { + let mint_data: PreSignedMint = PreSignedMint { collection: 0, item: 0, - metadata: bvec![0], + // metadata: vec![0], only_account: None, - deadline: 1, + deadline: 10000000, }; - let signature = MultiSignature::Sr25519(user1_pair.sign(&Encode::encode(&mint_data))); - dbg!(user1); - + let message = Encode::encode(&mint_data); + + use sp_core::hexdisplay::HexDisplay; + dbg!(HexDisplay::from(&message)); + // 0000000000000000008096980000000000 + + let signature = MultiSignature::Sr25519(user1_pair.sign(&message)); + // let a = &array_bytes::hex2bytes_unchecked("00000000000000000080969800")[..]; + // dbg!(a); + // let signature = MultiSignature::Sr25519(user1_pair.sign(&a)); + + // use sp_runtime::traits::{IdentifyAccount, Verify}; + // dbg!(signature.verify(&*message, &user1_signer.clone().into_account())); + + // use sp_core::crypto::Ss58Codec; + // dbg!(user1_pair.public().to_ss58check()); + // dbg!(user1); + dbg!(&signature); + // dbg!(&user1_signer); + dbg!(&user1_pair.public()); + + /* + 2023-01-13 14:20:54 DDEBUG: msg 00000000000000000080969800 + 2023-01-13 14:20:54 DDEBUG: signature MultiSignature::Sr25519(9483ca2df9b4ffe1dae4fa1412377ab6bf00e51e85ca5ebb0a9730861712f62d203d026e61090d5570f50c389563c4b1fd0b819e3c0df8179408184259192685) + 2023-01-13 14:20:54 DDEBUG: signer d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...) + + 2023-01-13 14:39:51 DDEBUG: msg 00000000000000000080969800 + 2023-01-13 14:39:51 DDEBUG: signature MultiSignature::Sr25519(20a4c1caededa2b23a76105bfc3c483d5ca9b2cfb8d6a470084c28c5219ad95624f54250c795134ba81ad9ac8cb2f08cf2f5c1449dfe5a21e74e18c83bad4e8f) + 2023-01-13 14:39:51 DDEBUG: signer d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...) + + 2023-01-13 16:08:06 DDEBUG: msg 00000000000000000080969800 + 2023-01-13 16:08:06 DDEBUG: signature MultiSignature::Sr25519(9483ca2df9b4ffe1dae4fa1412377ab6bf00e51e85ca5ebb0a9730861712f62d203d026e61090d5570f50c389563c4b1fd0b819e3c0df8179408184259192685) + 2023-01-13 16:08:06 DDEBUG: signer d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...) + */ let user2 = 2; Balances::make_free_balance_be(&user1, 100); diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index 6cf821d7660a5..a4852c98fd48a 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -486,8 +486,8 @@ pub struct PreSignedMint { pub(super) collection: CollectionId, /// Item's id. pub(super) item: ItemId, - /// Additional item's metadata. - pub(super) metadata: Vec, + // Additional item's metadata. + // pub(super) metadata: Vec, /// Restrict the claim to a particular account. pub(super) only_account: Option, /// A deadline for the signature. From 124d872e275f2a3c0aa6a69acdf3107606d6f828 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 17 Jan 2023 11:39:02 +0100 Subject: [PATCH 04/25] Fix the deposits --- frame/nfts/src/features/metadata.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/frame/nfts/src/features/metadata.rs b/frame/nfts/src/features/metadata.rs index 39645d7784f08..c4d355f1922fc 100644 --- a/frame/nfts/src/features/metadata.rs +++ b/frame/nfts/src/features/metadata.rs @@ -60,14 +60,16 @@ impl, I: 'static> Pallet { .saturating_add(T::MetadataDepositBase::get()); } - // the previous deposit was taken from the item's owner - if old_deposit.account.is_some() && maybe_depositor.is_none() { - T::Currency::unreserve(&old_deposit.account.unwrap(), old_deposit.amount); - T::Currency::reserve(&collection_details.owner, deposit)?; + let depositor = maybe_depositor.clone().unwrap_or(collection_details.owner.clone()); + let old_depositor = old_deposit.account.unwrap_or(collection_details.owner.clone()); + + if depositor != old_depositor { + T::Currency::unreserve(&old_depositor, old_deposit.amount); + T::Currency::reserve(&depositor, deposit)?; } else if deposit > old_deposit.amount { - T::Currency::reserve(&collection_details.owner, deposit - old_deposit.amount)?; + T::Currency::reserve(&depositor, deposit - old_deposit.amount)?; } else if deposit < old_deposit.amount { - T::Currency::unreserve(&collection_details.owner, old_deposit.amount - deposit); + T::Currency::unreserve(&depositor, old_deposit.amount - deposit); } if maybe_depositor.is_none() { From bb911660cd91e8ffbd1486232759d56e9893411a Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 17 Jan 2023 11:39:23 +0100 Subject: [PATCH 05/25] Refactoring + tests + benchmarks --- Cargo.lock | 1 - frame/nfts/Cargo.toml | 1 - frame/nfts/src/benchmarking.rs | 36 ++++ frame/nfts/src/features/create_delete_item.rs | 40 +++++ frame/nfts/src/lib.rs | 44 +---- frame/nfts/src/tests.rs | 160 +++++++++++------- frame/nfts/src/types.rs | 4 +- frame/nfts/src/weights.rs | 13 ++ 8 files changed, 196 insertions(+), 103 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 178887b2cb92b..eb644202ae382 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5902,7 +5902,6 @@ dependencies = [ name = "pallet-nfts" version = "4.0.0-dev" dependencies = [ - "array-bytes", "enumflags2", "frame-benchmarking", "frame-support", diff --git a/frame/nfts/Cargo.toml b/frame/nfts/Cargo.toml index d2a5378a6f817..d2cdb48532fd0 100644 --- a/frame/nfts/Cargo.toml +++ b/frame/nfts/Cargo.toml @@ -25,7 +25,6 @@ sp-runtime = { version = "7.0.0", default-features = false, path = "../../primit sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } [dev-dependencies] -array-bytes = "4.1" pallet-balances = { version = "4.0.0-dev", path = "../balances" } sp-core = { version = "7.0.0", path = "../../primitives/core" } sp-io = { version = "7.0.0", path = "../../primitives/io" } diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index 6517445da672d..623461fccd7b7 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -31,6 +31,7 @@ use frame_support::{ BoundedVec, }; use frame_system::RawOrigin as SystemOrigin; +use sp_core::Pair; use sp_runtime::traits::{Bounded, One}; use sp_std::prelude::*; @@ -714,5 +715,40 @@ benchmarks_instance_pallet! { }.into()); } + mint_pre_signed { + let caller_pair = sp_core::sr25519::Pair::from_string("//Alice", None).unwrap(); + let caller_signer = MultiSigner::Sr25519(caller_pair.public()); + let caller = Nfts::::signer_to_account(caller_signer.clone()).unwrap(); + T::Currency::make_free_balance_be(&caller, DepositBalanceOf::::max_value()); + let caller_lookup = T::Lookup::unlookup(caller.clone()); + + let collection = T::Helper::collection(0); + let item = T::Helper::item(0); + assert_ok!(Nfts::::force_create( + SystemOrigin::Root.into(), + caller_lookup.clone(), + default_collection_config::() + )); + + let metadata = vec![0u8; T::StringLimit::get() as usize]; + let mint_data = PreSignedMint { + collection, + item, + metadata: metadata.clone(), + only_account: None, + deadline: One::one(), + }; + let message = Encode::encode(&mint_data); + let signature = MultiSignature::Sr25519(caller_pair.sign(&message)); + + let target: T::AccountId = account("target", 0, SEED); + T::Currency::make_free_balance_be(&target, DepositBalanceOf::::max_value()); + frame_system::Pallet::::set_block_number(One::one()); + }: _(SystemOrigin::Signed(target.clone()), mint_data, signature, caller_signer) + verify { + let metadata: BoundedVec<_, _> = metadata.try_into().unwrap(); + assert_last_event::(Event::ItemMetadataSet { collection, item, data: metadata }.into()); + } + impl_benchmark_test_suite!(Nfts, crate::mock::new_test_ext(), crate::mock::Test); } diff --git a/frame/nfts/src/features/create_delete_item.rs b/frame/nfts/src/features/create_delete_item.rs index f724fe5c63b43..90f4494691575 100644 --- a/frame/nfts/src/features/create_delete_item.rs +++ b/frame/nfts/src/features/create_delete_item.rs @@ -85,6 +85,46 @@ impl, I: 'static> Pallet { Ok(()) } + pub(crate) fn do_mint_pre_signed( + mint_to: T::AccountId, + mint_data: PreSignedMintOf, + signer: T::AccountId, + ) -> DispatchResult { + let PreSignedMint { collection, item, metadata, deadline, only_account } = mint_data; + let metadata = Self::construct_metadata(metadata)?; + + if let Some(account) = only_account { + ensure!(account == mint_to, Error::::WrongOrigin); + } + + let now = frame_system::Pallet::::block_number(); + ensure!(deadline >= now, Error::::DeadlineExpired); + + let collection_details = + Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; + ensure!(collection_details.owner == signer, Error::::NoPermission); + + let item_config = ItemConfig { settings: Self::get_default_item_settings(&collection)? }; + Self::do_mint( + collection, + item, + Some(mint_to.clone()), + mint_to.clone(), + item_config, + |_, _| Ok(()), + )?; + if !metadata.len().is_zero() { + Self::do_set_item_metadata( + Some(collection_details.owner), + collection, + item, + metadata, + Some(mint_to), + )?; + } + Ok(()) + } + pub fn do_burn( collection: T::CollectionId, item: T::ItemId, diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 1cc3d3fb94fdf..57ab224f1ec19 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -1777,7 +1777,7 @@ pub mod pallet { } #[pallet::call_index(37)] - #[pallet::weight(0)] + #[pallet::weight(T::WeightInfo::mint_pre_signed())] pub fn mint_pre_signed( origin: OriginFor, data: PreSignedMintOf, @@ -1786,52 +1786,12 @@ pub mod pallet { ) -> DispatchResult { let origin = ensure_signed(origin)?; let msg = Encode::encode(&data); - use sp_core::hexdisplay::HexDisplay; - log::info!("DDEBUG: msg {:?}", HexDisplay::from(&msg)); - log::info!("DDEBUG: signature {:?}", &signature); - log::info!("DDEBUG: signer {:?}", &signer.clone().into_account()); ensure!( signature.verify(&*msg, &signer.clone().into_account()), Error::::WrongSignature ); - let signer_account = Self::signer_to_account(signer)?; - log::info!("DDEBUG: signer_account {:?}", &signer_account); - - let PreSignedMint { collection, item, /* metadata, */ deadline, only_account } = data; - // let metadata = Self::construct_metadata(metadata)?; - - if let Some(account) = only_account { - ensure!(account == origin, Error::::WrongOrigin); - } - - let now = frame_system::Pallet::::block_number(); - ensure!(deadline >= now, Error::::DeadlineExpired); - - let collection_details = - Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - ensure!(collection_details.owner == signer_account, Error::::NoPermission); - - let item_config = - ItemConfig { settings: Self::get_default_item_settings(&collection)? }; - Self::do_mint( - collection, - item, - Some(origin.clone()), - origin.clone(), - item_config, - |_, _| Ok(()), - )?; - /*if !metadata.len().is_zero() { - Self::do_set_item_metadata( - Some(collection_details.owner), - collection, - item, - metadata, - Some(origin), - )?; - }*/ - Ok(()) + Self::do_mint_pre_signed(origin, data, signer_account) } } } diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index a3bd1f7b01bd2..ea18b016c5316 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -2503,72 +2503,118 @@ fn add_remove_item_attributes_approval_should_work() { #[test] fn pre_signed_mints_should_work() { new_test_ext().execute_with(|| { - let user1_pair = sp_core::sr25519::Pair::from_string("//Alice", None).unwrap(); - let user1_signer = MultiSigner::Sr25519(user1_pair.public()); - let user1 = Nfts::signer_to_account(user1_signer.clone()).unwrap(); - let mint_data: PreSignedMint = PreSignedMint { + let user_1_pair = sp_core::sr25519::Pair::from_string("//Alice", None).unwrap(); + let user_1_signer = MultiSigner::Sr25519(user_1_pair.public()); + let user_1 = Nfts::signer_to_account(user_1_signer.clone()).unwrap(); + let mint_data = PreSignedMint { collection: 0, item: 0, - // metadata: vec![0], + metadata: vec![00, 01], only_account: None, deadline: 10000000, }; let message = Encode::encode(&mint_data); + let signature = MultiSignature::Sr25519(user_1_pair.sign(&message)); + let user_2 = 2; + let user_3 = 3; - use sp_core::hexdisplay::HexDisplay; - dbg!(HexDisplay::from(&message)); - // 0000000000000000008096980000000000 - - let signature = MultiSignature::Sr25519(user1_pair.sign(&message)); - // let a = &array_bytes::hex2bytes_unchecked("00000000000000000080969800")[..]; - // dbg!(a); - // let signature = MultiSignature::Sr25519(user1_pair.sign(&a)); - - // use sp_runtime::traits::{IdentifyAccount, Verify}; - // dbg!(signature.verify(&*message, &user1_signer.clone().into_account())); - - // use sp_core::crypto::Ss58Codec; - // dbg!(user1_pair.public().to_ss58check()); - // dbg!(user1); - dbg!(&signature); - // dbg!(&user1_signer); - dbg!(&user1_pair.public()); - - /* - 2023-01-13 14:20:54 DDEBUG: msg 00000000000000000080969800 - 2023-01-13 14:20:54 DDEBUG: signature MultiSignature::Sr25519(9483ca2df9b4ffe1dae4fa1412377ab6bf00e51e85ca5ebb0a9730861712f62d203d026e61090d5570f50c389563c4b1fd0b819e3c0df8179408184259192685) - 2023-01-13 14:20:54 DDEBUG: signer d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...) - - 2023-01-13 14:39:51 DDEBUG: msg 00000000000000000080969800 - 2023-01-13 14:39:51 DDEBUG: signature MultiSignature::Sr25519(20a4c1caededa2b23a76105bfc3c483d5ca9b2cfb8d6a470084c28c5219ad95624f54250c795134ba81ad9ac8cb2f08cf2f5c1449dfe5a21e74e18c83bad4e8f) - 2023-01-13 14:39:51 DDEBUG: signer d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...) - - 2023-01-13 16:08:06 DDEBUG: msg 00000000000000000080969800 - 2023-01-13 16:08:06 DDEBUG: signature MultiSignature::Sr25519(9483ca2df9b4ffe1dae4fa1412377ab6bf00e51e85ca5ebb0a9730861712f62d203d026e61090d5570f50c389563c4b1fd0b819e3c0df8179408184259192685) - 2023-01-13 16:08:06 DDEBUG: signer d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...) - */ - let user2 = 2; - - Balances::make_free_balance_be(&user1, 100); - Balances::make_free_balance_be(&user2, 100); + Balances::make_free_balance_be(&user_1, 100); + Balances::make_free_balance_be(&user_2, 100); assert_ok!(Nfts::create( - RuntimeOrigin::signed(user1), - user1, - collection_config_with_all_settings_enabled() + RuntimeOrigin::signed(user_1), + user_1, + collection_config_with_all_settings_enabled(), )); + assert_ok!(Nfts::mint_pre_signed( - RuntimeOrigin::signed(user2), - mint_data, - signature, - user1_signer - )); - assert_eq!(items(), vec![(user2, 0, 0)]); - // validate metadata (ok and not ok) - // validate balances - // validate signature - // validate deadline - // validate balance on burn - // validate collection owner - // validate wrong collection's and item's ids + RuntimeOrigin::signed(user_2), + mint_data.clone(), + signature.clone(), + user_1_signer.clone(), + )); + assert_eq!(items(), vec![(user_2, 0, 0)]); + let metadata = ItemMetadataOf::::get(0, 0).unwrap(); + assert_eq!(metadata.deposit, ItemMetadataDeposit { account: Some(user_2), amount: 3 }); + assert_eq!(metadata.data, vec![00, 01]); + + assert_eq!(Balances::free_balance(&user_1), 100 - 2); // 2 - collection deposit + assert_eq!(Balances::free_balance(&user_2), 100 - 1 - 3); // 1 - item deposit, 3 - metadata + + assert_noop!( + Nfts::mint_pre_signed( + RuntimeOrigin::signed(user_2), + mint_data, + signature.clone(), + user_1_signer.clone(), + ), + Error::::AlreadyExists + ); + + assert_ok!(Nfts::burn(RuntimeOrigin::signed(user_2), 0, 0, Some(user_2))); + assert_eq!(Balances::free_balance(&user_2), 100); + + // check errors + let mint_data = PreSignedMint { + collection: 0, + item: 0, + metadata: vec![], + only_account: Some(2), + deadline: 10000000, + }; + + assert_noop!( + Nfts::mint_pre_signed( + RuntimeOrigin::signed(user_2), + mint_data.clone(), + signature.clone(), + user_1_signer.clone(), + ), + Error::::WrongSignature + ); + + let message = Encode::encode(&mint_data); + let signature = MultiSignature::Sr25519(user_1_pair.sign(&message)); + + assert_noop!( + Nfts::mint_pre_signed( + RuntimeOrigin::signed(user_3), + mint_data.clone(), + signature.clone(), + user_1_signer.clone(), + ), + Error::::WrongOrigin + ); + + System::set_block_number(10000001); + assert_noop!( + Nfts::mint_pre_signed( + RuntimeOrigin::signed(user_2), + mint_data, + signature, + user_1_signer.clone(), + ), + Error::::DeadlineExpired + ); + System::set_block_number(1); + + let mint_data = PreSignedMint { + collection: 1, + item: 0, + metadata: vec![], + only_account: Some(2), + deadline: 10000000, + }; + let message = Encode::encode(&mint_data); + let signature = MultiSignature::Sr25519(user_1_pair.sign(&message)); + + assert_noop!( + Nfts::mint_pre_signed( + RuntimeOrigin::signed(user_2), + mint_data, + signature, + user_1_signer.clone(), + ), + Error::::UnknownCollection + ); }) } diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index a4852c98fd48a..6cf821d7660a5 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -486,8 +486,8 @@ pub struct PreSignedMint { pub(super) collection: CollectionId, /// Item's id. pub(super) item: ItemId, - // Additional item's metadata. - // pub(super) metadata: Vec, + /// Additional item's metadata. + pub(super) metadata: Vec, /// Restrict the claim to a particular account. pub(super) only_account: Option, /// A deadline for the signature. diff --git a/frame/nfts/src/weights.rs b/frame/nfts/src/weights.rs index f05f8ca514c3e..637956fb827ab 100644 --- a/frame/nfts/src/weights.rs +++ b/frame/nfts/src/weights.rs @@ -85,6 +85,7 @@ pub trait WeightInfo { fn create_swap() -> Weight; fn cancel_swap() -> Weight; fn claim_swap() -> Weight; + fn mint_pre_signed() -> Weight; } /// Weights for pallet_nfts using the Substrate node and recommended hardware. @@ -467,6 +468,12 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(11)) } + fn mint_pre_signed() -> Weight { + // Minimum execution time: 101_076 nanoseconds. + Weight::from_ref_time(101_863_000) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(11)) + } } // For backwards compatibility and tests @@ -848,4 +855,10 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(11)) } + fn mint_pre_signed() -> Weight { + // Minimum execution time: 101_076 nanoseconds. + Weight::from_ref_time(101_863_000) + .saturating_add(RocksDbWeight::get().reads(8)) + .saturating_add(RocksDbWeight::get().writes(11)) + } } From 9f7e563cb6636d13200e77ac2bc25ce46f2736c9 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 17 Jan 2023 12:01:49 +0100 Subject: [PATCH 06/25] Add sp-core/runtime-benchmarks --- frame/nfts/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/nfts/Cargo.toml b/frame/nfts/Cargo.toml index d2cdb48532fd0..52e8c9f3b975a 100644 --- a/frame/nfts/Cargo.toml +++ b/frame/nfts/Cargo.toml @@ -46,6 +46,7 @@ std = [ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", + "sp-core/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] From a4c7e794d6a38a8b33d40387ce27fe3488772d7b Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 17 Jan 2023 12:24:44 +0100 Subject: [PATCH 07/25] Remove sp-core from dev deps --- frame/nfts/Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/frame/nfts/Cargo.toml b/frame/nfts/Cargo.toml index 52e8c9f3b975a..cd93aebfa89f4 100644 --- a/frame/nfts/Cargo.toml +++ b/frame/nfts/Cargo.toml @@ -26,7 +26,6 @@ sp-std = { version = "5.0.0", default-features = false, path = "../../primitives [dev-dependencies] pallet-balances = { version = "4.0.0-dev", path = "../balances" } -sp-core = { version = "7.0.0", path = "../../primitives/core" } sp-io = { version = "7.0.0", path = "../../primitives/io" } sp-std = { version = "5.0.0", path = "../../primitives/std" } @@ -46,7 +45,6 @@ std = [ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", - "sp-core/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] From 09f86aa206e5bbc944136d2b60a35bdd2b506cba Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 17 Jan 2023 12:37:50 +0100 Subject: [PATCH 08/25] Enable full_crypto for benchmarks --- frame/democracy/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index 49dbe133d6919..03ce22739884f 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -47,6 +47,7 @@ std = [ "sp-core/std", ] runtime-benchmarks = [ + "sp-core/full_crypto", "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", From dc9ff1888cd197a8bad3eb685874a08409e2dee2 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Fri, 20 Jan 2023 19:10:16 +0100 Subject: [PATCH 09/25] Typo --- frame/democracy/Cargo.toml | 1 - frame/nfts/Cargo.toml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index 03ce22739884f..49dbe133d6919 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -47,7 +47,6 @@ std = [ "sp-core/std", ] runtime-benchmarks = [ - "sp-core/full_crypto", "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", diff --git a/frame/nfts/Cargo.toml b/frame/nfts/Cargo.toml index cd93aebfa89f4..8fd5c9e7b37f0 100644 --- a/frame/nfts/Cargo.toml +++ b/frame/nfts/Cargo.toml @@ -43,6 +43,7 @@ std = [ "sp-std/std", ] runtime-benchmarks = [ + "sp-core/full_crypto", "frame-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", From 55eeb12387a1ab8968a6757a1c13c469430b396e Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Sat, 21 Jan 2023 15:07:11 +0100 Subject: [PATCH 10/25] Fix --- Cargo.lock | 1 + frame/nfts/Cargo.toml | 6 +++--- frame/nfts/src/benchmarking.rs | 8 ++++---- frame/nfts/src/mock.rs | 4 ++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb644202ae382..ac3c9eeec52a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5912,6 +5912,7 @@ dependencies = [ "scale-info", "sp-core", "sp-io", + "sp-keystore", "sp-runtime", "sp-std", ] diff --git a/frame/nfts/Cargo.toml b/frame/nfts/Cargo.toml index 8fd5c9e7b37f0..7f0cddc7ec1eb 100644 --- a/frame/nfts/Cargo.toml +++ b/frame/nfts/Cargo.toml @@ -21,13 +21,13 @@ frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" } +sp-io = { version = "7.0.0", default-features = false, path = "../../primitives/io" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" } sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } [dev-dependencies] pallet-balances = { version = "4.0.0-dev", path = "../balances" } -sp-io = { version = "7.0.0", path = "../../primitives/io" } -sp-std = { version = "5.0.0", path = "../../primitives/std" } +sp-keystore = { version = "0.13.0", path = "../../primitives/keystore" } [features] default = ["std"] @@ -39,11 +39,11 @@ std = [ "log/std", "scale-info/std", "sp-core/std", + "sp-io/std", "sp-runtime/std", "sp-std/std", ] runtime-benchmarks = [ - "sp-core/full_crypto", "frame-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index 623461fccd7b7..d0fa864f5a602 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -31,7 +31,7 @@ use frame_support::{ BoundedVec, }; use frame_system::RawOrigin as SystemOrigin; -use sp_core::Pair; +use sp_io::crypto::{sr25519_generate, sr25519_sign}; use sp_runtime::traits::{Bounded, One}; use sp_std::prelude::*; @@ -716,8 +716,8 @@ benchmarks_instance_pallet! { } mint_pre_signed { - let caller_pair = sp_core::sr25519::Pair::from_string("//Alice", None).unwrap(); - let caller_signer = MultiSigner::Sr25519(caller_pair.public()); + let caller_public = sr25519_generate(0.into(), None); + let caller_signer = MultiSigner::Sr25519(caller_public); let caller = Nfts::::signer_to_account(caller_signer.clone()).unwrap(); T::Currency::make_free_balance_be(&caller, DepositBalanceOf::::max_value()); let caller_lookup = T::Lookup::unlookup(caller.clone()); @@ -739,7 +739,7 @@ benchmarks_instance_pallet! { deadline: One::one(), }; let message = Encode::encode(&mint_data); - let signature = MultiSignature::Sr25519(caller_pair.sign(&message)); + let signature = MultiSignature::Sr25519(sr25519_sign(0.into(), &caller_public, &message).unwrap()); let target: T::AccountId = account("target", 0, SEED); T::Currency::make_free_balance_be(&target, DepositBalanceOf::::max_value()); diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index 912a4d90186e0..f10240b1ae77a 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -25,11 +25,13 @@ use frame_support::{ traits::{AsEnsureOriginWithArg, ConstU32, ConstU64}, }; use sp_core::H256; +use sp_keystore::{testing::KeyStore, KeystoreExt}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, MultiSignature, }; +use std::sync::Arc; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -118,7 +120,9 @@ impl Config for Test { pub(crate) fn new_test_ext() -> sp_io::TestExternalities { let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let keystore = KeyStore::new(); let mut ext = sp_io::TestExternalities::new(t); + ext.register_extension(KeystoreExt(Arc::new(keystore))); ext.execute_with(|| System::set_block_number(1)); ext } From e8ea9ec625c5e285cbaaf659bc960bf2272a9783 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Date: Sat, 21 Jan 2023 15:09:23 +0100 Subject: [PATCH 11/25] Update frame/nfts/src/mock.rs Co-authored-by: Squirrel --- frame/nfts/src/mock.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index f10240b1ae77a..bb0c3dce44477 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -90,7 +90,9 @@ impl pallet_balances::Config for Test { parameter_types! { pub storage Features: PalletFeatures = PalletFeatures::all_enabled(); } + pub type Signature = MultiSignature; + impl Config for Test { type RuntimeEvent = RuntimeEvent; type CollectionId = u32; From 62edf5fef3fc6c86f685bbd4da4bbd6455bbf601 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Sat, 21 Jan 2023 15:08:10 +0000 Subject: [PATCH 12/25] ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_nfts --- frame/nfts/src/weights.rs | 402 ++++++++++++++++++++------------------ 1 file changed, 210 insertions(+), 192 deletions(-) diff --git a/frame/nfts/src/weights.rs b/frame/nfts/src/weights.rs index 637956fb827ab..41322cbbfcce9 100644 --- a/frame/nfts/src/weights.rs +++ b/frame/nfts/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_nfts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -97,8 +97,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts CollectionConfigOf (r:0 w:1) // Storage: Nfts CollectionAccount (r:0 w:1) fn create() -> Weight { - // Minimum execution time: 44_312 nanoseconds. - Weight::from_ref_time(44_871_000) + // Minimum execution time: 42_982 nanoseconds. + Weight::from_ref_time(43_574_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -108,15 +108,15 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts CollectionConfigOf (r:0 w:1) // Storage: Nfts CollectionAccount (r:0 w:1) fn force_create() -> Weight { - // Minimum execution time: 31_654 nanoseconds. - Weight::from_ref_time(32_078_000) + // Minimum execution time: 30_887 nanoseconds. + Weight::from_ref_time(31_188_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts Item (r:1001 w:1000) + // Storage: Nfts ItemMetadataOf (r:1001 w:1000) // Storage: Nfts Attribute (r:1001 w:1000) - // Storage: Nfts ItemMetadataOf (r:0 w:1000) // Storage: Nfts CollectionRoleOf (r:0 w:1) // Storage: Nfts CollectionMetadataOf (r:0 w:1) // Storage: Nfts CollectionConfigOf (r:0 w:1) @@ -127,15 +127,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { - // Minimum execution time: 19_183_393 nanoseconds. - Weight::from_ref_time(17_061_526_855) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(353_523).saturating_mul(n.into())) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(1_861_080).saturating_mul(m.into())) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(8_858_987).saturating_mul(a.into())) - .saturating_add(T::DbWeight::get().reads(1003)) + // Minimum execution time: 24_247_290 nanoseconds. + Weight::from_ref_time(16_139_155_366) + // Standard Error: 22_364 + .saturating_add(Weight::from_ref_time(50_294).saturating_mul(n.into())) + // Standard Error: 22_364 + .saturating_add(Weight::from_ref_time(8_029_857).saturating_mul(m.into())) + // Standard Error: 22_364 + .saturating_add(Weight::from_ref_time(9_459_276).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1004)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(3005)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(m.into()))) @@ -148,8 +149,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts ItemConfigOf (r:1 w:1) // Storage: Nfts Account (r:0 w:1) fn mint() -> Weight { - // Minimum execution time: 57_753 nanoseconds. - Weight::from_ref_time(58_313_000) + // Minimum execution time: 57_032 nanoseconds. + Weight::from_ref_time(57_869_000) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -160,23 +161,24 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts ItemConfigOf (r:1 w:1) // Storage: Nfts Account (r:0 w:1) fn force_mint() -> Weight { - // Minimum execution time: 56_429 nanoseconds. - Weight::from_ref_time(57_202_000) + // Minimum execution time: 56_205 nanoseconds. + Weight::from_ref_time(57_625_000) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } + // Storage: Nfts ItemConfigOf (r:1 w:1) // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts Item (r:1 w:1) // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) + // Storage: Nfts ItemMetadataOf (r:1 w:0) // Storage: Nfts Account (r:0 w:1) // Storage: Nfts ItemPriceOf (r:0 w:1) // Storage: Nfts ItemAttributesApprovalsOf (r:0 w:1) // Storage: Nfts PendingSwapOf (r:0 w:1) fn burn() -> Weight { - // Minimum execution time: 59_681 nanoseconds. - Weight::from_ref_time(60_058_000) - .saturating_add(T::DbWeight::get().reads(4)) + // Minimum execution time: 61_913 nanoseconds. + Weight::from_ref_time(62_266_000) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } // Storage: Nfts Collection (r:1 w:0) @@ -189,8 +191,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts ItemPriceOf (r:0 w:1) // Storage: Nfts PendingSwapOf (r:0 w:1) fn transfer() -> Weight { - // Minimum execution time: 66_085 nanoseconds. - Weight::from_ref_time(67_065_000) + // Minimum execution time: 64_839 nanoseconds. + Weight::from_ref_time(65_302_000) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -199,10 +201,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts Item (r:102 w:102) /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { - // Minimum execution time: 25_949 nanoseconds. - Weight::from_ref_time(26_106_000) - // Standard Error: 10_326 - .saturating_add(Weight::from_ref_time(11_496_776).saturating_mul(i.into())) + // Minimum execution time: 25_641 nanoseconds. + Weight::from_ref_time(25_930_000) + // Standard Error: 9_928 + .saturating_add(Weight::from_ref_time(11_454_374).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -210,24 +212,24 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts CollectionRoleOf (r:1 w:0) // Storage: Nfts ItemConfigOf (r:1 w:1) fn lock_item_transfer() -> Weight { - // Minimum execution time: 30_080 nanoseconds. - Weight::from_ref_time(30_825_000) + // Minimum execution time: 29_993 nanoseconds. + Weight::from_ref_time(30_506_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Nfts CollectionRoleOf (r:1 w:0) // Storage: Nfts ItemConfigOf (r:1 w:1) fn unlock_item_transfer() -> Weight { - // Minimum execution time: 30_612 nanoseconds. - Weight::from_ref_time(31_422_000) + // Minimum execution time: 29_695 nanoseconds. + Weight::from_ref_time(30_158_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Nfts CollectionRoleOf (r:1 w:0) // Storage: Nfts CollectionConfigOf (r:1 w:1) fn lock_collection() -> Weight { - // Minimum execution time: 27_470 nanoseconds. - Weight::from_ref_time(28_015_000) + // Minimum execution time: 27_892 nanoseconds. + Weight::from_ref_time(28_316_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -235,40 +237,40 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts CollectionAccount (r:0 w:2) fn transfer_ownership() -> Weight { - // Minimum execution time: 33_750 nanoseconds. - Weight::from_ref_time(34_139_000) + // Minimum execution time: 33_388 nanoseconds. + Weight::from_ref_time(33_805_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts CollectionRoleOf (r:0 w:4) fn set_team() -> Weight { - // Minimum execution time: 36_565 nanoseconds. - Weight::from_ref_time(37_464_000) + // Minimum execution time: 35_566 nanoseconds. + Weight::from_ref_time(36_054_000) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts CollectionAccount (r:0 w:2) fn force_collection_owner() -> Weight { - // Minimum execution time: 29_028 nanoseconds. - Weight::from_ref_time(29_479_000) + // Minimum execution time: 27_682 nanoseconds. + Weight::from_ref_time(28_389_000) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Nfts Collection (r:1 w:0) // Storage: Nfts CollectionConfigOf (r:0 w:1) fn force_collection_config() -> Weight { - // Minimum execution time: 24_695 nanoseconds. - Weight::from_ref_time(25_304_000) + // Minimum execution time: 24_467 nanoseconds. + Weight::from_ref_time(25_156_000) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Nfts Collection (r:1 w:0) // Storage: Nfts ItemConfigOf (r:1 w:1) fn lock_item_properties() -> Weight { - // Minimum execution time: 28_910 nanoseconds. - Weight::from_ref_time(29_186_000) + // Minimum execution time: 28_839 nanoseconds. + Weight::from_ref_time(29_512_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -277,16 +279,16 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts ItemConfigOf (r:1 w:0) // Storage: Nfts Attribute (r:1 w:1) fn set_attribute() -> Weight { - // Minimum execution time: 56_407 nanoseconds. - Weight::from_ref_time(58_176_000) + // Minimum execution time: 55_858 nanoseconds. + Weight::from_ref_time(56_385_000) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts Attribute (r:1 w:1) fn force_set_attribute() -> Weight { - // Minimum execution time: 36_402 nanoseconds. - Weight::from_ref_time(37_034_000) + // Minimum execution time: 36_189 nanoseconds. + Weight::from_ref_time(36_646_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -294,16 +296,16 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts ItemConfigOf (r:1 w:0) fn clear_attribute() -> Weight { - // Minimum execution time: 52_022 nanoseconds. - Weight::from_ref_time(54_059_000) + // Minimum execution time: 51_976 nanoseconds. + Weight::from_ref_time(52_628_000) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Nfts Item (r:1 w:0) // Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) fn approve_item_attributes() -> Weight { - // Minimum execution time: 28_475 nanoseconds. - Weight::from_ref_time(29_162_000) + // Minimum execution time: 28_390 nanoseconds. + Weight::from_ref_time(28_884_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -313,10 +315,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `n` is `[0, 1000]`. fn cancel_item_attributes_approval(n: u32, ) -> Weight { - // Minimum execution time: 37_529 nanoseconds. - Weight::from_ref_time(38_023_000) - // Standard Error: 8_136 - .saturating_add(Weight::from_ref_time(7_452_872).saturating_mul(n.into())) + // Minimum execution time: 37_482 nanoseconds. + Weight::from_ref_time(37_758_000) + // Standard Error: 7_546 + .saturating_add(Weight::from_ref_time(7_323_180).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2)) @@ -327,17 +329,17 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts CollectionConfigOf (r:1 w:0) // Storage: Nfts ItemMetadataOf (r:1 w:1) fn set_metadata() -> Weight { - // Minimum execution time: 49_300 nanoseconds. - Weight::from_ref_time(49_790_000) + // Minimum execution time: 48_931 nanoseconds. + Weight::from_ref_time(49_604_000) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } + // Storage: Nfts ItemMetadataOf (r:1 w:1) // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts ItemMetadataOf (r:1 w:1) fn clear_metadata() -> Weight { - // Minimum execution time: 47_248 nanoseconds. - Weight::from_ref_time(48_094_000) + // Minimum execution time: 47_197 nanoseconds. + Weight::from_ref_time(48_765_000) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -345,8 +347,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts CollectionMetadataOf (r:1 w:1) fn set_collection_metadata() -> Weight { - // Minimum execution time: 44_137 nanoseconds. - Weight::from_ref_time(44_905_000) + // Minimum execution time: 43_870 nanoseconds. + Weight::from_ref_time(44_106_000) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -354,8 +356,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts CollectionConfigOf (r:1 w:0) // Storage: Nfts CollectionMetadataOf (r:1 w:1) fn clear_collection_metadata() -> Weight { - // Minimum execution time: 43_005 nanoseconds. - Weight::from_ref_time(43_898_000) + // Minimum execution time: 43_744 nanoseconds. + Weight::from_ref_time(44_528_000) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -363,47 +365,47 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts CollectionConfigOf (r:1 w:0) // Storage: Nfts CollectionRoleOf (r:1 w:0) fn approve_transfer() -> Weight { - // Minimum execution time: 36_344 nanoseconds. - Weight::from_ref_time(36_954_000) + // Minimum execution time: 35_463 nanoseconds. + Weight::from_ref_time(35_996_000) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Nfts Item (r:1 w:1) // Storage: Nfts CollectionRoleOf (r:1 w:0) fn cancel_approval() -> Weight { - // Minimum execution time: 32_418 nanoseconds. - Weight::from_ref_time(33_029_000) + // Minimum execution time: 32_784 nanoseconds. + Weight::from_ref_time(33_589_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Nfts Item (r:1 w:1) // Storage: Nfts CollectionRoleOf (r:1 w:0) fn clear_all_transfer_approvals() -> Weight { - // Minimum execution time: 31_448 nanoseconds. - Weight::from_ref_time(31_979_000) + // Minimum execution time: 30_975 nanoseconds. + Weight::from_ref_time(31_552_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Nfts OwnershipAcceptance (r:1 w:1) fn set_accept_ownership() -> Weight { - // Minimum execution time: 27_487 nanoseconds. - Weight::from_ref_time(28_080_000) + // Minimum execution time: 27_344 nanoseconds. + Weight::from_ref_time(28_013_000) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Nfts CollectionConfigOf (r:1 w:1) // Storage: Nfts Collection (r:1 w:0) fn set_collection_max_supply() -> Weight { - // Minimum execution time: 28_235 nanoseconds. - Weight::from_ref_time(28_967_000) + // Minimum execution time: 29_030 nanoseconds. + Weight::from_ref_time(29_507_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Nfts Collection (r:1 w:0) // Storage: Nfts CollectionConfigOf (r:1 w:1) fn update_mint_settings() -> Weight { - // Minimum execution time: 28_172 nanoseconds. - Weight::from_ref_time(28_636_000) + // Minimum execution time: 27_589 nanoseconds. + Weight::from_ref_time(28_227_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -412,8 +414,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts ItemConfigOf (r:1 w:0) // Storage: Nfts ItemPriceOf (r:0 w:1) fn set_price() -> Weight { - // Minimum execution time: 35_336 nanoseconds. - Weight::from_ref_time(36_026_000) + // Minimum execution time: 33_904 nanoseconds. + Weight::from_ref_time(35_012_000) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -426,31 +428,31 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts Account (r:0 w:2) // Storage: Nfts PendingSwapOf (r:0 w:1) fn buy_item() -> Weight { - // Minimum execution time: 70_971 nanoseconds. - Weight::from_ref_time(72_036_000) + // Minimum execution time: 70_536 nanoseconds. + Weight::from_ref_time(71_362_000) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(6)) } /// The range of component `n` is `[0, 10]`. fn pay_tips(n: u32, ) -> Weight { - // Minimum execution time: 5_151 nanoseconds. - Weight::from_ref_time(11_822_888) - // Standard Error: 38_439 - .saturating_add(Weight::from_ref_time(3_511_844).saturating_mul(n.into())) + // Minimum execution time: 4_737 nanoseconds. + Weight::from_ref_time(11_256_563) + // Standard Error: 37_576 + .saturating_add(Weight::from_ref_time(3_505_187).saturating_mul(n.into())) } // Storage: Nfts Item (r:2 w:0) // Storage: Nfts PendingSwapOf (r:0 w:1) fn create_swap() -> Weight { - // Minimum execution time: 33_027 nanoseconds. - Weight::from_ref_time(33_628_000) + // Minimum execution time: 32_663 nanoseconds. + Weight::from_ref_time(33_023_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Nfts PendingSwapOf (r:1 w:1) // Storage: Nfts Item (r:1 w:0) fn cancel_swap() -> Weight { - // Minimum execution time: 35_890 nanoseconds. - Weight::from_ref_time(36_508_000) + // Minimum execution time: 35_411 nanoseconds. + Weight::from_ref_time(35_916_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -463,16 +465,23 @@ impl WeightInfo for SubstrateWeight { // Storage: Nfts Account (r:0 w:4) // Storage: Nfts ItemPriceOf (r:0 w:2) fn claim_swap() -> Weight { - // Minimum execution time: 101_076 nanoseconds. - Weight::from_ref_time(101_863_000) + // Minimum execution time: 100_367 nanoseconds. + Weight::from_ref_time(101_233_000) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(11)) } + // Storage: Nfts Collection (r:1 w:1) + // Storage: Nfts CollectionConfigOf (r:1 w:0) + // Storage: Nfts Item (r:1 w:1) + // Storage: Nfts ItemConfigOf (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Nfts ItemMetadataOf (r:1 w:1) + // Storage: Nfts Account (r:0 w:1) fn mint_pre_signed() -> Weight { - // Minimum execution time: 101_076 nanoseconds. - Weight::from_ref_time(101_863_000) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(11)) + // Minimum execution time: 125_160 nanoseconds. + Weight::from_ref_time(126_581_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(6)) } } @@ -484,8 +493,8 @@ impl WeightInfo for () { // Storage: Nfts CollectionConfigOf (r:0 w:1) // Storage: Nfts CollectionAccount (r:0 w:1) fn create() -> Weight { - // Minimum execution time: 44_312 nanoseconds. - Weight::from_ref_time(44_871_000) + // Minimum execution time: 42_982 nanoseconds. + Weight::from_ref_time(43_574_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(5)) } @@ -495,15 +504,15 @@ impl WeightInfo for () { // Storage: Nfts CollectionConfigOf (r:0 w:1) // Storage: Nfts CollectionAccount (r:0 w:1) fn force_create() -> Weight { - // Minimum execution time: 31_654 nanoseconds. - Weight::from_ref_time(32_078_000) + // Minimum execution time: 30_887 nanoseconds. + Weight::from_ref_time(31_188_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(5)) } // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts Item (r:1001 w:1000) + // Storage: Nfts ItemMetadataOf (r:1001 w:1000) // Storage: Nfts Attribute (r:1001 w:1000) - // Storage: Nfts ItemMetadataOf (r:0 w:1000) // Storage: Nfts CollectionRoleOf (r:0 w:1) // Storage: Nfts CollectionMetadataOf (r:0 w:1) // Storage: Nfts CollectionConfigOf (r:0 w:1) @@ -514,15 +523,16 @@ impl WeightInfo for () { /// The range of component `m` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { - // Minimum execution time: 19_183_393 nanoseconds. - Weight::from_ref_time(17_061_526_855) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(353_523).saturating_mul(n.into())) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(1_861_080).saturating_mul(m.into())) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(8_858_987).saturating_mul(a.into())) - .saturating_add(RocksDbWeight::get().reads(1003)) + // Minimum execution time: 24_247_290 nanoseconds. + Weight::from_ref_time(16_139_155_366) + // Standard Error: 22_364 + .saturating_add(Weight::from_ref_time(50_294).saturating_mul(n.into())) + // Standard Error: 22_364 + .saturating_add(Weight::from_ref_time(8_029_857).saturating_mul(m.into())) + // Standard Error: 22_364 + .saturating_add(Weight::from_ref_time(9_459_276).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(1004)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(RocksDbWeight::get().writes(3005)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(m.into()))) @@ -535,8 +545,8 @@ impl WeightInfo for () { // Storage: Nfts ItemConfigOf (r:1 w:1) // Storage: Nfts Account (r:0 w:1) fn mint() -> Weight { - // Minimum execution time: 57_753 nanoseconds. - Weight::from_ref_time(58_313_000) + // Minimum execution time: 57_032 nanoseconds. + Weight::from_ref_time(57_869_000) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(4)) } @@ -547,23 +557,24 @@ impl WeightInfo for () { // Storage: Nfts ItemConfigOf (r:1 w:1) // Storage: Nfts Account (r:0 w:1) fn force_mint() -> Weight { - // Minimum execution time: 56_429 nanoseconds. - Weight::from_ref_time(57_202_000) + // Minimum execution time: 56_205 nanoseconds. + Weight::from_ref_time(57_625_000) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(4)) } + // Storage: Nfts ItemConfigOf (r:1 w:1) // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts Item (r:1 w:1) // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) + // Storage: Nfts ItemMetadataOf (r:1 w:0) // Storage: Nfts Account (r:0 w:1) // Storage: Nfts ItemPriceOf (r:0 w:1) // Storage: Nfts ItemAttributesApprovalsOf (r:0 w:1) // Storage: Nfts PendingSwapOf (r:0 w:1) fn burn() -> Weight { - // Minimum execution time: 59_681 nanoseconds. - Weight::from_ref_time(60_058_000) - .saturating_add(RocksDbWeight::get().reads(4)) + // Minimum execution time: 61_913 nanoseconds. + Weight::from_ref_time(62_266_000) + .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(7)) } // Storage: Nfts Collection (r:1 w:0) @@ -576,8 +587,8 @@ impl WeightInfo for () { // Storage: Nfts ItemPriceOf (r:0 w:1) // Storage: Nfts PendingSwapOf (r:0 w:1) fn transfer() -> Weight { - // Minimum execution time: 66_085 nanoseconds. - Weight::from_ref_time(67_065_000) + // Minimum execution time: 64_839 nanoseconds. + Weight::from_ref_time(65_302_000) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(6)) } @@ -586,10 +597,10 @@ impl WeightInfo for () { // Storage: Nfts Item (r:102 w:102) /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { - // Minimum execution time: 25_949 nanoseconds. - Weight::from_ref_time(26_106_000) - // Standard Error: 10_326 - .saturating_add(Weight::from_ref_time(11_496_776).saturating_mul(i.into())) + // Minimum execution time: 25_641 nanoseconds. + Weight::from_ref_time(25_930_000) + // Standard Error: 9_928 + .saturating_add(Weight::from_ref_time(11_454_374).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -597,24 +608,24 @@ impl WeightInfo for () { // Storage: Nfts CollectionRoleOf (r:1 w:0) // Storage: Nfts ItemConfigOf (r:1 w:1) fn lock_item_transfer() -> Weight { - // Minimum execution time: 30_080 nanoseconds. - Weight::from_ref_time(30_825_000) + // Minimum execution time: 29_993 nanoseconds. + Weight::from_ref_time(30_506_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Nfts CollectionRoleOf (r:1 w:0) // Storage: Nfts ItemConfigOf (r:1 w:1) fn unlock_item_transfer() -> Weight { - // Minimum execution time: 30_612 nanoseconds. - Weight::from_ref_time(31_422_000) + // Minimum execution time: 29_695 nanoseconds. + Weight::from_ref_time(30_158_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Nfts CollectionRoleOf (r:1 w:0) // Storage: Nfts CollectionConfigOf (r:1 w:1) fn lock_collection() -> Weight { - // Minimum execution time: 27_470 nanoseconds. - Weight::from_ref_time(28_015_000) + // Minimum execution time: 27_892 nanoseconds. + Weight::from_ref_time(28_316_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -622,40 +633,40 @@ impl WeightInfo for () { // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts CollectionAccount (r:0 w:2) fn transfer_ownership() -> Weight { - // Minimum execution time: 33_750 nanoseconds. - Weight::from_ref_time(34_139_000) + // Minimum execution time: 33_388 nanoseconds. + Weight::from_ref_time(33_805_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(4)) } // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts CollectionRoleOf (r:0 w:4) fn set_team() -> Weight { - // Minimum execution time: 36_565 nanoseconds. - Weight::from_ref_time(37_464_000) + // Minimum execution time: 35_566 nanoseconds. + Weight::from_ref_time(36_054_000) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(5)) } // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts CollectionAccount (r:0 w:2) fn force_collection_owner() -> Weight { - // Minimum execution time: 29_028 nanoseconds. - Weight::from_ref_time(29_479_000) + // Minimum execution time: 27_682 nanoseconds. + Weight::from_ref_time(28_389_000) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: Nfts Collection (r:1 w:0) // Storage: Nfts CollectionConfigOf (r:0 w:1) fn force_collection_config() -> Weight { - // Minimum execution time: 24_695 nanoseconds. - Weight::from_ref_time(25_304_000) + // Minimum execution time: 24_467 nanoseconds. + Weight::from_ref_time(25_156_000) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Nfts Collection (r:1 w:0) // Storage: Nfts ItemConfigOf (r:1 w:1) fn lock_item_properties() -> Weight { - // Minimum execution time: 28_910 nanoseconds. - Weight::from_ref_time(29_186_000) + // Minimum execution time: 28_839 nanoseconds. + Weight::from_ref_time(29_512_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -664,16 +675,16 @@ impl WeightInfo for () { // Storage: Nfts ItemConfigOf (r:1 w:0) // Storage: Nfts Attribute (r:1 w:1) fn set_attribute() -> Weight { - // Minimum execution time: 56_407 nanoseconds. - Weight::from_ref_time(58_176_000) + // Minimum execution time: 55_858 nanoseconds. + Weight::from_ref_time(56_385_000) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts Attribute (r:1 w:1) fn force_set_attribute() -> Weight { - // Minimum execution time: 36_402 nanoseconds. - Weight::from_ref_time(37_034_000) + // Minimum execution time: 36_189 nanoseconds. + Weight::from_ref_time(36_646_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(2)) } @@ -681,16 +692,16 @@ impl WeightInfo for () { // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts ItemConfigOf (r:1 w:0) fn clear_attribute() -> Weight { - // Minimum execution time: 52_022 nanoseconds. - Weight::from_ref_time(54_059_000) + // Minimum execution time: 51_976 nanoseconds. + Weight::from_ref_time(52_628_000) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: Nfts Item (r:1 w:0) // Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) fn approve_item_attributes() -> Weight { - // Minimum execution time: 28_475 nanoseconds. - Weight::from_ref_time(29_162_000) + // Minimum execution time: 28_390 nanoseconds. + Weight::from_ref_time(28_884_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -700,10 +711,10 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `n` is `[0, 1000]`. fn cancel_item_attributes_approval(n: u32, ) -> Weight { - // Minimum execution time: 37_529 nanoseconds. - Weight::from_ref_time(38_023_000) - // Standard Error: 8_136 - .saturating_add(Weight::from_ref_time(7_452_872).saturating_mul(n.into())) + // Minimum execution time: 37_482 nanoseconds. + Weight::from_ref_time(37_758_000) + // Standard Error: 7_546 + .saturating_add(Weight::from_ref_time(7_323_180).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2)) @@ -714,17 +725,17 @@ impl WeightInfo for () { // Storage: Nfts CollectionConfigOf (r:1 w:0) // Storage: Nfts ItemMetadataOf (r:1 w:1) fn set_metadata() -> Weight { - // Minimum execution time: 49_300 nanoseconds. - Weight::from_ref_time(49_790_000) + // Minimum execution time: 48_931 nanoseconds. + Weight::from_ref_time(49_604_000) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(2)) } + // Storage: Nfts ItemMetadataOf (r:1 w:1) // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts ItemMetadataOf (r:1 w:1) fn clear_metadata() -> Weight { - // Minimum execution time: 47_248 nanoseconds. - Weight::from_ref_time(48_094_000) + // Minimum execution time: 47_197 nanoseconds. + Weight::from_ref_time(48_765_000) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(2)) } @@ -732,8 +743,8 @@ impl WeightInfo for () { // Storage: Nfts Collection (r:1 w:1) // Storage: Nfts CollectionMetadataOf (r:1 w:1) fn set_collection_metadata() -> Weight { - // Minimum execution time: 44_137 nanoseconds. - Weight::from_ref_time(44_905_000) + // Minimum execution time: 43_870 nanoseconds. + Weight::from_ref_time(44_106_000) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(2)) } @@ -741,8 +752,8 @@ impl WeightInfo for () { // Storage: Nfts CollectionConfigOf (r:1 w:0) // Storage: Nfts CollectionMetadataOf (r:1 w:1) fn clear_collection_metadata() -> Weight { - // Minimum execution time: 43_005 nanoseconds. - Weight::from_ref_time(43_898_000) + // Minimum execution time: 43_744 nanoseconds. + Weight::from_ref_time(44_528_000) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -750,47 +761,47 @@ impl WeightInfo for () { // Storage: Nfts CollectionConfigOf (r:1 w:0) // Storage: Nfts CollectionRoleOf (r:1 w:0) fn approve_transfer() -> Weight { - // Minimum execution time: 36_344 nanoseconds. - Weight::from_ref_time(36_954_000) + // Minimum execution time: 35_463 nanoseconds. + Weight::from_ref_time(35_996_000) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Nfts Item (r:1 w:1) // Storage: Nfts CollectionRoleOf (r:1 w:0) fn cancel_approval() -> Weight { - // Minimum execution time: 32_418 nanoseconds. - Weight::from_ref_time(33_029_000) + // Minimum execution time: 32_784 nanoseconds. + Weight::from_ref_time(33_589_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Nfts Item (r:1 w:1) // Storage: Nfts CollectionRoleOf (r:1 w:0) fn clear_all_transfer_approvals() -> Weight { - // Minimum execution time: 31_448 nanoseconds. - Weight::from_ref_time(31_979_000) + // Minimum execution time: 30_975 nanoseconds. + Weight::from_ref_time(31_552_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Nfts OwnershipAcceptance (r:1 w:1) fn set_accept_ownership() -> Weight { - // Minimum execution time: 27_487 nanoseconds. - Weight::from_ref_time(28_080_000) + // Minimum execution time: 27_344 nanoseconds. + Weight::from_ref_time(28_013_000) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Nfts CollectionConfigOf (r:1 w:1) // Storage: Nfts Collection (r:1 w:0) fn set_collection_max_supply() -> Weight { - // Minimum execution time: 28_235 nanoseconds. - Weight::from_ref_time(28_967_000) + // Minimum execution time: 29_030 nanoseconds. + Weight::from_ref_time(29_507_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Nfts Collection (r:1 w:0) // Storage: Nfts CollectionConfigOf (r:1 w:1) fn update_mint_settings() -> Weight { - // Minimum execution time: 28_172 nanoseconds. - Weight::from_ref_time(28_636_000) + // Minimum execution time: 27_589 nanoseconds. + Weight::from_ref_time(28_227_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -799,8 +810,8 @@ impl WeightInfo for () { // Storage: Nfts ItemConfigOf (r:1 w:0) // Storage: Nfts ItemPriceOf (r:0 w:1) fn set_price() -> Weight { - // Minimum execution time: 35_336 nanoseconds. - Weight::from_ref_time(36_026_000) + // Minimum execution time: 33_904 nanoseconds. + Weight::from_ref_time(35_012_000) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -813,31 +824,31 @@ impl WeightInfo for () { // Storage: Nfts Account (r:0 w:2) // Storage: Nfts PendingSwapOf (r:0 w:1) fn buy_item() -> Weight { - // Minimum execution time: 70_971 nanoseconds. - Weight::from_ref_time(72_036_000) + // Minimum execution time: 70_536 nanoseconds. + Weight::from_ref_time(71_362_000) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(6)) } /// The range of component `n` is `[0, 10]`. fn pay_tips(n: u32, ) -> Weight { - // Minimum execution time: 5_151 nanoseconds. - Weight::from_ref_time(11_822_888) - // Standard Error: 38_439 - .saturating_add(Weight::from_ref_time(3_511_844).saturating_mul(n.into())) + // Minimum execution time: 4_737 nanoseconds. + Weight::from_ref_time(11_256_563) + // Standard Error: 37_576 + .saturating_add(Weight::from_ref_time(3_505_187).saturating_mul(n.into())) } // Storage: Nfts Item (r:2 w:0) // Storage: Nfts PendingSwapOf (r:0 w:1) fn create_swap() -> Weight { - // Minimum execution time: 33_027 nanoseconds. - Weight::from_ref_time(33_628_000) + // Minimum execution time: 32_663 nanoseconds. + Weight::from_ref_time(33_023_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Nfts PendingSwapOf (r:1 w:1) // Storage: Nfts Item (r:1 w:0) fn cancel_swap() -> Weight { - // Minimum execution time: 35_890 nanoseconds. - Weight::from_ref_time(36_508_000) + // Minimum execution time: 35_411 nanoseconds. + Weight::from_ref_time(35_916_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -850,15 +861,22 @@ impl WeightInfo for () { // Storage: Nfts Account (r:0 w:4) // Storage: Nfts ItemPriceOf (r:0 w:2) fn claim_swap() -> Weight { - // Minimum execution time: 101_076 nanoseconds. - Weight::from_ref_time(101_863_000) + // Minimum execution time: 100_367 nanoseconds. + Weight::from_ref_time(101_233_000) .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(11)) } + // Storage: Nfts Collection (r:1 w:1) + // Storage: Nfts CollectionConfigOf (r:1 w:0) + // Storage: Nfts Item (r:1 w:1) + // Storage: Nfts ItemConfigOf (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Nfts ItemMetadataOf (r:1 w:1) + // Storage: Nfts Account (r:0 w:1) fn mint_pre_signed() -> Weight { - // Minimum execution time: 101_076 nanoseconds. - Weight::from_ref_time(101_863_000) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(11)) + // Minimum execution time: 125_160 nanoseconds. + Weight::from_ref_time(126_581_000) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(6)) } } From b119156738dfb7b035f41b4623ac9b7877df4835 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Sun, 22 Jan 2023 17:56:27 +0100 Subject: [PATCH 13/25] Add docs --- frame/nfts/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 57ab224f1ec19..f508cda215cdd 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -1776,6 +1776,17 @@ pub mod pallet { ) } + /// Mint an item by providing the pre-signed approval. + /// + /// Origin must be Signed. + /// + /// - `data`: The pre-signed approval that consists of the information about the item, its + /// metadata, who can mint it (`None` for anyone) and until what block number. + /// - `signature`: The signature of the `data` object. + /// - `signer`: The `data` object's signer. Should be an owner of the collection. + /// + /// Emits `Issued` on success. + /// Emits `ItemMetadataSet` if the metadata was not empty. #[pallet::call_index(37)] #[pallet::weight(T::WeightInfo::mint_pre_signed())] pub fn mint_pre_signed( From 781f8343441ee2105f909a47df68deef98be510c Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 31 Jan 2023 16:30:38 +0200 Subject: [PATCH 14/25] Add attributes into the pre-signed object & track the deposit owner for attributes --- bin/node/runtime/src/lib.rs | 2 + frame/nfts/src/benchmarking.rs | 22 +++-- frame/nfts/src/features/attributes.rs | 81 +++++++++++++------ frame/nfts/src/features/create_delete_item.rs | 22 ++++- frame/nfts/src/lib.rs | 16 +++- frame/nfts/src/mock.rs | 1 + frame/nfts/src/tests.rs | 55 +++++++++++-- frame/nfts/src/types.rs | 2 + 8 files changed, 162 insertions(+), 39 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 0ac6ade9127e8..13dc2556ff9d8 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1560,6 +1560,7 @@ impl pallet_uniques::Config for Runtime { parameter_types! { pub Features: PalletFeatures = PalletFeatures::all_enabled(); + pub const MaxAttributesPerCall: u32 = 10; } impl pallet_nfts::Config for Runtime { @@ -1580,6 +1581,7 @@ impl pallet_nfts::Config for Runtime { type ItemAttributesApprovalsLimit = ItemAttributesApprovalsLimit; type MaxTips = MaxTips; type MaxDeadlineDuration = MaxDeadlineDuration; + type MaxAttributesPerCall = MaxAttributesPerCall; type Features = Features; type WeightInfo = pallet_nfts::weights::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index d0fa864f5a602..7fe569d3bdd69 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -149,6 +149,14 @@ fn default_item_config() -> ItemConfig { ItemConfig { settings: ItemSettings::all_enabled() } } +fn make_filled_vec(value: u16, length: usize) -> Vec { + let mut vec = vec![0u8; length]; + let mut s = Vec::from(value.to_be_bytes()); + vec.truncate(length - s.len()); + vec.append(&mut s); + vec +} + benchmarks_instance_pallet! { create { let collection = T::Helper::collection(0); @@ -437,11 +445,7 @@ benchmarks_instance_pallet! { T::Currency::make_free_balance_be(&target, DepositBalanceOf::::max_value()); let value: BoundedVec<_, _> = vec![0u8; T::ValueLimit::get() as usize].try_into().unwrap(); for i in 0..n { - let mut key = vec![0u8; T::KeyLimit::get() as usize]; - let mut s = Vec::from((i as u16).to_be_bytes()); - key.truncate(s.len()); - key.append(&mut s); - + let key = make_filled_vec(i as u16, T::KeyLimit::get() as usize); Nfts::::set_attribute( SystemOrigin::Signed(target.clone()).into(), T::Helper::collection(0), @@ -716,6 +720,7 @@ benchmarks_instance_pallet! { } mint_pre_signed { + let n in 0 .. T::MaxAttributesPerCall::get() as u32; let caller_public = sr25519_generate(0.into(), None); let caller_signer = MultiSigner::Sr25519(caller_public); let caller = Nfts::::signer_to_account(caller_signer.clone()).unwrap(); @@ -731,9 +736,16 @@ benchmarks_instance_pallet! { )); let metadata = vec![0u8; T::StringLimit::get() as usize]; + let mut attributes = vec![]; + let attribute_value = vec![0u8; T::ValueLimit::get() as usize]; + for i in 0..n { + let attribute_key = make_filled_vec(i as u16, T::KeyLimit::get() as usize); + attributes.push((attribute_key, attribute_value.clone())); + } let mint_data = PreSignedMint { collection, item, + attributes, metadata: metadata.clone(), only_account: None, deadline: One::one(), diff --git a/frame/nfts/src/features/attributes.rs b/frame/nfts/src/features/attributes.rs index b25f2a60cd62d..51c75233c1d0c 100644 --- a/frame/nfts/src/features/attributes.rs +++ b/frame/nfts/src/features/attributes.rs @@ -26,6 +26,7 @@ impl, I: 'static> Pallet { namespace: AttributeNamespace, key: BoundedVec, value: BoundedVec, + depositor: T::AccountId, ) -> DispatchResult { ensure!( Self::is_pallet_feature_enabled(PalletFeature::Attributes), @@ -66,7 +67,8 @@ impl, I: 'static> Pallet { } let attribute = Attribute::::get((collection, maybe_item, &namespace, &key)); - if attribute.is_none() { + let attribute_exists = attribute.is_some(); + if !attribute_exists { collection_details.attributes.saturating_inc(); } @@ -74,6 +76,7 @@ impl, I: 'static> Pallet { attribute.map_or(AttributeDeposit { account: None, amount: Zero::zero() }, |m| m.1); let mut deposit = Zero::zero(); + // disabled DepositRequired setting only affects the CollectionOwner namespace if collection_config.is_setting_enabled(CollectionSetting::DepositRequired) || namespace != AttributeNamespace::CollectionOwner { @@ -82,33 +85,50 @@ impl, I: 'static> Pallet { .saturating_add(T::AttributeDepositBase::get()); } + let is_collection_owner_namespace = namespace == AttributeNamespace::CollectionOwner; + let is_depositor_collection_owner = + is_collection_owner_namespace && collection_details.owner == depositor; + + // NOTE: in the CollectionOwner namespace if the depositor is `None` that means the deposit + // was paid by the collection's owner. + let old_depositor = + if is_collection_owner_namespace && old_deposit.account.is_none() && attribute_exists { + Some(collection_details.owner.clone()) + } else { + old_deposit.account + }; + let depositor_has_changed = old_depositor != Some(depositor.clone()); + // NOTE: when we transfer an item, we don't move attributes in the ItemOwner namespace. // When the new owner updates the same attribute, we will update the depositor record // and return the deposit to the previous owner. - if old_deposit.account.is_some() && old_deposit.account != Some(origin.clone()) { - T::Currency::unreserve(&old_deposit.account.unwrap(), old_deposit.amount); - T::Currency::reserve(&origin, deposit)?; + if depositor_has_changed { + if let Some(old_depositor) = old_depositor { + T::Currency::unreserve(&old_depositor, old_deposit.amount); + } + T::Currency::reserve(&depositor, deposit)?; } else if deposit > old_deposit.amount { - T::Currency::reserve(&origin, deposit - old_deposit.amount)?; + T::Currency::reserve(&depositor, deposit - old_deposit.amount)?; } else if deposit < old_deposit.amount { - T::Currency::unreserve(&origin, old_deposit.amount - deposit); + T::Currency::unreserve(&depositor, old_deposit.amount - deposit); } - // NOTE: we don't track the depositor in the CollectionOwner namespace as it's always a - // collection's owner. This simplifies the collection's transfer to another owner. - let deposit_owner = match namespace { - AttributeNamespace::CollectionOwner => { - collection_details.owner_deposit.saturating_accrue(deposit); + if is_depositor_collection_owner { + if !depositor_has_changed { collection_details.owner_deposit.saturating_reduce(old_deposit.amount); - None - }, - _ => Some(origin), - }; + } + collection_details.owner_deposit.saturating_accrue(deposit); + } + let new_deposit_owner = match is_depositor_collection_owner { + true => None, + false => Some(depositor), + }; Attribute::::insert( (&collection, maybe_item, &namespace, &key), - (&value, AttributeDeposit { account: deposit_owner, amount: deposit }), + (&value, AttributeDeposit { account: new_deposit_owner, amount: deposit }), ); + Collection::::insert(collection, &collection_details); Self::deposit_event(Event::AttributeSet { collection, maybe_item, key, value, namespace }); Ok(()) @@ -188,10 +208,21 @@ impl, I: 'static> Pallet { // NOTE: if the item was previously burned, the ItemConfigOf record // might not exist. In that case, we allow to clear the attribute. let maybe_is_locked = Self::get_item_config(&collection, &item) - .map_or(false, |c| { - c.has_disabled_setting(ItemSetting::UnlockedAttributes) + .map_or(None, |c| { + Some(c.has_disabled_setting(ItemSetting::UnlockedAttributes)) }); - ensure!(!maybe_is_locked, Error::::LockedItemAttributes); + match maybe_is_locked { + Some(is_locked) => { + // when item exists, then only the collection's owner can clear that + // attribute + ensure!( + check_owner == &collection_details.owner, + Error::::NoPermission + ); + ensure!(!is_locked, Error::::LockedItemAttributes); + }, + None => (), + } }, }, _ => (), @@ -199,16 +230,16 @@ impl, I: 'static> Pallet { } collection_details.attributes.saturating_dec(); - match namespace { - AttributeNamespace::CollectionOwner => { + + match deposit.account { + Some(deposit_account) => { + T::Currency::unreserve(&deposit_account, deposit.amount); + }, + None if namespace == AttributeNamespace::CollectionOwner => { collection_details.owner_deposit.saturating_reduce(deposit.amount); T::Currency::unreserve(&collection_details.owner, deposit.amount); }, _ => (), - }; - - if let Some(deposit_account) = deposit.account { - T::Currency::unreserve(&deposit_account, deposit.amount); } Collection::::insert(collection, &collection_details); diff --git a/frame/nfts/src/features/create_delete_item.rs b/frame/nfts/src/features/create_delete_item.rs index 90f4494691575..63d7a540c3ae6 100644 --- a/frame/nfts/src/features/create_delete_item.rs +++ b/frame/nfts/src/features/create_delete_item.rs @@ -90,9 +90,14 @@ impl, I: 'static> Pallet { mint_data: PreSignedMintOf, signer: T::AccountId, ) -> DispatchResult { - let PreSignedMint { collection, item, metadata, deadline, only_account } = mint_data; + let PreSignedMint { collection, item, attributes, metadata, deadline, only_account } = + mint_data; let metadata = Self::construct_metadata(metadata)?; + ensure!( + attributes.len() <= T::MaxAttributesPerCall::get() as usize, + Error::::MaxAttributesLimitReached + ); if let Some(account) = only_account { ensure!(account == mint_to, Error::::WrongOrigin); } @@ -113,13 +118,24 @@ impl, I: 'static> Pallet { item_config, |_, _| Ok(()), )?; + for (key, value) in attributes { + Self::do_set_attribute( + collection_details.owner.clone(), + collection, + Some(item), + AttributeNamespace::CollectionOwner, + Self::construct_attribute_key(key)?, + Self::construct_attribute_value(value)?, + mint_to.clone(), + )?; + } if !metadata.len().is_zero() { Self::do_set_item_metadata( - Some(collection_details.owner), + Some(collection_details.owner.clone()), collection, item, metadata, - Some(mint_to), + Some(mint_to.clone()), )?; } Ok(()) diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index f508cda215cdd..8d9c2c95da0be 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -168,6 +168,10 @@ pub mod pallet { #[pallet::constant] type MaxDeadlineDuration: Get<::BlockNumber>; + /// The max number of attributes a user could set per call. + #[pallet::constant] + type MaxAttributesPerCall: Get; + /// Disables some of pallet's features. #[pallet::constant] type Features: Get; @@ -600,6 +604,8 @@ pub mod pallet { WrongSignature, /// The provided metadata might be too long. IncorrectMetadata, + /// Can't set more attributes per one call. + MaxAttributesLimitReached, } #[pallet::call] @@ -1332,7 +1338,15 @@ pub mod pallet { value: BoundedVec, ) -> DispatchResult { let origin = ensure_signed(origin)?; - Self::do_set_attribute(origin, collection, maybe_item, namespace, key, value) + Self::do_set_attribute( + origin.clone(), + collection, + maybe_item, + namespace, + key, + value, + origin, + ) } /// Force-set an attribute for a collection or item. diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index bb0c3dce44477..129000575e8c7 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -113,6 +113,7 @@ impl Config for Test { type ItemAttributesApprovalsLimit = ConstU32<2>; type MaxTips = ConstU32<10>; type MaxDeadlineDuration = ConstU64<10000>; + type MaxAttributesPerCall = ConstU32<2>; type Features = Features; type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index ea18b016c5316..91679554af09e 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -2509,7 +2509,8 @@ fn pre_signed_mints_should_work() { let mint_data = PreSignedMint { collection: 0, item: 0, - metadata: vec![00, 01], + attributes: vec![(vec![0], vec![1]), (vec![2], vec![3])], + metadata: vec![0, 1], only_account: None, deadline: 10000000, }; @@ -2535,10 +2536,28 @@ fn pre_signed_mints_should_work() { assert_eq!(items(), vec![(user_2, 0, 0)]); let metadata = ItemMetadataOf::::get(0, 0).unwrap(); assert_eq!(metadata.deposit, ItemMetadataDeposit { account: Some(user_2), amount: 3 }); - assert_eq!(metadata.data, vec![00, 01]); + assert_eq!(metadata.data, vec![0, 1]); + + assert_eq!( + attributes(0), + vec![ + (Some(0), AttributeNamespace::CollectionOwner, bvec![0], bvec![1]), + (Some(0), AttributeNamespace::CollectionOwner, bvec![2], bvec![3]), + ] + ); + let attribute_key: BoundedVec<_, _> = bvec![0]; + let (_, deposit) = Attribute::::get(( + 0, + Some(0), + AttributeNamespace::CollectionOwner, + &attribute_key, + )) + .unwrap(); + assert_eq!(deposit.account, Some(user_2)); + assert_eq!(deposit.amount, 3); assert_eq!(Balances::free_balance(&user_1), 100 - 2); // 2 - collection deposit - assert_eq!(Balances::free_balance(&user_2), 100 - 1 - 3); // 1 - item deposit, 3 - metadata + assert_eq!(Balances::free_balance(&user_2), 100 - 1 - 3 - 6); // 1 - item deposit, 3 - metadata, 6 - attributes assert_noop!( Nfts::mint_pre_signed( @@ -2551,17 +2570,19 @@ fn pre_signed_mints_should_work() { ); assert_ok!(Nfts::burn(RuntimeOrigin::signed(user_2), 0, 0, Some(user_2))); - assert_eq!(Balances::free_balance(&user_2), 100); + assert_eq!(Balances::free_balance(&user_2), 100 - 6); - // check errors + // validate the `only_account` field let mint_data = PreSignedMint { collection: 0, item: 0, + attributes: vec![], metadata: vec![], only_account: Some(2), deadline: 10000000, }; + // can't mint with the wrong signature assert_noop!( Nfts::mint_pre_signed( RuntimeOrigin::signed(user_2), @@ -2585,6 +2606,7 @@ fn pre_signed_mints_should_work() { Error::::WrongOrigin ); + // validate signature's expiration System::set_block_number(10000001); assert_noop!( Nfts::mint_pre_signed( @@ -2597,9 +2619,11 @@ fn pre_signed_mints_should_work() { ); System::set_block_number(1); + // validate the collection let mint_data = PreSignedMint { collection: 1, item: 0, + attributes: vec![], metadata: vec![], only_account: Some(2), deadline: 10000000, @@ -2616,5 +2640,26 @@ fn pre_signed_mints_should_work() { ), Error::::UnknownCollection ); + + // validate max attributes limit + let mint_data = PreSignedMint { + collection: 0, + item: 0, + attributes: vec![(vec![0], vec![1]), (vec![2], vec![3]), (vec![2], vec![3])], + metadata: vec![0, 1], + only_account: None, + deadline: 10000000, + }; + let message = Encode::encode(&mint_data); + let signature = MultiSignature::Sr25519(user_1_pair.sign(&message)); + assert_noop!( + Nfts::mint_pre_signed( + RuntimeOrigin::signed(user_2), + mint_data, + signature, + user_1_signer.clone(), + ), + Error::::MaxAttributesLimitReached + ); }) } diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index 6cf821d7660a5..c2ecd61c23028 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -486,6 +486,8 @@ pub struct PreSignedMint { pub(super) collection: CollectionId, /// Item's id. pub(super) item: ItemId, + /// Additional item's key-value attributes. + pub(super) attributes: Vec<(Vec, Vec)>, /// Additional item's metadata. pub(super) metadata: Vec, /// Restrict the claim to a particular account. From 839c37cbff9f0d416933f37dd2609bbdc9d8d09d Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 31 Jan 2023 16:34:13 +0200 Subject: [PATCH 15/25] Update docs --- frame/nfts/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 8d9c2c95da0be..0e6ce525c8118 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -1795,7 +1795,7 @@ pub mod pallet { /// Origin must be Signed. /// /// - `data`: The pre-signed approval that consists of the information about the item, its - /// metadata, who can mint it (`None` for anyone) and until what block number. + /// metadata, attributes, who can mint it (`None` for anyone) and until what block number. /// - `signature`: The signature of the `data` object. /// - `signer`: The `data` object's signer. Should be an owner of the collection. /// From 7120dd0772b74498debfaf0dcede23391ce569f3 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 31 Jan 2023 15:43:29 +0000 Subject: [PATCH 16/25] ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_nfts --- frame/nfts/src/weights.rs | 439 +++++++++++++++++++++----------------- 1 file changed, 240 insertions(+), 199 deletions(-) diff --git a/frame/nfts/src/weights.rs b/frame/nfts/src/weights.rs index a8e62727c2673..40592c29988ed 100644 --- a/frame/nfts/src/weights.rs +++ b/frame/nfts/src/weights.rs @@ -18,25 +18,26 @@ //! Autogenerated weights for pallet_nfts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/substrate +// target/production/substrate // benchmark // pallet -// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_nfts // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/nfts/src/weights.rs +// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet_nfts +// --chain=dev // --header=./HEADER-APACHE2 +// --output=./frame/nfts/src/weights.rs // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -85,7 +86,7 @@ pub trait WeightInfo { fn create_swap() -> Weight; fn cancel_swap() -> Weight; fn claim_swap() -> Weight; - fn mint_pre_signed() -> Weight; + fn mint_pre_signed(n: u32, ) -> Weight; } /// Weights for pallet_nfts using the Substrate node and recommended hardware. @@ -105,8 +106,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `214` // Estimated: `3054` - // Minimum execution time: 32_467 nanoseconds. - Weight::from_parts(33_236_000, 3054) + // Minimum execution time: 33_666 nanoseconds. + Weight::from_parts(34_405_000, 3054) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -124,8 +125,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3054` - // Minimum execution time: 22_198 nanoseconds. - Weight::from_parts(22_776_000, 3054) + // Minimum execution time: 22_028 nanoseconds. + Weight::from_parts(23_030_000, 3054) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -152,18 +153,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1000]`. /// The range of component `m` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. - fn destroy(n: u32, m: u32, a: u32, ) -> Weight { + fn destroy(_n: u32, m: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `172781 + m * (127 ±0) + a * (402 ±0)` // Estimated: `3347427 + a * (2921 ±0) + m * (2615 ±0)` - // Minimum execution time: 24_021_657 nanoseconds. - Weight::from_parts(16_029_391_606, 3347427) - // Standard Error: 20_364 - .saturating_add(Weight::from_ref_time(300_580).saturating_mul(n.into())) - // Standard Error: 20_364 - .saturating_add(Weight::from_ref_time(7_748_502).saturating_mul(m.into())) - // Standard Error: 20_364 - .saturating_add(Weight::from_ref_time(9_183_566).saturating_mul(a.into())) + // Minimum execution time: 27_944_985 nanoseconds. + Weight::from_parts(19_865_318_850, 3347427) + // Standard Error: 32_345 + .saturating_add(Weight::from_ref_time(8_729_316).saturating_mul(m.into())) + // Standard Error: 32_345 + .saturating_add(Weight::from_ref_time(10_264_491).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(1004_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) @@ -189,8 +188,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `448` // Estimated: `13506` - // Minimum execution time: 42_634 nanoseconds. - Weight::from_parts(43_231_000, 13506) + // Minimum execution time: 43_925 nanoseconds. + Weight::from_parts(45_885_000, 13506) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -210,8 +209,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `448` // Estimated: `13506` - // Minimum execution time: 41_686 nanoseconds. - Weight::from_parts(41_991_000, 13506) + // Minimum execution time: 42_832 nanoseconds. + Weight::from_parts(44_621_000, 13506) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -237,8 +236,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `647` // Estimated: `13573` - // Minimum execution time: 45_192 nanoseconds. - Weight::from_parts(45_792_000, 13573) + // Minimum execution time: 47_787 nanoseconds. + Weight::from_parts(49_204_000, 13573) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -264,8 +263,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `882` // Estimated: `16109` - // Minimum execution time: 51_962 nanoseconds. - Weight::from_parts(52_367_000, 16109) + // Minimum execution time: 55_524 nanoseconds. + Weight::from_parts(56_962_000, 16109) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -280,10 +279,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `756 + i * (140 ±0)` // Estimated: `5103 + i * (3336 ±0)` - // Minimum execution time: 15_512 nanoseconds. - Weight::from_parts(15_731_000, 5103) - // Standard Error: 9_495 - .saturating_add(Weight::from_ref_time(11_462_413).saturating_mul(i.into())) + // Minimum execution time: 15_246 nanoseconds. + Weight::from_parts(15_671_000, 5103) + // Standard Error: 20_348 + .saturating_add(Weight::from_ref_time(14_692_422).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -297,8 +296,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `401` // Estimated: `5067` - // Minimum execution time: 19_273 nanoseconds. - Weight::from_parts(19_508_000, 5067) + // Minimum execution time: 19_270 nanoseconds. + Weight::from_parts(19_775_000, 5067) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -310,8 +309,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `401` // Estimated: `5067` - // Minimum execution time: 19_022 nanoseconds. - Weight::from_parts(19_430_000, 5067) + // Minimum execution time: 19_364 nanoseconds. + Weight::from_parts(20_274_000, 5067) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -323,8 +322,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `289` // Estimated: `5092` - // Minimum execution time: 17_593 nanoseconds. - Weight::from_parts(17_950_000, 5092) + // Minimum execution time: 17_036 nanoseconds. + Weight::from_parts(17_750_000, 5092) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -338,8 +337,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `381` // Estimated: `5082` - // Minimum execution time: 22_068 nanoseconds. - Weight::from_parts(22_235_000, 5082) + // Minimum execution time: 22_104 nanoseconds. + Weight::from_parts(23_022_000, 5082) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -351,8 +350,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `362` // Estimated: `2555` - // Minimum execution time: 25_056 nanoseconds. - Weight::from_parts(25_767_000, 2555) + // Minimum execution time: 24_516 nanoseconds. + Weight::from_parts(25_300_000, 2555) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -364,8 +363,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `304` // Estimated: `2555` - // Minimum execution time: 17_398 nanoseconds. - Weight::from_parts(17_684_000, 2555) + // Minimum execution time: 16_974 nanoseconds. + Weight::from_parts(17_654_000, 2555) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -377,8 +376,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `242` // Estimated: `2555` - // Minimum execution time: 14_054 nanoseconds. - Weight::from_parts(14_243_000, 2555) + // Minimum execution time: 13_190 nanoseconds. + Weight::from_parts(13_826_000, 2555) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -390,8 +389,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `445` // Estimated: `5078` - // Minimum execution time: 17_662 nanoseconds. - Weight::from_parts(18_073_000, 5078) + // Minimum execution time: 17_336 nanoseconds. + Weight::from_parts(18_242_000, 5078) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -407,8 +406,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `474` // Estimated: `10547` - // Minimum execution time: 40_098 nanoseconds. - Weight::from_parts(40_649_000, 10547) + // Minimum execution time: 40_791 nanoseconds. + Weight::from_parts(42_489_000, 10547) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -420,8 +419,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `337` // Estimated: `5476` - // Minimum execution time: 25_178 nanoseconds. - Weight::from_parts(25_473_000, 5476) + // Minimum execution time: 24_620 nanoseconds. + Weight::from_parts(25_370_000, 5476) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -435,8 +434,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `916` // Estimated: `7999` - // Minimum execution time: 35_202 nanoseconds. - Weight::from_parts(35_518_000, 7999) + // Minimum execution time: 36_411 nanoseconds. + Weight::from_parts(37_439_000, 7999) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -448,8 +447,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `379` // Estimated: `6492` - // Minimum execution time: 17_260 nanoseconds. - Weight::from_parts(17_498_000, 6492) + // Minimum execution time: 16_696 nanoseconds. + Weight::from_parts(17_411_000, 6492) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -464,12 +463,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1000]`. fn cancel_item_attributes_approval(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `865 + n * (367 ±0)` + // Measured: `899 + n * (396 ±0)` // Estimated: `12016 + n * (2921 ±0)` - // Minimum execution time: 25_579 nanoseconds. - Weight::from_parts(25_846_000, 12016) - // Standard Error: 7_759 - .saturating_add(Weight::from_ref_time(7_159_200).saturating_mul(n.into())) + // Minimum execution time: 25_928 nanoseconds. + Weight::from_parts(26_440_000, 12016) + // Standard Error: 9_158 + .saturating_add(Weight::from_ref_time(9_271_441).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -488,8 +487,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `474` // Estimated: `10241` - // Minimum execution time: 33_285 nanoseconds. - Weight::from_parts(33_692_000, 10241) + // Minimum execution time: 34_150 nanoseconds. + Weight::from_parts(35_398_000, 10241) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -503,8 +502,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `609` // Estimated: `7693` - // Minimum execution time: 30_670 nanoseconds. - Weight::from_parts(31_282_000, 7693) + // Minimum execution time: 31_871 nanoseconds. + Weight::from_parts(33_057_000, 7693) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -518,8 +517,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `333` // Estimated: `7665` - // Minimum execution time: 28_313 nanoseconds. - Weight::from_parts(28_724_000, 7665) + // Minimum execution time: 28_843 nanoseconds. + Weight::from_parts(30_057_000, 7665) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -533,8 +532,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `476` // Estimated: `7665` - // Minimum execution time: 27_034 nanoseconds. - Weight::from_parts(27_655_000, 7665) + // Minimum execution time: 27_777 nanoseconds. + Weight::from_parts(28_471_000, 7665) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -548,8 +547,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `466` // Estimated: `8428` - // Minimum execution time: 23_408 nanoseconds. - Weight::from_parts(23_916_000, 8428) + // Minimum execution time: 23_726 nanoseconds. + Weight::from_parts(24_455_000, 8428) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -561,8 +560,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `474` // Estimated: `5880` - // Minimum execution time: 21_177 nanoseconds. - Weight::from_parts(21_492_000, 5880) + // Minimum execution time: 21_051 nanoseconds. + Weight::from_parts(21_722_000, 5880) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -574,8 +573,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `474` // Estimated: `5880` - // Minimum execution time: 20_279 nanoseconds. - Weight::from_parts(20_919_000, 5880) + // Minimum execution time: 20_095 nanoseconds. + Weight::from_parts(20_770_000, 5880) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -585,8 +584,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `42` // Estimated: `2527` - // Minimum execution time: 14_921 nanoseconds. - Weight::from_parts(15_382_000, 2527) + // Minimum execution time: 14_078 nanoseconds. + Weight::from_parts(14_582_000, 2527) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -598,8 +597,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `333` // Estimated: `5103` - // Minimum execution time: 18_201 nanoseconds. - Weight::from_parts(18_628_000, 5103) + // Minimum execution time: 17_677 nanoseconds. + Weight::from_parts(18_381_000, 5103) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -611,8 +610,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `333` // Estimated: `5103` - // Minimum execution time: 16_870 nanoseconds. - Weight::from_parts(17_318_000, 5103) + // Minimum execution time: 16_295 nanoseconds. + Weight::from_parts(17_036_000, 5103) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -628,8 +627,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `516` // Estimated: `8407` - // Minimum execution time: 22_604 nanoseconds. - Weight::from_parts(22_867_000, 8407) + // Minimum execution time: 22_847 nanoseconds. + Weight::from_parts(23_536_000, 8407) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -653,8 +652,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `934` // Estimated: `16129` - // Minimum execution time: 56_849 nanoseconds. - Weight::from_parts(57_336_000, 16129) + // Minimum execution time: 60_517 nanoseconds. + Weight::from_parts(62_528_000, 16129) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -663,10 +662,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_308 nanoseconds. - Weight::from_ref_time(4_805_401) - // Standard Error: 13_875 - .saturating_add(Weight::from_ref_time(3_167_190).saturating_mul(n.into())) + // Minimum execution time: 1_866 nanoseconds. + Weight::from_ref_time(3_949_301) + // Standard Error: 11_044 + .saturating_add(Weight::from_ref_time(3_424_466).saturating_mul(n.into())) } /// Storage: Nfts Item (r:2 w:0) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) @@ -676,8 +675,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `524` // Estimated: `6672` - // Minimum execution time: 20_395 nanoseconds. - Weight::from_parts(20_716_000, 6672) + // Minimum execution time: 21_174 nanoseconds. + Weight::from_parts(21_619_000, 6672) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -689,8 +688,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `511` // Estimated: `5882` - // Minimum execution time: 19_936 nanoseconds. - Weight::from_parts(20_344_000, 5882) + // Minimum execution time: 20_606 nanoseconds. + Weight::from_parts(21_150_000, 5882) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -714,19 +713,41 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1097` // Estimated: `21970` - // Minimum execution time: 80_884 nanoseconds. - Weight::from_parts(81_643_000, 21970) + // Minimum execution time: 88_414 nanoseconds. + Weight::from_parts(91_830_000, 21970) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) } - fn mint_pre_signed() -> Weight { - // Proof Size summary in bytes: - // Measured: `1097` - // Estimated: `21970` - // Minimum execution time: 80_884 nanoseconds. - Weight::from_parts(81_643_000, 21970) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(11_u64)) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:10 w:10) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:1) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 10]`. + fn mint_pre_signed(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `596` + // Estimated: `16180 + n * (2921 ±0)` + // Minimum execution time: 124_354 nanoseconds. + Weight::from_parts(133_779_491, 16180) + // Standard Error: 38_452 + .saturating_add(Weight::from_ref_time(25_110_697).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(6_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) } } @@ -746,8 +767,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `214` // Estimated: `3054` - // Minimum execution time: 32_467 nanoseconds. - Weight::from_parts(33_236_000, 3054) + // Minimum execution time: 33_666 nanoseconds. + Weight::from_parts(34_405_000, 3054) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -765,8 +786,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3054` - // Minimum execution time: 22_198 nanoseconds. - Weight::from_parts(22_776_000, 3054) + // Minimum execution time: 22_028 nanoseconds. + Weight::from_parts(23_030_000, 3054) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -793,18 +814,16 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1000]`. /// The range of component `m` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. - fn destroy(n: u32, m: u32, a: u32, ) -> Weight { + fn destroy(_n: u32, m: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `172781 + m * (127 ±0) + a * (402 ±0)` // Estimated: `3347427 + a * (2921 ±0) + m * (2615 ±0)` - // Minimum execution time: 24_021_657 nanoseconds. - Weight::from_parts(16_029_391_606, 3347427) - // Standard Error: 20_364 - .saturating_add(Weight::from_ref_time(300_580).saturating_mul(n.into())) - // Standard Error: 20_364 - .saturating_add(Weight::from_ref_time(7_748_502).saturating_mul(m.into())) - // Standard Error: 20_364 - .saturating_add(Weight::from_ref_time(9_183_566).saturating_mul(a.into())) + // Minimum execution time: 27_944_985 nanoseconds. + Weight::from_parts(19_865_318_850, 3347427) + // Standard Error: 32_345 + .saturating_add(Weight::from_ref_time(8_729_316).saturating_mul(m.into())) + // Standard Error: 32_345 + .saturating_add(Weight::from_ref_time(10_264_491).saturating_mul(a.into())) .saturating_add(RocksDbWeight::get().reads(1004_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) @@ -830,8 +849,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `448` // Estimated: `13506` - // Minimum execution time: 42_634 nanoseconds. - Weight::from_parts(43_231_000, 13506) + // Minimum execution time: 43_925 nanoseconds. + Weight::from_parts(45_885_000, 13506) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -851,8 +870,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `448` // Estimated: `13506` - // Minimum execution time: 41_686 nanoseconds. - Weight::from_parts(41_991_000, 13506) + // Minimum execution time: 42_832 nanoseconds. + Weight::from_parts(44_621_000, 13506) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -878,8 +897,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `647` // Estimated: `13573` - // Minimum execution time: 45_192 nanoseconds. - Weight::from_parts(45_792_000, 13573) + // Minimum execution time: 47_787 nanoseconds. + Weight::from_parts(49_204_000, 13573) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -905,8 +924,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `882` // Estimated: `16109` - // Minimum execution time: 51_962 nanoseconds. - Weight::from_parts(52_367_000, 16109) + // Minimum execution time: 55_524 nanoseconds. + Weight::from_parts(56_962_000, 16109) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -921,10 +940,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `756 + i * (140 ±0)` // Estimated: `5103 + i * (3336 ±0)` - // Minimum execution time: 15_512 nanoseconds. - Weight::from_parts(15_731_000, 5103) - // Standard Error: 9_495 - .saturating_add(Weight::from_ref_time(11_462_413).saturating_mul(i.into())) + // Minimum execution time: 15_246 nanoseconds. + Weight::from_parts(15_671_000, 5103) + // Standard Error: 20_348 + .saturating_add(Weight::from_ref_time(14_692_422).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -938,8 +957,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `401` // Estimated: `5067` - // Minimum execution time: 19_273 nanoseconds. - Weight::from_parts(19_508_000, 5067) + // Minimum execution time: 19_270 nanoseconds. + Weight::from_parts(19_775_000, 5067) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -951,8 +970,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `401` // Estimated: `5067` - // Minimum execution time: 19_022 nanoseconds. - Weight::from_parts(19_430_000, 5067) + // Minimum execution time: 19_364 nanoseconds. + Weight::from_parts(20_274_000, 5067) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -964,8 +983,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `289` // Estimated: `5092` - // Minimum execution time: 17_593 nanoseconds. - Weight::from_parts(17_950_000, 5092) + // Minimum execution time: 17_036 nanoseconds. + Weight::from_parts(17_750_000, 5092) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -979,8 +998,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `381` // Estimated: `5082` - // Minimum execution time: 22_068 nanoseconds. - Weight::from_parts(22_235_000, 5082) + // Minimum execution time: 22_104 nanoseconds. + Weight::from_parts(23_022_000, 5082) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -992,8 +1011,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `362` // Estimated: `2555` - // Minimum execution time: 25_056 nanoseconds. - Weight::from_parts(25_767_000, 2555) + // Minimum execution time: 24_516 nanoseconds. + Weight::from_parts(25_300_000, 2555) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -1005,8 +1024,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `304` // Estimated: `2555` - // Minimum execution time: 17_398 nanoseconds. - Weight::from_parts(17_684_000, 2555) + // Minimum execution time: 16_974 nanoseconds. + Weight::from_parts(17_654_000, 2555) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1018,8 +1037,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `242` // Estimated: `2555` - // Minimum execution time: 14_054 nanoseconds. - Weight::from_parts(14_243_000, 2555) + // Minimum execution time: 13_190 nanoseconds. + Weight::from_parts(13_826_000, 2555) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1031,8 +1050,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `445` // Estimated: `5078` - // Minimum execution time: 17_662 nanoseconds. - Weight::from_parts(18_073_000, 5078) + // Minimum execution time: 17_336 nanoseconds. + Weight::from_parts(18_242_000, 5078) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1048,8 +1067,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `474` // Estimated: `10547` - // Minimum execution time: 40_098 nanoseconds. - Weight::from_parts(40_649_000, 10547) + // Minimum execution time: 40_791 nanoseconds. + Weight::from_parts(42_489_000, 10547) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1061,8 +1080,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `337` // Estimated: `5476` - // Minimum execution time: 25_178 nanoseconds. - Weight::from_parts(25_473_000, 5476) + // Minimum execution time: 24_620 nanoseconds. + Weight::from_parts(25_370_000, 5476) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1076,8 +1095,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `916` // Estimated: `7999` - // Minimum execution time: 35_202 nanoseconds. - Weight::from_parts(35_518_000, 7999) + // Minimum execution time: 36_411 nanoseconds. + Weight::from_parts(37_439_000, 7999) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1089,8 +1108,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `379` // Estimated: `6492` - // Minimum execution time: 17_260 nanoseconds. - Weight::from_parts(17_498_000, 6492) + // Minimum execution time: 16_696 nanoseconds. + Weight::from_parts(17_411_000, 6492) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1105,12 +1124,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1000]`. fn cancel_item_attributes_approval(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `865 + n * (367 ±0)` + // Measured: `899 + n * (396 ±0)` // Estimated: `12016 + n * (2921 ±0)` - // Minimum execution time: 25_579 nanoseconds. - Weight::from_parts(25_846_000, 12016) - // Standard Error: 7_759 - .saturating_add(Weight::from_ref_time(7_159_200).saturating_mul(n.into())) + // Minimum execution time: 25_928 nanoseconds. + Weight::from_parts(26_440_000, 12016) + // Standard Error: 9_158 + .saturating_add(Weight::from_ref_time(9_271_441).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -1129,8 +1148,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `474` // Estimated: `10241` - // Minimum execution time: 33_285 nanoseconds. - Weight::from_parts(33_692_000, 10241) + // Minimum execution time: 34_150 nanoseconds. + Weight::from_parts(35_398_000, 10241) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1144,8 +1163,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `609` // Estimated: `7693` - // Minimum execution time: 30_670 nanoseconds. - Weight::from_parts(31_282_000, 7693) + // Minimum execution time: 31_871 nanoseconds. + Weight::from_parts(33_057_000, 7693) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1159,8 +1178,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `333` // Estimated: `7665` - // Minimum execution time: 28_313 nanoseconds. - Weight::from_parts(28_724_000, 7665) + // Minimum execution time: 28_843 nanoseconds. + Weight::from_parts(30_057_000, 7665) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1174,8 +1193,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `476` // Estimated: `7665` - // Minimum execution time: 27_034 nanoseconds. - Weight::from_parts(27_655_000, 7665) + // Minimum execution time: 27_777 nanoseconds. + Weight::from_parts(28_471_000, 7665) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1189,8 +1208,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `466` // Estimated: `8428` - // Minimum execution time: 23_408 nanoseconds. - Weight::from_parts(23_916_000, 8428) + // Minimum execution time: 23_726 nanoseconds. + Weight::from_parts(24_455_000, 8428) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1202,8 +1221,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `474` // Estimated: `5880` - // Minimum execution time: 21_177 nanoseconds. - Weight::from_parts(21_492_000, 5880) + // Minimum execution time: 21_051 nanoseconds. + Weight::from_parts(21_722_000, 5880) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1215,8 +1234,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `474` // Estimated: `5880` - // Minimum execution time: 20_279 nanoseconds. - Weight::from_parts(20_919_000, 5880) + // Minimum execution time: 20_095 nanoseconds. + Weight::from_parts(20_770_000, 5880) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1226,8 +1245,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `42` // Estimated: `2527` - // Minimum execution time: 14_921 nanoseconds. - Weight::from_parts(15_382_000, 2527) + // Minimum execution time: 14_078 nanoseconds. + Weight::from_parts(14_582_000, 2527) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1239,8 +1258,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `333` // Estimated: `5103` - // Minimum execution time: 18_201 nanoseconds. - Weight::from_parts(18_628_000, 5103) + // Minimum execution time: 17_677 nanoseconds. + Weight::from_parts(18_381_000, 5103) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1252,8 +1271,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `333` // Estimated: `5103` - // Minimum execution time: 16_870 nanoseconds. - Weight::from_parts(17_318_000, 5103) + // Minimum execution time: 16_295 nanoseconds. + Weight::from_parts(17_036_000, 5103) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1269,8 +1288,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `516` // Estimated: `8407` - // Minimum execution time: 22_604 nanoseconds. - Weight::from_parts(22_867_000, 8407) + // Minimum execution time: 22_847 nanoseconds. + Weight::from_parts(23_536_000, 8407) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1294,8 +1313,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `934` // Estimated: `16129` - // Minimum execution time: 56_849 nanoseconds. - Weight::from_parts(57_336_000, 16129) + // Minimum execution time: 60_517 nanoseconds. + Weight::from_parts(62_528_000, 16129) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1304,10 +1323,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_308 nanoseconds. - Weight::from_ref_time(4_805_401) - // Standard Error: 13_875 - .saturating_add(Weight::from_ref_time(3_167_190).saturating_mul(n.into())) + // Minimum execution time: 1_866 nanoseconds. + Weight::from_ref_time(3_949_301) + // Standard Error: 11_044 + .saturating_add(Weight::from_ref_time(3_424_466).saturating_mul(n.into())) } /// Storage: Nfts Item (r:2 w:0) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) @@ -1317,8 +1336,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `524` // Estimated: `6672` - // Minimum execution time: 20_395 nanoseconds. - Weight::from_parts(20_716_000, 6672) + // Minimum execution time: 21_174 nanoseconds. + Weight::from_parts(21_619_000, 6672) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1330,8 +1349,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `511` // Estimated: `5882` - // Minimum execution time: 19_936 nanoseconds. - Weight::from_parts(20_344_000, 5882) + // Minimum execution time: 20_606 nanoseconds. + Weight::from_parts(21_150_000, 5882) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1355,18 +1374,40 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1097` // Estimated: `21970` - // Minimum execution time: 80_884 nanoseconds. - Weight::from_parts(81_643_000, 21970) + // Minimum execution time: 88_414 nanoseconds. + Weight::from_parts(91_830_000, 21970) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(11_u64)) } - fn mint_pre_signed() -> Weight { - // Proof Size summary in bytes: - // Measured: `1097` - // Estimated: `21970` - // Minimum execution time: 80_884 nanoseconds. - Weight::from_parts(81_643_000, 21970) - .saturating_add(RocksDbWeight::get().reads(8_u64)) - .saturating_add(RocksDbWeight::get().writes(11_u64)) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:10 w:10) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:1) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 10]`. + fn mint_pre_signed(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `596` + // Estimated: `16180 + n * (2921 ±0)` + // Minimum execution time: 124_354 nanoseconds. + Weight::from_parts(133_779_491, 16180) + // Standard Error: 38_452 + .saturating_add(Weight::from_ref_time(25_110_697).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) } } From 088dddd3fed36fcab5ff9ddcbdd698af2bc86ed0 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 31 Jan 2023 17:50:39 +0200 Subject: [PATCH 17/25] Add the number of attributes provided to weights --- frame/nfts/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 0e6ce525c8118..eefaba4d8ae21 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -1802,7 +1802,7 @@ pub mod pallet { /// Emits `Issued` on success. /// Emits `ItemMetadataSet` if the metadata was not empty. #[pallet::call_index(37)] - #[pallet::weight(T::WeightInfo::mint_pre_signed())] + #[pallet::weight(T::WeightInfo::mint_pre_signed(data.attributes.len() as u32))] pub fn mint_pre_signed( origin: OriginFor, data: PreSignedMintOf, From 603a1941183d8e25e01da3689372aa6e313c3094 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Wed, 1 Feb 2023 18:06:03 +0200 Subject: [PATCH 18/25] Support pre-signed attributes --- frame/nfts/src/benchmarking.rs | 52 ++++++ frame/nfts/src/features/attributes.rs | 51 ++++++ frame/nfts/src/lib.rs | 38 ++++ frame/nfts/src/tests.rs | 246 ++++++++++++++++++++++++++ frame/nfts/src/types.rs | 20 +++ frame/nfts/src/weights.rs | 29 +++ 6 files changed, 436 insertions(+) diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index e021324939c8d..4328b62e8f268 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -765,5 +765,57 @@ benchmarks_instance_pallet! { assert_last_event::(Event::ItemMetadataSet { collection, item, data: metadata }.into()); } + set_attributes_pre_signed { + let n in 0 .. T::MaxAttributesPerCall::get() as u32; + let (collection, caller, _) = create_collection::(); + + let item_owner: T::AccountId = account("item_owner", 0, SEED); + let item_owner_lookup = T::Lookup::unlookup(item_owner.clone()); + + let account_public = sr25519_generate(0.into(), None); + let account_signer = MultiSigner::Sr25519(account_public); + let account = Nfts::::signer_to_account(account_signer.clone()).unwrap(); + let account_lookup = T::Lookup::unlookup(account.clone()); + + T::Currency::make_free_balance_be(&item_owner, DepositBalanceOf::::max_value()); + + let item = T::Helper::item(0); + assert_ok!(Nfts::::force_mint( + SystemOrigin::Root.into(), + collection, + item, + item_owner_lookup.clone(), + default_item_config(), + )); + + let mut attributes = vec![]; + let attribute_value = vec![0u8; T::ValueLimit::get() as usize]; + for i in 0..n { + let attribute_key = make_filled_vec(i as u16, T::KeyLimit::get() as usize); + attributes.push((attribute_key, attribute_value.clone())); + } + let pre_signed_data = PreSignedAttributes { + collection, + item, + attributes, + namespace: AttributeNamespace::Account(account.clone()), + deadline: One::one(), + }; + let message = Encode::encode(&pre_signed_data); + let signature = MultiSignature::Sr25519(sr25519_sign(0.into(), &account_public, &message).unwrap()); + + frame_system::Pallet::::set_block_number(One::one()); + }: _(SystemOrigin::Signed(item_owner.clone()), pre_signed_data, signature, account_signer) + verify { + assert_last_event::( + Event::PreSignedAttributesSet { + collection, + item, + namespace: AttributeNamespace::Account(account.clone()), + } + .into(), + ); + } + impl_benchmark_test_suite!(Nfts, crate::mock::new_test_ext(), crate::mock::Test); } diff --git a/frame/nfts/src/features/attributes.rs b/frame/nfts/src/features/attributes.rs index 51c75233c1d0c..c89c723b2e86a 100644 --- a/frame/nfts/src/features/attributes.rs +++ b/frame/nfts/src/features/attributes.rs @@ -165,6 +165,57 @@ impl, I: 'static> Pallet { Ok(()) } + pub(crate) fn do_set_attributes_pre_signed( + origin: T::AccountId, + data: PreSignedAttributesOf, + signer: T::AccountId, + ) -> DispatchResult { + let PreSignedAttributes { collection, item, attributes, namespace, deadline } = data; + + ensure!( + attributes.len() <= T::MaxAttributesPerCall::get() as usize, + Error::::MaxAttributesLimitReached + ); + + let now = frame_system::Pallet::::block_number(); + ensure!(deadline >= now, Error::::DeadlineExpired); + + let item_details = + Item::::get(&collection, &item).ok_or(Error::::UnknownItem)?; + ensure!(item_details.owner == origin, Error::::NoPermission); + + match &namespace { + AttributeNamespace::CollectionOwner => {}, + AttributeNamespace::Account(account) => { + ensure!(account == &signer, Error::::NoPermission); + let approvals = ItemAttributesApprovalsOf::::get(&collection, &item); + if !approvals.contains(account) { + Self::do_approve_item_attributes( + origin.clone(), + collection, + item, + account.clone(), + )?; + } + }, + _ => return Err(Error::::WrongNamespace.into()), + } + + for (key, value) in attributes { + Self::do_set_attribute( + signer.clone(), + collection, + Some(item), + namespace.clone(), + Self::construct_attribute_key(key)?, + Self::construct_attribute_value(value)?, + origin.clone(), + )?; + } + Self::deposit_event(Event::PreSignedAttributesSet { collection, item, namespace }); + Ok(()) + } + pub(crate) fn do_clear_attribute( maybe_check_owner: Option, collection: T::CollectionId, diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index eefaba4d8ae21..e619c7f6407f9 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -516,6 +516,12 @@ pub mod pallet { price: Option>>, deadline: ::BlockNumber, }, + /// New attributes have been set for an `item` of the `collection`. + PreSignedAttributesSet { + collection: T::CollectionId, + item: T::ItemId, + namespace: AttributeNamespace, + }, } #[pallet::error] @@ -606,6 +612,8 @@ pub mod pallet { IncorrectMetadata, /// Can't set more attributes per one call. MaxAttributesLimitReached, + /// The provided namespace isn't supported in this call. + WrongNamespace, } #[pallet::call] @@ -1818,6 +1826,36 @@ pub mod pallet { let signer_account = Self::signer_to_account(signer)?; Self::do_mint_pre_signed(origin, data, signer_account) } + + /// Set attributes for an item by providing the pre-signed approval. + /// + /// Origin must be Signed and must be an owner of the `data.item`. + /// + /// - `data`: The pre-signed approval that consists of the information about the item, + /// attributes to update and until what block number. + /// - `signature`: The signature of the `data` object. + /// - `signer`: The `data` object's signer. Should be an owner of the collection for the + /// `CollectionOwner` namespace. + /// + /// Emits `AttributeSet`. + /// Emits `PreSignedAttributesSet`. + #[pallet::call_index(38)] + #[pallet::weight(T::WeightInfo::set_attributes_pre_signed(data.attributes.len() as u32))] + pub fn set_attributes_pre_signed( + origin: OriginFor, + data: PreSignedAttributesOf, + signature: MultiSignature, + signer: MultiSigner, + ) -> DispatchResult { + let origin = ensure_signed(origin)?; + let msg = Encode::encode(&data); + ensure!( + signature.verify(&*msg, &signer.clone().into_account()), + Error::::WrongSignature + ); + let signer_account = Self::signer_to_account(signer)?; + Self::do_set_attributes_pre_signed(origin, data, signer_account) + } } } diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index 91679554af09e..6978ced41d7e5 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -2663,3 +2663,249 @@ fn pre_signed_mints_should_work() { ); }) } + +#[test] +fn pre_signed_attributes_should_work() { + new_test_ext().execute_with(|| { + let user_1_pair = sp_core::sr25519::Pair::from_string("//Alice", None).unwrap(); + let user_1_signer = MultiSigner::Sr25519(user_1_pair.public()); + let user_1 = Nfts::signer_to_account(user_1_signer.clone()).unwrap(); + let user_2 = 2; + let user_3_pair = sp_core::sr25519::Pair::from_string("//Bob", None).unwrap(); + let user_3_signer = MultiSigner::Sr25519(user_3_pair.public()); + let user_3 = Nfts::signer_to_account(user_3_signer.clone()).unwrap(); + let collection_id = 0; + let item_id = 0; + + Balances::make_free_balance_be(&user_1, 100); + Balances::make_free_balance_be(&user_2, 100); + Balances::make_free_balance_be(&user_3, 100); + assert_ok!(Nfts::create( + RuntimeOrigin::signed(user_1), + user_1, + collection_config_with_all_settings_enabled(), + )); + assert_ok!(Nfts::mint(RuntimeOrigin::signed(user_1), collection_id, item_id, user_2, None)); + + // validate the CollectionOwner namespace + let pre_signed_data = PreSignedAttributes { + collection: 0, + item: 0, + attributes: vec![(vec![0], vec![1]), (vec![2], vec![3])], + namespace: AttributeNamespace::CollectionOwner, + deadline: 10000000, + }; + let message = Encode::encode(&pre_signed_data); + let signature = MultiSignature::Sr25519(user_1_pair.sign(&message)); + + assert_ok!(Nfts::set_attributes_pre_signed( + RuntimeOrigin::signed(user_2), + pre_signed_data.clone(), + signature.clone(), + user_1_signer.clone(), + )); + + assert_eq!( + attributes(0), + vec![ + (Some(0), AttributeNamespace::CollectionOwner, bvec![0], bvec![1]), + (Some(0), AttributeNamespace::CollectionOwner, bvec![2], bvec![3]), + ] + ); + let attribute_key: BoundedVec<_, _> = bvec![0]; + let (_, deposit) = Attribute::::get(( + 0, + Some(0), + AttributeNamespace::CollectionOwner, + &attribute_key, + )) + .unwrap(); + assert_eq!(deposit.account, Some(user_2)); + assert_eq!(deposit.amount, 3); + + assert_eq!(Balances::free_balance(&user_1), 100 - 2 - 1); // 2 - collection deposit, 1 - item deposit + assert_eq!(Balances::free_balance(&user_2), 100 - 6); // 6 - attributes + + // validate the deposit gets returned on attribute update from collection's owner + assert_ok!(Nfts::set_attribute( + RuntimeOrigin::signed(user_1), + collection_id, + Some(item_id), + AttributeNamespace::CollectionOwner, + bvec![0], + bvec![1], + )); + let (_, deposit) = Attribute::::get(( + 0, + Some(0), + AttributeNamespace::CollectionOwner, + &attribute_key, + )) + .unwrap(); + assert_eq!(deposit.account, None); + assert_eq!(deposit.amount, 3); + + // validate the Account namespace + let pre_signed_data = PreSignedAttributes { + collection: 0, + item: 0, + attributes: vec![(vec![0], vec![1]), (vec![2], vec![3])], + namespace: AttributeNamespace::Account(user_3), + deadline: 10000000, + }; + let message = Encode::encode(&pre_signed_data); + let signature = MultiSignature::Sr25519(user_3_pair.sign(&message)); + + assert_ok!(Nfts::set_attributes_pre_signed( + RuntimeOrigin::signed(user_2), + pre_signed_data.clone(), + signature.clone(), + user_3_signer.clone(), + )); + + assert_eq!( + attributes(0), + vec![ + (Some(0), AttributeNamespace::CollectionOwner, bvec![0], bvec![1]), + (Some(0), AttributeNamespace::Account(user_3), bvec![0], bvec![1]), + (Some(0), AttributeNamespace::CollectionOwner, bvec![2], bvec![3]), + (Some(0), AttributeNamespace::Account(user_3), bvec![2], bvec![3]), + ] + ); + + let attribute_key: BoundedVec<_, _> = bvec![0]; + let (_, deposit) = Attribute::::get(( + 0, + Some(0), + AttributeNamespace::Account(user_3), + &attribute_key, + )) + .unwrap(); + assert_eq!(deposit.account, Some(user_2)); + assert_eq!(deposit.amount, 3); + + assert_eq!(Balances::free_balance(&user_2), 100 - 9); + assert_eq!(Balances::free_balance(&user_3), 100); + + // validate the deposit gets returned on attribute update from user_3 + assert_ok!(Nfts::set_attribute( + RuntimeOrigin::signed(user_3), + collection_id, + Some(item_id), + AttributeNamespace::Account(user_3), + bvec![0], + bvec![1], + )); + let (_, deposit) = Attribute::::get(( + 0, + Some(0), + AttributeNamespace::Account(user_3), + &attribute_key, + )) + .unwrap(); + assert_eq!(deposit.account, Some(user_3)); + assert_eq!(deposit.amount, 3); + + assert_eq!(Balances::free_balance(&user_2), 100 - 6); + assert_eq!(Balances::free_balance(&user_3), 100 - 3); + + // can't update with the wrong signature + assert_noop!( + Nfts::set_attributes_pre_signed( + RuntimeOrigin::signed(user_2), + pre_signed_data.clone(), + signature.clone(), + user_1_signer.clone(), + ), + Error::::WrongSignature + ); + + // can't update if I don't own that item + assert_noop!( + Nfts::set_attributes_pre_signed( + RuntimeOrigin::signed(user_3), + pre_signed_data.clone(), + signature.clone(), + user_3_signer.clone(), + ), + Error::::NoPermission + ); + + // can't update the CollectionOwner namespace if the signer is not an owner of that + // collection + let pre_signed_data = PreSignedAttributes { + collection: 0, + item: 0, + attributes: vec![(vec![0], vec![1]), (vec![2], vec![3])], + namespace: AttributeNamespace::CollectionOwner, + deadline: 10000000, + }; + let message = Encode::encode(&pre_signed_data); + let signature = MultiSignature::Sr25519(user_3_pair.sign(&message)); + + assert_noop!( + Nfts::set_attributes_pre_signed( + RuntimeOrigin::signed(user_2), + pre_signed_data.clone(), + signature.clone(), + user_3_signer.clone(), + ), + Error::::NoPermission + ); + + // validate signature's expiration + System::set_block_number(10000001); + assert_noop!( + Nfts::set_attributes_pre_signed( + RuntimeOrigin::signed(user_2), + pre_signed_data.clone(), + signature.clone(), + user_3_signer.clone(), + ), + Error::::DeadlineExpired + ); + System::set_block_number(1); + + // validate item & collection + let pre_signed_data = PreSignedAttributes { + collection: 1, + item: 1, + attributes: vec![(vec![0], vec![1]), (vec![2], vec![3])], + namespace: AttributeNamespace::CollectionOwner, + deadline: 10000000, + }; + let message = Encode::encode(&pre_signed_data); + let signature = MultiSignature::Sr25519(user_1_pair.sign(&message)); + + assert_noop!( + Nfts::set_attributes_pre_signed( + RuntimeOrigin::signed(user_2), + pre_signed_data.clone(), + signature.clone(), + user_1_signer.clone(), + ), + Error::::UnknownItem + ); + + // validate max attributes limit + let pre_signed_data = PreSignedAttributes { + collection: 1, + item: 1, + attributes: vec![(vec![0], vec![1]), (vec![2], vec![3]), (vec![2], vec![3])], + namespace: AttributeNamespace::CollectionOwner, + deadline: 10000000, + }; + let message = Encode::encode(&pre_signed_data); + let signature = MultiSignature::Sr25519(user_1_pair.sign(&message)); + + assert_noop!( + Nfts::set_attributes_pre_signed( + RuntimeOrigin::signed(user_2), + pre_signed_data.clone(), + signature.clone(), + user_1_signer.clone(), + ), + Error::::MaxAttributesLimitReached + ); + }) +} diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index c2ecd61c23028..fc43547ceb538 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -67,6 +67,12 @@ pub(super) type PreSignedMintOf = PreSignedMint< ::AccountId, ::BlockNumber, >; +pub(super) type PreSignedAttributesOf = PreSignedAttributes< + >::CollectionId, + >::ItemId, + ::AccountId, + ::BlockNumber, +>; pub trait Incrementable { fn increment(&self) -> Self; @@ -495,3 +501,17 @@ pub struct PreSignedMint { /// A deadline for the signature. pub(super) deadline: Deadline, } + +#[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] +pub struct PreSignedAttributes { + /// Collection's id. + pub(super) collection: CollectionId, + /// Item's id. + pub(super) item: ItemId, + /// Key-value attributes. + pub(super) attributes: Vec<(Vec, Vec)>, + /// Attributes' namespace. + pub(super) namespace: AttributeNamespace, + /// A deadline for the signature. + pub(super) deadline: Deadline, +} diff --git a/frame/nfts/src/weights.rs b/frame/nfts/src/weights.rs index 40592c29988ed..86dff124eab39 100644 --- a/frame/nfts/src/weights.rs +++ b/frame/nfts/src/weights.rs @@ -87,6 +87,7 @@ pub trait WeightInfo { fn cancel_swap() -> Weight; fn claim_swap() -> Weight; fn mint_pre_signed(n: u32, ) -> Weight; + fn set_attributes_pre_signed(n: u32, ) -> Weight; } /// Weights for pallet_nfts using the Substrate node and recommended hardware. @@ -749,6 +750,20 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) } + fn set_attributes_pre_signed(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `596` + // Estimated: `16180 + n * (2921 ±0)` + // Minimum execution time: 124_354 nanoseconds. + Weight::from_parts(133_779_491, 16180) + // Standard Error: 38_452 + .saturating_add(Weight::from_ref_time(25_110_697).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(6_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) + } } // For backwards compatibility and tests @@ -1410,4 +1425,18 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) } + fn set_attributes_pre_signed(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `596` + // Estimated: `16180 + n * (2921 ±0)` + // Minimum execution time: 124_354 nanoseconds. + Weight::from_parts(133_779_491, 16180) + // Standard Error: 38_452 + .saturating_add(Weight::from_ref_time(25_110_697).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) + } } From 30b26a7e66786df8a34d8c76b0e797bb871106d2 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Thu, 2 Feb 2023 12:36:40 +0200 Subject: [PATCH 19/25] Update docs --- frame/nfts/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index e619c7f6407f9..0369429bb7be7 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -1808,6 +1808,7 @@ pub mod pallet { /// - `signer`: The `data` object's signer. Should be an owner of the collection. /// /// Emits `Issued` on success. + /// Emits `AttributeSet` if the attributes were provided. /// Emits `ItemMetadataSet` if the metadata was not empty. #[pallet::call_index(37)] #[pallet::weight(T::WeightInfo::mint_pre_signed(data.attributes.len() as u32))] From 2c43623307d7e8bf903b4ebfd60ad3091ce6c05e Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 14 Feb 2023 12:29:55 +0200 Subject: [PATCH 20/25] Fix merge artifacts --- frame/nfts/src/benchmarking.rs | 16 ++++---- frame/nfts/src/lib.rs | 12 ++---- frame/nfts/src/tests.rs | 72 ++++++++++++++++++---------------- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index 8f78c5a1c0f0e..8bb92c911494c 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -775,15 +775,13 @@ benchmarks_instance_pallet! { set_attributes_pre_signed { let n in 0 .. T::MaxAttributesPerCall::get() as u32; - let (collection, caller, _) = create_collection::(); + let (collection, _, _) = create_collection::(); let item_owner: T::AccountId = account("item_owner", 0, SEED); let item_owner_lookup = T::Lookup::unlookup(item_owner.clone()); - let account_public = sr25519_generate(0.into(), None); - let account_signer = MultiSigner::Sr25519(account_public); - let account = Nfts::::signer_to_account(account_signer.clone()).unwrap(); - let account_lookup = T::Lookup::unlookup(account.clone()); + let signer_public = sr25519_generate(0.into(), None); + let signer: T::AccountId = MultiSigner::Sr25519(signer_public).into_account().into(); T::Currency::make_free_balance_be(&item_owner, DepositBalanceOf::::max_value()); @@ -806,20 +804,20 @@ benchmarks_instance_pallet! { collection, item, attributes, - namespace: AttributeNamespace::Account(account.clone()), + namespace: AttributeNamespace::Account(signer.clone()), deadline: One::one(), }; let message = Encode::encode(&pre_signed_data); - let signature = MultiSignature::Sr25519(sr25519_sign(0.into(), &account_public, &message).unwrap()); + let signature = MultiSignature::Sr25519(sr25519_sign(0.into(), &signer_public, &message).unwrap()); frame_system::Pallet::::set_block_number(One::one()); - }: _(SystemOrigin::Signed(item_owner.clone()), pre_signed_data, signature, account_signer) + }: _(SystemOrigin::Signed(item_owner.clone()), pre_signed_data, signature.into(), signer.clone()) verify { assert_last_event::( Event::PreSignedAttributesSet { collection, item, - namespace: AttributeNamespace::Account(account.clone()), + namespace: AttributeNamespace::Account(signer.clone()), } .into(), ); diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index a9951ea7b944b..9a859cc68e411 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -1850,17 +1850,13 @@ pub mod pallet { pub fn set_attributes_pre_signed( origin: OriginFor, data: PreSignedAttributesOf, - signature: MultiSignature, - signer: MultiSigner, + signature: T::OffchainSignature, + signer: T::AccountId, ) -> DispatchResult { let origin = ensure_signed(origin)?; let msg = Encode::encode(&data); - ensure!( - signature.verify(&*msg, &signer.clone().into_account()), - Error::::WrongSignature - ); - let signer_account = Self::signer_to_account(signer)?; - Self::do_set_attributes_pre_signed(origin, data, signer_account) + ensure!(signature.verify(&*msg, &signer), Error::::WrongSignature); + Self::do_set_attributes_pre_signed(origin, data, signer) } } } diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index dfcadb3b12e00..cc2e9c6220a75 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -3182,11 +3182,11 @@ fn pre_signed_attributes_should_work() { new_test_ext().execute_with(|| { let user_1_pair = sp_core::sr25519::Pair::from_string("//Alice", None).unwrap(); let user_1_signer = MultiSigner::Sr25519(user_1_pair.public()); - let user_1 = Nfts::signer_to_account(user_1_signer.clone()).unwrap(); - let user_2 = 2; + let user_1 = user_1_signer.clone().into_account(); + let user_2 = account(2); let user_3_pair = sp_core::sr25519::Pair::from_string("//Bob", None).unwrap(); let user_3_signer = MultiSigner::Sr25519(user_3_pair.public()); - let user_3 = Nfts::signer_to_account(user_3_signer.clone()).unwrap(); + let user_3 = user_3_signer.clone().into_account(); let collection_id = 0; let item_id = 0; @@ -3194,11 +3194,17 @@ fn pre_signed_attributes_should_work() { Balances::make_free_balance_be(&user_2, 100); Balances::make_free_balance_be(&user_3, 100); assert_ok!(Nfts::create( - RuntimeOrigin::signed(user_1), - user_1, + RuntimeOrigin::signed(user_1.clone()), + user_1.clone(), collection_config_with_all_settings_enabled(), )); - assert_ok!(Nfts::mint(RuntimeOrigin::signed(user_1), collection_id, item_id, user_2, None)); + assert_ok!(Nfts::mint( + RuntimeOrigin::signed(user_1.clone()), + collection_id, + item_id, + user_2.clone(), + None, + )); // validate the CollectionOwner namespace let pre_signed_data = PreSignedAttributes { @@ -3212,10 +3218,10 @@ fn pre_signed_attributes_should_work() { let signature = MultiSignature::Sr25519(user_1_pair.sign(&message)); assert_ok!(Nfts::set_attributes_pre_signed( - RuntimeOrigin::signed(user_2), + RuntimeOrigin::signed(user_2.clone()), pre_signed_data.clone(), signature.clone(), - user_1_signer.clone(), + user_1.clone(), )); assert_eq!( @@ -3233,7 +3239,7 @@ fn pre_signed_attributes_should_work() { &attribute_key, )) .unwrap(); - assert_eq!(deposit.account, Some(user_2)); + assert_eq!(deposit.account, Some(user_2.clone())); assert_eq!(deposit.amount, 3); assert_eq!(Balances::free_balance(&user_1), 100 - 2 - 1); // 2 - collection deposit, 1 - item deposit @@ -3241,7 +3247,7 @@ fn pre_signed_attributes_should_work() { // validate the deposit gets returned on attribute update from collection's owner assert_ok!(Nfts::set_attribute( - RuntimeOrigin::signed(user_1), + RuntimeOrigin::signed(user_1.clone()), collection_id, Some(item_id), AttributeNamespace::CollectionOwner, @@ -3263,26 +3269,26 @@ fn pre_signed_attributes_should_work() { collection: 0, item: 0, attributes: vec![(vec![0], vec![1]), (vec![2], vec![3])], - namespace: AttributeNamespace::Account(user_3), + namespace: AttributeNamespace::Account(user_3.clone()), deadline: 10000000, }; let message = Encode::encode(&pre_signed_data); let signature = MultiSignature::Sr25519(user_3_pair.sign(&message)); assert_ok!(Nfts::set_attributes_pre_signed( - RuntimeOrigin::signed(user_2), + RuntimeOrigin::signed(user_2.clone()), pre_signed_data.clone(), signature.clone(), - user_3_signer.clone(), + user_3.clone(), )); assert_eq!( attributes(0), vec![ (Some(0), AttributeNamespace::CollectionOwner, bvec![0], bvec![1]), - (Some(0), AttributeNamespace::Account(user_3), bvec![0], bvec![1]), + (Some(0), AttributeNamespace::Account(user_3.clone()), bvec![0], bvec![1]), (Some(0), AttributeNamespace::CollectionOwner, bvec![2], bvec![3]), - (Some(0), AttributeNamespace::Account(user_3), bvec![2], bvec![3]), + (Some(0), AttributeNamespace::Account(user_3.clone()), bvec![2], bvec![3]), ] ); @@ -3290,11 +3296,11 @@ fn pre_signed_attributes_should_work() { let (_, deposit) = Attribute::::get(( 0, Some(0), - AttributeNamespace::Account(user_3), + AttributeNamespace::Account(user_3.clone()), &attribute_key, )) .unwrap(); - assert_eq!(deposit.account, Some(user_2)); + assert_eq!(deposit.account, Some(user_2.clone())); assert_eq!(deposit.amount, 3); assert_eq!(Balances::free_balance(&user_2), 100 - 9); @@ -3302,21 +3308,21 @@ fn pre_signed_attributes_should_work() { // validate the deposit gets returned on attribute update from user_3 assert_ok!(Nfts::set_attribute( - RuntimeOrigin::signed(user_3), + RuntimeOrigin::signed(user_3.clone()), collection_id, Some(item_id), - AttributeNamespace::Account(user_3), + AttributeNamespace::Account(user_3.clone()), bvec![0], bvec![1], )); let (_, deposit) = Attribute::::get(( 0, Some(0), - AttributeNamespace::Account(user_3), + AttributeNamespace::Account(user_3.clone()), &attribute_key, )) .unwrap(); - assert_eq!(deposit.account, Some(user_3)); + assert_eq!(deposit.account, Some(user_3.clone())); assert_eq!(deposit.amount, 3); assert_eq!(Balances::free_balance(&user_2), 100 - 6); @@ -3325,10 +3331,10 @@ fn pre_signed_attributes_should_work() { // can't update with the wrong signature assert_noop!( Nfts::set_attributes_pre_signed( - RuntimeOrigin::signed(user_2), + RuntimeOrigin::signed(user_2.clone()), pre_signed_data.clone(), signature.clone(), - user_1_signer.clone(), + user_1.clone(), ), Error::::WrongSignature ); @@ -3336,10 +3342,10 @@ fn pre_signed_attributes_should_work() { // can't update if I don't own that item assert_noop!( Nfts::set_attributes_pre_signed( - RuntimeOrigin::signed(user_3), + RuntimeOrigin::signed(user_3.clone()), pre_signed_data.clone(), signature.clone(), - user_3_signer.clone(), + user_3.clone(), ), Error::::NoPermission ); @@ -3358,10 +3364,10 @@ fn pre_signed_attributes_should_work() { assert_noop!( Nfts::set_attributes_pre_signed( - RuntimeOrigin::signed(user_2), + RuntimeOrigin::signed(user_2.clone()), pre_signed_data.clone(), signature.clone(), - user_3_signer.clone(), + user_3.clone(), ), Error::::NoPermission ); @@ -3370,10 +3376,10 @@ fn pre_signed_attributes_should_work() { System::set_block_number(10000001); assert_noop!( Nfts::set_attributes_pre_signed( - RuntimeOrigin::signed(user_2), + RuntimeOrigin::signed(user_2.clone()), pre_signed_data.clone(), signature.clone(), - user_3_signer.clone(), + user_3.clone(), ), Error::::DeadlineExpired ); @@ -3392,10 +3398,10 @@ fn pre_signed_attributes_should_work() { assert_noop!( Nfts::set_attributes_pre_signed( - RuntimeOrigin::signed(user_2), + RuntimeOrigin::signed(user_2.clone()), pre_signed_data.clone(), signature.clone(), - user_1_signer.clone(), + user_1.clone(), ), Error::::UnknownItem ); @@ -3413,10 +3419,10 @@ fn pre_signed_attributes_should_work() { assert_noop!( Nfts::set_attributes_pre_signed( - RuntimeOrigin::signed(user_2), + RuntimeOrigin::signed(user_2.clone()), pre_signed_data.clone(), signature.clone(), - user_1_signer.clone(), + user_1.clone(), ), Error::::MaxAttributesLimitReached ); From 1a9fdee1bc2318222a55d18486c103a18ad3d15c Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Wed, 15 Feb 2023 11:17:02 +0200 Subject: [PATCH 21/25] Update docs --- frame/nfts/src/features/attributes.rs | 2 ++ frame/nfts/src/lib.rs | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frame/nfts/src/features/attributes.rs b/frame/nfts/src/features/attributes.rs index c89c723b2e86a..bfde7af896551 100644 --- a/frame/nfts/src/features/attributes.rs +++ b/frame/nfts/src/features/attributes.rs @@ -184,6 +184,8 @@ impl, I: 'static> Pallet { Item::::get(&collection, &item).ok_or(Error::::UnknownItem)?; ensure!(item_details.owner == origin, Error::::NoPermission); + // Only the CollectionOwner and Account() namespaces could be updated in this way. + // For the Account() namespace we check and set the approval if it wasn't set before. match &namespace { AttributeNamespace::CollectionOwner => {}, AttributeNamespace::Account(account) => { diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 9a859cc68e411..9a64222635d9d 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -1843,8 +1843,9 @@ pub mod pallet { /// - `signer`: The `data` object's signer. Should be an owner of the collection for the /// `CollectionOwner` namespace. /// - /// Emits `AttributeSet`. - /// Emits `PreSignedAttributesSet`. + /// Emits `AttributeSet` for each provided attribute. + /// Emits `ItemAttributesApprovalAdded` if the approval wasn't set before. + /// Emits `PreSignedAttributesSet` on success. #[pallet::call_index(38)] #[pallet::weight(T::WeightInfo::set_attributes_pre_signed(data.attributes.len() as u32))] pub fn set_attributes_pre_signed( From 2056b919be285e7ce30f7bc5fa0bc764769750d2 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Wed, 15 Feb 2023 12:39:33 +0200 Subject: [PATCH 22/25] Add more tests --- frame/nfts/src/tests.rs | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index cc2e9c6220a75..84e5e59bfc2bf 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -3264,6 +3264,40 @@ fn pre_signed_attributes_should_work() { assert_eq!(deposit.account, None); assert_eq!(deposit.amount, 3); + // validate we don't partially modify the state + assert_eq!(item_attributes_approvals(collection_id, item_id), vec![]); + let pre_signed_data = PreSignedAttributes { + collection: 0, + item: 0, + attributes: vec![(vec![0], vec![1]), (vec![2; 51], vec![3])], + namespace: AttributeNamespace::Account(user_3.clone()), + deadline: 10000000, + }; + let message = Encode::encode(&pre_signed_data); + let signature = MultiSignature::Sr25519(user_3_pair.sign(&message)); + + assert_noop!( + Nfts::set_attributes_pre_signed( + RuntimeOrigin::signed(user_2.clone()), + pre_signed_data.clone(), + signature.clone(), + user_3.clone(), + ), + Error::::IncorrectData + ); + + // no new approval was set + assert_eq!(item_attributes_approvals(collection_id, item_id), vec![]); + + // no new attributes were added + assert_eq!( + attributes(0), + vec![ + (Some(0), AttributeNamespace::CollectionOwner, bvec![0], bvec![1]), + (Some(0), AttributeNamespace::CollectionOwner, bvec![2], bvec![3]), + ] + ); + // validate the Account namespace let pre_signed_data = PreSignedAttributes { collection: 0, @@ -3291,6 +3325,7 @@ fn pre_signed_attributes_should_work() { (Some(0), AttributeNamespace::Account(user_3.clone()), bvec![2], bvec![3]), ] ); + assert_eq!(item_attributes_approvals(collection_id, item_id), vec![user_3.clone()]); let attribute_key: BoundedVec<_, _> = bvec![0]; let (_, deposit) = Attribute::::get(( @@ -3426,5 +3461,26 @@ fn pre_signed_attributes_should_work() { ), Error::::MaxAttributesLimitReached ); + + // validate the attribute's value length + let pre_signed_data = PreSignedAttributes { + collection: 0, + item: 0, + attributes: vec![(vec![0], vec![1]), (vec![2], vec![3; 51])], + namespace: AttributeNamespace::CollectionOwner, + deadline: 10000000, + }; + let message = Encode::encode(&pre_signed_data); + let signature = MultiSignature::Sr25519(user_1_pair.sign(&message)); + + assert_noop!( + Nfts::set_attributes_pre_signed( + RuntimeOrigin::signed(user_2.clone()), + pre_signed_data.clone(), + signature.clone(), + user_1.clone(), + ), + Error::::IncorrectData + ); }) } From 0032b2eda5d80bb7ba12ae4211fc6ff656f87c9b Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 15 Feb 2023 11:31:56 +0000 Subject: [PATCH 23/25] ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_nfts --- frame/nfts/src/weights.rs | 500 +++++++++++++++++++++++--------------- 1 file changed, 302 insertions(+), 198 deletions(-) diff --git a/frame/nfts/src/weights.rs b/frame/nfts/src/weights.rs index 86dff124eab39..8b8a82edb6783 100644 --- a/frame/nfts/src/weights.rs +++ b/frame/nfts/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_nfts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-02-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-osnnfcqu-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -107,8 +107,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `214` // Estimated: `3054` - // Minimum execution time: 33_666 nanoseconds. - Weight::from_parts(34_405_000, 3054) + // Minimum execution time: 33_769 nanoseconds. + Weight::from_ref_time(36_031_000) + .saturating_add(Weight::from_proof_size(3054)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -126,8 +127,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3054` - // Minimum execution time: 22_028 nanoseconds. - Weight::from_parts(23_030_000, 3054) + // Minimum execution time: 21_767 nanoseconds. + Weight::from_ref_time(22_565_000) + .saturating_add(Weight::from_proof_size(3054)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -157,21 +159,22 @@ impl WeightInfo for SubstrateWeight { fn destroy(_n: u32, m: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `172781 + m * (127 ±0) + a * (402 ±0)` - // Estimated: `3347427 + a * (2921 ±0) + m * (2615 ±0)` - // Minimum execution time: 27_944_985 nanoseconds. - Weight::from_parts(19_865_318_850, 3347427) - // Standard Error: 32_345 - .saturating_add(Weight::from_ref_time(8_729_316).saturating_mul(m.into())) - // Standard Error: 32_345 - .saturating_add(Weight::from_ref_time(10_264_491).saturating_mul(a.into())) + // Estimated: `3347427 + m * (2615 ±0) + a * (2921 ±0)` + // Minimum execution time: 26_973_627 nanoseconds. + Weight::from_ref_time(19_692_361_714) + .saturating_add(Weight::from_proof_size(3347427)) + // Standard Error: 17_036 + .saturating_add(Weight::from_ref_time(7_797_219).saturating_mul(m.into())) + // Standard Error: 17_036 + .saturating_add(Weight::from_ref_time(9_504_128).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(1004_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(3005_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) - .saturating_add(Weight::from_proof_size(2921).saturating_mul(a.into())) .saturating_add(Weight::from_proof_size(2615).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(2921).saturating_mul(a.into())) } /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) @@ -189,8 +192,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `448` // Estimated: `13506` - // Minimum execution time: 43_925 nanoseconds. - Weight::from_parts(45_885_000, 13506) + // Minimum execution time: 44_837 nanoseconds. + Weight::from_ref_time(46_794_000) + .saturating_add(Weight::from_proof_size(13506)) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -210,8 +214,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `448` // Estimated: `13506` - // Minimum execution time: 42_832 nanoseconds. - Weight::from_parts(44_621_000, 13506) + // Minimum execution time: 43_976 nanoseconds. + Weight::from_ref_time(44_831_000) + .saturating_add(Weight::from_proof_size(13506)) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -237,8 +242,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `647` // Estimated: `13573` - // Minimum execution time: 47_787 nanoseconds. - Weight::from_parts(49_204_000, 13573) + // Minimum execution time: 48_233 nanoseconds. + Weight::from_ref_time(50_113_000) + .saturating_add(Weight::from_proof_size(13573)) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -264,8 +270,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `882` // Estimated: `16109` - // Minimum execution time: 55_524 nanoseconds. - Weight::from_parts(56_962_000, 16109) + // Minimum execution time: 55_452 nanoseconds. + Weight::from_ref_time(57_642_000) + .saturating_add(Weight::from_proof_size(16109)) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -280,10 +287,11 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `756 + i * (140 ±0)` // Estimated: `5103 + i * (3336 ±0)` - // Minimum execution time: 15_246 nanoseconds. - Weight::from_parts(15_671_000, 5103) - // Standard Error: 20_348 - .saturating_add(Weight::from_ref_time(14_692_422).saturating_mul(i.into())) + // Minimum execution time: 15_598 nanoseconds. + Weight::from_ref_time(15_926_000) + .saturating_add(Weight::from_proof_size(5103)) + // Standard Error: 13_692 + .saturating_add(Weight::from_ref_time(14_040_741).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -297,8 +305,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `401` // Estimated: `5067` - // Minimum execution time: 19_270 nanoseconds. - Weight::from_parts(19_775_000, 5067) + // Minimum execution time: 19_686 nanoseconds. + Weight::from_ref_time(20_404_000) + .saturating_add(Weight::from_proof_size(5067)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -310,8 +319,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `401` // Estimated: `5067` - // Minimum execution time: 19_364 nanoseconds. - Weight::from_parts(20_274_000, 5067) + // Minimum execution time: 19_172 nanoseconds. + Weight::from_ref_time(20_151_000) + .saturating_add(Weight::from_proof_size(5067)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -323,8 +333,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `289` // Estimated: `5092` - // Minimum execution time: 17_036 nanoseconds. - Weight::from_parts(17_750_000, 5092) + // Minimum execution time: 17_063 nanoseconds. + Weight::from_ref_time(17_482_000) + .saturating_add(Weight::from_proof_size(5092)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -338,8 +349,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `381` // Estimated: `5082` - // Minimum execution time: 22_104 nanoseconds. - Weight::from_parts(23_022_000, 5082) + // Minimum execution time: 21_974 nanoseconds. + Weight::from_ref_time(22_770_000) + .saturating_add(Weight::from_proof_size(5082)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -351,8 +363,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `362` // Estimated: `2555` - // Minimum execution time: 24_516 nanoseconds. - Weight::from_parts(25_300_000, 2555) + // Minimum execution time: 24_341 nanoseconds. + Weight::from_ref_time(25_059_000) + .saturating_add(Weight::from_proof_size(2555)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -364,8 +377,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `304` // Estimated: `2555` - // Minimum execution time: 16_974 nanoseconds. - Weight::from_parts(17_654_000, 2555) + // Minimum execution time: 16_897 nanoseconds. + Weight::from_ref_time(17_560_000) + .saturating_add(Weight::from_proof_size(2555)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -377,8 +391,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `242` // Estimated: `2555` - // Minimum execution time: 13_190 nanoseconds. - Weight::from_parts(13_826_000, 2555) + // Minimum execution time: 13_239 nanoseconds. + Weight::from_ref_time(13_963_000) + .saturating_add(Weight::from_proof_size(2555)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -390,8 +405,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `445` // Estimated: `5078` - // Minimum execution time: 17_336 nanoseconds. - Weight::from_parts(18_242_000, 5078) + // Minimum execution time: 17_187 nanoseconds. + Weight::from_ref_time(17_942_000) + .saturating_add(Weight::from_proof_size(5078)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -407,8 +423,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `474` // Estimated: `10547` - // Minimum execution time: 40_791 nanoseconds. - Weight::from_parts(42_489_000, 10547) + // Minimum execution time: 40_925 nanoseconds. + Weight::from_ref_time(42_733_000) + .saturating_add(Weight::from_proof_size(10547)) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -420,8 +437,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `337` // Estimated: `5476` - // Minimum execution time: 24_620 nanoseconds. - Weight::from_parts(25_370_000, 5476) + // Minimum execution time: 24_486 nanoseconds. + Weight::from_ref_time(25_409_000) + .saturating_add(Weight::from_proof_size(5476)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -435,8 +453,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `916` // Estimated: `7999` - // Minimum execution time: 36_411 nanoseconds. - Weight::from_parts(37_439_000, 7999) + // Minimum execution time: 36_643 nanoseconds. + Weight::from_ref_time(37_805_000) + .saturating_add(Weight::from_proof_size(7999)) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -448,8 +467,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `379` // Estimated: `6492` - // Minimum execution time: 16_696 nanoseconds. - Weight::from_parts(17_411_000, 6492) + // Minimum execution time: 16_798 nanoseconds. + Weight::from_ref_time(17_326_000) + .saturating_add(Weight::from_proof_size(6492)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -466,10 +486,11 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `899 + n * (396 ±0)` // Estimated: `12016 + n * (2921 ±0)` - // Minimum execution time: 25_928 nanoseconds. - Weight::from_parts(26_440_000, 12016) - // Standard Error: 9_158 - .saturating_add(Weight::from_ref_time(9_271_441).saturating_mul(n.into())) + // Minimum execution time: 25_524 nanoseconds. + Weight::from_ref_time(26_107_000) + .saturating_add(Weight::from_proof_size(12016)) + // Standard Error: 5_460 + .saturating_add(Weight::from_ref_time(9_030_830).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -488,8 +509,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `474` // Estimated: `10241` - // Minimum execution time: 34_150 nanoseconds. - Weight::from_parts(35_398_000, 10241) + // Minimum execution time: 34_400 nanoseconds. + Weight::from_ref_time(35_469_000) + .saturating_add(Weight::from_proof_size(10241)) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -503,8 +525,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `609` // Estimated: `7693` - // Minimum execution time: 31_871 nanoseconds. - Weight::from_parts(33_057_000, 7693) + // Minimum execution time: 31_560 nanoseconds. + Weight::from_ref_time(33_081_000) + .saturating_add(Weight::from_proof_size(7693)) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -518,8 +541,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `333` // Estimated: `7665` - // Minimum execution time: 28_843 nanoseconds. - Weight::from_parts(30_057_000, 7665) + // Minimum execution time: 28_821 nanoseconds. + Weight::from_ref_time(30_010_000) + .saturating_add(Weight::from_proof_size(7665)) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -533,8 +557,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `476` // Estimated: `7665` - // Minimum execution time: 27_777 nanoseconds. - Weight::from_parts(28_471_000, 7665) + // Minimum execution time: 27_608 nanoseconds. + Weight::from_ref_time(28_766_000) + .saturating_add(Weight::from_proof_size(7665)) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -548,8 +573,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `466` // Estimated: `8428` - // Minimum execution time: 23_726 nanoseconds. - Weight::from_parts(24_455_000, 8428) + // Minimum execution time: 23_987 nanoseconds. + Weight::from_ref_time(24_819_000) + .saturating_add(Weight::from_proof_size(8428)) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -561,8 +587,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `474` // Estimated: `5880` - // Minimum execution time: 21_051 nanoseconds. - Weight::from_parts(21_722_000, 5880) + // Minimum execution time: 21_254 nanoseconds. + Weight::from_ref_time(21_826_000) + .saturating_add(Weight::from_proof_size(5880)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -574,8 +601,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `474` // Estimated: `5880` - // Minimum execution time: 20_095 nanoseconds. - Weight::from_parts(20_770_000, 5880) + // Minimum execution time: 20_272 nanoseconds. + Weight::from_ref_time(20_922_000) + .saturating_add(Weight::from_proof_size(5880)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -585,8 +613,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `42` // Estimated: `2527` - // Minimum execution time: 14_078 nanoseconds. - Weight::from_parts(14_582_000, 2527) + // Minimum execution time: 14_287 nanoseconds. + Weight::from_ref_time(14_960_000) + .saturating_add(Weight::from_proof_size(2527)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -598,8 +627,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `333` // Estimated: `5103` - // Minimum execution time: 17_677 nanoseconds. - Weight::from_parts(18_381_000, 5103) + // Minimum execution time: 17_948 nanoseconds. + Weight::from_ref_time(18_780_000) + .saturating_add(Weight::from_proof_size(5103)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -611,8 +641,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `333` // Estimated: `5103` - // Minimum execution time: 16_295 nanoseconds. - Weight::from_parts(17_036_000, 5103) + // Minimum execution time: 16_616 nanoseconds. + Weight::from_ref_time(17_155_000) + .saturating_add(Weight::from_proof_size(5103)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -628,8 +659,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `516` // Estimated: `8407` - // Minimum execution time: 22_847 nanoseconds. - Weight::from_parts(23_536_000, 8407) + // Minimum execution time: 22_777 nanoseconds. + Weight::from_ref_time(23_955_000) + .saturating_add(Weight::from_proof_size(8407)) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -653,8 +685,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `934` // Estimated: `16129` - // Minimum execution time: 60_517 nanoseconds. - Weight::from_parts(62_528_000, 16129) + // Minimum execution time: 61_131 nanoseconds. + Weight::from_ref_time(62_791_000) + .saturating_add(Weight::from_proof_size(16129)) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -663,10 +696,11 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_866 nanoseconds. - Weight::from_ref_time(3_949_301) - // Standard Error: 11_044 - .saturating_add(Weight::from_ref_time(3_424_466).saturating_mul(n.into())) + // Minimum execution time: 1_952 nanoseconds. + Weight::from_ref_time(3_975_700) + .saturating_add(Weight::from_proof_size(0)) + // Standard Error: 11_254 + .saturating_add(Weight::from_ref_time(3_501_698).saturating_mul(n.into())) } /// Storage: Nfts Item (r:2 w:0) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) @@ -676,8 +710,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `524` // Estimated: `6672` - // Minimum execution time: 21_174 nanoseconds. - Weight::from_parts(21_619_000, 6672) + // Minimum execution time: 20_327 nanoseconds. + Weight::from_ref_time(21_714_000) + .saturating_add(Weight::from_proof_size(6672)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -689,8 +724,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `511` // Estimated: `5882` - // Minimum execution time: 20_606 nanoseconds. - Weight::from_parts(21_150_000, 5882) + // Minimum execution time: 20_668 nanoseconds. + Weight::from_ref_time(21_416_000) + .saturating_add(Weight::from_proof_size(5882)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -714,8 +750,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1097` // Estimated: `21970` - // Minimum execution time: 88_414 nanoseconds. - Weight::from_parts(91_830_000, 21970) + // Minimum execution time: 88_006 nanoseconds. + Weight::from_ref_time(90_390_000) + .saturating_add(Weight::from_proof_size(21970)) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) } @@ -740,27 +777,42 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `596` // Estimated: `16180 + n * (2921 ±0)` - // Minimum execution time: 124_354 nanoseconds. - Weight::from_parts(133_779_491, 16180) - // Standard Error: 38_452 - .saturating_add(Weight::from_ref_time(25_110_697).saturating_mul(n.into())) + // Minimum execution time: 124_967 nanoseconds. + Weight::from_ref_time(131_602_642) + .saturating_add(Weight::from_proof_size(16180)) + // Standard Error: 36_480 + .saturating_add(Weight::from_ref_time(25_811_394).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:10 w:10) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 10]`. fn set_attributes_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `596` - // Estimated: `16180 + n * (2921 ±0)` - // Minimum execution time: 124_354 nanoseconds. - Weight::from_parts(133_779_491, 16180) - // Standard Error: 38_452 - .saturating_add(Weight::from_ref_time(25_110_697).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(6_u64)) + // Measured: `716` + // Estimated: `14198 + n * (2921 ±0)` + // Minimum execution time: 84_153 nanoseconds. + Weight::from_ref_time(96_401_623) + .saturating_add(Weight::from_proof_size(14198)) + // Standard Error: 70_244 + .saturating_add(Weight::from_ref_time(26_866_222).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(6_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) } @@ -782,8 +834,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `214` // Estimated: `3054` - // Minimum execution time: 33_666 nanoseconds. - Weight::from_parts(34_405_000, 3054) + // Minimum execution time: 33_769 nanoseconds. + Weight::from_ref_time(36_031_000) + .saturating_add(Weight::from_proof_size(3054)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -801,8 +854,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3054` - // Minimum execution time: 22_028 nanoseconds. - Weight::from_parts(23_030_000, 3054) + // Minimum execution time: 21_767 nanoseconds. + Weight::from_ref_time(22_565_000) + .saturating_add(Weight::from_proof_size(3054)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -832,21 +886,22 @@ impl WeightInfo for () { fn destroy(_n: u32, m: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `172781 + m * (127 ±0) + a * (402 ±0)` - // Estimated: `3347427 + a * (2921 ±0) + m * (2615 ±0)` - // Minimum execution time: 27_944_985 nanoseconds. - Weight::from_parts(19_865_318_850, 3347427) - // Standard Error: 32_345 - .saturating_add(Weight::from_ref_time(8_729_316).saturating_mul(m.into())) - // Standard Error: 32_345 - .saturating_add(Weight::from_ref_time(10_264_491).saturating_mul(a.into())) + // Estimated: `3347427 + m * (2615 ±0) + a * (2921 ±0)` + // Minimum execution time: 26_973_627 nanoseconds. + Weight::from_ref_time(19_692_361_714) + .saturating_add(Weight::from_proof_size(3347427)) + // Standard Error: 17_036 + .saturating_add(Weight::from_ref_time(7_797_219).saturating_mul(m.into())) + // Standard Error: 17_036 + .saturating_add(Weight::from_ref_time(9_504_128).saturating_mul(a.into())) .saturating_add(RocksDbWeight::get().reads(1004_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(RocksDbWeight::get().writes(3005_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(m.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) - .saturating_add(Weight::from_proof_size(2921).saturating_mul(a.into())) .saturating_add(Weight::from_proof_size(2615).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(2921).saturating_mul(a.into())) } /// Storage: Nfts CollectionConfigOf (r:1 w:0) /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) @@ -864,8 +919,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `448` // Estimated: `13506` - // Minimum execution time: 43_925 nanoseconds. - Weight::from_parts(45_885_000, 13506) + // Minimum execution time: 44_837 nanoseconds. + Weight::from_ref_time(46_794_000) + .saturating_add(Weight::from_proof_size(13506)) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -885,8 +941,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `448` // Estimated: `13506` - // Minimum execution time: 42_832 nanoseconds. - Weight::from_parts(44_621_000, 13506) + // Minimum execution time: 43_976 nanoseconds. + Weight::from_ref_time(44_831_000) + .saturating_add(Weight::from_proof_size(13506)) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -912,8 +969,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `647` // Estimated: `13573` - // Minimum execution time: 47_787 nanoseconds. - Weight::from_parts(49_204_000, 13573) + // Minimum execution time: 48_233 nanoseconds. + Weight::from_ref_time(50_113_000) + .saturating_add(Weight::from_proof_size(13573)) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -939,8 +997,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `882` // Estimated: `16109` - // Minimum execution time: 55_524 nanoseconds. - Weight::from_parts(56_962_000, 16109) + // Minimum execution time: 55_452 nanoseconds. + Weight::from_ref_time(57_642_000) + .saturating_add(Weight::from_proof_size(16109)) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -955,10 +1014,11 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `756 + i * (140 ±0)` // Estimated: `5103 + i * (3336 ±0)` - // Minimum execution time: 15_246 nanoseconds. - Weight::from_parts(15_671_000, 5103) - // Standard Error: 20_348 - .saturating_add(Weight::from_ref_time(14_692_422).saturating_mul(i.into())) + // Minimum execution time: 15_598 nanoseconds. + Weight::from_ref_time(15_926_000) + .saturating_add(Weight::from_proof_size(5103)) + // Standard Error: 13_692 + .saturating_add(Weight::from_ref_time(14_040_741).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -972,8 +1032,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `401` // Estimated: `5067` - // Minimum execution time: 19_270 nanoseconds. - Weight::from_parts(19_775_000, 5067) + // Minimum execution time: 19_686 nanoseconds. + Weight::from_ref_time(20_404_000) + .saturating_add(Weight::from_proof_size(5067)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -985,8 +1046,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `401` // Estimated: `5067` - // Minimum execution time: 19_364 nanoseconds. - Weight::from_parts(20_274_000, 5067) + // Minimum execution time: 19_172 nanoseconds. + Weight::from_ref_time(20_151_000) + .saturating_add(Weight::from_proof_size(5067)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -998,8 +1060,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `289` // Estimated: `5092` - // Minimum execution time: 17_036 nanoseconds. - Weight::from_parts(17_750_000, 5092) + // Minimum execution time: 17_063 nanoseconds. + Weight::from_ref_time(17_482_000) + .saturating_add(Weight::from_proof_size(5092)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1013,8 +1076,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `381` // Estimated: `5082` - // Minimum execution time: 22_104 nanoseconds. - Weight::from_parts(23_022_000, 5082) + // Minimum execution time: 21_974 nanoseconds. + Weight::from_ref_time(22_770_000) + .saturating_add(Weight::from_proof_size(5082)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -1026,8 +1090,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `362` // Estimated: `2555` - // Minimum execution time: 24_516 nanoseconds. - Weight::from_parts(25_300_000, 2555) + // Minimum execution time: 24_341 nanoseconds. + Weight::from_ref_time(25_059_000) + .saturating_add(Weight::from_proof_size(2555)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -1039,8 +1104,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `304` // Estimated: `2555` - // Minimum execution time: 16_974 nanoseconds. - Weight::from_parts(17_654_000, 2555) + // Minimum execution time: 16_897 nanoseconds. + Weight::from_ref_time(17_560_000) + .saturating_add(Weight::from_proof_size(2555)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1052,8 +1118,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `242` // Estimated: `2555` - // Minimum execution time: 13_190 nanoseconds. - Weight::from_parts(13_826_000, 2555) + // Minimum execution time: 13_239 nanoseconds. + Weight::from_ref_time(13_963_000) + .saturating_add(Weight::from_proof_size(2555)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1065,8 +1132,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `445` // Estimated: `5078` - // Minimum execution time: 17_336 nanoseconds. - Weight::from_parts(18_242_000, 5078) + // Minimum execution time: 17_187 nanoseconds. + Weight::from_ref_time(17_942_000) + .saturating_add(Weight::from_proof_size(5078)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1082,8 +1150,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `474` // Estimated: `10547` - // Minimum execution time: 40_791 nanoseconds. - Weight::from_parts(42_489_000, 10547) + // Minimum execution time: 40_925 nanoseconds. + Weight::from_ref_time(42_733_000) + .saturating_add(Weight::from_proof_size(10547)) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1095,8 +1164,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `337` // Estimated: `5476` - // Minimum execution time: 24_620 nanoseconds. - Weight::from_parts(25_370_000, 5476) + // Minimum execution time: 24_486 nanoseconds. + Weight::from_ref_time(25_409_000) + .saturating_add(Weight::from_proof_size(5476)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1110,8 +1180,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `916` // Estimated: `7999` - // Minimum execution time: 36_411 nanoseconds. - Weight::from_parts(37_439_000, 7999) + // Minimum execution time: 36_643 nanoseconds. + Weight::from_ref_time(37_805_000) + .saturating_add(Weight::from_proof_size(7999)) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1123,8 +1194,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `379` // Estimated: `6492` - // Minimum execution time: 16_696 nanoseconds. - Weight::from_parts(17_411_000, 6492) + // Minimum execution time: 16_798 nanoseconds. + Weight::from_ref_time(17_326_000) + .saturating_add(Weight::from_proof_size(6492)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1141,10 +1213,11 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `899 + n * (396 ±0)` // Estimated: `12016 + n * (2921 ±0)` - // Minimum execution time: 25_928 nanoseconds. - Weight::from_parts(26_440_000, 12016) - // Standard Error: 9_158 - .saturating_add(Weight::from_ref_time(9_271_441).saturating_mul(n.into())) + // Minimum execution time: 25_524 nanoseconds. + Weight::from_ref_time(26_107_000) + .saturating_add(Weight::from_proof_size(12016)) + // Standard Error: 5_460 + .saturating_add(Weight::from_ref_time(9_030_830).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -1163,8 +1236,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `474` // Estimated: `10241` - // Minimum execution time: 34_150 nanoseconds. - Weight::from_parts(35_398_000, 10241) + // Minimum execution time: 34_400 nanoseconds. + Weight::from_ref_time(35_469_000) + .saturating_add(Weight::from_proof_size(10241)) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1178,8 +1252,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `609` // Estimated: `7693` - // Minimum execution time: 31_871 nanoseconds. - Weight::from_parts(33_057_000, 7693) + // Minimum execution time: 31_560 nanoseconds. + Weight::from_ref_time(33_081_000) + .saturating_add(Weight::from_proof_size(7693)) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1193,8 +1268,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `333` // Estimated: `7665` - // Minimum execution time: 28_843 nanoseconds. - Weight::from_parts(30_057_000, 7665) + // Minimum execution time: 28_821 nanoseconds. + Weight::from_ref_time(30_010_000) + .saturating_add(Weight::from_proof_size(7665)) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1208,8 +1284,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `476` // Estimated: `7665` - // Minimum execution time: 27_777 nanoseconds. - Weight::from_parts(28_471_000, 7665) + // Minimum execution time: 27_608 nanoseconds. + Weight::from_ref_time(28_766_000) + .saturating_add(Weight::from_proof_size(7665)) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1223,8 +1300,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `466` // Estimated: `8428` - // Minimum execution time: 23_726 nanoseconds. - Weight::from_parts(24_455_000, 8428) + // Minimum execution time: 23_987 nanoseconds. + Weight::from_ref_time(24_819_000) + .saturating_add(Weight::from_proof_size(8428)) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1236,8 +1314,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `474` // Estimated: `5880` - // Minimum execution time: 21_051 nanoseconds. - Weight::from_parts(21_722_000, 5880) + // Minimum execution time: 21_254 nanoseconds. + Weight::from_ref_time(21_826_000) + .saturating_add(Weight::from_proof_size(5880)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1249,8 +1328,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `474` // Estimated: `5880` - // Minimum execution time: 20_095 nanoseconds. - Weight::from_parts(20_770_000, 5880) + // Minimum execution time: 20_272 nanoseconds. + Weight::from_ref_time(20_922_000) + .saturating_add(Weight::from_proof_size(5880)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1260,8 +1340,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `42` // Estimated: `2527` - // Minimum execution time: 14_078 nanoseconds. - Weight::from_parts(14_582_000, 2527) + // Minimum execution time: 14_287 nanoseconds. + Weight::from_ref_time(14_960_000) + .saturating_add(Weight::from_proof_size(2527)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1273,8 +1354,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `333` // Estimated: `5103` - // Minimum execution time: 17_677 nanoseconds. - Weight::from_parts(18_381_000, 5103) + // Minimum execution time: 17_948 nanoseconds. + Weight::from_ref_time(18_780_000) + .saturating_add(Weight::from_proof_size(5103)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1286,8 +1368,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `333` // Estimated: `5103` - // Minimum execution time: 16_295 nanoseconds. - Weight::from_parts(17_036_000, 5103) + // Minimum execution time: 16_616 nanoseconds. + Weight::from_ref_time(17_155_000) + .saturating_add(Weight::from_proof_size(5103)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1303,8 +1386,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `516` // Estimated: `8407` - // Minimum execution time: 22_847 nanoseconds. - Weight::from_parts(23_536_000, 8407) + // Minimum execution time: 22_777 nanoseconds. + Weight::from_ref_time(23_955_000) + .saturating_add(Weight::from_proof_size(8407)) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1328,8 +1412,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `934` // Estimated: `16129` - // Minimum execution time: 60_517 nanoseconds. - Weight::from_parts(62_528_000, 16129) + // Minimum execution time: 61_131 nanoseconds. + Weight::from_ref_time(62_791_000) + .saturating_add(Weight::from_proof_size(16129)) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1338,10 +1423,11 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_866 nanoseconds. - Weight::from_ref_time(3_949_301) - // Standard Error: 11_044 - .saturating_add(Weight::from_ref_time(3_424_466).saturating_mul(n.into())) + // Minimum execution time: 1_952 nanoseconds. + Weight::from_ref_time(3_975_700) + .saturating_add(Weight::from_proof_size(0)) + // Standard Error: 11_254 + .saturating_add(Weight::from_ref_time(3_501_698).saturating_mul(n.into())) } /// Storage: Nfts Item (r:2 w:0) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) @@ -1351,8 +1437,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `524` // Estimated: `6672` - // Minimum execution time: 21_174 nanoseconds. - Weight::from_parts(21_619_000, 6672) + // Minimum execution time: 20_327 nanoseconds. + Weight::from_ref_time(21_714_000) + .saturating_add(Weight::from_proof_size(6672)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1364,8 +1451,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `511` // Estimated: `5882` - // Minimum execution time: 20_606 nanoseconds. - Weight::from_parts(21_150_000, 5882) + // Minimum execution time: 20_668 nanoseconds. + Weight::from_ref_time(21_416_000) + .saturating_add(Weight::from_proof_size(5882)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1389,8 +1477,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1097` // Estimated: `21970` - // Minimum execution time: 88_414 nanoseconds. - Weight::from_parts(91_830_000, 21970) + // Minimum execution time: 88_006 nanoseconds. + Weight::from_ref_time(90_390_000) + .saturating_add(Weight::from_proof_size(21970)) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(11_u64)) } @@ -1415,27 +1504,42 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `596` // Estimated: `16180 + n * (2921 ±0)` - // Minimum execution time: 124_354 nanoseconds. - Weight::from_parts(133_779_491, 16180) - // Standard Error: 38_452 - .saturating_add(Weight::from_ref_time(25_110_697).saturating_mul(n.into())) + // Minimum execution time: 124_967 nanoseconds. + Weight::from_ref_time(131_602_642) + .saturating_add(Weight::from_proof_size(16180)) + // Standard Error: 36_480 + .saturating_add(Weight::from_ref_time(25_811_394).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:10 w:10) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 10]`. fn set_attributes_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `596` - // Estimated: `16180 + n * (2921 ±0)` - // Minimum execution time: 124_354 nanoseconds. - Weight::from_parts(133_779_491, 16180) - // Standard Error: 38_452 - .saturating_add(Weight::from_ref_time(25_110_697).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(6_u64)) + // Measured: `716` + // Estimated: `14198 + n * (2921 ±0)` + // Minimum execution time: 84_153 nanoseconds. + Weight::from_ref_time(96_401_623) + .saturating_add(Weight::from_proof_size(14198)) + // Standard Error: 70_244 + .saturating_add(Weight::from_ref_time(26_866_222).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(6_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) } From 5e81316a14a15ef3f996b6998f82596b57bc9860 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Date: Wed, 22 Feb 2023 15:11:02 +0200 Subject: [PATCH 24/25] Update frame/nfts/src/types.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- frame/nfts/src/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index fc43547ceb538..da1a2d6abd044 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -504,9 +504,9 @@ pub struct PreSignedMint { #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct PreSignedAttributes { - /// Collection's id. + /// Collection's ID. pub(super) collection: CollectionId, - /// Item's id. + /// Item's ID. pub(super) item: ItemId, /// Key-value attributes. pub(super) attributes: Vec<(Vec, Vec)>, From 72bcea2015799defd2238dbfbabc10de8538eb12 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Date: Wed, 22 Feb 2023 15:11:53 +0200 Subject: [PATCH 25/25] Update types.rs --- frame/nfts/src/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index da1a2d6abd044..cccfef404cb18 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -490,7 +490,7 @@ impl_codec_bitflags!(CollectionRoles, u8, CollectionRole); pub struct PreSignedMint { /// A collection of the item to be minted. pub(super) collection: CollectionId, - /// Item's id. + /// Item's ID. pub(super) item: ItemId, /// Additional item's key-value attributes. pub(super) attributes: Vec<(Vec, Vec)>,