difftreelog
feat(nonfungible) benchmarking
in: master
5 files changed
pallets/nonfungible/Cargo.tomldiffbeforeafterboth--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -20,6 +20,7 @@
evm-coder = { default-features = false, path = '../../crates/evm-coder' }
pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
ethereum = { default-features = false, version = "0.9.0" }
+frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.10' }
[features]
default = ["std"]
@@ -33,5 +34,10 @@
"evm-coder/std",
"ethereum/std",
"pallet-evm-coder-substrate/std",
+ 'frame-benchmarking/std',
+]
+runtime-benchmarks = [
+ 'frame-benchmarking',
+ 'frame-support/runtime-benchmarks',
+ 'frame-system/runtime-benchmarks',
]
-runtime-benchmarks = []
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -1 +1,101 @@
-#![cfg(feature = "runtime-benchmarking")]
+use super::*;
+use crate::{Pallet, Config, NonfungibleHandle};
+
+use sp_std::prelude::*;
+use pallet_common::benchmarking::{create_collection_raw, create_data};
+use frame_benchmarking::{benchmarks, account};
+use nft_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH};
+use pallet_common::bench_init;
+use core::convert::TryInto;
+
+const SEED: u32 = 1;
+
+fn create_max_item_data<T: Config>(owner: T::CrossAccountId) -> CreateItemData<T> {
+ let const_data = create_data(CUSTOM_DATA_LIMIT as usize).try_into().unwrap();
+ let variable_data = create_data(CUSTOM_DATA_LIMIT as usize).try_into().unwrap();
+ CreateItemData {
+ const_data,
+ variable_data,
+ owner,
+ }
+}
+fn create_max_item<T: Config>(
+ collection: &NonfungibleHandle<T>,
+ sender: &T::CrossAccountId,
+ owner: T::CrossAccountId,
+) -> Result<TokenId, DispatchError> {
+ <Pallet<T>>::create_item(&collection, sender, create_max_item_data(owner))?;
+ Ok(TokenId(<TokensMinted<T>>::get(&collection.id)))
+}
+
+fn create_collection<T: Config>(
+ owner: T::AccountId,
+) -> Result<NonfungibleHandle<T>, DispatchError> {
+ create_collection_raw(
+ owner,
+ CollectionMode::NFT,
+ <Pallet<T>>::init_collection,
+ NonfungibleHandle::cast,
+ )
+}
+
+benchmarks! {
+ create_item {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ sender: cross_from_sub(owner); to: cross_sub;
+ };
+ }: {create_max_item(&collection, &sender, to.clone())?}
+
+ create_multiple_items {
+ let b in 0..MAX_ITEMS_PER_BATCH;
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ sender: cross_from_sub(owner); to: cross_sub;
+ };
+ let data = (0..b).map(|_| create_max_item_data(to.clone())).collect();
+ }: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+
+ burn_item {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ sender: cross_from_sub(owner); burner: cross_sub;
+ };
+ let item = create_max_item(&collection, &sender, burner.clone())?;
+ }: {<Pallet<T>>::burn(&collection, &burner, item)?}
+
+ transfer {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ owner: cross_from_sub; sender: cross_sub; receiver: cross_sub;
+ };
+ let item = create_max_item(&collection, &owner, sender.clone())?;
+ }: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item)?}
+
+ approve {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
+ };
+ let item = create_max_item(&collection, &owner, sender.clone())?;
+ }: {<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?}
+
+ transfer_from {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;
+ };
+ let item = create_max_item(&collection, &owner, sender.clone())?;
+ <Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?;
+ }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item)?}
+
+ set_variable_metadata {
+ let b in 0..CUSTOM_DATA_LIMIT;
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ owner: cross_from_sub; sender: cross_sub;
+ };
+ let item = create_max_item(&collection, &owner, sender.clone())?;
+ let data = create_data(b as usize);
+ }: {<Pallet<T>>::set_variable_metadata(&collection, &sender, item, data)?}
+}
pallets/nonfungible/src/common.rsdiffbeforeafterboth1use core::marker::PhantomData;23use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};4use nft_data_structs::TokenId;5use pallet_common::{6 CommonCollectionOperations, CommonWeightInfo, account::CrossAccountId, with_weight,7};8use sp_runtime::DispatchError;9use sp_std::vec::Vec;1011use crate::{12 AccountBalance, Allowance, Config, CreateItemData, DataKind, Error, NonfungibleHandle, Owned,13 Owner, Pallet, SelfWeightOf, TokenData, weights::WeightInfo,14};1516pub struct CommonWeights<T: Config>(PhantomData<T>);17impl<T: Config> CommonWeightInfo for CommonWeights<T> {18 fn create_item() -> Weight {19 <SelfWeightOf<T>>::create_item()20 }2122 fn create_multiple_items(amount: u32) -> Weight {23 <SelfWeightOf<T>>::create_multiple_items(amount)24 }2526 fn burn_item() -> Weight {27 <SelfWeightOf<T>>::burn_item()28 }2930 fn transfer() -> Weight {31 <SelfWeightOf<T>>::transfer()32 }3334 fn approve() -> Weight {35 <SelfWeightOf<T>>::approve()36 }3738 fn transfer_from() -> Weight {39 <SelfWeightOf<T>>::transfer_from()40 }4142 fn set_variable_metadata(_bytes: u32) -> Weight {43 <SelfWeightOf<T>>::set_variable_metadata()44 }45}4647fn map_create_data<T: Config>(48 data: nft_data_structs::CreateItemData,49 to: &T::CrossAccountId,50) -> Result<CreateItemData<T>, DispatchError> {51 match data {52 nft_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData {53 const_data: data.const_data,54 variable_data: data.variable_data,55 owner: to.clone(),56 }),57 _ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),58 }59}6061impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {62 fn create_item(63 &self,64 sender: T::CrossAccountId,65 to: T::CrossAccountId,66 data: nft_data_structs::CreateItemData,67 ) -> DispatchResultWithPostInfo {68 with_weight(69 <Pallet<T>>::create_item(self, &sender, map_create_data(data, &to)?),70 <SelfWeightOf<T>>::create_item(),71 )72 }7374 fn create_multiple_items(75 &self,76 sender: T::CrossAccountId,77 to: T::CrossAccountId,78 data: Vec<nft_data_structs::CreateItemData>,79 ) -> DispatchResultWithPostInfo {80 let data = data81 .into_iter()82 .map(|d| map_create_data::<T>(d, &to))83 .collect::<Result<Vec<_>, DispatchError>>()?;8485 let amount = data.len();86 with_weight(87 <Pallet<T>>::create_multiple_items(self, &sender, data),88 <SelfWeightOf<T>>::create_multiple_items(amount as u32),89 )90 }9192 fn burn_item(93 &self,94 sender: T::CrossAccountId,95 token: TokenId,96 amount: u128,97 ) -> DispatchResultWithPostInfo {98 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);99 if amount == 1 {100 with_weight(101 <Pallet<T>>::burn(&self, &sender, token),102 <SelfWeightOf<T>>::burn_item(),103 )104 } else {105 Ok(().into())106 }107 }108109 fn transfer(110 &self,111 from: T::CrossAccountId,112 to: T::CrossAccountId,113 token: TokenId,114 amount: u128,115 ) -> DispatchResultWithPostInfo {116 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);117 if amount == 1 {118 with_weight(119 <Pallet<T>>::transfer(&self, &from, &to, token),120 <SelfWeightOf<T>>::transfer(),121 )122 } else {123 Ok(().into())124 }125 }126127 fn approve(128 &self,129 sender: T::CrossAccountId,130 spender: T::CrossAccountId,131 token: TokenId,132 amount: u128,133 ) -> DispatchResultWithPostInfo {134 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);135136 with_weight(137 if amount == 1 {138 <Pallet<T>>::set_allowance(&self, &sender, token, Some(&spender))139 } else {140 <Pallet<T>>::set_allowance(&self, &sender, token, None)141 },142 <SelfWeightOf<T>>::approve(),143 )144 }145146 fn transfer_from(147 &self,148 sender: T::CrossAccountId,149 from: T::CrossAccountId,150 to: T::CrossAccountId,151 token: TokenId,152 amount: u128,153 ) -> DispatchResultWithPostInfo {154 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);155156 if amount == 1 {157 with_weight(158 <Pallet<T>>::transfer_from(&self, &sender, &from, &to, token),159 <SelfWeightOf<T>>::transfer_from(),160 )161 } else {162 Ok(().into())163 }164 }165166 fn set_variable_metadata(167 &self,168 sender: T::CrossAccountId,169 token: TokenId,170 data: Vec<u8>,171 ) -> DispatchResultWithPostInfo {172 with_weight(173 <Pallet<T>>::set_variable_metadata(&self, &sender, token, data),174 <SelfWeightOf<T>>::set_variable_metadata(),175 )176 }177178 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {179 <Owned<T>>::iter_prefix((self.id, account.as_sub()))180 .map(|(id, _)| id)181 .collect()182 }183184 fn token_exists(&self, token: TokenId) -> bool {185 <Pallet<T>>::token_exists(self, token)186 }187188 fn last_token_id(&self) -> TokenId {189 TokenId(<TokensMinted<T>>::get(self.id))190 }191192 fn token_owner(&self, token: TokenId) -> T::CrossAccountId {193 <TokenData<T>>::get((self.id, token))194 .map(|t| t.owner)195 .unwrap_or_default()196 }197 fn const_metadata(&self, token: TokenId) -> Vec<u8> {198 <TokenData<T>>::get((self.id, token))199 .map(|t| t.const_data.clone())200 .unwrap_or_default()201 }202 fn variable_metadata(&self, token: TokenId) -> Vec<u8> {203 <TokenData<T>>::get((self.id, token))204 .map(|t| t.variable_data.clone())205 .unwrap_or_default()206 }207208 fn collection_tokens(&self) -> u32 {209 <Pallet<T>>::total_supply(self)210 }211212 fn account_balance(&self, account: T::CrossAccountId) -> u32 {213 <AccountBalance<T>>::get((self.id, account.as_sub()))214 }215216 fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {217 if <TokenData<T>>::get((self.id, token))218 .map(|a| a.owner == account)219 .unwrap_or(false)220 {221 1222 } else {223 0224 }225 }226227 fn allowance(228 &self,229 sender: T::CrossAccountId,230 spender: T::CrossAccountId,231 token: TokenId,232 ) -> u128 {233 if <TokenData<T>>::get((self.id, token))234 .map(|a| a.owner == sender)235 .unwrap_or(false)236 {237 0238 } else if <Allowance<T>>::get((self.id, token)) == Some(spender) {239 1240 } else {241 0242 }243 }244}1use core::marker::PhantomData;23use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};4use nft_data_structs::TokenId;5use pallet_common::{6 CommonCollectionOperations, CommonWeightInfo, account::CrossAccountId, with_weight,7};8use sp_runtime::DispatchError;9use sp_std::vec::Vec;1011use crate::{12 AccountBalance, Allowance, Config, CreateItemData, Error, NonfungibleHandle, Owned, Pallet,13 SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted,14};1516pub struct CommonWeights<T: Config>(PhantomData<T>);17impl<T: Config> CommonWeightInfo for CommonWeights<T> {18 fn create_item() -> Weight {19 <SelfWeightOf<T>>::create_item()20 }2122 fn create_multiple_items(amount: u32) -> Weight {23 <SelfWeightOf<T>>::create_multiple_items(amount)24 }2526 fn burn_item() -> Weight {27 <SelfWeightOf<T>>::burn_item()28 }2930 fn transfer() -> Weight {31 <SelfWeightOf<T>>::transfer()32 }3334 fn approve() -> Weight {35 <SelfWeightOf<T>>::approve()36 }3738 fn transfer_from() -> Weight {39 <SelfWeightOf<T>>::transfer_from()40 }4142 fn set_variable_metadata(bytes: u32) -> Weight {43 <SelfWeightOf<T>>::set_variable_metadata(bytes)44 }45}4647fn map_create_data<T: Config>(48 data: nft_data_structs::CreateItemData,49 to: &T::CrossAccountId,50) -> Result<CreateItemData<T>, DispatchError> {51 match data {52 nft_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData {53 const_data: data.const_data,54 variable_data: data.variable_data,55 owner: to.clone(),56 }),57 _ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),58 }59}6061impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {62 fn create_item(63 &self,64 sender: T::CrossAccountId,65 to: T::CrossAccountId,66 data: nft_data_structs::CreateItemData,67 ) -> DispatchResultWithPostInfo {68 with_weight(69 <Pallet<T>>::create_item(self, &sender, map_create_data(data, &to)?),70 <CommonWeights<T>>::create_item(),71 )72 }7374 fn create_multiple_items(75 &self,76 sender: T::CrossAccountId,77 to: T::CrossAccountId,78 data: Vec<nft_data_structs::CreateItemData>,79 ) -> DispatchResultWithPostInfo {80 let data = data81 .into_iter()82 .map(|d| map_create_data::<T>(d, &to))83 .collect::<Result<Vec<_>, DispatchError>>()?;8485 let amount = data.len();86 with_weight(87 <Pallet<T>>::create_multiple_items(self, &sender, data),88 <CommonWeights<T>>::create_multiple_items(amount as u32),89 )90 }9192 fn burn_item(93 &self,94 sender: T::CrossAccountId,95 token: TokenId,96 amount: u128,97 ) -> DispatchResultWithPostInfo {98 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);99 if amount == 1 {100 with_weight(101 <Pallet<T>>::burn(&self, &sender, token),102 <CommonWeights<T>>::burn_item(),103 )104 } else {105 Ok(().into())106 }107 }108109 fn transfer(110 &self,111 from: T::CrossAccountId,112 to: T::CrossAccountId,113 token: TokenId,114 amount: u128,115 ) -> DispatchResultWithPostInfo {116 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);117 if amount == 1 {118 with_weight(119 <Pallet<T>>::transfer(&self, &from, &to, token),120 <CommonWeights<T>>::transfer(),121 )122 } else {123 Ok(().into())124 }125 }126127 fn approve(128 &self,129 sender: T::CrossAccountId,130 spender: T::CrossAccountId,131 token: TokenId,132 amount: u128,133 ) -> DispatchResultWithPostInfo {134 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);135136 with_weight(137 if amount == 1 {138 <Pallet<T>>::set_allowance(&self, &sender, token, Some(&spender))139 } else {140 <Pallet<T>>::set_allowance(&self, &sender, token, None)141 },142 <CommonWeights<T>>::approve(),143 )144 }145146 fn transfer_from(147 &self,148 sender: T::CrossAccountId,149 from: T::CrossAccountId,150 to: T::CrossAccountId,151 token: TokenId,152 amount: u128,153 ) -> DispatchResultWithPostInfo {154 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);155156 if amount == 1 {157 with_weight(158 <Pallet<T>>::transfer_from(&self, &sender, &from, &to, token),159 <CommonWeights<T>>::transfer_from(),160 )161 } else {162 Ok(().into())163 }164 }165166 fn set_variable_metadata(167 &self,168 sender: T::CrossAccountId,169 token: TokenId,170 data: Vec<u8>,171 ) -> DispatchResultWithPostInfo {172 let len = data.len();173 with_weight(174 <Pallet<T>>::set_variable_metadata(&self, &sender, token, data),175 <CommonWeights<T>>::set_variable_metadata(len as u32),176 )177 }178179 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {180 <Owned<T>>::iter_prefix((self.id, account.as_sub()))181 .map(|(id, _)| id)182 .collect()183 }184185 fn token_exists(&self, token: TokenId) -> bool {186 <Pallet<T>>::token_exists(self, token)187 }188189 fn last_token_id(&self) -> TokenId {190 TokenId(<TokensMinted<T>>::get(self.id))191 }192193 fn token_owner(&self, token: TokenId) -> T::CrossAccountId {194 <TokenData<T>>::get((self.id, token))195 .map(|t| t.owner)196 .unwrap_or_default()197 }198 fn const_metadata(&self, token: TokenId) -> Vec<u8> {199 <TokenData<T>>::get((self.id, token))200 .map(|t| t.const_data.clone())201 .unwrap_or_default()202 }203 fn variable_metadata(&self, token: TokenId) -> Vec<u8> {204 <TokenData<T>>::get((self.id, token))205 .map(|t| t.variable_data.clone())206 .unwrap_or_default()207 }208209 fn collection_tokens(&self) -> u32 {210 <Pallet<T>>::total_supply(self)211 }212213 fn account_balance(&self, account: T::CrossAccountId) -> u32 {214 <AccountBalance<T>>::get((self.id, account.as_sub()))215 }216217 fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {218 if <TokenData<T>>::get((self.id, token))219 .map(|a| a.owner == account)220 .unwrap_or(false)221 {222 1223 } else {224 0225 }226 }227228 fn allowance(229 &self,230 sender: T::CrossAccountId,231 spender: T::CrossAccountId,232 token: TokenId,233 ) -> u128 {234 if <TokenData<T>>::get((self.id, token))235 .map(|a| a.owner == sender)236 .unwrap_or(false)237 {238 0239 } else if <Allowance<T>>::get((self.id, token)) == Some(spender) {240 1241 } else {242 0243 }244 }245}pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -16,6 +16,7 @@
use codec::{Encode, Decode};
pub use pallet::*;
+#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;
pub mod common;
pub mod erc;
pallets/nonfungible/src/weights.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -1,3 +1,27 @@
+// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs
+
+//! Autogenerated weights for pallet_nonfungible
+//!
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
+//! DATE: 2021-10-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128
+
+// Executed Command:
+// target/release/nft
+// benchmark
+// --pallet
+// pallet-nonfungible
+// --wasm-execution
+// compiled
+// --extrinsic
+// *
+// --template
+// .maintain/frame-weight-template.hbs
+// --steps=50
+// --repeat=20
+// --output=./pallets/nonfungible/src/weights.rs
+
+
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
@@ -5,33 +29,144 @@
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;
+/// Weight functions needed for pallet_nonfungible.
pub trait WeightInfo {
fn create_item() -> Weight;
- fn create_multiple_items(b: u32) -> Weight;
+ fn create_multiple_items(b: u32, ) -> Weight;
fn burn_item() -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
fn transfer_from() -> Weight;
- fn set_variable_metadata() -> Weight;
+ fn set_variable_metadata(b: u32, ) -> Weight;
}
+/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
- fn create_item() -> Weight {0}
- fn create_multiple_items(_b: u32) -> Weight {0}
- fn burn_item() -> Weight {0}
- fn transfer() -> Weight {0}
- fn approve() -> Weight {0}
- fn transfer_from() -> Weight {0}
- fn set_variable_metadata() -> Weight {0}
+ // Storage: Nonfungible TokensMinted (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:1 w:1)
+ // Storage: Nonfungible TokenData (r:0 w:1)
+ // Storage: Nonfungible Owned (r:0 w:1)
+ fn create_item() -> Weight {
+ (16_902_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(2 as Weight))
+ .saturating_add(T::DbWeight::get().writes(4 as Weight))
+ }
+ // Storage: Nonfungible TokensMinted (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:1 w:1)
+ // Storage: Nonfungible TokenData (r:0 w:4)
+ // Storage: Nonfungible Owned (r:0 w:4)
+ fn create_multiple_items(b: u32, ) -> Weight {
+ (15_860_000 as Weight)
+ // Standard Error: 5_000
+ .saturating_add((3_916_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(T::DbWeight::get().reads(2 as Weight))
+ .saturating_add(T::DbWeight::get().writes(2 as Weight))
+ .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))
+ }
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ // Storage: Nonfungible TokensBurnt (r:1 w:1)
+ // Storage: Nonfungible Allowance (r:1 w:0)
+ // Storage: Nonfungible Owned (r:0 w:1)
+ fn burn_item() -> Weight {
+ (17_966_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(3 as Weight))
+ .saturating_add(T::DbWeight::get().writes(3 as Weight))
+ }
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:2 w:2)
+ // Storage: Nonfungible Allowance (r:1 w:0)
+ // Storage: Nonfungible Owned (r:0 w:2)
+ fn transfer() -> Weight {
+ (23_886_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ .saturating_add(T::DbWeight::get().writes(5 as Weight))
+ }
+ // Storage: Nonfungible TokenData (r:1 w:0)
+ // Storage: Nonfungible Allowance (r:1 w:1)
+ fn approve() -> Weight {
+ (14_697_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(2 as Weight))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
+ }
+ // Storage: Nonfungible Allowance (r:1 w:1)
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:2 w:2)
+ // Storage: Nonfungible Owned (r:0 w:2)
+ fn transfer_from() -> Weight {
+ (28_001_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ .saturating_add(T::DbWeight::get().writes(6 as Weight))
+ }
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ fn set_variable_metadata(_b: u32, ) -> Weight {
+ (6_380_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(1 as Weight))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
+ }
}
+// For backwards compatibility and tests
impl WeightInfo for () {
- fn create_item() -> Weight {0}
- fn create_multiple_items(_b: u32) -> Weight {0}
- fn burn_item() -> Weight {0}
- fn transfer() -> Weight {0}
- fn approve() -> Weight {0}
- fn transfer_from() -> Weight {0}
- fn set_variable_metadata() -> Weight {0}
+ // Storage: Nonfungible TokensMinted (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:1 w:1)
+ // Storage: Nonfungible TokenData (r:0 w:1)
+ // Storage: Nonfungible Owned (r:0 w:1)
+ fn create_item() -> Weight {
+ (16_902_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(2 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(4 as Weight))
+ }
+ // Storage: Nonfungible TokensMinted (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:1 w:1)
+ // Storage: Nonfungible TokenData (r:0 w:4)
+ // Storage: Nonfungible Owned (r:0 w:4)
+ fn create_multiple_items(b: u32, ) -> Weight {
+ (15_860_000 as Weight)
+ // Standard Error: 5_000
+ .saturating_add((3_916_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(RocksDbWeight::get().reads(2 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(2 as Weight))
+ .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))
+ }
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ // Storage: Nonfungible TokensBurnt (r:1 w:1)
+ // Storage: Nonfungible Allowance (r:1 w:0)
+ // Storage: Nonfungible Owned (r:0 w:1)
+ fn burn_item() -> Weight {
+ (17_966_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(3 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(3 as Weight))
+ }
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:2 w:2)
+ // Storage: Nonfungible Allowance (r:1 w:0)
+ // Storage: Nonfungible Owned (r:0 w:2)
+ fn transfer() -> Weight {
+ (23_886_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(4 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(5 as Weight))
+ }
+ // Storage: Nonfungible TokenData (r:1 w:0)
+ // Storage: Nonfungible Allowance (r:1 w:1)
+ fn approve() -> Weight {
+ (14_697_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(2 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(1 as Weight))
+ }
+ // Storage: Nonfungible Allowance (r:1 w:1)
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:2 w:2)
+ // Storage: Nonfungible Owned (r:0 w:2)
+ fn transfer_from() -> Weight {
+ (28_001_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(4 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(6 as Weight))
+ }
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ fn set_variable_metadata(_b: u32, ) -> Weight {
+ (6_380_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(1 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(1 as Weight))
+ }
}