difftreelog
Merge pull request #52 from usetech-llc/NFTPAR_260_217
in: master
NFTPAR-260_217. Benchmarks
4 files changed
pallets/nft/src/benchmarking.rsdiffbeforeafterboth356356357 }: set_variable_meta_data(RawOrigin::Signed(caller.clone()), 2, 1, [1, 2, 3].to_vec())357 }: set_variable_meta_data(RawOrigin::Signed(caller.clone()), 2, 1, [1, 2, 3].to_vec())358359 set_schema_version {360 let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();361 let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();362 let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();363 let mode: CollectionMode = CollectionMode::NFT;364 let caller: T::AccountId = T::AccountId::from(whitelisted_caller());365 Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;366 }: set_schema_version(RawOrigin::Signed(caller.clone()), 2, SchemaVersion::Unique)367368 set_chain_limits {369 let caller: T::AccountId = T::AccountId::from(whitelisted_caller());370 let limits = ChainLimits { 371 collection_numbers_limit: 0,372 account_token_ownership_limit: 0,373 collections_admins_limit: 0,374 custom_data_limit: 0,375 nft_sponsor_transfer_timeout: 0,376 fungible_sponsor_transfer_timeout: 0,377 refungible_sponsor_transfer_timeout: 0378 };379 }: set_chain_limits(RawOrigin::Signed(caller.clone()), limits)380381 set_contract_sponsoring_rate_limit {382 let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();383 let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();384 let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();385 let mode: CollectionMode = CollectionMode::NFT;386 let caller: T::AccountId = T::AccountId::from(whitelisted_caller());387 Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;388 let block_number: T::BlockNumber = 0.into(); 389 }: set_contract_sponsoring_rate_limit(RawOrigin::Signed(caller.clone()), caller.clone(), block_number)390391 set_collection_limits{392 let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();393 let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();394 let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();395 let mode: CollectionMode = CollectionMode::NFT;396 let caller: T::AccountId = T::AccountId::from(whitelisted_caller());397 Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;398 399 let cl = CollectionLimits {400 account_token_ownership_limit: 0,401 sponsored_data_size: 0,402 token_limit: 0,403 sponsor_transfer_timeout: 0404 };405406 }: set_collection_limits(RawOrigin::Signed(caller.clone()), 2, cl)407408 add_to_contract_white_list{409 let caller: T::AccountId = T::AccountId::from(whitelisted_caller());410 }: add_to_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), caller.clone())411412 remove_from_contract_white_list{413 let caller: T::AccountId = T::AccountId::from(whitelisted_caller());414 Nft::<T>::add_to_contract_white_list(RawOrigin::Signed(caller.clone()).into(), caller.clone(), caller.clone())?;415 }: remove_from_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), caller.clone())416417 toggle_contract_white_list{418 let caller: T::AccountId = T::AccountId::from(whitelisted_caller());419 }: toggle_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), true)358}420}pallets/nft/src/default_weights.rsdiffbeforeafterboth107 .saturating_add(DbWeight::get().reads(2 as Weight))107 .saturating_add(DbWeight::get().reads(2 as Weight))108 .saturating_add(DbWeight::get().writes(1 as Weight))108 .saturating_add(DbWeight::get().writes(1 as Weight))109 }109 }110 // fn set_chain_limits() -> Weight {111 // (0 as Weight)112 // .saturating_add(DbWeight::get().reads(1 as Weight))113 // .saturating_add(DbWeight::get().writes(1 as Weight))114 // }115 fn enable_contract_sponsoring() -> Weight {110 fn enable_contract_sponsoring() -> Weight {116 (13_000_000 as Weight)111 (13_000_000 as Weight)117 .saturating_add(DbWeight::get().reads(1 as Weight))112 .saturating_add(DbWeight::get().reads(1 as Weight))118 .saturating_add(DbWeight::get().writes(1 as Weight))113 .saturating_add(DbWeight::get().writes(1 as Weight))119 }114 }120 // fn set_contract_sponsoring_rate_limit() -> Weight {115 fn set_schema_version() -> Weight {121 // (0 as Weight)116 (8_500_000 as Weight)122 // .saturating_add(DbWeight::get().reads(1 as Weight))117 .saturating_add(DbWeight::get().reads(2 as Weight))123 // .saturating_add(DbWeight::get().writes(1 as Weight))118 .saturating_add(DbWeight::get().writes(1 as Weight))124 // }119 }120 fn set_chain_limits() -> Weight {121 (1_300_000 as Weight)122 .saturating_add(DbWeight::get().reads(0 as Weight))123 .saturating_add(DbWeight::get().writes(1 as Weight))124 }125 fn set_contract_sponsoring_rate_limit() -> Weight {126 (3_500_000 as Weight)127 .saturating_add(DbWeight::get().reads(0 as Weight))128 .saturating_add(DbWeight::get().writes(2 as Weight))129 } 130 fn toggle_contract_white_list() -> Weight {131 (3_000_000 as Weight)132 .saturating_add(DbWeight::get().reads(0 as Weight))133 .saturating_add(DbWeight::get().writes(2 as Weight))134 } 135 fn add_to_contract_white_list() -> Weight {136 (3_000_000 as Weight)137 .saturating_add(DbWeight::get().reads(0 as Weight))138 .saturating_add(DbWeight::get().writes(2 as Weight))139 } 140 fn remove_from_contract_white_list() -> Weight {141 (3_200_000 as Weight)142 .saturating_add(DbWeight::get().reads(0 as Weight))143 .saturating_add(DbWeight::get().writes(2 as Weight))144 }145 fn set_collection_limits() -> Weight {146 (8_900_000 as Weight)147 .saturating_add(DbWeight::get().reads(2 as Weight))148 .saturating_add(DbWeight::get().writes(1 as Weight))149 }125}150}126151pallets/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.rsdiffbeforeafterboth113 .saturating_add(DbWeight::get().reads(2 as Weight))113 .saturating_add(DbWeight::get().reads(2 as Weight))114 .saturating_add(DbWeight::get().writes(1 as Weight))114 .saturating_add(DbWeight::get().writes(1 as Weight))115 }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 {116 fn enable_contract_sponsoring() -> Weight {122 (13_000_000 as Weight)117 (13_000_000 as Weight)123 .saturating_add(DbWeight::get().reads(1 as Weight))118 .saturating_add(DbWeight::get().reads(1 as Weight))124 .saturating_add(DbWeight::get().writes(1 as Weight))119 .saturating_add(DbWeight::get().writes(1 as Weight))125 }120 }126 // fn set_contract_sponsoring_rate_limit() -> Weight {121 fn set_schema_version() -> Weight {127 // (0 as Weight)122 (8_500_000 as Weight)128 // .saturating_add(DbWeight::get().reads(1 as Weight))123 .saturating_add(DbWeight::get().reads(2 as Weight))129 // .saturating_add(DbWeight::get().writes(1 as Weight))124 .saturating_add(DbWeight::get().writes(1 as Weight))130 // }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 }131}156}132157