difftreelog
Merge pull request #52 from usetech-llc/NFTPAR_260_217
in: master
NFTPAR-260_217. Benchmarks
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.rsdiffbeforeafterboth233 fn set_variable_on_chain_schema() -> Weight;233 fn set_variable_on_chain_schema() -> Weight;234 fn set_variable_meta_data() -> Weight;234 fn set_variable_meta_data() -> Weight;235 fn enable_contract_sponsoring() -> Weight;235 fn enable_contract_sponsoring() -> Weight;236 fn set_schema_version() -> Weight;237 fn set_chain_limits() -> Weight;238 fn set_contract_sponsoring_rate_limit() -> Weight;239 fn toggle_contract_white_list() -> Weight;240 fn add_to_contract_white_list() -> Weight;241 fn remove_from_contract_white_list() -> Weight;242 fn set_collection_limits() -> Weight;236}243}237244238#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]245#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]1246 /// * collection_id.1253 /// * collection_id.1247 /// 1254 /// 1248 /// * schema: SchemaVersion: enum1255 /// * schema: SchemaVersion: enum1249 #[weight = 0]1256 #[weight = T::WeightInfo::set_schema_version()]1250 pub fn set_schema_version(1257 pub fn set_schema_version(1251 origin,1258 origin,1252 collection_id: CollectionId,1259 collection_id: CollectionId,1346 }1353 }134713541348 // Sudo permissions function1355 // Sudo permissions function1349 #[weight = 0]1356 #[weight = T::WeightInfo::set_chain_limits()]1350 pub fn set_chain_limits(1357 pub fn set_chain_limits(1351 origin,1358 origin,1352 limits: ChainLimits1359 limits: ChainLimits1353 ) -> DispatchResult {1360 ) -> DispatchResult {13611362 #[cfg(not(feature = "runtime-benchmarks"))]1354 ensure_root(origin)?;1363 ensure_root(origin)?;13641355 <ChainLimit>::put(limits);1365 <ChainLimit>::put(limits);1402 /// -`contract_address`: Address of the contract to sponsor1412 /// -`contract_address`: Address of the contract to sponsor1403 /// -`rate_limit`: Number of blocks to wait until the next sponsored transaction is allowed1413 /// -`rate_limit`: Number of blocks to wait until the next sponsored transaction is allowed1404 /// 1414 /// 1405 #[weight = 0]1415 #[weight = T::WeightInfo::set_contract_sponsoring_rate_limit()]1406 pub fn set_contract_sponsoring_rate_limit(1416 pub fn set_contract_sponsoring_rate_limit(1407 origin,1417 origin,1408 contract_address: T::AccountId,1418 contract_address: T::AccountId,1409 rate_limit: T::BlockNumber1419 rate_limit: T::BlockNumber1410 ) -> DispatchResult {1420 ) -> DispatchResult {1411 let sender = ensure_signed(origin)?;1421 let sender = ensure_signed(origin)?;14221423 #[cfg(feature = "runtime-benchmarks")]1424 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());14251412 Self::ensure_contract_owned(sender, &contract_address)?;1426 Self::ensure_contract_owned(sender, &contract_address)?;14131426 /// -`contract_address`: Address of the contract.1439 /// -`contract_address`: Address of the contract.1427 /// 1440 /// 1428 /// - `enable`: . 1441 /// - `enable`: . 1429 #[weight = 0]1442 #[weight = T::WeightInfo::toggle_contract_white_list()]1430 pub fn toggle_contract_white_list(1443 pub fn toggle_contract_white_list(1431 origin,1444 origin,1432 contract_address: T::AccountId,1445 contract_address: T::AccountId,1433 enable: bool1446 enable: bool1434 ) -> DispatchResult {1447 ) -> DispatchResult {1435 let sender = ensure_signed(origin)?;1448 let sender = ensure_signed(origin)?;14491450 #[cfg(feature = "runtime-benchmarks")]1451 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());14521436 Self::ensure_contract_owned(sender, &contract_address)?;1453 Self::ensure_contract_owned(sender, &contract_address)?;14371450 /// -`contract_address`: Address of the contract.1466 /// -`contract_address`: Address of the contract.1451 ///1467 ///1452 /// -`account_address`: Address to add.1468 /// -`account_address`: Address to add.1453 #[weight = 0]1469 #[weight = T::WeightInfo::add_to_contract_white_list()]1454 pub fn add_to_contract_white_list(1470 pub fn add_to_contract_white_list(1455 origin,1471 origin,1456 contract_address: T::AccountId,1472 contract_address: T::AccountId,1457 account_address: T::AccountId1473 account_address: T::AccountId1458 ) -> DispatchResult {1474 ) -> DispatchResult {1459 let sender = ensure_signed(origin)?;1475 let sender = ensure_signed(origin)?;14761477 #[cfg(feature = "runtime-benchmarks")]1478 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());1479 1460 Self::ensure_contract_owned(sender, &contract_address)?;1480 Self::ensure_contract_owned(sender, &contract_address)?; 1461 1474 /// -`contract_address`: Address of the contract.1493 /// -`contract_address`: Address of the contract.1475 ///1494 ///1476 /// -`account_address`: Address to remove.1495 /// -`account_address`: Address to remove.1477 #[weight = 0]1496 #[weight = T::WeightInfo::remove_from_contract_white_list()]1478 pub fn remove_from_contract_white_list(1497 pub fn remove_from_contract_white_list(1479 origin,1498 origin,1480 contract_address: T::AccountId,1499 contract_address: T::AccountId,1481 account_address: T::AccountId1500 account_address: T::AccountId1482 ) -> DispatchResult {1501 ) -> DispatchResult {1483 let sender = ensure_signed(origin)?;1502 let sender = ensure_signed(origin)?;15031504 #[cfg(feature = "runtime-benchmarks")]1505 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());15061484 Self::ensure_contract_owned(sender, &contract_address)?;1507 Self::ensure_contract_owned(sender, &contract_address)?;1485 1486 <ContractWhiteList<T>>::remove(contract_address, account_address);1508 <ContractWhiteList<T>>::remove(contract_address, account_address);1487 Ok(())1509 Ok(())1488 }1510 }148915111490 #[weight = 0]1512 #[weight = T::WeightInfo::set_collection_limits()]1491 pub fn set_collection_limits(1513 pub fn set_collection_limits(1492 origin,1514 origin,1493 collection_id: u32,1515 collection_id: u32,runtime/src/nft_weights.rsdiffbeforeafterboth--- a/runtime/src/nft_weights.rs
+++ b/runtime/src/nft_weights.rs
@@ -113,19 +113,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))
+ }
}