git.delta.rocks / unique-network / refs/commits / 57a41c175b30

difftreelog

NFTPAR-260_217. Benchmarks

str-mv2020-12-25parent: #d430fcf.patch.diff
in: master

4 files changed

modifiedpallets/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
modifiedpallets/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))
+    }
 }
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
251 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}
255262
256#[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: enum
1279 #[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 }
13771384
1378 // Sudo permissions function1385 // Sudo permissions function
1379 #[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: ChainLimits
1383 ) -> DispatchResult {1390 ) -> DispatchResult {
1391
1392 #[cfg(not(feature = "runtime-benchmarks"))]
1384 ensure_root(origin)?;1393 ensure_root(origin)?;
1394
1385 <ChainLimit>::put(limits);1395 <ChainLimit>::put(limits);
1432 /// -`contract_address`: Address of the contract to sponsor1442 /// -`contract_address`: Address of the contract to sponsor
1433 /// -`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 allowed
1434 /// 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::BlockNumber
1440 ) -> DispatchResult {1450 ) -> DispatchResult {
1441 let sender = ensure_signed(origin)?;1451 let sender = ensure_signed(origin)?;
1452
1453 #[cfg(feature = "runtime-benchmarks")]
1454 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());
1455
1442 Self::ensure_contract_owned(sender, &contract_address)?;1456 Self::ensure_contract_owned(sender, &contract_address)?;
1443
1456 /// -`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: bool
1464 ) -> DispatchResult {1477 ) -> DispatchResult {
1465 let sender = ensure_signed(origin)?;1478 let sender = ensure_signed(origin)?;
1479
1480 #[cfg(feature = "runtime-benchmarks")]
1481 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());
1482
1466 Self::ensure_contract_owned(sender, &contract_address)?;1483 Self::ensure_contract_owned(sender, &contract_address)?;
1467
1480 /// -`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::AccountId
1488 ) -> DispatchResult {1504 ) -> DispatchResult {
1489 let sender = ensure_signed(origin)?;1505 let sender = ensure_signed(origin)?;
1506
1507 #[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::AccountId
1512 ) -> DispatchResult {1531 ) -> DispatchResult {
1513 let sender = ensure_signed(origin)?;1532 let sender = ensure_signed(origin)?;
1533
1534 #[cfg(feature = "runtime-benchmarks")]
1535 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());
1536
1514 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 }
15191541
1520 #[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,
modifiedruntime/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))
+    }
 }