difftreelog
NFTPAR-260_217. Benchmarks
in: master
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.rsdiffbeforeafterboth251 fn set_variable_on_chain_schema() -> Weight;251 fn set_variable_on_chain_schema() -> Weight;252 fn set_variable_meta_data() -> Weight;252 fn set_variable_meta_data() -> Weight;253 fn enable_contract_sponsoring() -> Weight;253 fn enable_contract_sponsoring() -> Weight;254 fn set_schema_version() -> Weight;255 fn set_chain_limits() -> Weight;256 fn set_contract_sponsoring_rate_limit() -> Weight;257 fn toggle_contract_white_list() -> Weight;258 fn add_to_contract_white_list() -> Weight;259 fn remove_from_contract_white_list() -> Weight;260 fn set_collection_limits() -> Weight;254}261}255262256#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]263#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]1276 /// * collection_id.1283 /// * collection_id.1277 /// 1284 /// 1278 /// * schema: SchemaVersion: enum1285 /// * schema: SchemaVersion: enum1279 #[weight = 0]1286 #[weight = T::WeightInfo::set_schema_version()]1280 pub fn set_schema_version(1287 pub fn set_schema_version(1281 origin,1288 origin,1282 collection_id: CollectionId,1289 collection_id: CollectionId,1376 }1383 }137713841378 // Sudo permissions function1385 // Sudo permissions function1379 #[weight = 0]1386 #[weight = T::WeightInfo::set_chain_limits()]1380 pub fn set_chain_limits(1387 pub fn set_chain_limits(1381 origin,1388 origin,1382 limits: ChainLimits1389 limits: ChainLimits1383 ) -> DispatchResult {1390 ) -> DispatchResult {13911392 #[cfg(not(feature = "runtime-benchmarks"))]1384 ensure_root(origin)?;1393 ensure_root(origin)?;13941385 <ChainLimit>::put(limits);1395 <ChainLimit>::put(limits);1432 /// -`contract_address`: Address of the contract to sponsor1442 /// -`contract_address`: Address of the contract to sponsor1433 /// -`rate_limit`: Number of blocks to wait until the next sponsored transaction is allowed1443 /// -`rate_limit`: Number of blocks to wait until the next sponsored transaction is allowed1434 /// 1444 /// 1435 #[weight = 0]1445 #[weight = T::WeightInfo::set_contract_sponsoring_rate_limit()]1436 pub fn set_contract_sponsoring_rate_limit(1446 pub fn set_contract_sponsoring_rate_limit(1437 origin,1447 origin,1438 contract_address: T::AccountId,1448 contract_address: T::AccountId,1439 rate_limit: T::BlockNumber1449 rate_limit: T::BlockNumber1440 ) -> DispatchResult {1450 ) -> DispatchResult {1441 let sender = ensure_signed(origin)?;1451 let sender = ensure_signed(origin)?;14521453 #[cfg(feature = "runtime-benchmarks")]1454 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());14551442 Self::ensure_contract_owned(sender, &contract_address)?;1456 Self::ensure_contract_owned(sender, &contract_address)?;14431456 /// -`contract_address`: Address of the contract.1469 /// -`contract_address`: Address of the contract.1457 /// 1470 /// 1458 /// - `enable`: . 1471 /// - `enable`: . 1459 #[weight = 0]1472 #[weight = T::WeightInfo::toggle_contract_white_list()]1460 pub fn toggle_contract_white_list(1473 pub fn toggle_contract_white_list(1461 origin,1474 origin,1462 contract_address: T::AccountId,1475 contract_address: T::AccountId,1463 enable: bool1476 enable: bool1464 ) -> DispatchResult {1477 ) -> DispatchResult {1465 let sender = ensure_signed(origin)?;1478 let sender = ensure_signed(origin)?;14791480 #[cfg(feature = "runtime-benchmarks")]1481 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());14821466 Self::ensure_contract_owned(sender, &contract_address)?;1483 Self::ensure_contract_owned(sender, &contract_address)?;14671480 /// -`contract_address`: Address of the contract.1496 /// -`contract_address`: Address of the contract.1481 ///1497 ///1482 /// -`account_address`: Address to add.1498 /// -`account_address`: Address to add.1483 #[weight = 0]1499 #[weight = T::WeightInfo::add_to_contract_white_list()]1484 pub fn add_to_contract_white_list(1500 pub fn add_to_contract_white_list(1485 origin,1501 origin,1486 contract_address: T::AccountId,1502 contract_address: T::AccountId,1487 account_address: T::AccountId1503 account_address: T::AccountId1488 ) -> DispatchResult {1504 ) -> DispatchResult {1489 let sender = ensure_signed(origin)?;1505 let sender = ensure_signed(origin)?;15061507 #[cfg(feature = "runtime-benchmarks")]1508 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());1509 1490 Self::ensure_contract_owned(sender, &contract_address)?;1510 Self::ensure_contract_owned(sender, &contract_address)?; 1491 1504 /// -`contract_address`: Address of the contract.1523 /// -`contract_address`: Address of the contract.1505 ///1524 ///1506 /// -`account_address`: Address to remove.1525 /// -`account_address`: Address to remove.1507 #[weight = 0]1526 #[weight = T::WeightInfo::remove_from_contract_white_list()]1508 pub fn remove_from_contract_white_list(1527 pub fn remove_from_contract_white_list(1509 origin,1528 origin,1510 contract_address: T::AccountId,1529 contract_address: T::AccountId,1511 account_address: T::AccountId1530 account_address: T::AccountId1512 ) -> DispatchResult {1531 ) -> DispatchResult {1513 let sender = ensure_signed(origin)?;1532 let sender = ensure_signed(origin)?;15331534 #[cfg(feature = "runtime-benchmarks")]1535 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());15361514 Self::ensure_contract_owned(sender, &contract_address)?;1537 Self::ensure_contract_owned(sender, &contract_address)?;1515 1516 <ContractWhiteList<T>>::remove(contract_address, account_address);1538 <ContractWhiteList<T>>::remove(contract_address, account_address);1517 Ok(())1539 Ok(())1518 }1540 }151915411520 #[weight = 0]1542 #[weight = T::WeightInfo::set_collection_limits()]1521 pub fn set_collection_limits(1543 pub fn set_collection_limits(1522 origin,1544 origin,1523 collection_id: u32,1545 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