difftreelog
NFTPAR-260_217. Benchmarks
in: master
4 files changed
pallets/nft/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nft/src/benchmarking.rs
+++ b/pallets/nft/src/benchmarking.rs
@@ -355,4 +355,66 @@
Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;
}: set_variable_meta_data(RawOrigin::Signed(caller.clone()), 2, 1, [1, 2, 3].to_vec())
+
+ set_schema_version {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT;
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ }: set_schema_version(RawOrigin::Signed(caller.clone()), 2, SchemaVersion::Unique)
+
+ set_chain_limits {
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ let limits = ChainLimits {
+ collection_numbers_limit: 0,
+ account_token_ownership_limit: 0,
+ collections_admins_limit: 0,
+ custom_data_limit: 0,
+ nft_sponsor_transfer_timeout: 0,
+ fungible_sponsor_transfer_timeout: 0,
+ refungible_sponsor_transfer_timeout: 0
+ };
+ }: set_chain_limits(RawOrigin::Signed(caller.clone()), limits)
+
+ set_contract_sponsoring_rate_limit {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT;
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ let block_number: T::BlockNumber = 0.into();
+ }: set_contract_sponsoring_rate_limit(RawOrigin::Signed(caller.clone()), caller.clone(), block_number)
+
+ set_collection_limits{
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT;
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+
+ let cl = CollectionLimits {
+ account_token_ownership_limit: 0,
+ sponsored_data_size: 0,
+ token_limit: 0,
+ sponsor_transfer_timeout: 0
+ };
+
+ }: set_collection_limits(RawOrigin::Signed(caller.clone()), 2, cl)
+
+ add_to_contract_white_list{
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ }: add_to_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), caller.clone())
+
+ remove_from_contract_white_list{
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::add_to_contract_white_list(RawOrigin::Signed(caller.clone()).into(), caller.clone(), caller.clone())?;
+ }: remove_from_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), caller.clone())
+
+ toggle_contract_white_list{
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ }: toggle_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), true)
}
\ No newline at end of file
pallets/nft/src/default_weights.rsdiffbeforeafterboth--- a/pallets/nft/src/default_weights.rs
+++ b/pallets/nft/src/default_weights.rs
@@ -107,19 +107,44 @@
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
- // fn set_chain_limits() -> Weight {
- // (0 as Weight)
- // .saturating_add(DbWeight::get().reads(1 as Weight))
- // .saturating_add(DbWeight::get().writes(1 as Weight))
- // }
fn enable_contract_sponsoring() -> Weight {
(13_000_000 as Weight)
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
- // fn set_contract_sponsoring_rate_limit() -> Weight {
- // (0 as Weight)
- // .saturating_add(DbWeight::get().reads(1 as Weight))
- // .saturating_add(DbWeight::get().writes(1 as Weight))
- // }
+ fn set_schema_version() -> Weight {
+ (8_500_000 as Weight)
+ .saturating_add(DbWeight::get().reads(2 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn set_chain_limits() -> Weight {
+ (1_300_000 as Weight)
+ .saturating_add(DbWeight::get().reads(0 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn set_contract_sponsoring_rate_limit() -> Weight {
+ (3_500_000 as Weight)
+ .saturating_add(DbWeight::get().reads(0 as Weight))
+ .saturating_add(DbWeight::get().writes(2 as Weight))
+ }
+ fn toggle_contract_white_list() -> Weight {
+ (3_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(0 as Weight))
+ .saturating_add(DbWeight::get().writes(2 as Weight))
+ }
+ fn add_to_contract_white_list() -> Weight {
+ (3_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(0 as Weight))
+ .saturating_add(DbWeight::get().writes(2 as Weight))
+ }
+ fn remove_from_contract_white_list() -> Weight {
+ (3_200_000 as Weight)
+ .saturating_add(DbWeight::get().reads(0 as Weight))
+ .saturating_add(DbWeight::get().writes(2 as Weight))
+ }
+ fn set_collection_limits() -> Weight {
+ (8_900_000 as Weight)
+ .saturating_add(DbWeight::get().reads(2 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
}
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -251,6 +251,13 @@
fn set_variable_on_chain_schema() -> Weight;
fn set_variable_meta_data() -> Weight;
fn enable_contract_sponsoring() -> Weight;
+ fn set_schema_version() -> Weight;
+ fn set_chain_limits() -> Weight;
+ fn set_contract_sponsoring_rate_limit() -> Weight;
+ fn toggle_contract_white_list() -> Weight;
+ fn add_to_contract_white_list() -> Weight;
+ fn remove_from_contract_white_list() -> Weight;
+ fn set_collection_limits() -> Weight;
}
#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]
@@ -1276,7 +1283,7 @@
/// * collection_id.
///
/// * schema: SchemaVersion: enum
- #[weight = 0]
+ #[weight = T::WeightInfo::set_schema_version()]
pub fn set_schema_version(
origin,
collection_id: CollectionId,
@@ -1376,12 +1383,15 @@
}
// Sudo permissions function
- #[weight = 0]
+ #[weight = T::WeightInfo::set_chain_limits()]
pub fn set_chain_limits(
origin,
limits: ChainLimits
) -> DispatchResult {
+
+ #[cfg(not(feature = "runtime-benchmarks"))]
ensure_root(origin)?;
+
<ChainLimit>::put(limits);
Ok(())
}
@@ -1432,15 +1442,18 @@
/// -`contract_address`: Address of the contract to sponsor
/// -`rate_limit`: Number of blocks to wait until the next sponsored transaction is allowed
///
- #[weight = 0]
+ #[weight = T::WeightInfo::set_contract_sponsoring_rate_limit()]
pub fn set_contract_sponsoring_rate_limit(
origin,
contract_address: T::AccountId,
rate_limit: T::BlockNumber
) -> DispatchResult {
let sender = ensure_signed(origin)?;
- Self::ensure_contract_owned(sender, &contract_address)?;
+ #[cfg(feature = "runtime-benchmarks")]
+ <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());
+
+ Self::ensure_contract_owned(sender, &contract_address)?;
<ContractSponsoringRateLimit<T>>::insert(contract_address, rate_limit);
Ok(())
}
@@ -1456,15 +1469,18 @@
/// -`contract_address`: Address of the contract.
///
/// - `enable`: .
- #[weight = 0]
+ #[weight = T::WeightInfo::toggle_contract_white_list()]
pub fn toggle_contract_white_list(
origin,
contract_address: T::AccountId,
enable: bool
) -> DispatchResult {
let sender = ensure_signed(origin)?;
- Self::ensure_contract_owned(sender, &contract_address)?;
+ #[cfg(feature = "runtime-benchmarks")]
+ <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());
+
+ Self::ensure_contract_owned(sender, &contract_address)?;
<ContractWhiteListEnabled<T>>::insert(contract_address, enable);
Ok(())
}
@@ -1480,15 +1496,18 @@
/// -`contract_address`: Address of the contract.
///
/// -`account_address`: Address to add.
- #[weight = 0]
+ #[weight = T::WeightInfo::add_to_contract_white_list()]
pub fn add_to_contract_white_list(
origin,
contract_address: T::AccountId,
account_address: T::AccountId
) -> DispatchResult {
let sender = ensure_signed(origin)?;
- Self::ensure_contract_owned(sender, &contract_address)?;
+
+ #[cfg(feature = "runtime-benchmarks")]
+ <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());
+ Self::ensure_contract_owned(sender, &contract_address)?;
<ContractWhiteList<T>>::insert(contract_address, account_address, true);
Ok(())
}
@@ -1504,20 +1523,23 @@
/// -`contract_address`: Address of the contract.
///
/// -`account_address`: Address to remove.
- #[weight = 0]
+ #[weight = T::WeightInfo::remove_from_contract_white_list()]
pub fn remove_from_contract_white_list(
origin,
contract_address: T::AccountId,
account_address: T::AccountId
) -> DispatchResult {
let sender = ensure_signed(origin)?;
+
+ #[cfg(feature = "runtime-benchmarks")]
+ <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());
+
Self::ensure_contract_owned(sender, &contract_address)?;
-
<ContractWhiteList<T>>::remove(contract_address, account_address);
Ok(())
}
- #[weight = 0]
+ #[weight = T::WeightInfo::set_collection_limits()]
pub fn set_collection_limits(
origin,
collection_id: u32,
runtime/src/nft_weights.rsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};78pub struct WeightInfo;9impl pallet_nft::WeightInfo for WeightInfo {10 fn create_collection() -> Weight {11 (70_000_000 as Weight)12 .saturating_add(DbWeight::get().reads(7 as Weight))13 .saturating_add(DbWeight::get().writes(5 as Weight))14 }15 fn destroy_collection() -> Weight {16 (90_000_000 as Weight)17 .saturating_add(DbWeight::get().reads(2 as Weight))18 .saturating_add(DbWeight::get().writes(5 as Weight))19 }20 fn add_to_white_list() -> Weight {21 (30_000_000 as Weight)22 .saturating_add(DbWeight::get().reads(3 as Weight))23 .saturating_add(DbWeight::get().writes(1 as Weight))24 }25 fn remove_from_white_list() -> Weight {26 (35_000_000 as Weight)27 .saturating_add(DbWeight::get().reads(3 as Weight))28 .saturating_add(DbWeight::get().writes(1 as Weight))29 }30 fn set_public_access_mode() -> Weight {31 (27_000_000 as Weight)32 .saturating_add(DbWeight::get().reads(1 as Weight))33 .saturating_add(DbWeight::get().writes(1 as Weight))34 }35 fn set_mint_permission() -> Weight {36 (27_000_000 as Weight)37 .saturating_add(DbWeight::get().reads(1 as Weight))38 .saturating_add(DbWeight::get().writes(1 as Weight))39 }40 fn change_collection_owner() -> Weight {41 (27_000_000 as Weight)42 .saturating_add(DbWeight::get().reads(1 as Weight))43 .saturating_add(DbWeight::get().writes(1 as Weight))44 }45 fn add_collection_admin() -> Weight {46 (32_000_000 as Weight)47 .saturating_add(DbWeight::get().reads(3 as Weight))48 .saturating_add(DbWeight::get().writes(1 as Weight))49 }50 fn remove_collection_admin() -> Weight {51 (50_000_000 as Weight)52 .saturating_add(DbWeight::get().reads(2 as Weight))53 .saturating_add(DbWeight::get().writes(1 as Weight))54 }55 fn set_collection_sponsor() -> Weight {56 (32_000_000 as Weight)57 .saturating_add(DbWeight::get().reads(2 as Weight))58 .saturating_add(DbWeight::get().writes(1 as Weight))59 } 60 fn confirm_sponsorship() -> Weight {61 (22_000_000 as Weight)62 .saturating_add(DbWeight::get().reads(1 as Weight))63 .saturating_add(DbWeight::get().writes(1 as Weight))64 } 65 fn remove_collection_sponsor() -> Weight {66 (24_000_000 as Weight)67 .saturating_add(DbWeight::get().reads(1 as Weight))68 .saturating_add(DbWeight::get().writes(1 as Weight))69 } 70 fn create_item(s: usize, ) -> Weight {71 (130_000_000 as Weight)72 .saturating_add((2135 as Weight).saturating_mul(s as Weight).saturating_mul(500 as Weight)) // 500 is temparary multiplier, fee for storage73 .saturating_add(DbWeight::get().reads(10 as Weight))74 .saturating_add(DbWeight::get().writes(8 as Weight))75 } 76 fn burn_item() -> Weight {77 (170_000_000 as Weight)78 .saturating_add(DbWeight::get().reads(9 as Weight))79 .saturating_add(DbWeight::get().writes(7 as Weight))80 } 81 fn transfer() -> Weight {82 (125_000_000 as Weight)83 .saturating_add(DbWeight::get().reads(7 as Weight))84 .saturating_add(DbWeight::get().writes(7 as Weight))85 } 86 fn approve() -> Weight {87 (45_000_000 as Weight)88 .saturating_add(DbWeight::get().reads(3 as Weight))89 .saturating_add(DbWeight::get().writes(1 as Weight))90 }91 fn transfer_from() -> Weight {92 (150_000_000 as Weight)93 .saturating_add(DbWeight::get().reads(9 as Weight))94 .saturating_add(DbWeight::get().writes(8 as Weight))95 }96 fn set_offchain_schema() -> Weight {97 (33_000_000 as Weight)98 .saturating_add(DbWeight::get().reads(2 as Weight))99 .saturating_add(DbWeight::get().writes(1 as Weight))100 }101 fn set_const_on_chain_schema() -> Weight {102 (11_100_000 as Weight)103 .saturating_add(DbWeight::get().reads(2 as Weight))104 .saturating_add(DbWeight::get().writes(1 as Weight))105 }106 fn set_variable_on_chain_schema() -> Weight {107 (11_100_000 as Weight)108 .saturating_add(DbWeight::get().reads(2 as Weight))109 .saturating_add(DbWeight::get().writes(1 as Weight))110 }111 fn set_variable_meta_data() -> Weight {112 (17_500_000 as Weight)113 .saturating_add(DbWeight::get().reads(2 as Weight))114 .saturating_add(DbWeight::get().writes(1 as Weight))115 }116 // fn set_chain_limits() -> Weight {117 // (0 as Weight)118 // .saturating_add(DbWeight::get().reads(1 as Weight))119 // .saturating_add(DbWeight::get().writes(1 as Weight))120 // }121 fn enable_contract_sponsoring() -> Weight {122 (13_000_000 as Weight)123 .saturating_add(DbWeight::get().reads(1 as Weight))124 .saturating_add(DbWeight::get().writes(1 as Weight))125 }126 // fn set_contract_sponsoring_rate_limit() -> Weight {127 // (0 as Weight)128 // .saturating_add(DbWeight::get().reads(1 as Weight))129 // .saturating_add(DbWeight::get().writes(1 as Weight))130 // }131}1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};78pub struct WeightInfo;9impl pallet_nft::WeightInfo for WeightInfo {10 fn create_collection() -> Weight {11 (70_000_000 as Weight)12 .saturating_add(DbWeight::get().reads(7 as Weight))13 .saturating_add(DbWeight::get().writes(5 as Weight))14 }15 fn destroy_collection() -> Weight {16 (90_000_000 as Weight)17 .saturating_add(DbWeight::get().reads(2 as Weight))18 .saturating_add(DbWeight::get().writes(5 as Weight))19 }20 fn add_to_white_list() -> Weight {21 (30_000_000 as Weight)22 .saturating_add(DbWeight::get().reads(3 as Weight))23 .saturating_add(DbWeight::get().writes(1 as Weight))24 }25 fn remove_from_white_list() -> Weight {26 (35_000_000 as Weight)27 .saturating_add(DbWeight::get().reads(3 as Weight))28 .saturating_add(DbWeight::get().writes(1 as Weight))29 }30 fn set_public_access_mode() -> Weight {31 (27_000_000 as Weight)32 .saturating_add(DbWeight::get().reads(1 as Weight))33 .saturating_add(DbWeight::get().writes(1 as Weight))34 }35 fn set_mint_permission() -> Weight {36 (27_000_000 as Weight)37 .saturating_add(DbWeight::get().reads(1 as Weight))38 .saturating_add(DbWeight::get().writes(1 as Weight))39 }40 fn change_collection_owner() -> Weight {41 (27_000_000 as Weight)42 .saturating_add(DbWeight::get().reads(1 as Weight))43 .saturating_add(DbWeight::get().writes(1 as Weight))44 }45 fn add_collection_admin() -> Weight {46 (32_000_000 as Weight)47 .saturating_add(DbWeight::get().reads(3 as Weight))48 .saturating_add(DbWeight::get().writes(1 as Weight))49 }50 fn remove_collection_admin() -> Weight {51 (50_000_000 as Weight)52 .saturating_add(DbWeight::get().reads(2 as Weight))53 .saturating_add(DbWeight::get().writes(1 as Weight))54 }55 fn set_collection_sponsor() -> Weight {56 (32_000_000 as Weight)57 .saturating_add(DbWeight::get().reads(2 as Weight))58 .saturating_add(DbWeight::get().writes(1 as Weight))59 } 60 fn confirm_sponsorship() -> Weight {61 (22_000_000 as Weight)62 .saturating_add(DbWeight::get().reads(1 as Weight))63 .saturating_add(DbWeight::get().writes(1 as Weight))64 } 65 fn remove_collection_sponsor() -> Weight {66 (24_000_000 as Weight)67 .saturating_add(DbWeight::get().reads(1 as Weight))68 .saturating_add(DbWeight::get().writes(1 as Weight))69 } 70 fn create_item(s: usize, ) -> Weight {71 (130_000_000 as Weight)72 .saturating_add((2135 as Weight).saturating_mul(s as Weight).saturating_mul(500 as Weight)) // 500 is temparary multiplier, fee for storage73 .saturating_add(DbWeight::get().reads(10 as Weight))74 .saturating_add(DbWeight::get().writes(8 as Weight))75 } 76 fn burn_item() -> Weight {77 (170_000_000 as Weight)78 .saturating_add(DbWeight::get().reads(9 as Weight))79 .saturating_add(DbWeight::get().writes(7 as Weight))80 } 81 fn transfer() -> Weight {82 (125_000_000 as Weight)83 .saturating_add(DbWeight::get().reads(7 as Weight))84 .saturating_add(DbWeight::get().writes(7 as Weight))85 } 86 fn approve() -> Weight {87 (45_000_000 as Weight)88 .saturating_add(DbWeight::get().reads(3 as Weight))89 .saturating_add(DbWeight::get().writes(1 as Weight))90 }91 fn transfer_from() -> Weight {92 (150_000_000 as Weight)93 .saturating_add(DbWeight::get().reads(9 as Weight))94 .saturating_add(DbWeight::get().writes(8 as Weight))95 }96 fn set_offchain_schema() -> Weight {97 (33_000_000 as Weight)98 .saturating_add(DbWeight::get().reads(2 as Weight))99 .saturating_add(DbWeight::get().writes(1 as Weight))100 }101 fn set_const_on_chain_schema() -> Weight {102 (11_100_000 as Weight)103 .saturating_add(DbWeight::get().reads(2 as Weight))104 .saturating_add(DbWeight::get().writes(1 as Weight))105 }106 fn set_variable_on_chain_schema() -> Weight {107 (11_100_000 as Weight)108 .saturating_add(DbWeight::get().reads(2 as Weight))109 .saturating_add(DbWeight::get().writes(1 as Weight))110 }111 fn set_variable_meta_data() -> Weight {112 (17_500_000 as Weight)113 .saturating_add(DbWeight::get().reads(2 as Weight))114 .saturating_add(DbWeight::get().writes(1 as Weight))115 }116 fn enable_contract_sponsoring() -> Weight {117 (13_000_000 as Weight)118 .saturating_add(DbWeight::get().reads(1 as Weight))119 .saturating_add(DbWeight::get().writes(1 as Weight))120 }121 fn set_schema_version() -> Weight {122 (8_500_000 as Weight)123 .saturating_add(DbWeight::get().reads(2 as Weight))124 .saturating_add(DbWeight::get().writes(1 as Weight))125 }126 fn set_chain_limits() -> Weight {127 (1_300_000 as Weight)128 .saturating_add(DbWeight::get().reads(0 as Weight))129 .saturating_add(DbWeight::get().writes(1 as Weight))130 }131 fn set_contract_sponsoring_rate_limit() -> Weight {132 (3_500_000 as Weight)133 .saturating_add(DbWeight::get().reads(0 as Weight))134 .saturating_add(DbWeight::get().writes(2 as Weight))135 } 136 fn toggle_contract_white_list() -> Weight {137 (3_000_000 as Weight)138 .saturating_add(DbWeight::get().reads(0 as Weight))139 .saturating_add(DbWeight::get().writes(2 as Weight))140 } 141 fn add_to_contract_white_list() -> Weight {142 (3_000_000 as Weight)143 .saturating_add(DbWeight::get().reads(0 as Weight))144 .saturating_add(DbWeight::get().writes(2 as Weight))145 } 146 fn remove_from_contract_white_list() -> Weight {147 (3_200_000 as Weight)148 .saturating_add(DbWeight::get().reads(0 as Weight))149 .saturating_add(DbWeight::get().writes(2 as Weight))150 }151 fn set_collection_limits() -> Weight {152 (8_900_000 as Weight)153 .saturating_add(DbWeight::get().reads(2 as Weight))154 .saturating_add(DbWeight::get().writes(1 as Weight))155 }156}