difftreelog
refactor property writer / fix set_token_props weight
in: master
27 files changed
pallets/balances-adapter/src/common.rsdiffbeforeafterboth--- a/pallets/balances-adapter/src/common.rs
+++ b/pallets/balances-adapter/src/common.rs
@@ -30,15 +30,7 @@
Weight::default()
}
- fn delete_collection_properties(_amount: u32) -> Weight {
- Weight::default()
- }
-
fn set_token_properties(_amount: u32) -> Weight {
- Weight::default()
- }
-
- fn delete_token_properties(_amount: u32) -> Weight {
Weight::default()
}
@@ -63,18 +55,6 @@
}
fn burn_from() -> Weight {
- Weight::default()
- }
-
- fn burn_recursively_self_raw() -> Weight {
- Weight::default()
- }
-
- fn burn_recursively_breadth_raw(_amount: u32) -> Weight {
- Weight::default()
- }
-
- fn token_owner() -> Weight {
Weight::default()
}
@@ -124,16 +104,6 @@
_sender: <T>::CrossAccountId,
_token: TokenId,
_amount: u128,
- ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {
- fail!(<pallet_common::Error<T>>::UnsupportedOperation);
- }
-
- fn burn_item_recursively(
- &self,
- _sender: <T>::CrossAccountId,
- _token: TokenId,
- _self_budget: &dyn up_data_structs::budget::Budget,
- _breadth_budget: &dyn up_data_structs::budget::Budget,
) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
pallets/common/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -34,7 +34,7 @@
MAX_TOKEN_PREFIX_LENGTH,
};
-use crate::{CollectionHandle, Config, Pallet};
+use crate::{BenchmarkPropertyWriter, CollectionHandle, Config, Pallet};
const SEED: u32 = 1;
@@ -123,16 +123,6 @@
CollectionMode::NFT,
|owner: T::CrossAccountId, data| <Pallet<T>>::init_collection(owner.clone(), owner, data),
|h| h,
- )
-}
-
-pub fn load_is_admin_and_property_permissions<T: Config>(
- collection: &CollectionHandle<T>,
- sender: &T::CrossAccountId,
-) -> (bool, PropertiesPermissionMap) {
- (
- collection.is_owner_or_admin(sender),
- <Pallet<T>>::property_permissions(collection.id),
)
}
@@ -272,7 +262,7 @@
#[block]
{
- load_is_admin_and_property_permissions(&collection, &sender);
+ <BenchmarkPropertyWriter<T>>::load_collection_info(&&collection, &sender);
}
Ok(())
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -872,7 +872,7 @@
}
/// Value representation with delayed initialization time.
-pub struct LazyValue<T, F: FnOnce() -> T> {
+pub struct LazyValue<T, F> {
value: Option<T>,
f: Option<F>,
}
@@ -1902,7 +1902,9 @@
/// Collection property deletion weight.
///
/// * `amount`- The number of properties to set.
- fn delete_collection_properties(amount: u32) -> Weight;
+ fn delete_collection_properties(amount: u32) -> Weight {
+ Self::set_collection_properties(amount)
+ }
/// Token property setting weight.
///
@@ -1912,7 +1914,9 @@
/// Token property deletion weight.
///
/// * `amount`- The number of properties to delete.
- fn delete_token_properties(amount: u32) -> Weight;
+ fn delete_token_properties(amount: u32) -> Weight {
+ Self::set_token_properties(amount)
+ }
/// Token property permissions set weight.
///
@@ -1934,30 +1938,6 @@
/// The price of burning a token from another user.
fn burn_from() -> Weight;
- /// Differs from burn_item in case of Fungible and Refungible, as it should burn
- /// whole users's balance.
- ///
- /// This method shouldn't be used directly, as it doesn't count breadth price, use [burn_recursively](CommonWeightInfo::burn_recursively) instead
- fn burn_recursively_self_raw() -> Weight;
-
- /// Cost of iterating over `amount` children while burning, without counting child burning itself.
- ///
- /// This method shouldn't be used directly, as it doesn't count depth price, use [burn_recursively](CommonWeightInfo::burn_recursively) instead
- fn burn_recursively_breadth_raw(amount: u32) -> Weight;
-
- /// The price of recursive burning a token.
- ///
- /// `max_selfs` - The maximum burning weight of the token itself.
- /// `max_breadth` - The maximum number of nested tokens to burn.
- fn burn_recursively(max_selfs: u32, max_breadth: u32) -> Weight {
- Self::burn_recursively_self_raw()
- .saturating_mul(max_selfs.max(1) as u64)
- .saturating_add(Self::burn_recursively_breadth_raw(max_breadth))
- }
-
- /// The price of retrieving token owner
- fn token_owner() -> Weight;
-
/// The price of setting approval for all
fn set_allowance_for_all() -> Weight;
@@ -2029,20 +2009,6 @@
amount: u128,
) -> DispatchResultWithPostInfo;
- /// Burn token and all nested tokens recursievly.
- ///
- /// * `sender` - The user who owns the token.
- /// * `token` - Token id that will burned.
- /// * `self_budget` - The budget that can be spent on burning tokens.
- /// * `breadth_budget` - The budget that can be spent on burning nested tokens.
- fn burn_item_recursively(
- &self,
- sender: T::CrossAccountId,
- token: TokenId,
- self_budget: &dyn Budget,
- breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo;
-
/// Set collection properties.
///
/// * `sender` - Must be either the owner of the collection or its admin.
@@ -2373,14 +2339,6 @@
}
}
}
-
-/// A marker structure that enables the writer implementation
-/// to provide the interface to write properties to **newly created** tokens.
-pub struct NewTokenPropertyWriter;
-
-/// A marker structure that enables the writer implementation
-/// to provide the interface to write properties to **already existing** tokens.
-pub struct ExistingTokenPropertyWriter;
/// The type-safe interface for writing properties (setting or deleting) to tokens.
/// It has two distinct implementations for newly created tokens and existing ones.
@@ -2388,146 +2346,39 @@
/// This type utilizes the lazy evaluation to avoid repeating the computation
/// of several performance-heavy or PoV-heavy tasks,
/// such as checking the indirect ownership or reading the token property permissions.
-pub struct PropertyWriter<
- 'a,
- T,
- Handle,
- WriterVariant,
- FIsAdmin,
- FPropertyPermissions,
- FCheckTokenExist,
- FGetProperties,
-> where
- T: Config,
- FIsAdmin: FnOnce() -> bool,
- FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
-{
+pub struct PropertyWriter<'a, WriterVariant, T, Handle, FIsAdmin, FPropertyPermissions> {
collection: &'a Handle,
- is_collection_admin: LazyValue<bool, FIsAdmin>,
- property_permissions: LazyValue<PropertiesPermissionMap, FPropertyPermissions>,
- check_token_exist: FCheckTokenExist,
- get_properties: FGetProperties,
+ collection_lazy_info: PropertyWriterLazyCollectionInfo<FIsAdmin, FPropertyPermissions>,
_phantom: PhantomData<(T, WriterVariant)>,
}
-impl<'a, T, Handle, FIsAdmin, FPropertyPermissions, FCheckTokenExist, FGetProperties>
- PropertyWriter<
- 'a,
- T,
- Handle,
- NewTokenPropertyWriter,
- FIsAdmin,
- FPropertyPermissions,
- FCheckTokenExist,
- FGetProperties,
- > where
+impl<'a, T, Handle, WriterVariant, FIsAdmin, FPropertyPermissions>
+ PropertyWriter<'a, WriterVariant, T, Handle, FIsAdmin, FPropertyPermissions>
+where
T: Config,
Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
FIsAdmin: FnOnce() -> bool,
FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
- FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,
- FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,
{
- /// A function to write properties to a **newly created** token.
- pub fn write_token_properties(
+ fn internal_write_token_properties<FCheckTokenExist, FCheckTokenOwner, FGetProperties>(
&mut self,
- mint_target_is_sender: bool,
token_id: TokenId,
- properties_updates: impl Iterator<Item = Property>,
- log: evm_coder::ethereum::Log,
- ) -> DispatchResult {
- self.internal_write_token_properties(
- token_id,
- properties_updates.map(|p| (p.key, Some(p.value))),
- |_| Ok(mint_target_is_sender),
- log,
- )
- }
-}
-
-impl<'a, T, Handle, FIsAdmin, FPropertyPermissions, FCheckTokenExist, FGetProperties>
- PropertyWriter<
- 'a,
- T,
- Handle,
- ExistingTokenPropertyWriter,
- FIsAdmin,
- FPropertyPermissions,
- FCheckTokenExist,
- FGetProperties,
- > where
- T: Config,
- Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
- FIsAdmin: FnOnce() -> bool,
- FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
- FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,
- FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,
-{
- /// A function to write properties to an **already existing** token.
- pub fn write_token_properties(
- &mut self,
- sender: &T::CrossAccountId,
- token_id: TokenId,
- properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
- nesting_budget: &dyn Budget,
- log: evm_coder::ethereum::Log,
- ) -> DispatchResult {
- self.internal_write_token_properties(
- token_id,
- properties_updates,
- |collection| collection.check_token_indirect_owner(token_id, sender, nesting_budget),
- log,
- )
- }
-}
-
-impl<
- 'a,
- T,
- Handle,
- WriterVariant,
- FIsAdmin,
- FPropertyPermissions,
- FCheckTokenExist,
- FGetProperties,
- >
- PropertyWriter<
- 'a,
- T,
- Handle,
- WriterVariant,
- FIsAdmin,
- FPropertyPermissions,
- FCheckTokenExist,
- FGetProperties,
- > where
- T: Config,
- Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
- FIsAdmin: FnOnce() -> bool,
- FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
- FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,
- FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,
-{
- fn internal_write_token_properties<FCheckTokenOwner>(
- &mut self,
- token_id: TokenId,
+ mut token_lazy_info: PropertyWriterLazyTokenInfo<
+ FCheckTokenExist,
+ FCheckTokenOwner,
+ FGetProperties,
+ >,
properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
- check_token_owner: FCheckTokenOwner,
log: evm_coder::ethereum::Log,
) -> DispatchResult
where
- FCheckTokenOwner: FnOnce(&Handle) -> Result<bool, DispatchError>,
+ FCheckTokenExist: FnOnce() -> bool,
+ FCheckTokenOwner: FnOnce() -> Result<bool, DispatchError>,
+ FGetProperties: FnOnce() -> TokenProperties,
{
- let get_properties = self.get_properties;
- let mut stored_properties = LazyValue::new(move || get_properties(token_id));
-
- let mut is_token_owner = LazyValue::new(|| check_token_owner(self.collection));
-
- let check_token_exist = self.check_token_exist;
- let mut is_token_exist = LazyValue::new(move || check_token_exist(token_id));
-
for (key, value) in properties_updates {
let permission = self
+ .collection_lazy_info
.property_permissions
.value()
.get(&key)
@@ -2536,7 +2387,11 @@
match permission {
PropertyPermission { mutable: false, .. }
- if stored_properties.value().get(&key).is_some() =>
+ if token_lazy_info
+ .stored_properties
+ .value()
+ .get(&key)
+ .is_some() =>
{
return Err(<Error<T>>::NoPermission.into());
}
@@ -2548,15 +2403,16 @@
} => check_token_permissions::<T, _, _, _>(
collection_admin,
token_owner,
- &mut self.is_collection_admin,
- &mut is_token_owner,
- &mut is_token_exist,
+ &mut self.collection_lazy_info.is_collection_admin,
+ &mut token_lazy_info.is_token_owner,
+ &mut token_lazy_info.is_token_exist,
)?,
}
match value {
Some(value) => {
- stored_properties
+ token_lazy_info
+ .stored_properties
.value_mut()
.try_set(key.clone(), value)
.map_err(<Error<T>>::from)?;
@@ -2568,7 +2424,8 @@
));
}
None => {
- stored_properties
+ token_lazy_info
+ .stored_properties
.value_mut()
.remove(&key)
.map_err(<Error<T>>::from)?;
@@ -2582,142 +2439,330 @@
}
}
- let properties_changed = stored_properties.has_value();
+ let properties_changed = token_lazy_info.stored_properties.has_value();
if properties_changed {
<PalletEvm<T>>::deposit_log(log);
self.collection
- .set_token_properties_raw(token_id, stored_properties.into_inner());
+ .set_token_properties_raw(token_id, token_lazy_info.stored_properties.into_inner());
}
Ok(())
}
}
-/// Create a [`PropertyWriter`] for newly created tokens.
-pub fn property_writer_for_new_token<'a, T, Handle>(
- collection: &'a Handle,
- sender: &'a T::CrossAccountId,
-) -> PropertyWriter<
- 'a,
- T,
- Handle,
- NewTokenPropertyWriter,
- impl FnOnce() -> bool + 'a,
- impl FnOnce() -> PropertiesPermissionMap + 'a,
- impl Copy + FnOnce(TokenId) -> bool + 'a,
- impl Copy + FnOnce(TokenId) -> TokenProperties + 'a,
->
+/// A helper structure for the [`PropertyWriter`] that holds
+/// the collection-related info. The info is loaded using lazy evaluation.
+/// This info is common for any token for which we write properties.
+pub struct PropertyWriterLazyCollectionInfo<FIsAdmin, FPropertyPermissions> {
+ is_collection_admin: LazyValue<bool, FIsAdmin>,
+ property_permissions: LazyValue<PropertiesPermissionMap, FPropertyPermissions>,
+}
+
+/// A helper structure for the [`PropertyWriter`] that holds
+/// the token-related info. The info is loaded using lazy evaluation.
+pub struct PropertyWriterLazyTokenInfo<FCheckTokenExist, FCheckTokenOwner, FGetProperties> {
+ is_token_exist: LazyValue<bool, FCheckTokenExist>,
+ is_token_owner: LazyValue<Result<bool, DispatchError>, FCheckTokenOwner>,
+ stored_properties: LazyValue<TokenProperties, FGetProperties>,
+}
+
+impl<FCheckTokenExist, FCheckTokenOwner, FGetProperties>
+ PropertyWriterLazyTokenInfo<FCheckTokenExist, FCheckTokenOwner, FGetProperties>
where
+ FCheckTokenExist: FnOnce() -> bool,
+ FCheckTokenOwner: FnOnce() -> Result<bool, DispatchError>,
+ FGetProperties: FnOnce() -> TokenProperties,
+{
+ /// Create a lazy token info.
+ pub fn new(
+ check_token_exist: FCheckTokenExist,
+ check_token_owner: FCheckTokenOwner,
+ get_token_properties: FGetProperties,
+ ) -> Self {
+ Self {
+ is_token_exist: LazyValue::new(check_token_exist),
+ is_token_owner: LazyValue::new(check_token_owner),
+ stored_properties: LazyValue::new(get_token_properties),
+ }
+ }
+}
+
+/// A marker structure that enables the writer implementation
+/// to provide the interface to write properties to **newly created** tokens.
+pub struct NewTokenPropertyWriter<T>(PhantomData<T>);
+impl<T: Config> NewTokenPropertyWriter<T> {
+ /// Creates a [`PropertyWriter`] for **newly created** tokens.
+ pub fn new<'a, Handle>(
+ collection: &'a Handle,
+ sender: &'a T::CrossAccountId,
+ ) -> PropertyWriter<
+ 'a,
+ Self,
+ T,
+ Handle,
+ impl FnOnce() -> bool + 'a,
+ impl FnOnce() -> PropertiesPermissionMap + 'a,
+ >
+ where
+ T: Config,
+ Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
+ {
+ PropertyWriter {
+ collection,
+ collection_lazy_info: PropertyWriterLazyCollectionInfo {
+ is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
+ property_permissions: LazyValue::new(|| {
+ <Pallet<T>>::property_permissions(collection.id)
+ }),
+ },
+ _phantom: PhantomData,
+ }
+ }
+}
+
+impl<'a, T, Handle, FIsAdmin, FPropertyPermissions>
+ PropertyWriter<'a, NewTokenPropertyWriter<T>, T, Handle, FIsAdmin, FPropertyPermissions>
+where
T: Config,
Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
+ FIsAdmin: FnOnce() -> bool,
+ FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
{
- PropertyWriter {
- collection,
- is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
- property_permissions: LazyValue::new(|| <Pallet<T>>::property_permissions(collection.id)),
- check_token_exist: |token_id| {
- debug_assert!(collection.token_exists(token_id));
+ /// A function to write properties to a **newly created** token.
+ pub fn write_token_properties(
+ &mut self,
+ mint_target_is_sender: bool,
+ token_id: TokenId,
+ properties_updates: impl Iterator<Item = Property>,
+ log: evm_coder::ethereum::Log,
+ ) -> DispatchResult {
+ let check_token_exist = || {
+ debug_assert!(self.collection.token_exists(token_id));
true
- },
- get_properties: |token_id| {
- debug_assert!(collection.get_token_properties_raw(token_id).is_none());
+ };
+
+ let check_token_owner = || Ok(mint_target_is_sender);
+
+ let get_token_properties = || {
+ debug_assert!(self.collection.get_token_properties_raw(token_id).is_none());
TokenProperties::new()
- },
- _phantom: PhantomData,
+ };
+
+ self.internal_write_token_properties(
+ token_id,
+ PropertyWriterLazyTokenInfo::new(
+ check_token_exist,
+ check_token_owner,
+ get_token_properties,
+ ),
+ properties_updates.map(|p| (p.key, Some(p.value))),
+ log,
+ )
}
}
-#[cfg(feature = "runtime-benchmarks")]
-/// Create a `PropertyWriter` with preloaded `is_collection_admin` and `property_permissions.
-/// Also:
-/// * it will return `true` for the token ownership check.
-/// * it will return empty stored properties without reading them from the storage.
-pub fn collection_info_loaded_property_writer<T, Handle>(
- collection: &Handle,
- is_collection_admin: bool,
- property_permissions: PropertiesPermissionMap,
-) -> PropertyWriter<
- T,
- Handle,
- NewTokenPropertyWriter,
- impl FnOnce() -> bool,
- impl FnOnce() -> PropertiesPermissionMap,
- impl Copy + FnOnce(TokenId) -> bool,
- impl Copy + FnOnce(TokenId) -> TokenProperties,
->
+/// A marker structure that enables the writer implementation
+/// to provide the interface to write properties to **already existing** tokens.
+pub struct ExistingTokenPropertyWriter<T>(PhantomData<T>);
+impl<T: Config> ExistingTokenPropertyWriter<T> {
+ /// Creates a [`PropertyWriter`] for **already existing** tokens.
+ pub fn new<'a, Handle>(
+ collection: &'a Handle,
+ sender: &'a T::CrossAccountId,
+ ) -> PropertyWriter<
+ 'a,
+ Self,
+ T,
+ Handle,
+ impl FnOnce() -> bool + 'a,
+ impl FnOnce() -> PropertiesPermissionMap + 'a,
+ >
+ where
+ Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
+ {
+ PropertyWriter {
+ collection,
+ collection_lazy_info: PropertyWriterLazyCollectionInfo {
+ is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
+ property_permissions: LazyValue::new(|| {
+ <Pallet<T>>::property_permissions(collection.id)
+ }),
+ },
+ _phantom: PhantomData,
+ }
+ }
+}
+
+impl<'a, T, Handle, FIsAdmin, FPropertyPermissions>
+ PropertyWriter<'a, ExistingTokenPropertyWriter<T>, T, Handle, FIsAdmin, FPropertyPermissions>
where
T: Config,
Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
+ FIsAdmin: FnOnce() -> bool,
+ FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
{
- PropertyWriter {
- collection,
- is_collection_admin: LazyValue::new(move || is_collection_admin),
- property_permissions: LazyValue::new(move || property_permissions),
- check_token_exist: |_token_id| true,
- get_properties: |_token_id| TokenProperties::new(),
- _phantom: PhantomData,
+ /// A function to write properties to an **already existing** token.
+ pub fn write_token_properties(
+ &mut self,
+ sender: &T::CrossAccountId,
+ token_id: TokenId,
+ properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
+ nesting_budget: &dyn Budget,
+ log: evm_coder::ethereum::Log,
+ ) -> DispatchResult {
+ let check_token_exist = || self.collection.token_exists(token_id);
+ let check_token_owner = || {
+ self.collection
+ .check_token_indirect_owner(token_id, sender, nesting_budget)
+ };
+ let get_token_properties = || {
+ self.collection
+ .get_token_properties_raw(token_id)
+ .unwrap_or_default()
+ };
+
+ self.internal_write_token_properties(
+ token_id,
+ PropertyWriterLazyTokenInfo::new(
+ check_token_exist,
+ check_token_owner,
+ get_token_properties,
+ ),
+ properties_updates,
+ log,
+ )
}
}
-/// Create a [`PropertyWriter`] for already existing tokens.
-pub fn property_writer_for_existing_token<'a, T, Handle>(
- collection: &'a Handle,
- sender: &'a T::CrossAccountId,
-) -> PropertyWriter<
- 'a,
- T,
- Handle,
- ExistingTokenPropertyWriter,
- impl FnOnce() -> bool + 'a,
- impl FnOnce() -> PropertiesPermissionMap + 'a,
- impl Copy + FnOnce(TokenId) -> bool + 'a,
- impl Copy + FnOnce(TokenId) -> TokenProperties + 'a,
->
+/// A marker structure that enables the writer implementation
+/// to benchmark the token properties writing.
+#[cfg(feature = "runtime-benchmarks")]
+pub struct BenchmarkPropertyWriter<T>(PhantomData<T>);
+
+#[cfg(feature = "runtime-benchmarks")]
+impl<T: Config> BenchmarkPropertyWriter<T> {
+ /// Creates a [`PropertyWriter`] for benchmarking tokens properties writing.
+ pub fn new<'a, Handle, FIsAdmin, FPropertyPermissions>(
+ collection: &Handle,
+ collection_lazy_info: PropertyWriterLazyCollectionInfo<FIsAdmin, FPropertyPermissions>,
+ ) -> PropertyWriter<Self, T, Handle, FIsAdmin, FPropertyPermissions>
+ where
+ Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
+ FIsAdmin: FnOnce() -> bool,
+ FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
+ {
+ PropertyWriter {
+ collection,
+ collection_lazy_info,
+ _phantom: PhantomData,
+ }
+ }
+
+ /// Load the [`PropertyWriterLazyCollectionInfo`] from the storage.
+ pub fn load_collection_info<Handle>(
+ collection_handle: &Handle,
+ sender: &T::CrossAccountId,
+ ) -> PropertyWriterLazyCollectionInfo<
+ impl FnOnce() -> bool,
+ impl FnOnce() -> PropertiesPermissionMap,
+ >
+ where
+ Handle: Deref<Target = CollectionHandle<T>>,
+ {
+ let is_collection_admin = collection_handle.is_owner_or_admin(sender);
+ let property_permissions = <Pallet<T>>::property_permissions(collection_handle.id);
+
+ PropertyWriterLazyCollectionInfo {
+ is_collection_admin: LazyValue::new(move || is_collection_admin),
+ property_permissions: LazyValue::new(move || property_permissions),
+ }
+ }
+
+ /// Load the [`PropertyWriterLazyTokenInfo`] with token properties from the storage.
+ pub fn load_token_properties<Handle>(
+ collection: &Handle,
+ token_id: TokenId,
+ ) -> PropertyWriterLazyTokenInfo<
+ impl FnOnce() -> bool,
+ impl FnOnce() -> Result<bool, DispatchError>,
+ impl FnOnce() -> TokenProperties,
+ >
+ where
+ Handle: CommonCollectionOperations<T>,
+ {
+ let stored_properties = collection
+ .get_token_properties_raw(token_id)
+ .unwrap_or_default();
+
+ PropertyWriterLazyTokenInfo {
+ is_token_exist: LazyValue::new(|| true),
+ is_token_owner: LazyValue::new(|| Ok(true)),
+ stored_properties: LazyValue::new(move || stored_properties),
+ }
+ }
+}
+
+#[cfg(feature = "runtime-benchmarks")]
+impl<'a, T, Handle, FIsAdmin, FPropertyPermissions>
+ PropertyWriter<'a, BenchmarkPropertyWriter<T>, T, Handle, FIsAdmin, FPropertyPermissions>
where
T: Config,
Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
+ FIsAdmin: FnOnce() -> bool,
+ FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
{
- PropertyWriter {
- collection,
- is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
- property_permissions: LazyValue::new(|| <Pallet<T>>::property_permissions(collection.id)),
- check_token_exist: |token_id| collection.token_exists(token_id),
- get_properties: |token_id| {
- collection
- .get_token_properties_raw(token_id)
- .unwrap_or_default()
- },
- _phantom: PhantomData,
+ /// A function to benchmark the writing of token properties.
+ pub fn write_token_properties(
+ &mut self,
+ token_id: TokenId,
+ properties_updates: impl Iterator<Item = Property>,
+ log: evm_coder::ethereum::Log,
+ ) -> DispatchResult {
+ let check_token_exist = || true;
+ let check_token_owner = || Ok(true);
+ let get_token_properties = || TokenProperties::new();
+
+ self.internal_write_token_properties(
+ token_id,
+ PropertyWriterLazyTokenInfo::new(
+ check_token_exist,
+ check_token_owner,
+ get_token_properties,
+ ),
+ properties_updates.map(|p| (p.key, Some(p.value))),
+ log,
+ )
}
}
-/// Computes the weight delta for newly created tokens with properties.
+/// Computes the weight of writing properties to tokens.
/// * `properties_nums` - The properties num of each created token.
-/// * `init_token_properties` - The function to obtain the weight from a token's properties num.
-pub fn init_token_properties_delta<T: Config, I: Fn(u32) -> Weight>(
+/// * `per_token_weight_weight` - The function to obtain the weight
+/// of writing properties from a token's properties num.
+pub fn write_token_properties_total_weight<T: Config, I: Fn(u32) -> Weight>(
properties_nums: impl Iterator<Item = u32>,
- init_token_properties: I,
+ per_token_weight: I,
) -> Weight {
- let mut delta = properties_nums
+ let mut weight = properties_nums
.filter_map(|properties_num| {
if properties_num > 0 {
- Some(init_token_properties(properties_num))
+ Some(per_token_weight(properties_num))
} else {
None
}
})
.fold(Weight::zero(), |a, b| a.saturating_add(b));
- // If at least once the `init_token_properties` was called,
- // it means at least one newly created token has properties.
- // Becuase of that, some common collection data also was loaded and we need to add this weight.
- // However, these common data was loaded only once which is guaranteed by the `PropertyWriter`.
- if !delta.is_zero() {
- delta = delta.saturating_add(<SelfWeightOf<T>>::init_token_properties_common())
+ if !weight.is_zero() {
+ // If we are here, it means the token properties were written at least once.
+ // Because of that, some common collection data was also loaded; we must add this weight.
+ // However, this common data was loaded only once, which is guaranteed by the `PropertyWriter`.
+
+ weight = weight.saturating_add(<SelfWeightOf<T>>::property_writer_load_collection_info());
}
- delta
+ weight
}
#[cfg(any(feature = "tests", test))]
pallets/common/src/weights.rsdiffbeforeafterboth--- a/pallets/common/src/weights.rs
+++ b/pallets/common/src/weights.rs
@@ -3,9 +3,9 @@
//! Autogenerated weights for pallet_common
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-09-30, STEPS: `50`, REPEAT: `400`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-10-05, STEPS: `50`, REPEAT: `80`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `bench-host`, CPU: `Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz`
+//! HOSTNAME: `hearthstone`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor`
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
// Executed Command:
@@ -20,7 +20,7 @@
// *
// --template=.maintain/frame-weight-template.hbs
// --steps=50
-// --repeat=400
+// --repeat=80
// --heap-pages=4096
// --output=./pallets/common/src/weights.rs
@@ -36,7 +36,7 @@
fn set_collection_properties(b: u32, ) -> Weight;
fn delete_collection_properties(b: u32, ) -> Weight;
fn check_accesslist() -> Weight;
- fn init_token_properties_common() -> Weight;
+ fn property_writer_load_collection_info() -> Weight;
}
/// Weights for pallet_common using the Substrate node and recommended hardware.
@@ -49,10 +49,10 @@
// Proof Size summary in bytes:
// Measured: `298`
// Estimated: `44457`
- // Minimum execution time: 4_987_000 picoseconds.
- Weight::from_parts(5_119_000, 44457)
- // Standard Error: 7_609
- .saturating_add(Weight::from_parts(5_750_459, 0).saturating_mul(b.into()))
+ // Minimum execution time: 2_840_000 picoseconds.
+ Weight::from_parts(1_988_405, 44457)
+ // Standard Error: 7_834
+ .saturating_add(Weight::from_parts(3_053_965, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -63,10 +63,10 @@
// Proof Size summary in bytes:
// Measured: `303 + b * (33030 ±0)`
// Estimated: `44457`
- // Minimum execution time: 4_923_000 picoseconds.
- Weight::from_parts(5_074_000, 44457)
- // Standard Error: 36_651
- .saturating_add(Weight::from_parts(23_145_677, 0).saturating_mul(b.into()))
+ // Minimum execution time: 2_770_000 picoseconds.
+ Weight::from_parts(2_940_000, 44457)
+ // Standard Error: 30_686
+ .saturating_add(Weight::from_parts(9_801_835, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -76,20 +76,20 @@
// Proof Size summary in bytes:
// Measured: `373`
// Estimated: `3535`
- // Minimum execution time: 4_271_000 picoseconds.
- Weight::from_parts(4_461_000, 3535)
+ // Minimum execution time: 2_830_000 picoseconds.
+ Weight::from_parts(2_950_000, 3535)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: Common IsAdmin (r:1 w:0)
/// Proof: Common IsAdmin (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)
/// Storage: Common CollectionPropertyPermissions (r:1 w:0)
/// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- fn init_token_properties_common() -> Weight {
+ fn property_writer_load_collection_info() -> Weight {
// Proof Size summary in bytes:
// Measured: `326`
// Estimated: `20191`
- // Minimum execution time: 5_889_000 picoseconds.
- Weight::from_parts(6_138_000, 20191)
+ // Minimum execution time: 3_970_000 picoseconds.
+ Weight::from_parts(4_140_000, 20191)
.saturating_add(T::DbWeight::get().reads(2_u64))
}
}
@@ -103,10 +103,10 @@
// Proof Size summary in bytes:
// Measured: `298`
// Estimated: `44457`
- // Minimum execution time: 4_987_000 picoseconds.
- Weight::from_parts(5_119_000, 44457)
- // Standard Error: 7_609
- .saturating_add(Weight::from_parts(5_750_459, 0).saturating_mul(b.into()))
+ // Minimum execution time: 2_840_000 picoseconds.
+ Weight::from_parts(1_988_405, 44457)
+ // Standard Error: 7_834
+ .saturating_add(Weight::from_parts(3_053_965, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -117,10 +117,10 @@
// Proof Size summary in bytes:
// Measured: `303 + b * (33030 ±0)`
// Estimated: `44457`
- // Minimum execution time: 4_923_000 picoseconds.
- Weight::from_parts(5_074_000, 44457)
- // Standard Error: 36_651
- .saturating_add(Weight::from_parts(23_145_677, 0).saturating_mul(b.into()))
+ // Minimum execution time: 2_770_000 picoseconds.
+ Weight::from_parts(2_940_000, 44457)
+ // Standard Error: 30_686
+ .saturating_add(Weight::from_parts(9_801_835, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -130,20 +130,20 @@
// Proof Size summary in bytes:
// Measured: `373`
// Estimated: `3535`
- // Minimum execution time: 4_271_000 picoseconds.
- Weight::from_parts(4_461_000, 3535)
+ // Minimum execution time: 2_830_000 picoseconds.
+ Weight::from_parts(2_950_000, 3535)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: Common IsAdmin (r:1 w:0)
/// Proof: Common IsAdmin (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)
/// Storage: Common CollectionPropertyPermissions (r:1 w:0)
/// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- fn init_token_properties_common() -> Weight {
+ fn property_writer_load_collection_info() -> Weight {
// Proof Size summary in bytes:
// Measured: `326`
// Estimated: `20191`
- // Minimum execution time: 5_889_000 picoseconds.
- Weight::from_parts(6_138_000, 20191)
+ // Minimum execution time: 3_970_000 picoseconds.
+ Weight::from_parts(4_140_000, 20191)
.saturating_add(RocksDbWeight::get().reads(2_u64))
}
}
pallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-coder-substrate/src/lib.rs
+++ b/pallets/evm-coder-substrate/src/lib.rs
@@ -84,7 +84,7 @@
}
impl<T: Config> budget::Budget for GasCallsBudget<'_, T> {
fn consume_custom(&self, calls: u32) -> bool {
- let (gas, overflown) = (calls as u64).overflowing_add(self.gas_per_call);
+ let (gas, overflown) = (calls as u64).overflowing_mul(self.gas_per_call);
if overflown {
return false;
}
pallets/foreign-assets/src/impl_fungibles.rsdiffbeforeafterboth--- a/pallets/foreign-assets/src/impl_fungibles.rs
+++ b/pallets/foreign-assets/src/impl_fungibles.rs
@@ -23,7 +23,7 @@
use pallet_common::{CollectionHandle, CommonCollectionOperations};
use pallet_fungible::FungibleHandle;
use sp_runtime::traits::{CheckedAdd, CheckedSub};
-use up_data_structs::budget::Value;
+use up_data_structs::budget;
use super::*;
@@ -327,7 +327,7 @@
&collection,
&account,
amount_data,
- &Value::new(0),
+ &budget::Value::new(0),
)?;
Ok(amount)
@@ -440,7 +440,7 @@
&T::CrossAccountId::from_sub(source.clone()),
&T::CrossAccountId::from_sub(dest.clone()),
amount.into(),
- &Value::new(0),
+ &budget::Value::new(0),
)
.map_err(|e| e.error)?;
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -16,14 +16,11 @@
use core::marker::PhantomData;
-use frame_support::{
- dispatch::DispatchResultWithPostInfo, ensure, fail, traits::Get, weights::Weight,
-};
+use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
use pallet_common::{
weights::WeightInfo as _, with_weight, CommonCollectionOperations, CommonWeightInfo,
RefungibleExtensions, SelfWeightOf as PalletCommonWeightOf,
};
-use pallet_structure::Error as StructureError;
use sp_runtime::{ArithmeticError, DispatchError};
use sp_std::{vec, vec::Vec};
use up_data_structs::{
@@ -58,18 +55,9 @@
fn set_collection_properties(amount: u32) -> Weight {
<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)
- }
-
- fn delete_collection_properties(amount: u32) -> Weight {
- <pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)
}
fn set_token_properties(_amount: u32) -> Weight {
- // Error
- Weight::zero()
- }
-
- fn delete_token_properties(_amount: u32) -> Weight {
// Error
Weight::zero()
}
@@ -80,7 +68,8 @@
}
fn transfer() -> Weight {
- <SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
+ <SelfWeightOf<T>>::transfer_raw()
+ .saturating_add(<PalletCommonWeightOf<T>>::check_accesslist().saturating_mul(2))
}
fn approve() -> Weight {
@@ -93,28 +82,14 @@
fn transfer_from() -> Weight {
Self::transfer()
- + <SelfWeightOf<T>>::check_allowed_raw()
- + <SelfWeightOf<T>>::set_allowance_unchecked_raw()
+ .saturating_add(<SelfWeightOf<T>>::check_allowed_raw())
+ .saturating_add(<SelfWeightOf<T>>::set_allowance_unchecked_raw())
}
fn burn_from() -> Weight {
<SelfWeightOf<T>>::burn_from()
}
- fn burn_recursively_self_raw() -> Weight {
- // Read to get total balance
- Self::burn_item() + T::DbWeight::get().reads(1)
- }
-
- fn burn_recursively_breadth_raw(_amount: u32) -> Weight {
- // Fungible tokens can't have children
- Weight::zero()
- }
-
- fn token_owner() -> Weight {
- Weight::zero()
- }
-
fn set_allowance_for_all() -> Weight {
Weight::zero()
}
@@ -200,26 +175,6 @@
with_weight(
<Pallet<T>>::burn(self, &sender, amount),
<CommonWeights<T>>::burn_item(),
- )
- }
-
- fn burn_item_recursively(
- &self,
- sender: T::CrossAccountId,
- token: TokenId,
- self_budget: &dyn Budget,
- _breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo {
- // Should not happen?
- ensure!(
- token == TokenId::default(),
- <Error<T>>::FungibleItemsHaveNoId
- );
- ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
-
- with_weight(
- <Pallet<T>>::burn(self, &sender, <Balance<T>>::get((self.id, &sender))),
- <CommonWeights<T>>::burn_recursively_self_raw(),
)
}
pallets/fungible/src/erc.rsdiffbeforeafterboth--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -32,12 +32,12 @@
use pallet_evm_coder_substrate::{
call, dispatch_to_evm,
execution::{PreDispatch, Result},
- frontier_contract,
+ frontier_contract, SubstrateRecorder,
};
use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
use sp_core::{Get, U256};
use sp_std::vec::Vec;
-use up_data_structs::CollectionMode;
+use up_data_structs::{budget::Budget, CollectionMode};
use crate::{
common::CommonWeights, weights::WeightInfo, Allowance, Balance, Config, FungibleHandle, Pallet,
@@ -73,6 +73,10 @@
amount: U256,
}
+fn nesting_budget<T: Config>(recorder: &SubstrateRecorder<T>) -> impl Budget + '_ {
+ recorder.weight_calls_budget(<StructureWeight<T>>::find_parent())
+}
+
#[solidity_interface(name = ERC20, events(ERC20Events), enum(derive(PreDispatch)), enum_attr(weight), expect_selector = 0x942e8b22)]
impl<T: Config> FungibleHandle<T> {
fn name(&self) -> Result<String> {
@@ -106,11 +110,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, amount, &budget)
+ <Pallet<T>>::transfer(self, &caller, &to, amount, &nesting_budget(&self.recorder))
.map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(true)
}
@@ -127,12 +128,16 @@
let from = T::CrossAccountId::from_eth(from);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
- .map_err(|e| dispatch_to_evm::<T>(e.error))?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(true)
}
#[weight(<SelfWeightOf<T>>::approve())]
@@ -164,10 +169,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::create_item(self, &caller, (to, amount), &budget)
+
+ <Pallet<T>>::create_item(self, &caller, (to, amount), &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -201,10 +204,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::create_item(self, &caller, (to, amount), &budget)
+
+ <Pallet<T>>::create_item(self, &caller, (to, amount), &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -236,12 +237,15 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -260,12 +264,15 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = from.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -274,9 +281,6 @@
#[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]
fn mint_bulk(&mut self, caller: Caller, amounts: Vec<AmountForAddress>) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let amounts = amounts
.into_iter()
.map(|AmountForAddress { to, amount }| {
@@ -287,7 +291,7 @@
})
.collect::<Result<_>>()?;
- <Pallet<T>>::create_multiple_items(self, &caller, amounts, &budget)
+ <Pallet<T>>::create_multiple_items(self, &caller, amounts, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -297,11 +301,9 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;
+ <Pallet<T>>::transfer(self, &caller, &to, amount, &nesting_budget(&self.recorder))
+ .map_err(|_| "transfer error")?;
Ok(true)
}
@@ -317,12 +319,16 @@
let from = from.into_sub_cross_account::<T>()?;
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
- .map_err(|e| dispatch_to_evm::<T>(e.error))?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(true)
}
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -262,9 +262,82 @@
{
<Pallet<T>>::burn_from(&collection, &burner, &sender, item, &Unlimited)?;
}
+ }
- Ok(())
- }
+ // set_token_properties {
+ // let b in 0..MAX_PROPERTIES_PER_ITEM;
+ // bench_init!{
+ // owner: sub; collection: collection(owner);
+ // owner: cross_from_sub;
+ // };
+ // let perms = (0..b).map(|k| PropertyKeyPermission {
+ // key: property_key(k as usize),
+ // permission: PropertyPermission {
+ // mutable: false,
+ // collection_admin: true,
+ // token_owner: true,
+ // },
+ // }).collect::<Vec<_>>();
+ // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+ // let props = (0..b).map(|k| Property {
+ // key: property_key(k as usize),
+ // value: property_value(),
+ // }).collect::<Vec<_>>();
+ // let item = create_max_item(&collection, &owner, owner.clone())?;
+ // }: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props.into_iter(), &Unlimited)?}
+
+ // load_token_properties {
+ // bench_init!{
+ // owner: sub; collection: collection(owner);
+ // owner: cross_from_sub;
+ // };
+
+ // let item = create_max_item(&collection, &owner, owner.clone())?;
+ // }: {
+ // pallet_common::BenchmarkPropertyWriter::<T>::load_token_properties(
+ // &collection,
+ // item,
+ // )
+ // }
+
+ // write_token_properties {
+ // let b in 0..MAX_PROPERTIES_PER_ITEM;
+ // bench_init!{
+ // owner: sub; collection: collection(owner);
+ // owner: cross_from_sub;
+ // };
+
+ // let perms = (0..b).map(|k| PropertyKeyPermission {
+ // key: property_key(k as usize),
+ // permission: PropertyPermission {
+ // mutable: false,
+ // collection_admin: true,
+ // token_owner: true,
+ // },
+ // }).collect::<Vec<_>>();
+ // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+ // let props = (0..b).map(|k| Property {
+ // key: property_key(k as usize),
+ // value: property_value(),
+ // }).collect::<Vec<_>>();
+ // let item = create_max_item(&collection, &owner, owner.clone())?;
+
+ // let lazy_collection_info = pallet_common::BenchmarkPropertyWriter::<T>::load_collection_info(
+ // &collection,
+ // &owner,
+ // );
+ // }: {
+ // let mut property_writer = pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
+
+ // property_writer.write_token_properties(
+ // item,
+ // props.into_iter(),
+ // crate::erc::ERC721TokenEvent::TokenChanged {
+ // token_id: item.into(),
+ // }
+ // .to_log(T::ContractAddress::get()),
+ // )?
+ // }
#[benchmark]
fn set_token_property_permissions(
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -18,8 +18,9 @@
use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
use pallet_common::{
- init_token_properties_delta, weights::WeightInfo as _, with_weight, CommonCollectionOperations,
- CommonWeightInfo, RefungibleExtensions, SelfWeightOf as PalletCommonWeightOf,
+ weights::WeightInfo as _, with_weight, write_token_properties_total_weight,
+ CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions,
+ SelfWeightOf as PalletCommonWeightOf,
};
use pallet_structure::Pallet as PalletStructure;
use sp_runtime::DispatchError;
@@ -39,9 +40,9 @@
fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
match data {
CreateItemExData::NFT(t) => <SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)
- .saturating_add(init_token_properties_delta::<T, _>(
+ .saturating_add(write_token_properties_total_weight::<T, _>(
t.iter().map(|t| t.properties.len() as u32),
- <SelfWeightOf<T>>::init_token_properties,
+ <SelfWeightOf<T>>::write_token_properties,
)),
_ => Weight::zero(),
}
@@ -49,12 +50,12 @@
fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {
<SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(
- init_token_properties_delta::<T, _>(
+ write_token_properties_total_weight::<T, _>(
data.iter().map(|t| match t {
up_data_structs::CreateItemData::NFT(n) => n.properties.len() as u32,
_ => 0,
}),
- <SelfWeightOf<T>>::init_token_properties,
+ <SelfWeightOf<T>>::write_token_properties,
),
)
}
@@ -67,16 +68,15 @@
<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)
}
- fn delete_collection_properties(amount: u32) -> Weight {
- <pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)
- }
-
fn set_token_properties(amount: u32) -> Weight {
- <SelfWeightOf<T>>::set_token_properties(amount)
+ write_token_properties_total_weight::<T, _>([amount].into_iter(), |amount| {
+ <SelfWeightOf<T>>::load_token_properties()
+ .saturating_add(<SelfWeightOf<T>>::write_token_properties(amount))
+ })
}
fn delete_token_properties(amount: u32) -> Weight {
- <SelfWeightOf<T>>::delete_token_properties(amount)
+ Self::set_token_properties(amount)
}
fn set_token_property_permissions(amount: u32) -> Weight {
@@ -84,7 +84,8 @@
}
fn transfer() -> Weight {
- <SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
+ <SelfWeightOf<T>>::transfer_raw()
+ .saturating_add(<PalletCommonWeightOf<T>>::check_accesslist().saturating_mul(2))
}
fn approve() -> Weight {
@@ -96,24 +97,11 @@
}
fn transfer_from() -> Weight {
- Self::transfer() + <SelfWeightOf<T>>::check_allowed_raw()
+ Self::transfer().saturating_add(<SelfWeightOf<T>>::check_allowed_raw())
}
fn burn_from() -> Weight {
<SelfWeightOf<T>>::burn_from()
- }
-
- fn burn_recursively_self_raw() -> Weight {
- <SelfWeightOf<T>>::burn_recursively_self_raw()
- }
-
- fn burn_recursively_breadth_raw(amount: u32) -> Weight {
- <SelfWeightOf<T>>::burn_recursively_breadth_plus_self_plus_self_per_each_raw(amount)
- .saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))
- }
-
- fn token_owner() -> Weight {
- <SelfWeightOf<T>>::token_owner()
}
fn set_allowance_for_all() -> Weight {
@@ -306,16 +294,6 @@
<Pallet<T>>::check_token_immediate_ownership(self, token, &sender)?;
Ok(().into())
}
- }
-
- fn burn_item_recursively(
- &self,
- sender: T::CrossAccountId,
- token: TokenId,
- self_budget: &dyn Budget,
- breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo {
- <Pallet<T>>::burn_recursively(self, &sender, token, self_budget, breadth_budget)
}
fn transfer(
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -38,14 +38,14 @@
use pallet_evm_coder_substrate::{
call, dispatch_to_evm,
execution::{Error, PreDispatch, Result},
- frontier_contract,
+ frontier_contract, SubstrateRecorder,
};
use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
use sp_core::{Get, U256};
use sp_std::{vec, vec::Vec};
use up_data_structs::{
- CollectionId, CollectionPropertiesVec, Property, PropertyKey, PropertyKeyPermission,
- PropertyPermission, TokenId,
+ budget::Budget, CollectionId, CollectionPropertiesVec, Property, PropertyKey,
+ PropertyKeyPermission, PropertyPermission, TokenId,
};
use crate::{
@@ -78,6 +78,10 @@
impl<T: Config> Contract for NonfungibleHandle<T> {...}
}
+fn nesting_budget<T: Config>(recorder: &SubstrateRecorder<T>) -> impl Budget + '_ {
+ recorder.weight_calls_budget(<StructureWeight<T>>::find_parent())
+}
+
/// @title A contract that allows to set and delete token properties and change token property permissions.
#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]
impl<T: Config> NonfungibleHandle<T> {
@@ -146,7 +150,7 @@
/// @param key Property key.
/// @param value Property value.
#[solidity(hide)]
- #[weight(<SelfWeightOf<T>>::set_token_properties(1))]
+ #[weight(<CommonWeights<T>>::set_token_properties(1))]
fn set_property(
&mut self,
caller: Caller,
@@ -161,16 +165,12 @@
.map_err(|_| "key too long")?;
let value = value.0.try_into().map_err(|_| "value too long")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
<Pallet<T>>::set_token_property(
self,
&caller,
TokenId(token_id),
Property { key, value },
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -179,7 +179,7 @@
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
/// @param properties settable properties
- #[weight(<SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
+ #[weight(<CommonWeights<T>>::set_token_properties(properties.len() as u32))]
fn set_properties(
&mut self,
caller: Caller,
@@ -189,10 +189,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
let properties = properties
.into_iter()
.map(eth::Property::try_into)
@@ -203,7 +199,7 @@
&caller,
TokenId(token_id),
properties.into_iter(),
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -213,7 +209,7 @@
/// @param tokenId ID of the token.
/// @param key Property key.
#[solidity(hide)]
- #[weight(<SelfWeightOf<T>>::delete_token_properties(1))]
+ #[weight(<CommonWeights<T>>::delete_token_properties(1))]
fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
@@ -221,19 +217,21 @@
.try_into()
.map_err(|_| "key too long")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
- <Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)
- .map_err(dispatch_to_evm::<T>)
+ <Pallet<T>>::delete_token_property(
+ self,
+ &caller,
+ TokenId(token_id),
+ key,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)
}
/// @notice Delete token properties value.
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
/// @param keys Properties key.
- #[weight(<SelfWeightOf<T>>::delete_token_properties(keys.len() as u32))]
+ #[weight(<CommonWeights<T>>::delete_token_properties(keys.len() as u32))]
fn delete_properties(
&mut self,
token_id: U256,
@@ -247,16 +245,12 @@
.map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))
.collect::<Result<Vec<_>>>()?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
<Pallet<T>>::delete_token_properties(
self,
&caller,
TokenId(token_id),
keys.into_iter(),
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -481,12 +475,16 @@
let from = T::CrossAccountId::from_eth(from);
let to = T::CrossAccountId::from_eth(to);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, token, &budget)
- .map_err(|e| dispatch_to_evm::<T>(e.error))?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ token,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(())
}
@@ -594,9 +592,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
if <TokensMinted<T>>::get(self.id)
.checked_add(1)
@@ -613,7 +608,7 @@
properties: BoundedVec::default(),
owner: to,
},
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
@@ -664,9 +659,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
if <TokensMinted<T>>::get(self.id)
.checked_add(1)
@@ -694,7 +686,7 @@
properties,
owner: to,
},
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
@@ -840,11 +832,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, token, &budget)
+ <Pallet<T>>::transfer(self, &caller, &to, token, &nesting_budget(&self.recorder))
.map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(())
}
@@ -864,11 +853,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, token, &budget)
+ <Pallet<T>>::transfer(self, &caller, &to, token, &nesting_budget(&self.recorder))
.map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(())
}
@@ -891,11 +877,16 @@
let from = from.into_sub_cross_account::<T>()?;
let to = to.into_sub_cross_account::<T>()?;
let token_id = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, &budget)
- .map_err(|e| dispatch_to_evm::<T>(e.error))?;
+
+ Pallet::<T>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ token_id,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(())
}
@@ -911,11 +902,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, token, &budget)
+ <Pallet<T>>::burn_from(self, &caller, &from, token, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -936,11 +924,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = from.into_sub_cross_account::<T>()?;
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, token, &budget)
+ <Pallet<T>>::burn_from(self, &caller, &from, token, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -966,9 +951,6 @@
let mut expected_index = <TokensMinted<T>>::get(self.id)
.checked_add(1)
.ok_or("item id overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let total_tokens = token_ids.len();
for id in token_ids.into_iter() {
@@ -985,7 +967,7 @@
})
.collect();
- <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)
+ <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -995,9 +977,6 @@
#[weight(<SelfWeightOf<T>>::create_multiple_items(data.len() as u32) + <SelfWeightOf<T>>::set_token_properties(data.len() as u32))]
fn mint_bulk_cross(&mut self, caller: Caller, data: Vec<MintTokenData>) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let mut create_nft_data = Vec::with_capacity(data.len());
for MintTokenData { owner, properties } in data {
@@ -1013,8 +992,13 @@
});
}
- <Pallet<T>>::create_multiple_items(self, &caller, create_nft_data, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::create_multiple_items(
+ self,
+ &caller,
+ create_nft_data,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -1037,9 +1021,6 @@
let mut expected_index = <TokensMinted<T>>::get(self.id)
.checked_add(1)
.ok_or("item id overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let mut data = Vec::with_capacity(tokens.len());
for TokenUri { id, uri } in tokens {
@@ -1066,7 +1047,7 @@
});
}
- <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)
+ <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -1096,10 +1077,6 @@
.map_err(|_| Error::Revert("too many properties".to_string()))?;
let caller = T::CrossAccountId::from_eth(caller);
-
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
<Pallet<T>>::create_item(
self,
@@ -1108,7 +1085,7 @@
properties,
owner: to,
},
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -109,7 +109,7 @@
};
use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
-use pallet_structure::{Error as StructureError, Pallet as PalletStructure};
+use pallet_structure::Pallet as PalletStructure;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::{Get, H160};
@@ -502,52 +502,7 @@
));
Ok(())
}
-
- /// Same as [`burn`] but burns all the tokens that are nested in the token first
- ///
- /// - `self_budget`: Limit for searching children in depth.
- /// - `breadth_budget`: Limit of breadth of searching children.
- ///
- /// [`burn`]: struct.Pallet.html#method.burn
- #[transactional]
- pub fn burn_recursively(
- collection: &NonfungibleHandle<T>,
- sender: &T::CrossAccountId,
- token: TokenId,
- self_budget: &dyn Budget,
- breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo {
- ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
- let current_token_account =
- T::CrossTokenAddressMapping::token_to_address(collection.id, token);
-
- let mut weight = Weight::zero();
-
- // This method is transactional, if user in fact doesn't have permissions to remove token -
- // tokens removed here will be restored after rejected transaction
- for ((collection, token), _) in <TokenChildren<T>>::iter_prefix((collection.id, token)) {
- ensure!(breadth_budget.consume(), <StructureError<T>>::BreadthLimit,);
- let PostDispatchInfo { actual_weight, .. } =
- <PalletStructure<T>>::burn_item_recursively(
- current_token_account.clone(),
- collection,
- token,
- self_budget,
- breadth_budget,
- )?;
- if let Some(actual_weight) = actual_weight {
- weight = weight.saturating_add(actual_weight);
- }
- }
-
- Self::burn(collection, sender, token)?;
- DispatchResultWithPostInfo::Ok(PostDispatchInfo {
- actual_weight: Some(weight + <SelfWeightOf<T>>::burn_item()),
- pays_fee: Pays::Yes,
- })
- }
-
/// A batch operation to add, edit or remove properties for a token.
///
/// - `nesting_budget`: Limit for searching parents in-depth to check ownership.
@@ -568,7 +523,7 @@
nesting_budget: &dyn Budget,
) -> DispatchResult {
let mut property_writer =
- pallet_common::property_writer_for_existing_token(collection, sender);
+ pallet_common::ExistingTokenPropertyWriter::new(collection, sender);
property_writer.write_token_properties(
sender,
@@ -915,7 +870,7 @@
// =========
- let mut property_writer = pallet_common::property_writer_for_new_token(collection, sender);
+ let mut property_writer = pallet_common::NewTokenPropertyWriter::new(collection, sender);
with_transaction(|| {
for (i, data) in data.iter().enumerate() {
pallets/nonfungible/src/weights.rsdiffbeforeafterboth1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_nonfungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2023-09-30, STEPS: `50`, REPEAT: `400`, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! WORST CASE MAP SIZE: `1000000`8//! HOSTNAME: `bench-host`, CPU: `Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz`9//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10241011// Executed Command:12// target/production/unique-collator13// benchmark14// pallet15// --pallet16// pallet-nonfungible17// --wasm-execution18// compiled19// --extrinsic20// *21// --template=.maintain/frame-weight-template.hbs22// --steps=5023// --repeat=40024// --heap-pages=409625// --output=./pallets/nonfungible/src/weights.rs2627#![cfg_attr(rustfmt, rustfmt_skip)]28#![allow(unused_parens)]29#![allow(unused_imports)]3031use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};32use sp_std::marker::PhantomData;3334/// Weight functions needed for pallet_nonfungible.35pub trait WeightInfo {36 fn create_item() -> Weight;37 fn create_multiple_items(b: u32, ) -> Weight;38 fn create_multiple_items_ex(b: u32, ) -> Weight;39 fn burn_item() -> Weight;40 fn burn_recursively_self_raw() -> Weight;41 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight;42 fn transfer_raw() -> Weight;43 fn approve() -> Weight;44 fn approve_from() -> Weight;45 fn check_allowed_raw() -> Weight;46 fn burn_from() -> Weight;47 fn set_token_property_permissions(b: u32, ) -> Weight;48 fn set_token_properties(b: u32, ) -> Weight;49 fn init_token_properties(b: u32, ) -> Weight;50 fn delete_token_properties(b: u32, ) -> Weight;51 fn token_owner() -> Weight;52 fn set_allowance_for_all() -> Weight;53 fn allowance_for_all() -> Weight;54 fn repair_item() -> Weight;55}5657/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.58pub struct SubstrateWeight<T>(PhantomData<T>);59impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {60 /// Storage: Nonfungible TokensMinted (r:1 w:1)61 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)62 /// Storage: Nonfungible AccountBalance (r:1 w:1)63 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)64 /// Storage: Nonfungible TokenData (r:0 w:1)65 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)66 /// Storage: Nonfungible Owned (r:0 w:1)67 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)68 fn create_item() -> Weight {69 // Proof Size summary in bytes:70 // Measured: `142`71 // Estimated: `3530`72 // Minimum execution time: 9_726_000 picoseconds.73 Weight::from_parts(10_059_000, 3530)74 .saturating_add(T::DbWeight::get().reads(2_u64))75 .saturating_add(T::DbWeight::get().writes(4_u64))76 }77 /// Storage: Nonfungible TokensMinted (r:1 w:1)78 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)79 /// Storage: Nonfungible AccountBalance (r:1 w:1)80 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)81 /// Storage: Nonfungible TokenData (r:0 w:200)82 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)83 /// Storage: Nonfungible Owned (r:0 w:200)84 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)85 /// The range of component `b` is `[0, 200]`.86 fn create_multiple_items(b: u32, ) -> Weight {87 // Proof Size summary in bytes:88 // Measured: `142`89 // Estimated: `3530`90 // Minimum execution time: 3_270_000 picoseconds.91 Weight::from_parts(3_693_659, 3530)92 // Standard Error: 25593 .saturating_add(Weight::from_parts(3_024_284, 0).saturating_mul(b.into()))94 .saturating_add(T::DbWeight::get().reads(2_u64))95 .saturating_add(T::DbWeight::get().writes(2_u64))96 .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(b.into())))97 }98 /// Storage: Nonfungible TokensMinted (r:1 w:1)99 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)100 /// Storage: Nonfungible AccountBalance (r:200 w:200)101 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)102 /// Storage: Nonfungible TokenData (r:0 w:200)103 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)104 /// Storage: Nonfungible Owned (r:0 w:200)105 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)106 /// The range of component `b` is `[0, 200]`.107 fn create_multiple_items_ex(b: u32, ) -> Weight {108 // Proof Size summary in bytes:109 // Measured: `142`110 // Estimated: `3481 + b * (2540 ±0)`111 // Minimum execution time: 3_188_000 picoseconds.112 Weight::from_parts(3_307_000, 3481)113 // Standard Error: 567114 .saturating_add(Weight::from_parts(4_320_449, 0).saturating_mul(b.into()))115 .saturating_add(T::DbWeight::get().reads(1_u64))116 .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))117 .saturating_add(T::DbWeight::get().writes(1_u64))118 .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into())))119 .saturating_add(Weight::from_parts(0, 2540).saturating_mul(b.into()))120 }121 /// Storage: Nonfungible TokenData (r:1 w:1)122 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)123 /// Storage: Nonfungible TokenChildren (r:1 w:0)124 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)125 /// Storage: Nonfungible TokensBurnt (r:1 w:1)126 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)127 /// Storage: Nonfungible AccountBalance (r:1 w:1)128 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)129 /// Storage: Nonfungible Allowance (r:1 w:0)130 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)131 /// Storage: Nonfungible Owned (r:0 w:1)132 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)133 /// Storage: Nonfungible TokenProperties (r:0 w:1)134 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)135 fn burn_item() -> Weight {136 // Proof Size summary in bytes:137 // Measured: `380`138 // Estimated: `3530`139 // Minimum execution time: 18_062_000 picoseconds.140 Weight::from_parts(18_433_000, 3530)141 .saturating_add(T::DbWeight::get().reads(5_u64))142 .saturating_add(T::DbWeight::get().writes(5_u64))143 }144 /// Storage: Nonfungible TokenChildren (r:1 w:0)145 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)146 /// Storage: Nonfungible TokenData (r:1 w:1)147 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)148 /// Storage: Nonfungible TokensBurnt (r:1 w:1)149 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)150 /// Storage: Nonfungible AccountBalance (r:1 w:1)151 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)152 /// Storage: Nonfungible Allowance (r:1 w:0)153 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)154 /// Storage: Nonfungible Owned (r:0 w:1)155 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)156 /// Storage: Nonfungible TokenProperties (r:0 w:1)157 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)158 fn burn_recursively_self_raw() -> Weight {159 // Proof Size summary in bytes:160 // Measured: `380`161 // Estimated: `3530`162 // Minimum execution time: 22_942_000 picoseconds.163 Weight::from_parts(23_527_000, 3530)164 .saturating_add(T::DbWeight::get().reads(5_u64))165 .saturating_add(T::DbWeight::get().writes(5_u64))166 }167 /// Storage: Nonfungible TokenChildren (r:401 w:200)168 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)169 /// Storage: Common CollectionById (r:1 w:0)170 /// Proof: Common CollectionById (max_values: None, max_size: Some(860), added: 3335, mode: MaxEncodedLen)171 /// Storage: Nonfungible TokenData (r:201 w:201)172 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)173 /// Storage: Nonfungible TokensBurnt (r:1 w:1)174 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)175 /// Storage: Nonfungible AccountBalance (r:2 w:2)176 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)177 /// Storage: Nonfungible Allowance (r:201 w:0)178 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)179 /// Storage: Nonfungible Owned (r:0 w:201)180 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)181 /// Storage: Nonfungible TokenProperties (r:0 w:201)182 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)183 /// The range of component `b` is `[0, 200]`.184 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {185 // Proof Size summary in bytes:186 // Measured: `1500 + b * (58 ±0)`187 // Estimated: `5874 + b * (5032 ±0)`188 // Minimum execution time: 22_709_000 picoseconds.189 Weight::from_parts(23_287_000, 5874)190 // Standard Error: 89_471191 .saturating_add(Weight::from_parts(63_285_201, 0).saturating_mul(b.into()))192 .saturating_add(T::DbWeight::get().reads(7_u64))193 .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(b.into())))194 .saturating_add(T::DbWeight::get().writes(6_u64))195 .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(b.into())))196 .saturating_add(Weight::from_parts(0, 5032).saturating_mul(b.into()))197 }198 /// Storage: Nonfungible TokenData (r:1 w:1)199 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)200 /// Storage: Nonfungible AccountBalance (r:2 w:2)201 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)202 /// Storage: Nonfungible Allowance (r:1 w:0)203 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)204 /// Storage: Nonfungible Owned (r:0 w:2)205 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)206 fn transfer_raw() -> Weight {207 // Proof Size summary in bytes:208 // Measured: `380`209 // Estimated: `6070`210 // Minimum execution time: 13_652_000 picoseconds.211 Weight::from_parts(13_981_000, 6070)212 .saturating_add(T::DbWeight::get().reads(4_u64))213 .saturating_add(T::DbWeight::get().writes(5_u64))214 }215 /// Storage: Nonfungible TokenData (r:1 w:0)216 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)217 /// Storage: Nonfungible Allowance (r:1 w:1)218 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)219 fn approve() -> Weight {220 // Proof Size summary in bytes:221 // Measured: `326`222 // Estimated: `3522`223 // Minimum execution time: 7_837_000 picoseconds.224 Weight::from_parts(8_113_000, 3522)225 .saturating_add(T::DbWeight::get().reads(2_u64))226 .saturating_add(T::DbWeight::get().writes(1_u64))227 }228 /// Storage: Nonfungible TokenData (r:1 w:0)229 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)230 /// Storage: Nonfungible Allowance (r:1 w:1)231 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)232 fn approve_from() -> Weight {233 // Proof Size summary in bytes:234 // Measured: `313`235 // Estimated: `3522`236 // Minimum execution time: 7_769_000 picoseconds.237 Weight::from_parts(7_979_000, 3522)238 .saturating_add(T::DbWeight::get().reads(2_u64))239 .saturating_add(T::DbWeight::get().writes(1_u64))240 }241 /// Storage: Nonfungible Allowance (r:1 w:0)242 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)243 fn check_allowed_raw() -> Weight {244 // Proof Size summary in bytes:245 // Measured: `362`246 // Estimated: `3522`247 // Minimum execution time: 4_194_000 picoseconds.248 Weight::from_parts(4_353_000, 3522)249 .saturating_add(T::DbWeight::get().reads(1_u64))250 }251 /// Storage: Nonfungible Allowance (r:1 w:1)252 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)253 /// Storage: Nonfungible TokenData (r:1 w:1)254 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)255 /// Storage: Nonfungible TokenChildren (r:1 w:0)256 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)257 /// Storage: Nonfungible TokensBurnt (r:1 w:1)258 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)259 /// Storage: Nonfungible AccountBalance (r:1 w:1)260 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)261 /// Storage: Nonfungible Owned (r:0 w:1)262 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)263 /// Storage: Nonfungible TokenProperties (r:0 w:1)264 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)265 fn burn_from() -> Weight {266 // Proof Size summary in bytes:267 // Measured: `463`268 // Estimated: `3530`269 // Minimum execution time: 21_978_000 picoseconds.270 Weight::from_parts(22_519_000, 3530)271 .saturating_add(T::DbWeight::get().reads(5_u64))272 .saturating_add(T::DbWeight::get().writes(6_u64))273 }274 /// Storage: Common CollectionPropertyPermissions (r:1 w:1)275 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)276 /// The range of component `b` is `[0, 64]`.277 fn set_token_property_permissions(b: u32, ) -> Weight {278 // Proof Size summary in bytes:279 // Measured: `314`280 // Estimated: `20191`281 // Minimum execution time: 1_457_000 picoseconds.282 Weight::from_parts(1_563_000, 20191)283 // Standard Error: 14_041284 .saturating_add(Weight::from_parts(8_452_415, 0).saturating_mul(b.into()))285 .saturating_add(T::DbWeight::get().reads(1_u64))286 .saturating_add(T::DbWeight::get().writes(1_u64))287 }288 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)289 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)290 /// Storage: Nonfungible TokenProperties (r:1 w:1)291 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)292 /// Storage: Nonfungible TokenData (r:1 w:0)293 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)294 /// The range of component `b` is `[0, 64]`.295 fn set_token_properties(b: u32, ) -> Weight {296 // Proof Size summary in bytes:297 // Measured: `640 + b * (261 ±0)`298 // Estimated: `36269`299 // Minimum execution time: 963_000 picoseconds.300 Weight::from_parts(1_126_511, 36269)301 // Standard Error: 9_175302 .saturating_add(Weight::from_parts(5_096_011, 0).saturating_mul(b.into()))303 .saturating_add(T::DbWeight::get().reads(3_u64))304 .saturating_add(T::DbWeight::get().writes(1_u64))305 }306 /// Storage: Nonfungible TokenProperties (r:0 w:1)307 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)308 /// The range of component `b` is `[0, 64]`.309 fn init_token_properties(b: u32, ) -> Weight {310 // Proof Size summary in bytes:311 // Measured: `0`312 // Estimated: `0`313 // Minimum execution time: 194_000 picoseconds.314 Weight::from_parts(222_000, 0)315 // Standard Error: 7_295316 .saturating_add(Weight::from_parts(4_499_463, 0).saturating_mul(b.into()))317 .saturating_add(T::DbWeight::get().writes(1_u64))318 }319 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)320 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)321 /// Storage: Nonfungible TokenData (r:1 w:0)322 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)323 /// Storage: Nonfungible TokenProperties (r:1 w:1)324 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)325 /// The range of component `b` is `[0, 64]`.326 fn delete_token_properties(b: u32, ) -> Weight {327 // Proof Size summary in bytes:328 // Measured: `699 + b * (33291 ±0)`329 // Estimated: `36269`330 // Minimum execution time: 992_000 picoseconds.331 Weight::from_parts(1_043_000, 36269)332 // Standard Error: 37_370333 .saturating_add(Weight::from_parts(23_672_870, 0).saturating_mul(b.into()))334 .saturating_add(T::DbWeight::get().reads(3_u64))335 .saturating_add(T::DbWeight::get().writes(1_u64))336 }337 /// Storage: Nonfungible TokenData (r:1 w:0)338 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)339 fn token_owner() -> Weight {340 // Proof Size summary in bytes:341 // Measured: `326`342 // Estimated: `3522`343 // Minimum execution time: 3_743_000 picoseconds.344 Weight::from_parts(3_908_000, 3522)345 .saturating_add(T::DbWeight::get().reads(1_u64))346 }347 /// Storage: Nonfungible CollectionAllowance (r:0 w:1)348 /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)349 fn set_allowance_for_all() -> Weight {350 // Proof Size summary in bytes:351 // Measured: `0`352 // Estimated: `0`353 // Minimum execution time: 4_106_000 picoseconds.354 Weight::from_parts(4_293_000, 0)355 .saturating_add(T::DbWeight::get().writes(1_u64))356 }357 /// Storage: Nonfungible CollectionAllowance (r:1 w:0)358 /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)359 fn allowance_for_all() -> Weight {360 // Proof Size summary in bytes:361 // Measured: `142`362 // Estimated: `3576`363 // Minimum execution time: 2_775_000 picoseconds.364 Weight::from_parts(2_923_000, 3576)365 .saturating_add(T::DbWeight::get().reads(1_u64))366 }367 /// Storage: Nonfungible TokenProperties (r:1 w:1)368 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)369 fn repair_item() -> Weight {370 // Proof Size summary in bytes:371 // Measured: `279`372 // Estimated: `36269`373 // Minimum execution time: 3_033_000 picoseconds.374 Weight::from_parts(3_174_000, 36269)375 .saturating_add(T::DbWeight::get().reads(1_u64))376 .saturating_add(T::DbWeight::get().writes(1_u64))377 }378}379380// For backwards compatibility and tests381impl WeightInfo for () {382 /// Storage: Nonfungible TokensMinted (r:1 w:1)383 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)384 /// Storage: Nonfungible AccountBalance (r:1 w:1)385 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)386 /// Storage: Nonfungible TokenData (r:0 w:1)387 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)388 /// Storage: Nonfungible Owned (r:0 w:1)389 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)390 fn create_item() -> Weight {391 // Proof Size summary in bytes:392 // Measured: `142`393 // Estimated: `3530`394 // Minimum execution time: 9_726_000 picoseconds.395 Weight::from_parts(10_059_000, 3530)396 .saturating_add(RocksDbWeight::get().reads(2_u64))397 .saturating_add(RocksDbWeight::get().writes(4_u64))398 }399 /// Storage: Nonfungible TokensMinted (r:1 w:1)400 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)401 /// Storage: Nonfungible AccountBalance (r:1 w:1)402 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)403 /// Storage: Nonfungible TokenData (r:0 w:200)404 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)405 /// Storage: Nonfungible Owned (r:0 w:200)406 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)407 /// The range of component `b` is `[0, 200]`.408 fn create_multiple_items(b: u32, ) -> Weight {409 // Proof Size summary in bytes:410 // Measured: `142`411 // Estimated: `3530`412 // Minimum execution time: 3_270_000 picoseconds.413 Weight::from_parts(3_693_659, 3530)414 // Standard Error: 255415 .saturating_add(Weight::from_parts(3_024_284, 0).saturating_mul(b.into()))416 .saturating_add(RocksDbWeight::get().reads(2_u64))417 .saturating_add(RocksDbWeight::get().writes(2_u64))418 .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(b.into())))419 }420 /// Storage: Nonfungible TokensMinted (r:1 w:1)421 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)422 /// Storage: Nonfungible AccountBalance (r:200 w:200)423 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)424 /// Storage: Nonfungible TokenData (r:0 w:200)425 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)426 /// Storage: Nonfungible Owned (r:0 w:200)427 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)428 /// The range of component `b` is `[0, 200]`.429 fn create_multiple_items_ex(b: u32, ) -> Weight {430 // Proof Size summary in bytes:431 // Measured: `142`432 // Estimated: `3481 + b * (2540 ±0)`433 // Minimum execution time: 3_188_000 picoseconds.434 Weight::from_parts(3_307_000, 3481)435 // Standard Error: 567436 .saturating_add(Weight::from_parts(4_320_449, 0).saturating_mul(b.into()))437 .saturating_add(RocksDbWeight::get().reads(1_u64))438 .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))439 .saturating_add(RocksDbWeight::get().writes(1_u64))440 .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(b.into())))441 .saturating_add(Weight::from_parts(0, 2540).saturating_mul(b.into()))442 }443 /// Storage: Nonfungible TokenData (r:1 w:1)444 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)445 /// Storage: Nonfungible TokenChildren (r:1 w:0)446 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)447 /// Storage: Nonfungible TokensBurnt (r:1 w:1)448 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)449 /// Storage: Nonfungible AccountBalance (r:1 w:1)450 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)451 /// Storage: Nonfungible Allowance (r:1 w:0)452 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)453 /// Storage: Nonfungible Owned (r:0 w:1)454 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)455 /// Storage: Nonfungible TokenProperties (r:0 w:1)456 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)457 fn burn_item() -> Weight {458 // Proof Size summary in bytes:459 // Measured: `380`460 // Estimated: `3530`461 // Minimum execution time: 18_062_000 picoseconds.462 Weight::from_parts(18_433_000, 3530)463 .saturating_add(RocksDbWeight::get().reads(5_u64))464 .saturating_add(RocksDbWeight::get().writes(5_u64))465 }466 /// Storage: Nonfungible TokenChildren (r:1 w:0)467 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)468 /// Storage: Nonfungible TokenData (r:1 w:1)469 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)470 /// Storage: Nonfungible TokensBurnt (r:1 w:1)471 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)472 /// Storage: Nonfungible AccountBalance (r:1 w:1)473 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)474 /// Storage: Nonfungible Allowance (r:1 w:0)475 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)476 /// Storage: Nonfungible Owned (r:0 w:1)477 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)478 /// Storage: Nonfungible TokenProperties (r:0 w:1)479 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)480 fn burn_recursively_self_raw() -> Weight {481 // Proof Size summary in bytes:482 // Measured: `380`483 // Estimated: `3530`484 // Minimum execution time: 22_942_000 picoseconds.485 Weight::from_parts(23_527_000, 3530)486 .saturating_add(RocksDbWeight::get().reads(5_u64))487 .saturating_add(RocksDbWeight::get().writes(5_u64))488 }489 /// Storage: Nonfungible TokenChildren (r:401 w:200)490 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)491 /// Storage: Common CollectionById (r:1 w:0)492 /// Proof: Common CollectionById (max_values: None, max_size: Some(860), added: 3335, mode: MaxEncodedLen)493 /// Storage: Nonfungible TokenData (r:201 w:201)494 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)495 /// Storage: Nonfungible TokensBurnt (r:1 w:1)496 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)497 /// Storage: Nonfungible AccountBalance (r:2 w:2)498 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)499 /// Storage: Nonfungible Allowance (r:201 w:0)500 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)501 /// Storage: Nonfungible Owned (r:0 w:201)502 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)503 /// Storage: Nonfungible TokenProperties (r:0 w:201)504 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)505 /// The range of component `b` is `[0, 200]`.506 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {507 // Proof Size summary in bytes:508 // Measured: `1500 + b * (58 ±0)`509 // Estimated: `5874 + b * (5032 ±0)`510 // Minimum execution time: 22_709_000 picoseconds.511 Weight::from_parts(23_287_000, 5874)512 // Standard Error: 89_471513 .saturating_add(Weight::from_parts(63_285_201, 0).saturating_mul(b.into()))514 .saturating_add(RocksDbWeight::get().reads(7_u64))515 .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(b.into())))516 .saturating_add(RocksDbWeight::get().writes(6_u64))517 .saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(b.into())))518 .saturating_add(Weight::from_parts(0, 5032).saturating_mul(b.into()))519 }520 /// Storage: Nonfungible TokenData (r:1 w:1)521 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)522 /// Storage: Nonfungible AccountBalance (r:2 w:2)523 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)524 /// Storage: Nonfungible Allowance (r:1 w:0)525 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)526 /// Storage: Nonfungible Owned (r:0 w:2)527 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)528 fn transfer_raw() -> Weight {529 // Proof Size summary in bytes:530 // Measured: `380`531 // Estimated: `6070`532 // Minimum execution time: 13_652_000 picoseconds.533 Weight::from_parts(13_981_000, 6070)534 .saturating_add(RocksDbWeight::get().reads(4_u64))535 .saturating_add(RocksDbWeight::get().writes(5_u64))536 }537 /// Storage: Nonfungible TokenData (r:1 w:0)538 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)539 /// Storage: Nonfungible Allowance (r:1 w:1)540 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)541 fn approve() -> Weight {542 // Proof Size summary in bytes:543 // Measured: `326`544 // Estimated: `3522`545 // Minimum execution time: 7_837_000 picoseconds.546 Weight::from_parts(8_113_000, 3522)547 .saturating_add(RocksDbWeight::get().reads(2_u64))548 .saturating_add(RocksDbWeight::get().writes(1_u64))549 }550 /// Storage: Nonfungible TokenData (r:1 w:0)551 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)552 /// Storage: Nonfungible Allowance (r:1 w:1)553 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)554 fn approve_from() -> Weight {555 // Proof Size summary in bytes:556 // Measured: `313`557 // Estimated: `3522`558 // Minimum execution time: 7_769_000 picoseconds.559 Weight::from_parts(7_979_000, 3522)560 .saturating_add(RocksDbWeight::get().reads(2_u64))561 .saturating_add(RocksDbWeight::get().writes(1_u64))562 }563 /// Storage: Nonfungible Allowance (r:1 w:0)564 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)565 fn check_allowed_raw() -> Weight {566 // Proof Size summary in bytes:567 // Measured: `362`568 // Estimated: `3522`569 // Minimum execution time: 4_194_000 picoseconds.570 Weight::from_parts(4_353_000, 3522)571 .saturating_add(RocksDbWeight::get().reads(1_u64))572 }573 /// Storage: Nonfungible Allowance (r:1 w:1)574 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)575 /// Storage: Nonfungible TokenData (r:1 w:1)576 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)577 /// Storage: Nonfungible TokenChildren (r:1 w:0)578 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)579 /// Storage: Nonfungible TokensBurnt (r:1 w:1)580 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)581 /// Storage: Nonfungible AccountBalance (r:1 w:1)582 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)583 /// Storage: Nonfungible Owned (r:0 w:1)584 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)585 /// Storage: Nonfungible TokenProperties (r:0 w:1)586 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)587 fn burn_from() -> Weight {588 // Proof Size summary in bytes:589 // Measured: `463`590 // Estimated: `3530`591 // Minimum execution time: 21_978_000 picoseconds.592 Weight::from_parts(22_519_000, 3530)593 .saturating_add(RocksDbWeight::get().reads(5_u64))594 .saturating_add(RocksDbWeight::get().writes(6_u64))595 }596 /// Storage: Common CollectionPropertyPermissions (r:1 w:1)597 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)598 /// The range of component `b` is `[0, 64]`.599 fn set_token_property_permissions(b: u32, ) -> Weight {600 // Proof Size summary in bytes:601 // Measured: `314`602 // Estimated: `20191`603 // Minimum execution time: 1_457_000 picoseconds.604 Weight::from_parts(1_563_000, 20191)605 // Standard Error: 14_041606 .saturating_add(Weight::from_parts(8_452_415, 0).saturating_mul(b.into()))607 .saturating_add(RocksDbWeight::get().reads(1_u64))608 .saturating_add(RocksDbWeight::get().writes(1_u64))609 }610 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)611 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)612 /// Storage: Nonfungible TokenProperties (r:1 w:1)613 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)614 /// Storage: Nonfungible TokenData (r:1 w:0)615 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)616 /// The range of component `b` is `[0, 64]`.617 fn set_token_properties(b: u32, ) -> Weight {618 // Proof Size summary in bytes:619 // Measured: `640 + b * (261 ±0)`620 // Estimated: `36269`621 // Minimum execution time: 963_000 picoseconds.622 Weight::from_parts(1_126_511, 36269)623 // Standard Error: 9_175624 .saturating_add(Weight::from_parts(5_096_011, 0).saturating_mul(b.into()))625 .saturating_add(RocksDbWeight::get().reads(3_u64))626 .saturating_add(RocksDbWeight::get().writes(1_u64))627 }628 /// Storage: Nonfungible TokenProperties (r:0 w:1)629 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)630 /// The range of component `b` is `[0, 64]`.631 fn init_token_properties(b: u32, ) -> Weight {632 // Proof Size summary in bytes:633 // Measured: `0`634 // Estimated: `0`635 // Minimum execution time: 194_000 picoseconds.636 Weight::from_parts(222_000, 0)637 // Standard Error: 7_295638 .saturating_add(Weight::from_parts(4_499_463, 0).saturating_mul(b.into()))639 .saturating_add(RocksDbWeight::get().writes(1_u64))640 }641 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)642 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)643 /// Storage: Nonfungible TokenData (r:1 w:0)644 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)645 /// Storage: Nonfungible TokenProperties (r:1 w:1)646 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)647 /// The range of component `b` is `[0, 64]`.648 fn delete_token_properties(b: u32, ) -> Weight {649 // Proof Size summary in bytes:650 // Measured: `699 + b * (33291 ±0)`651 // Estimated: `36269`652 // Minimum execution time: 992_000 picoseconds.653 Weight::from_parts(1_043_000, 36269)654 // Standard Error: 37_370655 .saturating_add(Weight::from_parts(23_672_870, 0).saturating_mul(b.into()))656 .saturating_add(RocksDbWeight::get().reads(3_u64))657 .saturating_add(RocksDbWeight::get().writes(1_u64))658 }659 /// Storage: Nonfungible TokenData (r:1 w:0)660 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)661 fn token_owner() -> Weight {662 // Proof Size summary in bytes:663 // Measured: `326`664 // Estimated: `3522`665 // Minimum execution time: 3_743_000 picoseconds.666 Weight::from_parts(3_908_000, 3522)667 .saturating_add(RocksDbWeight::get().reads(1_u64))668 }669 /// Storage: Nonfungible CollectionAllowance (r:0 w:1)670 /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)671 fn set_allowance_for_all() -> Weight {672 // Proof Size summary in bytes:673 // Measured: `0`674 // Estimated: `0`675 // Minimum execution time: 4_106_000 picoseconds.676 Weight::from_parts(4_293_000, 0)677 .saturating_add(RocksDbWeight::get().writes(1_u64))678 }679 /// Storage: Nonfungible CollectionAllowance (r:1 w:0)680 /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)681 fn allowance_for_all() -> Weight {682 // Proof Size summary in bytes:683 // Measured: `142`684 // Estimated: `3576`685 // Minimum execution time: 2_775_000 picoseconds.686 Weight::from_parts(2_923_000, 3576)687 .saturating_add(RocksDbWeight::get().reads(1_u64))688 }689 /// Storage: Nonfungible TokenProperties (r:1 w:1)690 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)691 fn repair_item() -> Weight {692 // Proof Size summary in bytes:693 // Measured: `279`694 // Estimated: `36269`695 // Minimum execution time: 3_033_000 picoseconds.696 Weight::from_parts(3_174_000, 36269)697 .saturating_add(RocksDbWeight::get().reads(1_u64))698 .saturating_add(RocksDbWeight::get().writes(1_u64))699 }700}7011// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_nonfungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2023-10-05, STEPS: `50`, REPEAT: `80`, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! WORST CASE MAP SIZE: `1000000`8//! HOSTNAME: `hearthstone`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor`9//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10241011// Executed Command:12// target/production/unique-collator13// benchmark14// pallet15// --pallet16// pallet-nonfungible17// --wasm-execution18// compiled19// --extrinsic20// *21// --template=.maintain/frame-weight-template.hbs22// --steps=5023// --repeat=8024// --heap-pages=409625// --output=./pallets/nonfungible/src/weights.rs2627#![cfg_attr(rustfmt, rustfmt_skip)]28#![allow(unused_parens)]29#![allow(unused_imports)]3031use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};32use sp_std::marker::PhantomData;3334/// Weight functions needed for pallet_nonfungible.35pub trait WeightInfo {36 fn create_item() -> Weight;37 fn create_multiple_items(b: u32, ) -> Weight;38 fn create_multiple_items_ex(b: u32, ) -> Weight;39 fn burn_item() -> Weight;40 fn burn_recursively_self_raw() -> Weight;41 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight;42 fn transfer_raw() -> Weight;43 fn approve() -> Weight;44 fn approve_from() -> Weight;45 fn check_allowed_raw() -> Weight;46 fn burn_from() -> Weight;47 fn set_token_property_permissions(b: u32, ) -> Weight;48 fn set_token_properties(b: u32, ) -> Weight;49 fn load_token_properties() -> Weight;50 fn write_token_properties(b: u32, ) -> Weight;51 fn delete_token_properties(b: u32, ) -> Weight;52 fn token_owner() -> Weight;53 fn set_allowance_for_all() -> Weight;54 fn allowance_for_all() -> Weight;55 fn repair_item() -> Weight;56}5758/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.59pub struct SubstrateWeight<T>(PhantomData<T>);60impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {61 /// Storage: Nonfungible TokensMinted (r:1 w:1)62 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)63 /// Storage: Nonfungible AccountBalance (r:1 w:1)64 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)65 /// Storage: Nonfungible TokenData (r:0 w:1)66 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)67 /// Storage: Nonfungible Owned (r:0 w:1)68 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)69 fn create_item() -> Weight {70 // Proof Size summary in bytes:71 // Measured: `142`72 // Estimated: `3530`73 // Minimum execution time: 4_990_000 picoseconds.74 Weight::from_parts(5_170_000, 3530)75 .saturating_add(T::DbWeight::get().reads(2_u64))76 .saturating_add(T::DbWeight::get().writes(4_u64))77 }78 /// Storage: Nonfungible TokensMinted (r:1 w:1)79 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)80 /// Storage: Nonfungible AccountBalance (r:1 w:1)81 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)82 /// Storage: Nonfungible TokenData (r:0 w:200)83 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)84 /// Storage: Nonfungible Owned (r:0 w:200)85 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)86 /// The range of component `b` is `[0, 200]`.87 fn create_multiple_items(b: u32, ) -> Weight {88 // Proof Size summary in bytes:89 // Measured: `142`90 // Estimated: `3530`91 // Minimum execution time: 1_680_000 picoseconds.92 Weight::from_parts(1_720_000, 3530)93 // Standard Error: 67494 .saturating_add(Weight::from_parts(2_406_591, 0).saturating_mul(b.into()))95 .saturating_add(T::DbWeight::get().reads(2_u64))96 .saturating_add(T::DbWeight::get().writes(2_u64))97 .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(b.into())))98 }99 /// Storage: Nonfungible TokensMinted (r:1 w:1)100 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)101 /// Storage: Nonfungible AccountBalance (r:200 w:200)102 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)103 /// Storage: Nonfungible TokenData (r:0 w:200)104 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)105 /// Storage: Nonfungible Owned (r:0 w:200)106 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)107 /// The range of component `b` is `[0, 200]`.108 fn create_multiple_items_ex(b: u32, ) -> Weight {109 // Proof Size summary in bytes:110 // Measured: `142`111 // Estimated: `3481 + b * (2540 ±0)`112 // Minimum execution time: 1_680_000 picoseconds.113 Weight::from_parts(1_720_000, 3481)114 // Standard Error: 1_729115 .saturating_add(Weight::from_parts(3_418_983, 0).saturating_mul(b.into()))116 .saturating_add(T::DbWeight::get().reads(1_u64))117 .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))118 .saturating_add(T::DbWeight::get().writes(1_u64))119 .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into())))120 .saturating_add(Weight::from_parts(0, 2540).saturating_mul(b.into()))121 }122 /// Storage: Nonfungible TokenData (r:1 w:1)123 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)124 /// Storage: Nonfungible TokenChildren (r:1 w:0)125 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)126 /// Storage: Nonfungible TokensBurnt (r:1 w:1)127 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)128 /// Storage: Nonfungible AccountBalance (r:1 w:1)129 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)130 /// Storage: Nonfungible Allowance (r:1 w:0)131 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)132 /// Storage: Nonfungible Owned (r:0 w:1)133 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)134 /// Storage: Nonfungible TokenProperties (r:0 w:1)135 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)136 fn burn_item() -> Weight {137 // Proof Size summary in bytes:138 // Measured: `380`139 // Estimated: `3530`140 // Minimum execution time: 10_700_000 picoseconds.141 Weight::from_parts(11_180_000, 3530)142 .saturating_add(T::DbWeight::get().reads(5_u64))143 .saturating_add(T::DbWeight::get().writes(5_u64))144 }145 /// Storage: Nonfungible TokenChildren (r:1 w:0)146 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)147 /// Storage: Nonfungible TokenData (r:1 w:1)148 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)149 /// Storage: Nonfungible TokensBurnt (r:1 w:1)150 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)151 /// Storage: Nonfungible AccountBalance (r:1 w:1)152 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)153 /// Storage: Nonfungible Allowance (r:1 w:0)154 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)155 /// Storage: Nonfungible Owned (r:0 w:1)156 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)157 /// Storage: Nonfungible TokenProperties (r:0 w:1)158 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)159 fn burn_recursively_self_raw() -> Weight {160 // Proof Size summary in bytes:161 // Measured: `380`162 // Estimated: `3530`163 // Minimum execution time: 13_650_000 picoseconds.164 Weight::from_parts(13_910_000, 3530)165 .saturating_add(T::DbWeight::get().reads(5_u64))166 .saturating_add(T::DbWeight::get().writes(5_u64))167 }168 /// Storage: Nonfungible TokenChildren (r:401 w:200)169 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)170 /// Storage: Common CollectionById (r:1 w:0)171 /// Proof: Common CollectionById (max_values: None, max_size: Some(860), added: 3335, mode: MaxEncodedLen)172 /// Storage: Nonfungible TokenData (r:201 w:201)173 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)174 /// Storage: Nonfungible TokensBurnt (r:1 w:1)175 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)176 /// Storage: Nonfungible AccountBalance (r:2 w:2)177 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)178 /// Storage: Nonfungible Allowance (r:201 w:0)179 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)180 /// Storage: Nonfungible Owned (r:0 w:201)181 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)182 /// Storage: Nonfungible TokenProperties (r:0 w:201)183 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)184 /// The range of component `b` is `[0, 200]`.185 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {186 // Proof Size summary in bytes:187 // Measured: `1500 + b * (58 ±0)`188 // Estimated: `5874 + b * (5032 ±0)`189 // Minimum execution time: 13_500_000 picoseconds.190 Weight::from_parts(13_830_000, 5874)191 // Standard Error: 136_447192 .saturating_add(Weight::from_parts(43_149_279, 0).saturating_mul(b.into()))193 .saturating_add(T::DbWeight::get().reads(7_u64))194 .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(b.into())))195 .saturating_add(T::DbWeight::get().writes(6_u64))196 .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(b.into())))197 .saturating_add(Weight::from_parts(0, 5032).saturating_mul(b.into()))198 }199 /// Storage: Nonfungible TokenData (r:1 w:1)200 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)201 /// Storage: Nonfungible AccountBalance (r:2 w:2)202 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)203 /// Storage: Nonfungible Allowance (r:1 w:0)204 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)205 /// Storage: Nonfungible Owned (r:0 w:2)206 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)207 fn transfer_raw() -> Weight {208 // Proof Size summary in bytes:209 // Measured: `380`210 // Estimated: `6070`211 // Minimum execution time: 8_440_000 picoseconds.212 Weight::from_parts(8_680_000, 6070)213 .saturating_add(T::DbWeight::get().reads(4_u64))214 .saturating_add(T::DbWeight::get().writes(5_u64))215 }216 /// Storage: Nonfungible TokenData (r:1 w:0)217 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)218 /// Storage: Nonfungible Allowance (r:1 w:1)219 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)220 fn approve() -> Weight {221 // Proof Size summary in bytes:222 // Measured: `326`223 // Estimated: `3522`224 // Minimum execution time: 4_580_000 picoseconds.225 Weight::from_parts(4_850_000, 3522)226 .saturating_add(T::DbWeight::get().reads(2_u64))227 .saturating_add(T::DbWeight::get().writes(1_u64))228 }229 /// Storage: Nonfungible TokenData (r:1 w:0)230 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)231 /// Storage: Nonfungible Allowance (r:1 w:1)232 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)233 fn approve_from() -> Weight {234 // Proof Size summary in bytes:235 // Measured: `313`236 // Estimated: `3522`237 // Minimum execution time: 4_650_000 picoseconds.238 Weight::from_parts(4_890_000, 3522)239 .saturating_add(T::DbWeight::get().reads(2_u64))240 .saturating_add(T::DbWeight::get().writes(1_u64))241 }242 /// Storage: Nonfungible Allowance (r:1 w:0)243 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)244 fn check_allowed_raw() -> Weight {245 // Proof Size summary in bytes:246 // Measured: `362`247 // Estimated: `3522`248 // Minimum execution time: 2_630_000 picoseconds.249 Weight::from_parts(2_760_000, 3522)250 .saturating_add(T::DbWeight::get().reads(1_u64))251 }252 /// Storage: Nonfungible Allowance (r:1 w:1)253 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)254 /// Storage: Nonfungible TokenData (r:1 w:1)255 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)256 /// Storage: Nonfungible TokenChildren (r:1 w:0)257 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)258 /// Storage: Nonfungible TokensBurnt (r:1 w:1)259 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)260 /// Storage: Nonfungible AccountBalance (r:1 w:1)261 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)262 /// Storage: Nonfungible Owned (r:0 w:1)263 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)264 /// Storage: Nonfungible TokenProperties (r:0 w:1)265 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)266 fn burn_from() -> Weight {267 // Proof Size summary in bytes:268 // Measured: `463`269 // Estimated: `3530`270 // Minimum execution time: 13_300_000 picoseconds.271 Weight::from_parts(13_650_000, 3530)272 .saturating_add(T::DbWeight::get().reads(5_u64))273 .saturating_add(T::DbWeight::get().writes(6_u64))274 }275 /// Storage: Common CollectionPropertyPermissions (r:1 w:1)276 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)277 /// The range of component `b` is `[0, 64]`.278 fn set_token_property_permissions(b: u32, ) -> Weight {279 // Proof Size summary in bytes:280 // Measured: `314`281 // Estimated: `20191`282 // Minimum execution time: 550_000 picoseconds.283 Weight::from_parts(600_000, 20191)284 // Standard Error: 23_117285 .saturating_add(Weight::from_parts(6_048_092, 0).saturating_mul(b.into()))286 .saturating_add(T::DbWeight::get().reads(1_u64))287 .saturating_add(T::DbWeight::get().writes(1_u64))288 }289 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)290 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)291 /// Storage: Nonfungible TokenProperties (r:1 w:1)292 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)293 /// Storage: Nonfungible TokenData (r:1 w:0)294 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)295 /// The range of component `b` is `[0, 64]`.296 fn set_token_properties(b: u32, ) -> Weight {297 // Proof Size summary in bytes:298 // Measured: `640 + b * (261 ±0)`299 // Estimated: `36269`300 // Minimum execution time: 340_000 picoseconds.301 Weight::from_parts(7_359_078, 36269)302 // Standard Error: 9_052303 .saturating_add(Weight::from_parts(2_763_267, 0).saturating_mul(b.into()))304 .saturating_add(T::DbWeight::get().reads(3_u64))305 .saturating_add(T::DbWeight::get().writes(1_u64))306 }307 /// Storage: Nonfungible TokenProperties (r:1 w:0)308 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)309 fn load_token_properties() -> Weight {310 // Proof Size summary in bytes:311 // Measured: `279`312 // Estimated: `36269`313 // Minimum execution time: 1_610_000 picoseconds.314 Weight::from_parts(1_690_000, 36269)315 .saturating_add(T::DbWeight::get().reads(1_u64))316 }317 /// Storage: Nonfungible TokenProperties (r:0 w:1)318 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)319 /// The range of component `b` is `[0, 64]`.320 fn write_token_properties(b: u32, ) -> Weight {321 // Proof Size summary in bytes:322 // Measured: `0`323 // Estimated: `0`324 // Minimum execution time: 70_000 picoseconds.325 Weight::from_parts(3_262_181, 0)326 // Standard Error: 5_240327 .saturating_add(Weight::from_parts(2_426_582, 0).saturating_mul(b.into()))328 .saturating_add(T::DbWeight::get().writes(1_u64))329 }330 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)331 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)332 /// Storage: Nonfungible TokenData (r:1 w:0)333 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)334 /// Storage: Nonfungible TokenProperties (r:1 w:1)335 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)336 /// The range of component `b` is `[0, 64]`.337 fn delete_token_properties(b: u32, ) -> Weight {338 // Proof Size summary in bytes:339 // Measured: `699 + b * (33291 ±0)`340 // Estimated: `36269`341 // Minimum execution time: 350_000 picoseconds.342 Weight::from_parts(370_000, 36269)343 // Standard Error: 29_081344 .saturating_add(Weight::from_parts(9_667_268, 0).saturating_mul(b.into()))345 .saturating_add(T::DbWeight::get().reads(3_u64))346 .saturating_add(T::DbWeight::get().writes(1_u64))347 }348 /// Storage: Nonfungible TokenData (r:1 w:0)349 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)350 fn token_owner() -> Weight {351 // Proof Size summary in bytes:352 // Measured: `326`353 // Estimated: `3522`354 // Minimum execution time: 2_380_000 picoseconds.355 Weight::from_parts(2_500_000, 3522)356 .saturating_add(T::DbWeight::get().reads(1_u64))357 }358 /// Storage: Nonfungible CollectionAllowance (r:0 w:1)359 /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)360 fn set_allowance_for_all() -> Weight {361 // Proof Size summary in bytes:362 // Measured: `0`363 // Estimated: `0`364 // Minimum execution time: 2_060_000 picoseconds.365 Weight::from_parts(2_150_000, 0)366 .saturating_add(T::DbWeight::get().writes(1_u64))367 }368 /// Storage: Nonfungible CollectionAllowance (r:1 w:0)369 /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)370 fn allowance_for_all() -> Weight {371 // Proof Size summary in bytes:372 // Measured: `142`373 // Estimated: `3576`374 // Minimum execution time: 1_630_000 picoseconds.375 Weight::from_parts(1_730_000, 3576)376 .saturating_add(T::DbWeight::get().reads(1_u64))377 }378 /// Storage: Nonfungible TokenProperties (r:1 w:1)379 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)380 fn repair_item() -> Weight {381 // Proof Size summary in bytes:382 // Measured: `279`383 // Estimated: `36269`384 // Minimum execution time: 1_700_000 picoseconds.385 Weight::from_parts(1_780_000, 36269)386 .saturating_add(T::DbWeight::get().reads(1_u64))387 .saturating_add(T::DbWeight::get().writes(1_u64))388 }389}390391// For backwards compatibility and tests392impl WeightInfo for () {393 /// Storage: Nonfungible TokensMinted (r:1 w:1)394 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)395 /// Storage: Nonfungible AccountBalance (r:1 w:1)396 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)397 /// Storage: Nonfungible TokenData (r:0 w:1)398 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)399 /// Storage: Nonfungible Owned (r:0 w:1)400 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)401 fn create_item() -> Weight {402 // Proof Size summary in bytes:403 // Measured: `142`404 // Estimated: `3530`405 // Minimum execution time: 4_990_000 picoseconds.406 Weight::from_parts(5_170_000, 3530)407 .saturating_add(RocksDbWeight::get().reads(2_u64))408 .saturating_add(RocksDbWeight::get().writes(4_u64))409 }410 /// Storage: Nonfungible TokensMinted (r:1 w:1)411 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)412 /// Storage: Nonfungible AccountBalance (r:1 w:1)413 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)414 /// Storage: Nonfungible TokenData (r:0 w:200)415 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)416 /// Storage: Nonfungible Owned (r:0 w:200)417 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)418 /// The range of component `b` is `[0, 200]`.419 fn create_multiple_items(b: u32, ) -> Weight {420 // Proof Size summary in bytes:421 // Measured: `142`422 // Estimated: `3530`423 // Minimum execution time: 1_680_000 picoseconds.424 Weight::from_parts(1_720_000, 3530)425 // Standard Error: 674426 .saturating_add(Weight::from_parts(2_406_591, 0).saturating_mul(b.into()))427 .saturating_add(RocksDbWeight::get().reads(2_u64))428 .saturating_add(RocksDbWeight::get().writes(2_u64))429 .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(b.into())))430 }431 /// Storage: Nonfungible TokensMinted (r:1 w:1)432 /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)433 /// Storage: Nonfungible AccountBalance (r:200 w:200)434 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)435 /// Storage: Nonfungible TokenData (r:0 w:200)436 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)437 /// Storage: Nonfungible Owned (r:0 w:200)438 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)439 /// The range of component `b` is `[0, 200]`.440 fn create_multiple_items_ex(b: u32, ) -> Weight {441 // Proof Size summary in bytes:442 // Measured: `142`443 // Estimated: `3481 + b * (2540 ±0)`444 // Minimum execution time: 1_680_000 picoseconds.445 Weight::from_parts(1_720_000, 3481)446 // Standard Error: 1_729447 .saturating_add(Weight::from_parts(3_418_983, 0).saturating_mul(b.into()))448 .saturating_add(RocksDbWeight::get().reads(1_u64))449 .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))450 .saturating_add(RocksDbWeight::get().writes(1_u64))451 .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(b.into())))452 .saturating_add(Weight::from_parts(0, 2540).saturating_mul(b.into()))453 }454 /// Storage: Nonfungible TokenData (r:1 w:1)455 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)456 /// Storage: Nonfungible TokenChildren (r:1 w:0)457 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)458 /// Storage: Nonfungible TokensBurnt (r:1 w:1)459 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)460 /// Storage: Nonfungible AccountBalance (r:1 w:1)461 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)462 /// Storage: Nonfungible Allowance (r:1 w:0)463 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)464 /// Storage: Nonfungible Owned (r:0 w:1)465 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)466 /// Storage: Nonfungible TokenProperties (r:0 w:1)467 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)468 fn burn_item() -> Weight {469 // Proof Size summary in bytes:470 // Measured: `380`471 // Estimated: `3530`472 // Minimum execution time: 10_700_000 picoseconds.473 Weight::from_parts(11_180_000, 3530)474 .saturating_add(RocksDbWeight::get().reads(5_u64))475 .saturating_add(RocksDbWeight::get().writes(5_u64))476 }477 /// Storage: Nonfungible TokenChildren (r:1 w:0)478 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)479 /// Storage: Nonfungible TokenData (r:1 w:1)480 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)481 /// Storage: Nonfungible TokensBurnt (r:1 w:1)482 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)483 /// Storage: Nonfungible AccountBalance (r:1 w:1)484 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)485 /// Storage: Nonfungible Allowance (r:1 w:0)486 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)487 /// Storage: Nonfungible Owned (r:0 w:1)488 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)489 /// Storage: Nonfungible TokenProperties (r:0 w:1)490 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)491 fn burn_recursively_self_raw() -> Weight {492 // Proof Size summary in bytes:493 // Measured: `380`494 // Estimated: `3530`495 // Minimum execution time: 13_650_000 picoseconds.496 Weight::from_parts(13_910_000, 3530)497 .saturating_add(RocksDbWeight::get().reads(5_u64))498 .saturating_add(RocksDbWeight::get().writes(5_u64))499 }500 /// Storage: Nonfungible TokenChildren (r:401 w:200)501 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)502 /// Storage: Common CollectionById (r:1 w:0)503 /// Proof: Common CollectionById (max_values: None, max_size: Some(860), added: 3335, mode: MaxEncodedLen)504 /// Storage: Nonfungible TokenData (r:201 w:201)505 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)506 /// Storage: Nonfungible TokensBurnt (r:1 w:1)507 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)508 /// Storage: Nonfungible AccountBalance (r:2 w:2)509 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)510 /// Storage: Nonfungible Allowance (r:201 w:0)511 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)512 /// Storage: Nonfungible Owned (r:0 w:201)513 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)514 /// Storage: Nonfungible TokenProperties (r:0 w:201)515 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)516 /// The range of component `b` is `[0, 200]`.517 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {518 // Proof Size summary in bytes:519 // Measured: `1500 + b * (58 ±0)`520 // Estimated: `5874 + b * (5032 ±0)`521 // Minimum execution time: 13_500_000 picoseconds.522 Weight::from_parts(13_830_000, 5874)523 // Standard Error: 136_447524 .saturating_add(Weight::from_parts(43_149_279, 0).saturating_mul(b.into()))525 .saturating_add(RocksDbWeight::get().reads(7_u64))526 .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(b.into())))527 .saturating_add(RocksDbWeight::get().writes(6_u64))528 .saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(b.into())))529 .saturating_add(Weight::from_parts(0, 5032).saturating_mul(b.into()))530 }531 /// Storage: Nonfungible TokenData (r:1 w:1)532 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)533 /// Storage: Nonfungible AccountBalance (r:2 w:2)534 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)535 /// Storage: Nonfungible Allowance (r:1 w:0)536 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)537 /// Storage: Nonfungible Owned (r:0 w:2)538 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)539 fn transfer_raw() -> Weight {540 // Proof Size summary in bytes:541 // Measured: `380`542 // Estimated: `6070`543 // Minimum execution time: 8_440_000 picoseconds.544 Weight::from_parts(8_680_000, 6070)545 .saturating_add(RocksDbWeight::get().reads(4_u64))546 .saturating_add(RocksDbWeight::get().writes(5_u64))547 }548 /// Storage: Nonfungible TokenData (r:1 w:0)549 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)550 /// Storage: Nonfungible Allowance (r:1 w:1)551 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)552 fn approve() -> Weight {553 // Proof Size summary in bytes:554 // Measured: `326`555 // Estimated: `3522`556 // Minimum execution time: 4_580_000 picoseconds.557 Weight::from_parts(4_850_000, 3522)558 .saturating_add(RocksDbWeight::get().reads(2_u64))559 .saturating_add(RocksDbWeight::get().writes(1_u64))560 }561 /// Storage: Nonfungible TokenData (r:1 w:0)562 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)563 /// Storage: Nonfungible Allowance (r:1 w:1)564 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)565 fn approve_from() -> Weight {566 // Proof Size summary in bytes:567 // Measured: `313`568 // Estimated: `3522`569 // Minimum execution time: 4_650_000 picoseconds.570 Weight::from_parts(4_890_000, 3522)571 .saturating_add(RocksDbWeight::get().reads(2_u64))572 .saturating_add(RocksDbWeight::get().writes(1_u64))573 }574 /// Storage: Nonfungible Allowance (r:1 w:0)575 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)576 fn check_allowed_raw() -> Weight {577 // Proof Size summary in bytes:578 // Measured: `362`579 // Estimated: `3522`580 // Minimum execution time: 2_630_000 picoseconds.581 Weight::from_parts(2_760_000, 3522)582 .saturating_add(RocksDbWeight::get().reads(1_u64))583 }584 /// Storage: Nonfungible Allowance (r:1 w:1)585 /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)586 /// Storage: Nonfungible TokenData (r:1 w:1)587 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)588 /// Storage: Nonfungible TokenChildren (r:1 w:0)589 /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)590 /// Storage: Nonfungible TokensBurnt (r:1 w:1)591 /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)592 /// Storage: Nonfungible AccountBalance (r:1 w:1)593 /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)594 /// Storage: Nonfungible Owned (r:0 w:1)595 /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)596 /// Storage: Nonfungible TokenProperties (r:0 w:1)597 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)598 fn burn_from() -> Weight {599 // Proof Size summary in bytes:600 // Measured: `463`601 // Estimated: `3530`602 // Minimum execution time: 13_300_000 picoseconds.603 Weight::from_parts(13_650_000, 3530)604 .saturating_add(RocksDbWeight::get().reads(5_u64))605 .saturating_add(RocksDbWeight::get().writes(6_u64))606 }607 /// Storage: Common CollectionPropertyPermissions (r:1 w:1)608 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)609 /// The range of component `b` is `[0, 64]`.610 fn set_token_property_permissions(b: u32, ) -> Weight {611 // Proof Size summary in bytes:612 // Measured: `314`613 // Estimated: `20191`614 // Minimum execution time: 550_000 picoseconds.615 Weight::from_parts(600_000, 20191)616 // Standard Error: 23_117617 .saturating_add(Weight::from_parts(6_048_092, 0).saturating_mul(b.into()))618 .saturating_add(RocksDbWeight::get().reads(1_u64))619 .saturating_add(RocksDbWeight::get().writes(1_u64))620 }621 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)622 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)623 /// Storage: Nonfungible TokenProperties (r:1 w:1)624 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)625 /// Storage: Nonfungible TokenData (r:1 w:0)626 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)627 /// The range of component `b` is `[0, 64]`.628 fn set_token_properties(b: u32, ) -> Weight {629 // Proof Size summary in bytes:630 // Measured: `640 + b * (261 ±0)`631 // Estimated: `36269`632 // Minimum execution time: 340_000 picoseconds.633 Weight::from_parts(7_359_078, 36269)634 // Standard Error: 9_052635 .saturating_add(Weight::from_parts(2_763_267, 0).saturating_mul(b.into()))636 .saturating_add(RocksDbWeight::get().reads(3_u64))637 .saturating_add(RocksDbWeight::get().writes(1_u64))638 }639 /// Storage: Nonfungible TokenProperties (r:1 w:0)640 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)641 fn load_token_properties() -> Weight {642 // Proof Size summary in bytes:643 // Measured: `279`644 // Estimated: `36269`645 // Minimum execution time: 1_610_000 picoseconds.646 Weight::from_parts(1_690_000, 36269)647 .saturating_add(RocksDbWeight::get().reads(1_u64))648 }649 /// Storage: Nonfungible TokenProperties (r:0 w:1)650 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)651 /// The range of component `b` is `[0, 64]`.652 fn write_token_properties(b: u32, ) -> Weight {653 // Proof Size summary in bytes:654 // Measured: `0`655 // Estimated: `0`656 // Minimum execution time: 70_000 picoseconds.657 Weight::from_parts(3_262_181, 0)658 // Standard Error: 5_240659 .saturating_add(Weight::from_parts(2_426_582, 0).saturating_mul(b.into()))660 .saturating_add(RocksDbWeight::get().writes(1_u64))661 }662 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)663 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)664 /// Storage: Nonfungible TokenData (r:1 w:0)665 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)666 /// Storage: Nonfungible TokenProperties (r:1 w:1)667 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)668 /// The range of component `b` is `[0, 64]`.669 fn delete_token_properties(b: u32, ) -> Weight {670 // Proof Size summary in bytes:671 // Measured: `699 + b * (33291 ±0)`672 // Estimated: `36269`673 // Minimum execution time: 350_000 picoseconds.674 Weight::from_parts(370_000, 36269)675 // Standard Error: 29_081676 .saturating_add(Weight::from_parts(9_667_268, 0).saturating_mul(b.into()))677 .saturating_add(RocksDbWeight::get().reads(3_u64))678 .saturating_add(RocksDbWeight::get().writes(1_u64))679 }680 /// Storage: Nonfungible TokenData (r:1 w:0)681 /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)682 fn token_owner() -> Weight {683 // Proof Size summary in bytes:684 // Measured: `326`685 // Estimated: `3522`686 // Minimum execution time: 2_380_000 picoseconds.687 Weight::from_parts(2_500_000, 3522)688 .saturating_add(RocksDbWeight::get().reads(1_u64))689 }690 /// Storage: Nonfungible CollectionAllowance (r:0 w:1)691 /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)692 fn set_allowance_for_all() -> Weight {693 // Proof Size summary in bytes:694 // Measured: `0`695 // Estimated: `0`696 // Minimum execution time: 2_060_000 picoseconds.697 Weight::from_parts(2_150_000, 0)698 .saturating_add(RocksDbWeight::get().writes(1_u64))699 }700 /// Storage: Nonfungible CollectionAllowance (r:1 w:0)701 /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)702 fn allowance_for_all() -> Weight {703 // Proof Size summary in bytes:704 // Measured: `142`705 // Estimated: `3576`706 // Minimum execution time: 1_630_000 picoseconds.707 Weight::from_parts(1_730_000, 3576)708 .saturating_add(RocksDbWeight::get().reads(1_u64))709 }710 /// Storage: Nonfungible TokenProperties (r:1 w:1)711 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)712 fn repair_item() -> Weight {713 // Proof Size summary in bytes:714 // Measured: `279`715 // Estimated: `36269`716 // Minimum execution time: 1_700_000 picoseconds.717 Weight::from_parts(1_780_000, 36269)718 .saturating_add(RocksDbWeight::get().reads(1_u64))719 .saturating_add(RocksDbWeight::get().writes(1_u64))720 }721}722pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -19,10 +19,7 @@
use frame_benchmarking::v2::*;
use pallet_common::{
bench_init,
- benchmarking::{
- create_collection_raw, /*load_is_admin_and_property_permissions,*/ property_key,
- property_value,
- },
+ benchmarking::{create_collection_raw, property_key, property_value},
};
use sp_std::prelude::*;
use up_data_structs::{
@@ -424,6 +421,81 @@
Ok(())
}
+ // set_token_properties {
+ // let b in 0..MAX_PROPERTIES_PER_ITEM;
+ // bench_init!{
+ // owner: sub; collection: collection(owner);
+ // owner: cross_from_sub;
+ // };
+ // let perms = (0..b).map(|k| PropertyKeyPermission {
+ // key: property_key(k as usize),
+ // permission: PropertyPermission {
+ // mutable: false,
+ // collection_admin: true,
+ // token_owner: true,
+ // },
+ // }).collect::<Vec<_>>();
+ // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+ // let props = (0..b).map(|k| Property {
+ // key: property_key(k as usize),
+ // value: property_value(),
+ // }).collect::<Vec<_>>();
+ // let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
+ // }: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props.into_iter(), &Unlimited)?}
+
+ // load_token_properties {
+ // bench_init!{
+ // owner: sub; collection: collection(owner);
+ // owner: cross_from_sub;
+ // };
+
+ // let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
+ // }: {
+ // pallet_common::BenchmarkPropertyWriter::<T>::load_token_properties(
+ // &collection,
+ // item,
+ // )
+ // }
+
+ // write_token_properties {
+ // let b in 0..MAX_PROPERTIES_PER_ITEM;
+ // bench_init!{
+ // owner: sub; collection: collection(owner);
+ // owner: cross_from_sub;
+ // };
+
+ // let perms = (0..b).map(|k| PropertyKeyPermission {
+ // key: property_key(k as usize),
+ // permission: PropertyPermission {
+ // mutable: false,
+ // collection_admin: true,
+ // token_owner: true,
+ // },
+ // }).collect::<Vec<_>>();
+ // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+ // let props = (0..b).map(|k| Property {
+ // key: property_key(k as usize),
+ // value: property_value(),
+ // }).collect::<Vec<_>>();
+ // let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
+
+ // let lazy_collection_info = pallet_common::BenchmarkPropertyWriter::<T>::load_collection_info(
+ // &collection,
+ // &owner,
+ // );
+ // }: {
+ // let mut property_writer = pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
+
+ // property_writer.write_token_properties(
+ // item,
+ // props.into_iter(),
+ // crate::erc::ERC721TokenEvent::TokenChanged {
+ // token_id: item.into(),
+ // }
+ // .to_log(T::ContractAddress::get()),
+ // )?
+ // }
+
#[benchmark]
fn set_token_property_permissions(
b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -16,14 +16,12 @@
use core::marker::PhantomData;
-use frame_support::{
- dispatch::DispatchResultWithPostInfo, ensure, fail, traits::Get, weights::Weight,
-};
+use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};
use pallet_common::{
- init_token_properties_delta, weights::WeightInfo as _, with_weight, CommonCollectionOperations,
- CommonWeightInfo, RefungibleExtensions,
+ weights::WeightInfo as _, with_weight, write_token_properties_total_weight,
+ CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions,
};
-use pallet_structure::{Error as StructureError, Pallet as PalletStructure};
+use pallet_structure::Pallet as PalletStructure;
use sp_runtime::DispatchError;
use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
use up_data_structs::{
@@ -50,14 +48,14 @@
impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {
<SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(
- init_token_properties_delta::<T, _>(
+ write_token_properties_total_weight::<T, _>(
data.iter().map(|data| match data {
up_data_structs::CreateItemData::ReFungible(rft_data) => {
rft_data.properties.len() as u32
}
_ => 0,
}),
- <SelfWeightOf<T>>::init_token_properties,
+ <SelfWeightOf<T>>::write_token_properties,
),
)
}
@@ -66,16 +64,16 @@
match call {
CreateItemExData::RefungibleMultipleOwners(i) => {
<SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32)
- .saturating_add(init_token_properties_delta::<T, _>(
+ .saturating_add(write_token_properties_total_weight::<T, _>(
[i.properties.len() as u32].into_iter(),
- <SelfWeightOf<T>>::init_token_properties,
+ <SelfWeightOf<T>>::write_token_properties,
))
}
CreateItemExData::RefungibleMultipleItems(i) => {
<SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32)
- .saturating_add(init_token_properties_delta::<T, _>(
+ .saturating_add(write_token_properties_total_weight::<T, _>(
i.iter().map(|d| d.properties.len() as u32),
- <SelfWeightOf<T>>::init_token_properties,
+ <SelfWeightOf<T>>::write_token_properties,
))
}
_ => Weight::zero(),
@@ -88,18 +86,13 @@
fn set_collection_properties(amount: u32) -> Weight {
<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)
- }
-
- fn delete_collection_properties(amount: u32) -> Weight {
- <pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)
}
fn set_token_properties(amount: u32) -> Weight {
- <SelfWeightOf<T>>::set_token_properties(amount)
- }
-
- fn delete_token_properties(amount: u32) -> Weight {
- <SelfWeightOf<T>>::delete_token_properties(amount)
+ write_token_properties_total_weight::<T, _>([amount].into_iter(), |amount| {
+ <SelfWeightOf<T>>::load_token_properties()
+ + <SelfWeightOf<T>>::write_token_properties(amount)
+ })
}
fn set_token_property_permissions(amount: u32) -> Weight {
@@ -136,19 +129,6 @@
<SelfWeightOf<T>>::burn_from()
}
- fn burn_recursively_self_raw() -> Weight {
- // Read to get total balance
- Self::burn_item() + T::DbWeight::get().reads(1)
- }
- fn burn_recursively_breadth_raw(_amount: u32) -> Weight {
- // Refungible token can't have children
- Weight::zero()
- }
-
- fn token_owner() -> Weight {
- <SelfWeightOf<T>>::token_owner()
- }
-
fn set_allowance_for_all() -> Weight {
<SelfWeightOf<T>>::set_allowance_for_all()
}
@@ -262,25 +242,6 @@
with_weight(
<Pallet<T>>::burn(self, &sender, token, amount),
<CommonWeights<T>>::burn_item(),
- )
- }
-
- fn burn_item_recursively(
- &self,
- sender: T::CrossAccountId,
- token: TokenId,
- self_budget: &dyn Budget,
- _breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo {
- ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
- with_weight(
- <Pallet<T>>::burn(
- self,
- &sender,
- token,
- <Balance<T>>::get((self.id, token, &sender)),
- ),
- <CommonWeights<T>>::burn_recursively_self_raw(),
)
}
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -32,26 +32,26 @@
use pallet_common::{
erc::{static_property::key, CollectionCall, CommonEvmHandler},
eth::{self, TokenUri},
- CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
+ CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations, CommonWeightInfo,
Error as CommonError,
};
use pallet_evm::{account::CrossAccountId, PrecompileHandle};
use pallet_evm_coder_substrate::{
call, dispatch_to_evm,
execution::{Error, PreDispatch, Result},
- frontier_contract,
+ frontier_contract, SubstrateRecorder,
};
use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
use sp_core::{Get, H160, U256};
use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
use up_data_structs::{
- mapping::TokenAddressMapping, CollectionId, CollectionPropertiesVec, Property, PropertyKey,
- PropertyKeyPermission, PropertyPermission, TokenId, TokenOwnerError,
+ budget::Budget, mapping::TokenAddressMapping, CollectionId, CollectionPropertiesVec, Property,
+ PropertyKey, PropertyKeyPermission, PropertyPermission, TokenId, TokenOwnerError,
};
use crate::{
- weights::WeightInfo, AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle,
- SelfWeightOf, TokenProperties, TokensMinted, TotalSupply,
+ common::CommonWeights, weights::WeightInfo, AccountBalance, Balance, Config, CreateItemData,
+ Pallet, RefungibleHandle, SelfWeightOf, TokenProperties, TokensMinted, TotalSupply,
};
frontier_contract! {
@@ -90,6 +90,10 @@
pub properties: Vec<eth::Property>,
}
+pub fn nesting_budget<T: Config>(recorder: &SubstrateRecorder<T>) -> impl Budget + '_ {
+ recorder.weight_calls_budget(<StructureWeight<T>>::find_parent())
+}
+
/// @title A contract that allows to set and delete token properties and change token property permissions.
#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]
impl<T: Config> RefungibleHandle<T> {
@@ -158,7 +162,7 @@
/// @param key Property key.
/// @param value Property value.
#[solidity(hide)]
- #[weight(<SelfWeightOf<T>>::set_token_properties(1))]
+ #[weight(<CommonWeights<T>>::set_token_properties(1))]
fn set_property(
&mut self,
caller: Caller,
@@ -173,16 +177,12 @@
.map_err(|_| "key too long")?;
let value = value.0.try_into().map_err(|_| "value too long")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
<Pallet<T>>::set_token_property(
self,
&caller,
TokenId(token_id),
Property { key, value },
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -191,7 +191,7 @@
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
/// @param properties settable properties
- #[weight(<SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
+ #[weight(<CommonWeights<T>>::set_token_properties(properties.len() as u32))]
fn set_properties(
&mut self,
caller: Caller,
@@ -201,10 +201,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
let properties = properties
.into_iter()
.map(eth::Property::try_into)
@@ -215,7 +211,7 @@
&caller,
TokenId(token_id),
properties.into_iter(),
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -225,7 +221,7 @@
/// @param tokenId ID of the token.
/// @param key Property key.
#[solidity(hide)]
- #[weight(<SelfWeightOf<T>>::delete_token_properties(1))]
+ #[weight(<CommonWeights<T>>::delete_token_properties(1))]
fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
@@ -233,19 +229,21 @@
.try_into()
.map_err(|_| "key too long")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
- <Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)
- .map_err(dispatch_to_evm::<T>)
+ <Pallet<T>>::delete_token_property(
+ self,
+ &caller,
+ TokenId(token_id),
+ key,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)
}
/// @notice Delete token properties value.
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
/// @param keys Properties key.
- #[weight(<SelfWeightOf<T>>::delete_token_properties(keys.len() as u32))]
+ #[weight(<CommonWeights<T>>::delete_token_properties(keys.len() as u32))]
fn delete_properties(
&mut self,
token_id: U256,
@@ -258,17 +256,13 @@
.into_iter()
.map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))
.collect::<Result<Vec<_>>>()?;
-
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
<Pallet<T>>::delete_token_properties(
self,
&caller,
TokenId(token_id),
keys.into_iter(),
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -497,15 +491,20 @@
let from = T::CrossAccountId::from_eth(from);
let to = T::CrossAccountId::from_eth(to);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token, &from)?;
ensure_single_owner(self, token, balance)?;
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, token, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ token,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -629,9 +628,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
if <TokensMinted<T>>::get(self.id)
.checked_add(1)
@@ -653,7 +649,7 @@
users,
properties: CollectionPropertiesVec::default(),
},
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
@@ -704,9 +700,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
if <TokensMinted<T>>::get(self.id)
.checked_add(1)
@@ -736,7 +729,7 @@
self,
&caller,
CreateItemData::<T> { users, properties },
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
@@ -865,15 +858,19 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token, &caller)?;
ensure_single_owner(self, token, balance)?;
- <Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer(
+ self,
+ &caller,
+ &to,
+ token,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -893,15 +890,19 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token, &caller)?;
ensure_single_owner(self, token, balance)?;
- <Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer(
+ self,
+ &caller,
+ &to,
+ token,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -923,15 +924,20 @@
let from = from.into_sub_cross_account::<T>()?;
let to = to.into_sub_cross_account::<T>()?;
let token_id = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token_id, &from)?;
ensure_single_owner(self, token_id, balance)?;
- Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ Pallet::<T>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ token_id,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -948,15 +954,19 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token, &from)?;
ensure_single_owner(self, token, balance)?;
- <Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ token,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -977,15 +987,19 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = from.into_sub_cross_account::<T>()?;
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token, &from)?;
ensure_single_owner(self, token, balance)?;
- <Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ token,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -1010,9 +1024,6 @@
let mut expected_index = <TokensMinted<T>>::get(self.id)
.checked_add(1)
.ok_or("item id overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let total_tokens = token_ids.len();
for id in token_ids.into_iter() {
@@ -1035,7 +1046,7 @@
.map(|_| create_item_data.clone())
.collect();
- <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)
+ <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -1053,9 +1064,6 @@
token_properties: Vec<MintTokenData>,
) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let has_multiple_tokens = token_properties.len() > 1;
let mut create_rft_data = Vec::with_capacity(token_properties.len());
@@ -1084,8 +1092,13 @@
});
}
- <Pallet<T>>::create_multiple_items(self, &caller, create_rft_data, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::create_multiple_items(
+ self,
+ &caller,
+ create_rft_data,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -1108,9 +1121,6 @@
let mut expected_index = <TokensMinted<T>>::get(self.id)
.checked_add(1)
.ok_or("item id overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let mut data = Vec::with_capacity(tokens.len());
let users: BoundedBTreeMap<_, _, _> = [(to, 1)]
@@ -1143,7 +1153,7 @@
data.push(create_item_data);
}
- <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)
+ <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -1174,10 +1184,6 @@
let caller = T::CrossAccountId::from_eth(caller);
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
let users = [(to, 1)]
.into_iter()
.collect::<BTreeMap<_, _>>()
@@ -1187,7 +1193,7 @@
self,
&caller,
CreateItemData::<T> { users, properties },
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
pallets/refungible/src/erc_token.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -37,14 +37,13 @@
execution::{PreDispatch, Result},
frontier_contract, WithRecorder,
};
-use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
use sp_core::U256;
use sp_std::vec::Vec;
use up_data_structs::TokenId;
use crate::{
- common::CommonWeights, weights::WeightInfo, Allowance, Balance, Config, Pallet,
- RefungibleHandle, SelfWeightOf, TotalSupply,
+ common::CommonWeights, erc::nesting_budget, weights::WeightInfo, Allowance, Balance, Config,
+ Pallet, RefungibleHandle, SelfWeightOf, TotalSupply,
};
/// Refungible token handle contains information about token's collection and id
@@ -140,12 +139,16 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer(
+ self,
+ &caller,
+ &to,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -165,12 +168,17 @@
let from = T::CrossAccountId::from_eth(from);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -231,12 +239,16 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -254,12 +266,16 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = from.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -315,12 +331,16 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer(
+ self,
+ &caller,
+ &to,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -340,12 +360,17 @@
let from = from.into_sub_cross_account::<T>()?;
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
}
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -507,7 +507,7 @@
nesting_budget: &dyn Budget,
) -> DispatchResult {
let mut property_writer =
- pallet_common::property_writer_for_existing_token(collection, sender);
+ pallet_common::ExistingTokenPropertyWriter::new(collection, sender);
property_writer.write_token_properties(
sender,
@@ -858,7 +858,7 @@
// =========
- let mut property_writer = pallet_common::property_writer_for_new_token(collection, sender);
+ let mut property_writer = pallet_common::NewTokenPropertyWriter::new(collection, sender);
with_transaction(|| {
for (i, data) in data.iter().enumerate() {
pallets/refungible/src/weights.rsdiffbeforeafterboth--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -3,9 +3,9 @@
//! Autogenerated weights for pallet_refungible
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-09-30, STEPS: `50`, REPEAT: `400`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-10-05, STEPS: `50`, REPEAT: `80`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `bench-host`, CPU: `Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz`
+//! HOSTNAME: `hearthstone`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor`
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
// Executed Command:
@@ -20,7 +20,7 @@
// *
// --template=.maintain/frame-weight-template.hbs
// --steps=50
-// --repeat=400
+// --repeat=80
// --heap-pages=4096
// --output=./pallets/refungible/src/weights.rs
@@ -52,7 +52,8 @@
fn burn_from() -> Weight;
fn set_token_property_permissions(b: u32, ) -> Weight;
fn set_token_properties(b: u32, ) -> Weight;
- fn init_token_properties(b: u32, ) -> Weight;
+ fn load_token_properties() -> Weight;
+ fn write_token_properties(b: u32, ) -> Weight;
fn delete_token_properties(b: u32, ) -> Weight;
fn repartition_item() -> Weight;
fn token_owner() -> Weight;
@@ -78,8 +79,8 @@
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3530`
- // Minimum execution time: 11_341_000 picoseconds.
- Weight::from_parts(11_741_000, 3530)
+ // Minimum execution time: 5_710_000 picoseconds.
+ Weight::from_parts(5_980_000, 3530)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
@@ -98,10 +99,10 @@
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3530`
- // Minimum execution time: 2_665_000 picoseconds.
- Weight::from_parts(2_791_000, 3530)
- // Standard Error: 996
- .saturating_add(Weight::from_parts(4_343_736, 0).saturating_mul(b.into()))
+ // Minimum execution time: 1_300_000 picoseconds.
+ Weight::from_parts(1_360_000, 3530)
+ // Standard Error: 2_783
+ .saturating_add(Weight::from_parts(3_456_531, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into())))
@@ -121,10 +122,10 @@
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3481 + b * (2540 ±0)`
- // Minimum execution time: 2_616_000 picoseconds.
- Weight::from_parts(2_726_000, 3481)
- // Standard Error: 665
- .saturating_add(Weight::from_parts(5_554_066, 0).saturating_mul(b.into()))
+ // Minimum execution time: 1_290_000 picoseconds.
+ Weight::from_parts(1_370_000, 3481)
+ // Standard Error: 3_198
+ .saturating_add(Weight::from_parts(4_435_305, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().writes(1_u64))
@@ -146,10 +147,10 @@
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3481 + b * (2540 ±0)`
- // Minimum execution time: 3_697_000 picoseconds.
- Weight::from_parts(2_136_481, 3481)
- // Standard Error: 567
- .saturating_add(Weight::from_parts(4_390_621, 0).saturating_mul(b.into()))
+ // Minimum execution time: 1_730_000 picoseconds.
+ Weight::from_parts(1_810_000, 3481)
+ // Standard Error: 1_923
+ .saturating_add(Weight::from_parts(3_500_817, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().writes(2_u64))
@@ -168,8 +169,8 @@
// Proof Size summary in bytes:
// Measured: `456`
// Estimated: `8682`
- // Minimum execution time: 22_859_000 picoseconds.
- Weight::from_parts(23_295_000, 8682)
+ // Minimum execution time: 14_010_000 picoseconds.
+ Weight::from_parts(16_300_000, 8682)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
@@ -189,8 +190,8 @@
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `3554`
- // Minimum execution time: 21_477_000 picoseconds.
- Weight::from_parts(22_037_000, 3554)
+ // Minimum execution time: 13_700_000 picoseconds.
+ Weight::from_parts(14_180_000, 3554)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
@@ -202,8 +203,8 @@
// Proof Size summary in bytes:
// Measured: `365`
// Estimated: `6118`
- // Minimum execution time: 13_714_000 picoseconds.
- Weight::from_parts(14_050_000, 6118)
+ // Minimum execution time: 8_990_000 picoseconds.
+ Weight::from_parts(9_400_000, 6118)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
@@ -219,8 +220,8 @@
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `6118`
- // Minimum execution time: 15_879_000 picoseconds.
- Weight::from_parts(16_266_000, 6118)
+ // Minimum execution time: 10_240_000 picoseconds.
+ Weight::from_parts(10_610_000, 6118)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
@@ -236,8 +237,8 @@
// Proof Size summary in bytes:
// Measured: `456`
// Estimated: `6118`
- // Minimum execution time: 18_186_000 picoseconds.
- Weight::from_parts(18_682_000, 6118)
+ // Minimum execution time: 12_040_000 picoseconds.
+ Weight::from_parts(12_390_000, 6118)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
@@ -253,8 +254,8 @@
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `6118`
- // Minimum execution time: 17_943_000 picoseconds.
- Weight::from_parts(18_333_000, 6118)
+ // Minimum execution time: 11_940_000 picoseconds.
+ Weight::from_parts(12_240_000, 6118)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
@@ -266,8 +267,8 @@
// Proof Size summary in bytes:
// Measured: `223`
// Estimated: `3554`
- // Minimum execution time: 8_391_000 picoseconds.
- Weight::from_parts(8_637_000, 3554)
+ // Minimum execution time: 5_150_000 picoseconds.
+ Weight::from_parts(5_440_000, 3554)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -279,8 +280,8 @@
// Proof Size summary in bytes:
// Measured: `211`
// Estimated: `3554`
- // Minimum execution time: 8_519_000 picoseconds.
- Weight::from_parts(8_760_000, 3554)
+ // Minimum execution time: 5_170_000 picoseconds.
+ Weight::from_parts(5_400_000, 3554)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -294,8 +295,8 @@
// Proof Size summary in bytes:
// Measured: `495`
// Estimated: `6118`
- // Minimum execution time: 19_554_000 picoseconds.
- Weight::from_parts(20_031_000, 6118)
+ // Minimum execution time: 13_150_000 picoseconds.
+ Weight::from_parts(13_600_000, 6118)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
@@ -313,8 +314,8 @@
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `6118`
- // Minimum execution time: 21_338_000 picoseconds.
- Weight::from_parts(21_803_000, 6118)
+ // Minimum execution time: 14_280_000 picoseconds.
+ Weight::from_parts(14_680_000, 6118)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
@@ -332,8 +333,8 @@
// Proof Size summary in bytes:
// Measured: `586`
// Estimated: `6118`
- // Minimum execution time: 24_179_000 picoseconds.
- Weight::from_parts(24_647_000, 6118)
+ // Minimum execution time: 16_110_000 picoseconds.
+ Weight::from_parts(16_710_000, 6118)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
@@ -351,8 +352,8 @@
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `6118`
- // Minimum execution time: 24_008_000 picoseconds.
- Weight::from_parts(24_545_000, 6118)
+ // Minimum execution time: 16_130_000 picoseconds.
+ Weight::from_parts(16_680_000, 6118)
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().writes(7_u64))
}
@@ -374,8 +375,8 @@
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `3570`
- // Minimum execution time: 27_907_000 picoseconds.
- Weight::from_parts(28_489_000, 3570)
+ // Minimum execution time: 18_380_000 picoseconds.
+ Weight::from_parts(18_870_000, 3570)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(7_u64))
}
@@ -386,10 +387,10 @@
// Proof Size summary in bytes:
// Measured: `314`
// Estimated: `20191`
- // Minimum execution time: 1_460_000 picoseconds.
- Weight::from_parts(1_564_000, 20191)
- // Standard Error: 14_117
- .saturating_add(Weight::from_parts(8_196_214, 0).saturating_mul(b.into()))
+ // Minimum execution time: 580_000 picoseconds.
+ Weight::from_parts(660_000, 20191)
+ // Standard Error: 29_964
+ .saturating_add(Weight::from_parts(6_251_766, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -404,24 +405,34 @@
// Proof Size summary in bytes:
// Measured: `502 + b * (261 ±0)`
// Estimated: `36269`
- // Minimum execution time: 1_012_000 picoseconds.
- Weight::from_parts(1_081_000, 36269)
- // Standard Error: 6_838
- .saturating_add(Weight::from_parts(5_801_181, 0).saturating_mul(b.into()))
+ // Minimum execution time: 350_000 picoseconds.
+ Weight::from_parts(2_269_806, 36269)
+ // Standard Error: 7_751
+ .saturating_add(Weight::from_parts(3_068_126, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
+ /// Storage: Refungible TokenProperties (r:1 w:0)
+ /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ fn load_token_properties() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `120`
+ // Estimated: `36269`
+ // Minimum execution time: 1_010_000 picoseconds.
+ Weight::from_parts(1_080_000, 36269)
+ .saturating_add(T::DbWeight::get().reads(1_u64))
+ }
/// Storage: Refungible TokenProperties (r:0 w:1)
/// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
/// The range of component `b` is `[0, 64]`.
- fn init_token_properties(b: u32, ) -> Weight {
+ fn write_token_properties(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 229_000 picoseconds.
- Weight::from_parts(253_000, 0)
- // Standard Error: 100_218
- .saturating_add(Weight::from_parts(12_632_221, 0).saturating_mul(b.into()))
+ // Minimum execution time: 70_000 picoseconds.
+ Weight::from_parts(1_363_449, 0)
+ // Standard Error: 8_964
+ .saturating_add(Weight::from_parts(2_665_759, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: Common CollectionPropertyPermissions (r:1 w:0)
@@ -435,10 +446,10 @@
// Proof Size summary in bytes:
// Measured: `561 + b * (33291 ±0)`
// Estimated: `36269`
- // Minimum execution time: 1_014_000 picoseconds.
- Weight::from_parts(1_065_000, 36269)
- // Standard Error: 39_536
- .saturating_add(Weight::from_parts(24_125_838, 0).saturating_mul(b.into()))
+ // Minimum execution time: 320_000 picoseconds.
+ Weight::from_parts(370_000, 36269)
+ // Standard Error: 28_541
+ .saturating_add(Weight::from_parts(9_863_065, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -450,8 +461,8 @@
// Proof Size summary in bytes:
// Measured: `288`
// Estimated: `3554`
- // Minimum execution time: 10_315_000 picoseconds.
- Weight::from_parts(10_601_000, 3554)
+ // Minimum execution time: 6_320_000 picoseconds.
+ Weight::from_parts(6_640_000, 3554)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
@@ -461,8 +472,8 @@
// Proof Size summary in bytes:
// Measured: `288`
// Estimated: `6118`
- // Minimum execution time: 4_898_000 picoseconds.
- Weight::from_parts(5_136_000, 6118)
+ // Minimum execution time: 2_520_000 picoseconds.
+ Weight::from_parts(2_680_000, 6118)
.saturating_add(T::DbWeight::get().reads(2_u64))
}
/// Storage: Refungible CollectionAllowance (r:0 w:1)
@@ -471,8 +482,8 @@
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 4_146_000 picoseconds.
- Weight::from_parts(4_337_000, 0)
+ // Minimum execution time: 2_070_000 picoseconds.
+ Weight::from_parts(2_230_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: Refungible CollectionAllowance (r:1 w:0)
@@ -481,8 +492,8 @@
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3576`
- // Minimum execution time: 2_170_000 picoseconds.
- Weight::from_parts(2_301_000, 3576)
+ // Minimum execution time: 1_270_000 picoseconds.
+ Weight::from_parts(1_420_000, 3576)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: Refungible TokenProperties (r:1 w:1)
@@ -491,8 +502,8 @@
// Proof Size summary in bytes:
// Measured: `120`
// Estimated: `36269`
- // Minimum execution time: 2_098_000 picoseconds.
- Weight::from_parts(2_251_000, 36269)
+ // Minimum execution time: 1_010_000 picoseconds.
+ Weight::from_parts(1_160_000, 36269)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -514,8 +525,8 @@
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3530`
- // Minimum execution time: 11_341_000 picoseconds.
- Weight::from_parts(11_741_000, 3530)
+ // Minimum execution time: 5_710_000 picoseconds.
+ Weight::from_parts(5_980_000, 3530)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
@@ -534,10 +545,10 @@
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3530`
- // Minimum execution time: 2_665_000 picoseconds.
- Weight::from_parts(2_791_000, 3530)
- // Standard Error: 996
- .saturating_add(Weight::from_parts(4_343_736, 0).saturating_mul(b.into()))
+ // Minimum execution time: 1_300_000 picoseconds.
+ Weight::from_parts(1_360_000, 3530)
+ // Standard Error: 2_783
+ .saturating_add(Weight::from_parts(3_456_531, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
.saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(b.into())))
@@ -557,10 +568,10 @@
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3481 + b * (2540 ±0)`
- // Minimum execution time: 2_616_000 picoseconds.
- Weight::from_parts(2_726_000, 3481)
- // Standard Error: 665
- .saturating_add(Weight::from_parts(5_554_066, 0).saturating_mul(b.into()))
+ // Minimum execution time: 1_290_000 picoseconds.
+ Weight::from_parts(1_370_000, 3481)
+ // Standard Error: 3_198
+ .saturating_add(Weight::from_parts(4_435_305, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(RocksDbWeight::get().writes(1_u64))
@@ -582,10 +593,10 @@
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3481 + b * (2540 ±0)`
- // Minimum execution time: 3_697_000 picoseconds.
- Weight::from_parts(2_136_481, 3481)
- // Standard Error: 567
- .saturating_add(Weight::from_parts(4_390_621, 0).saturating_mul(b.into()))
+ // Minimum execution time: 1_730_000 picoseconds.
+ Weight::from_parts(1_810_000, 3481)
+ // Standard Error: 1_923
+ .saturating_add(Weight::from_parts(3_500_817, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(RocksDbWeight::get().writes(2_u64))
@@ -604,8 +615,8 @@
// Proof Size summary in bytes:
// Measured: `456`
// Estimated: `8682`
- // Minimum execution time: 22_859_000 picoseconds.
- Weight::from_parts(23_295_000, 8682)
+ // Minimum execution time: 14_010_000 picoseconds.
+ Weight::from_parts(16_300_000, 8682)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
@@ -625,8 +636,8 @@
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `3554`
- // Minimum execution time: 21_477_000 picoseconds.
- Weight::from_parts(22_037_000, 3554)
+ // Minimum execution time: 13_700_000 picoseconds.
+ Weight::from_parts(14_180_000, 3554)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(6_u64))
}
@@ -638,8 +649,8 @@
// Proof Size summary in bytes:
// Measured: `365`
// Estimated: `6118`
- // Minimum execution time: 13_714_000 picoseconds.
- Weight::from_parts(14_050_000, 6118)
+ // Minimum execution time: 8_990_000 picoseconds.
+ Weight::from_parts(9_400_000, 6118)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
@@ -655,8 +666,8 @@
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `6118`
- // Minimum execution time: 15_879_000 picoseconds.
- Weight::from_parts(16_266_000, 6118)
+ // Minimum execution time: 10_240_000 picoseconds.
+ Weight::from_parts(10_610_000, 6118)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
@@ -672,8 +683,8 @@
// Proof Size summary in bytes:
// Measured: `456`
// Estimated: `6118`
- // Minimum execution time: 18_186_000 picoseconds.
- Weight::from_parts(18_682_000, 6118)
+ // Minimum execution time: 12_040_000 picoseconds.
+ Weight::from_parts(12_390_000, 6118)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
@@ -689,8 +700,8 @@
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `6118`
- // Minimum execution time: 17_943_000 picoseconds.
- Weight::from_parts(18_333_000, 6118)
+ // Minimum execution time: 11_940_000 picoseconds.
+ Weight::from_parts(12_240_000, 6118)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(6_u64))
}
@@ -702,8 +713,8 @@
// Proof Size summary in bytes:
// Measured: `223`
// Estimated: `3554`
- // Minimum execution time: 8_391_000 picoseconds.
- Weight::from_parts(8_637_000, 3554)
+ // Minimum execution time: 5_150_000 picoseconds.
+ Weight::from_parts(5_440_000, 3554)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -715,8 +726,8 @@
// Proof Size summary in bytes:
// Measured: `211`
// Estimated: `3554`
- // Minimum execution time: 8_519_000 picoseconds.
- Weight::from_parts(8_760_000, 3554)
+ // Minimum execution time: 5_170_000 picoseconds.
+ Weight::from_parts(5_400_000, 3554)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -730,8 +741,8 @@
// Proof Size summary in bytes:
// Measured: `495`
// Estimated: `6118`
- // Minimum execution time: 19_554_000 picoseconds.
- Weight::from_parts(20_031_000, 6118)
+ // Minimum execution time: 13_150_000 picoseconds.
+ Weight::from_parts(13_600_000, 6118)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
@@ -749,8 +760,8 @@
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `6118`
- // Minimum execution time: 21_338_000 picoseconds.
- Weight::from_parts(21_803_000, 6118)
+ // Minimum execution time: 14_280_000 picoseconds.
+ Weight::from_parts(14_680_000, 6118)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
@@ -768,8 +779,8 @@
// Proof Size summary in bytes:
// Measured: `586`
// Estimated: `6118`
- // Minimum execution time: 24_179_000 picoseconds.
- Weight::from_parts(24_647_000, 6118)
+ // Minimum execution time: 16_110_000 picoseconds.
+ Weight::from_parts(16_710_000, 6118)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
@@ -787,8 +798,8 @@
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `6118`
- // Minimum execution time: 24_008_000 picoseconds.
- Weight::from_parts(24_545_000, 6118)
+ // Minimum execution time: 16_130_000 picoseconds.
+ Weight::from_parts(16_680_000, 6118)
.saturating_add(RocksDbWeight::get().reads(6_u64))
.saturating_add(RocksDbWeight::get().writes(7_u64))
}
@@ -810,8 +821,8 @@
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `3570`
- // Minimum execution time: 27_907_000 picoseconds.
- Weight::from_parts(28_489_000, 3570)
+ // Minimum execution time: 18_380_000 picoseconds.
+ Weight::from_parts(18_870_000, 3570)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(7_u64))
}
@@ -822,10 +833,10 @@
// Proof Size summary in bytes:
// Measured: `314`
// Estimated: `20191`
- // Minimum execution time: 1_460_000 picoseconds.
- Weight::from_parts(1_564_000, 20191)
- // Standard Error: 14_117
- .saturating_add(Weight::from_parts(8_196_214, 0).saturating_mul(b.into()))
+ // Minimum execution time: 580_000 picoseconds.
+ Weight::from_parts(660_000, 20191)
+ // Standard Error: 29_964
+ .saturating_add(Weight::from_parts(6_251_766, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -840,24 +851,34 @@
// Proof Size summary in bytes:
// Measured: `502 + b * (261 ±0)`
// Estimated: `36269`
- // Minimum execution time: 1_012_000 picoseconds.
- Weight::from_parts(1_081_000, 36269)
- // Standard Error: 6_838
- .saturating_add(Weight::from_parts(5_801_181, 0).saturating_mul(b.into()))
+ // Minimum execution time: 350_000 picoseconds.
+ Weight::from_parts(2_269_806, 36269)
+ // Standard Error: 7_751
+ .saturating_add(Weight::from_parts(3_068_126, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
+ /// Storage: Refungible TokenProperties (r:1 w:0)
+ /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ fn load_token_properties() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `120`
+ // Estimated: `36269`
+ // Minimum execution time: 1_010_000 picoseconds.
+ Weight::from_parts(1_080_000, 36269)
+ .saturating_add(RocksDbWeight::get().reads(1_u64))
+ }
/// Storage: Refungible TokenProperties (r:0 w:1)
/// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
/// The range of component `b` is `[0, 64]`.
- fn init_token_properties(b: u32, ) -> Weight {
+ fn write_token_properties(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 229_000 picoseconds.
- Weight::from_parts(253_000, 0)
- // Standard Error: 100_218
- .saturating_add(Weight::from_parts(12_632_221, 0).saturating_mul(b.into()))
+ // Minimum execution time: 70_000 picoseconds.
+ Weight::from_parts(1_363_449, 0)
+ // Standard Error: 8_964
+ .saturating_add(Weight::from_parts(2_665_759, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: Common CollectionPropertyPermissions (r:1 w:0)
@@ -871,10 +892,10 @@
// Proof Size summary in bytes:
// Measured: `561 + b * (33291 ±0)`
// Estimated: `36269`
- // Minimum execution time: 1_014_000 picoseconds.
- Weight::from_parts(1_065_000, 36269)
- // Standard Error: 39_536
- .saturating_add(Weight::from_parts(24_125_838, 0).saturating_mul(b.into()))
+ // Minimum execution time: 320_000 picoseconds.
+ Weight::from_parts(370_000, 36269)
+ // Standard Error: 28_541
+ .saturating_add(Weight::from_parts(9_863_065, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -886,8 +907,8 @@
// Proof Size summary in bytes:
// Measured: `288`
// Estimated: `3554`
- // Minimum execution time: 10_315_000 picoseconds.
- Weight::from_parts(10_601_000, 3554)
+ // Minimum execution time: 6_320_000 picoseconds.
+ Weight::from_parts(6_640_000, 3554)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
@@ -897,8 +918,8 @@
// Proof Size summary in bytes:
// Measured: `288`
// Estimated: `6118`
- // Minimum execution time: 4_898_000 picoseconds.
- Weight::from_parts(5_136_000, 6118)
+ // Minimum execution time: 2_520_000 picoseconds.
+ Weight::from_parts(2_680_000, 6118)
.saturating_add(RocksDbWeight::get().reads(2_u64))
}
/// Storage: Refungible CollectionAllowance (r:0 w:1)
@@ -907,8 +928,8 @@
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 4_146_000 picoseconds.
- Weight::from_parts(4_337_000, 0)
+ // Minimum execution time: 2_070_000 picoseconds.
+ Weight::from_parts(2_230_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: Refungible CollectionAllowance (r:1 w:0)
@@ -917,8 +938,8 @@
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3576`
- // Minimum execution time: 2_170_000 picoseconds.
- Weight::from_parts(2_301_000, 3576)
+ // Minimum execution time: 1_270_000 picoseconds.
+ Weight::from_parts(1_420_000, 3576)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: Refungible TokenProperties (r:1 w:1)
@@ -927,8 +948,8 @@
// Proof Size summary in bytes:
// Measured: `120`
// Estimated: `36269`
- // Minimum execution time: 2_098_000 picoseconds.
- Weight::from_parts(2_251_000, 36269)
+ // Minimum execution time: 1_010_000 picoseconds.
+ Weight::from_parts(1_160_000, 36269)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
pallets/structure/src/lib.rsdiffbeforeafterboth--- a/pallets/structure/src/lib.rs
+++ b/pallets/structure/src/lib.rs
@@ -53,11 +53,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
-use frame_support::{
- dispatch::{DispatchResult, DispatchResultWithPostInfo},
- fail,
- pallet_prelude::*,
-};
+use frame_support::{dispatch::DispatchResult, fail, pallet_prelude::*};
use pallet_common::{
dispatch::CollectionDispatch, erc::CrossAccountId, eth::is_collection,
CommonCollectionOperations,
@@ -267,22 +263,6 @@
}
Err(<Error<T>>::DepthLimit.into())
- }
-
- /// Burn token and all of it's nested tokens
- ///
- /// - `self_budget`: Limit for searching children in depth.
- /// - `breadth_budget`: Limit of breadth of searching children.
- pub fn burn_item_recursively(
- from: T::CrossAccountId,
- collection: CollectionId,
- token: TokenId,
- self_budget: &dyn Budget,
- breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo {
- let dispatch = T::CollectionDispatch::dispatch(collection)?;
- let dispatch = dispatch.as_dyn();
- dispatch.burn_item_recursively(from, token, self_budget, breadth_budget)
}
/// Check if `token` indirectly owned by `user`
pallets/unique/Cargo.tomldiffbeforeafterboth--- a/pallets/unique/Cargo.toml
+++ b/pallets/unique/Cargo.toml
@@ -31,7 +31,9 @@
'parity-scale-codec/std',
'sp-runtime/std',
'sp-std/std',
+ 'up-common/std',
'up-data-structs/std',
+ 'pallet-structure/std',
]
stubgen = ["evm-coder/stubgen", "pallet-common/stubgen"]
try-runtime = ["frame-support/try-runtime"]
@@ -53,9 +55,11 @@
pallet-evm-coder-substrate = { workspace = true }
pallet-nonfungible = { workspace = true }
pallet-refungible = { workspace = true }
+pallet-structure = { workspace = true }
scale-info = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
+up-common = { workspace = true }
up-data-structs = { workspace = true }
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -84,13 +84,20 @@
#[frame_support::pallet]
pub mod pallet {
- use frame_support::{dispatch::DispatchResult, ensure, fail, storage::Key, BoundedVec};
+ use frame_support::{
+ dispatch::{DispatchErrorWithPostInfo, DispatchResult, PostDispatchInfo},
+ ensure, fail,
+ storage::Key,
+ BoundedVec,
+ };
use frame_system::{ensure_root, ensure_signed};
use pallet_common::{
dispatch::{dispatch_tx, CollectionDispatch},
- CollectionHandle, CommonWeightInfo, Pallet as PalletCommon, RefungibleExtensionsWeightInfo,
+ CollectionHandle, CommonCollectionOperations, CommonWeightInfo, Pallet as PalletCommon,
+ RefungibleExtensionsWeightInfo,
};
use pallet_evm::account::CrossAccountId;
+ use pallet_structure::weights::WeightInfo as StructureWeightInfo;
use scale_info::TypeInfo;
use sp_std::{vec, vec::Vec};
use up_data_structs::{
@@ -104,9 +111,6 @@
use weights::WeightInfo;
use super::*;
-
- /// A maximum number of levels of depth in the token nesting tree.
- pub const NESTING_BUDGET: u32 = 5;
/// Errors for the common Unique transactions.
#[pallet::error]
@@ -128,6 +132,8 @@
/// Weight information for common pallet operations.
type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;
+ type StructureWeightInfo: StructureWeightInfo;
+
/// Weight info information for extra refungible pallet operations.
type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;
}
@@ -264,7 +270,7 @@
impl<T: Config> Pallet<T> {
/// A maximum number of levels of depth in the token nesting tree.
fn nesting_budget() -> u32 {
- NESTING_BUDGET
+ 5
}
/// Maximal length of a collection name.
@@ -666,7 +672,7 @@
/// * `owner`: Address of the initial owner of the item.
/// * `data`: Token data describing the item to store on chain.
#[pallet::call_index(11)]
- #[pallet::weight(T::CommonWeightInfo::create_item(data))]
+ #[pallet::weight(T::CommonWeightInfo::create_item(data) + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn create_item(
origin: OriginFor<T>,
collection_id: CollectionId,
@@ -674,9 +680,9 @@
data: CreateItemData,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
+ Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
d.create_item(sender, owner, data, &budget)
})
}
@@ -700,7 +706,7 @@
/// * `owner`: Address of the initial owner of the tokens.
/// * `items_data`: Vector of data describing each item to be created.
#[pallet::call_index(12)]
- #[pallet::weight(T::CommonWeightInfo::create_multiple_items(items_data))]
+ #[pallet::weight(T::CommonWeightInfo::create_multiple_items(items_data) + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn create_multiple_items(
origin: OriginFor<T>,
collection_id: CollectionId,
@@ -709,9 +715,9 @@
) -> DispatchResultWithPostInfo {
ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
+ Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
d.create_multiple_items(sender, owner, items_data, &budget)
})
}
@@ -791,7 +797,7 @@
/// * `properties`: Vector of key-value pairs stored as the token's metadata.
/// Keys support Latin letters, `-`, `_`, and `.` as symbols.
#[pallet::call_index(15)]
- #[pallet::weight(T::CommonWeightInfo::set_token_properties(properties.len() as u32))]
+ #[pallet::weight(T::CommonWeightInfo::set_token_properties(properties.len() as u32) + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn set_token_properties(
origin: OriginFor<T>,
collection_id: CollectionId,
@@ -801,9 +807,9 @@
ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
+ Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
d.set_token_properties(sender, token_id, properties, &budget)
})
}
@@ -824,7 +830,7 @@
/// * `property_keys`: Vector of keys of the properties to be deleted.
/// Keys support Latin letters, `-`, `_`, and `.` as symbols.
#[pallet::call_index(16)]
- #[pallet::weight(T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32))]
+ #[pallet::weight(T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32) + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn delete_token_properties(
origin: OriginFor<T>,
collection_id: CollectionId,
@@ -834,9 +840,9 @@
ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
+ Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
d.delete_token_properties(sender, token_id, property_keys, &budget)
})
}
@@ -888,16 +894,16 @@
/// * `collection_id`: ID of the collection to which the tokens would belong.
/// * `data`: Explicit item creation data.
#[pallet::call_index(18)]
- #[pallet::weight(T::CommonWeightInfo::create_multiple_items_ex(data))]
+ #[pallet::weight(T::CommonWeightInfo::create_multiple_items_ex(data) + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn create_multiple_items_ex(
origin: OriginFor<T>,
collection_id: CollectionId,
data: CreateItemExData<T::CrossAccountId>,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
+ Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
d.create_multiple_items_ex(sender, data, &budget)
})
}
@@ -995,7 +1001,7 @@
/// * Fungible Mode: The desired number of pieces to burn.
/// * Re-Fungible Mode: The desired number of pieces to burn.
#[pallet::call_index(21)]
- #[pallet::weight(T::CommonWeightInfo::burn_from())]
+ #[pallet::weight(T::CommonWeightInfo::burn_from() + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn burn_from(
origin: OriginFor<T>,
collection_id: CollectionId,
@@ -1004,9 +1010,9 @@
value: u128,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
+ Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
d.burn_from(sender, from, item_id, value, &budget)
})
}
@@ -1033,7 +1039,7 @@
/// * Fungible Mode: The desired number of pieces to transfer.
/// * Re-Fungible Mode: The desired number of pieces to transfer.
#[pallet::call_index(22)]
- #[pallet::weight(T::CommonWeightInfo::transfer())]
+ #[pallet::weight(T::CommonWeightInfo::transfer() + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn transfer(
origin: OriginFor<T>,
recipient: T::CrossAccountId,
@@ -1042,9 +1048,9 @@
value: u128,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
+ Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
d.transfer(sender, recipient, item_id, value, &budget)
})
}
@@ -1138,7 +1144,7 @@
/// * Fungible Mode: The desired number of pieces to transfer.
/// * Re-Fungible Mode: The desired number of pieces to transfer.
#[pallet::call_index(25)]
- #[pallet::weight(T::CommonWeightInfo::transfer_from())]
+ #[pallet::weight(T::CommonWeightInfo::transfer_from() + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn transfer_from(
origin: OriginFor<T>,
from: T::CrossAccountId,
@@ -1148,9 +1154,9 @@
value: u128,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
+ Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
d.transfer_from(sender, from, recipient, item_id, value, &budget)
})
}
@@ -1348,5 +1354,44 @@
Ok(())
}
+
+ fn structure_nesting_budget() -> budget::Value {
+ budget::Value::new(Self::nesting_budget())
+ }
+
+ fn nesting_budget_weight(value: &budget::Value) -> Weight {
+ T::StructureWeightInfo::find_parent().saturating_mul(value.remaining() as u64)
+ }
+
+ fn nesting_budget_predispatch_weight() -> Weight {
+ Self::nesting_budget_weight(&Self::structure_nesting_budget())
+ }
+
+ pub fn dispatch_tx_with_nesting_budget<
+ C: FnOnce(&dyn CommonCollectionOperations<T>) -> DispatchResultWithPostInfo,
+ >(
+ collection: CollectionId,
+ budget: &budget::Value,
+ call: C,
+ ) -> DispatchResultWithPostInfo {
+ let mut result = dispatch_tx::<T, _>(collection, call);
+
+ match &mut result {
+ Ok(PostDispatchInfo {
+ actual_weight: Some(weight),
+ ..
+ })
+ | Err(DispatchErrorWithPostInfo {
+ post_info: PostDispatchInfo {
+ actual_weight: Some(weight),
+ ..
+ },
+ ..
+ }) => *weight += Self::nesting_budget_weight(budget),
+ _ => {}
+ }
+
+ result
+ }
}
}
primitives/common/src/constants.rsdiffbeforeafterboth--- a/primitives/common/src/constants.rs
+++ b/primitives/common/src/constants.rs
@@ -45,6 +45,7 @@
/// Minimum balance required to create or keep an account open.
pub const EXISTENTIAL_DEPOSIT: u128 = 0;
+
/// Amount of Balance reserved for candidate registration.
pub const GENESIS_LICENSE_BOND: u128 = 1_000_000_000_000 * UNIQUE;
/// Amount of maximum collators for Collator Selection.
primitives/data-structs/src/budget.rsdiffbeforeafterboth--- a/primitives/data-structs/src/budget.rs
+++ b/primitives/data-structs/src/budget.rs
@@ -1,4 +1,4 @@
-use core::cell::Cell;
+use sp_std::cell::Cell;
pub trait Budget {
/// Returns true while not exceeded
@@ -22,7 +22,7 @@
pub fn new(v: u32) -> Self {
Self(Cell::new(v))
}
- pub fn refund(self) -> u32 {
+ pub fn remaining(&self) -> u32 {
self.0.get()
}
}
runtime/common/config/pallets/mod.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -116,6 +116,7 @@
impl pallet_unique::Config for Runtime {
type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
type CommonWeightInfo = CommonWeights<Self>;
+ type StructureWeightInfo = pallet_structure::weights::SubstrateWeight<Self>;
type RefungibleExtensionsWeightInfo = CommonWeights<Self>;
}
runtime/common/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -84,7 +84,7 @@
}
fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
- let budget = up_data_structs::budget::Value::new(10);
+ let budget = budget::Value::new(10);
<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)
}
runtime/common/weights/mod.rsdiffbeforeafterboth--- a/runtime/common/weights/mod.rs
+++ b/runtime/common/weights/mod.rs
@@ -98,10 +98,6 @@
dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))
}
- fn delete_token_properties(amount: u32) -> Weight {
- dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))
- }
-
fn set_token_property_permissions(amount: u32) -> Weight {
dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))
}
@@ -124,26 +120,14 @@
fn burn_from() -> Weight {
dispatch_weight::<T>() + max_weight_of!(burn_from())
- }
-
- fn burn_recursively_self_raw() -> Weight {
- max_weight_of!(burn_recursively_self_raw())
- }
-
- fn burn_recursively_breadth_raw(amount: u32) -> Weight {
- max_weight_of!(burn_recursively_breadth_raw(amount))
- }
-
- fn token_owner() -> Weight {
- max_weight_of!(token_owner())
}
fn set_allowance_for_all() -> Weight {
- max_weight_of!(set_allowance_for_all())
+ dispatch_weight::<T>() + max_weight_of!(set_allowance_for_all())
}
fn force_repair_item() -> Weight {
- max_weight_of!(force_repair_item())
+ dispatch_weight::<T>() + max_weight_of!(force_repair_item())
}
}