git.delta.rocks / unique-network / refs/commits / 885f1d23d20d

difftreelog

fix compilation errors

Grigoriy Simonov2023-10-10parent: #4950cbc.patch.diff
in: master

4 files changed

modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -354,6 +354,7 @@
 		}
 		#[cfg(feature = "runtime-benchmarks")]
 		Some(Subcommand::Benchmark(cmd)) => {
+			use polkadot_cli::Block;
 			use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
 			let runner = cli.create_runner(cmd)?;
 			// Switch on the concrete benchmark sub-command-
@@ -363,6 +364,7 @@
 				}
 				BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
 					let partials = new_partial::<
+						_,
 						default_runtime::RuntimeApi,
 						DefaultRuntimeExecutor,
 						_,
@@ -371,6 +373,7 @@
 				}),
 				BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
 					let partials = new_partial::<
+						_,
 						default_runtime::RuntimeApi,
 						DefaultRuntimeExecutor,
 						_,
modifiedpallets/inflation/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/inflation/src/benchmarking.rs
+++ b/pallets/inflation/src/benchmarking.rs
@@ -31,11 +31,11 @@
 	fn on_initialize() -> Result<(), BenchmarkError> {
 		let block1: BlockNumberFor<T> = 1u32.into();
 		let block2: BlockNumberFor<T> = 2u32.into();
-		<Inflation<T> as Hooks>::on_initialize(block1); // Create Treasury account
+		<Inflation<T> as Hooks<_>>::on_initialize(block1); // Create Treasury account
 
 		#[block]
 		{
-			<Inflation<T> as Hooks>::on_initialize(block2);
+			<Inflation<T> as Hooks<_>>::on_initialize(block2);
 			// Benchmark deposit_into_existing path
 		}
 
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -360,29 +360,23 @@
 			.collect::<Vec<_>>();
 		let item = create_max_item(&collection, &owner, owner.clone())?;
 
-		let (is_collection_admin, property_permissions) =
-			load_is_admin_and_property_permissions(&collection, &owner);
+		// let (is_collection_admin, property_permissions) =
+		// 	load_is_admin_and_property_permissions(&collection, &owner);
 		todo!();
 		#[block]
-		{}
-		// let mut property_writer = pallet_common::collection_info_loaded_property_writer(
-		// 	&collection,
-		// 	is_collection_admin,
-		// 	property_permissions,
-		// );
+		{
+			// let mut property_writer =
+			// 	pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
 
-		// #[block]
-		// {
-		// 	property_writer.write_token_properties(
-		// 		true,
-		// 		item,
-		// 		props.into_iter(),
-		// 		crate::erc::ERC721TokenEvent::TokenChanged {
-		// 			token_id: item.into(),
-		// 		}
-		// 		.to_log(T::ContractAddress::get()),
-		// 	)?;
-		// }
+			// property_writer.write_token_properties(
+			// 	item,
+			// 	props.into_iter(),
+			// 	crate::erc::ERC721TokenEvent::TokenChanged {
+			// 		token_id: item.into(),
+			// 	}
+			// 	.to_log(T::ContractAddress::get()),
+			// )?;
+		}
 
 		Ok(())
 	}
modifiedpallets/unique/src/benchmarking.rsdiffbeforeafterboth
before · pallets/unique/src/benchmarking.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg(feature = "runtime-benchmarks")]1819use frame_benchmarking::v2::{account, benchmarks, BenchmarkError};20use frame_support::traits::{fungible::Balanced, tokens::Precision, Get};21use frame_system::RawOrigin;22use pallet_common::{23	benchmarking::{create_data, create_u16_data},24	erc::CrossAccountId,25	Config as CommonConfig,26};27use sp_runtime::DispatchError;28use up_data_structs::{29	CollectionId, CollectionLimits, CollectionMode, MAX_COLLECTION_DESCRIPTION_LENGTH,30	MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,31};3233use super::*;34use crate::Pallet;3536const SEED: u32 = 1;3738fn create_collection_helper<T: Config>(39	owner: T::AccountId,40	mode: CollectionMode,41) -> Result<CollectionId, DispatchError> {42	let _ = <T as CommonConfig>::Currency::deposit(43		&owner,44		T::CollectionCreationPrice::get(),45		Precision::Exact,46	)47	.unwrap();48	let col_name = create_u16_data::<{ MAX_COLLECTION_NAME_LENGTH }>();49	let col_desc = create_u16_data::<{ MAX_COLLECTION_DESCRIPTION_LENGTH }>();50	let token_prefix = create_data::<{ MAX_TOKEN_PREFIX_LENGTH }>();51	<Pallet<T>>::create_collection(52		RawOrigin::Signed(owner).into(),53		col_name,54		col_desc,55		token_prefix,56		mode,57	)?;58	Ok(<pallet_common::CreatedCollectionCount<T>>::get())59}60pub fn create_nft_collection<T: Config>(61	owner: T::AccountId,62) -> Result<CollectionId, DispatchError> {63	create_collection_helper::<T>(owner, CollectionMode::NFT)64}6566#[benchmarks]67mod benchmarks {68	use super::*;6970	#[benchmark]71	fn create_collection() -> Result<(), BenchmarkError> {72		let col_name = create_u16_data::<{ MAX_COLLECTION_NAME_LENGTH }>();73		let col_desc = create_u16_data::<{ MAX_COLLECTION_DESCRIPTION_LENGTH }>();74		let token_prefix = create_data::<{ MAX_TOKEN_PREFIX_LENGTH }>();75		let mode: CollectionMode = CollectionMode::NFT;76		let caller: T::AccountId = account("caller", 0, SEED);77		let _ = <T as CommonConfig>::Currency::deposit(78			&caller,79			T::CollectionCreationPrice::get(),80			Precision::Exact,81		)82		.unwrap();8384		#[extrinsic_call]85		_(86			RawOrigin::Signed(caller.clone()),87			col_name,88			col_desc,89			token_prefix,90			mode,91		);9293		assert_eq!(94			<pallet_common::CollectionById<T>>::get(CollectionId(1))95				.unwrap()96				.owner,97			caller98		);99100		Ok(())101	}102103	#[benchmark]104	fn destroy_collection() -> Result<(), BenchmarkError> {105		let caller: T::AccountId = account("caller", 0, SEED);106		let collection = create_nft_collection::<T>(caller.clone())?;107108		#[extrinsic_call]109		_(RawOrigin::Signed(caller.clone()), collection);110111		Ok(())112	}113114	#[benchmark]115	fn add_to_allow_list() -> Result<(), BenchmarkError> {116		let caller: T::AccountId = account("caller", 0, SEED);117		let allowlist_account: T::AccountId = account("admin", 0, SEED);118		let collection = create_nft_collection::<T>(caller.clone())?;119120		#[extrinsic_call]121		_(122			RawOrigin::Signed(caller.clone()),123			collection,124			T::CrossAccountId::from_sub(allowlist_account),125		);126127		Ok(())128	}129130	#[benchmark]131	fn remove_from_allow_list() -> Result<(), BenchmarkError> {132		let caller: T::AccountId = account("caller", 0, SEED);133		let allowlist_account: T::AccountId = account("admin", 0, SEED);134		let collection = create_nft_collection::<T>(caller.clone())?;135		<Pallet<T>>::add_to_allow_list(136			RawOrigin::Signed(caller.clone()).into(),137			collection,138			T::CrossAccountId::from_sub(allowlist_account.clone()),139		)?;140141		#[extrinsic_call]142		_(143			RawOrigin::Signed(caller.clone()),144			collection,145			T::CrossAccountId::from_sub(allowlist_account),146		);147148		Ok(())149	}150151	#[benchmark]152	fn change_collection_owner() -> Result<(), BenchmarkError> {153		let caller: T::AccountId = account("caller", 0, SEED);154		let collection = create_nft_collection::<T>(caller.clone())?;155		let new_owner: T::AccountId = account("admin", 0, SEED);156157		#[extrinsic_call]158		_(RawOrigin::Signed(caller.clone()), collection, new_owner);159160		Ok(())161	}162163	#[benchmark]164	fn add_collection_admin() -> Result<(), BenchmarkError> {165		let caller: T::AccountId = account("caller", 0, SEED);166		let collection = create_nft_collection::<T>(caller.clone())?;167		let new_admin: T::AccountId = account("admin", 0, SEED);168169		#[extrinsic_call]170		_(171			RawOrigin::Signed(caller.clone()),172			collection,173			T::CrossAccountId::from_sub(new_admin),174		);175176		Ok(())177	}178179	#[benchmark]180	fn remove_collection_admin() -> Result<(), BenchmarkError> {181		let caller: T::AccountId = account("caller", 0, SEED);182		let collection = create_nft_collection::<T>(caller.clone())?;183		let new_admin: T::AccountId = account("admin", 0, SEED);184		<Pallet<T>>::add_collection_admin(185			RawOrigin::Signed(caller.clone()).into(),186			collection,187			T::CrossAccountId::from_sub(new_admin.clone()),188		)?;189190		#[extrinsic_call]191		_(192			RawOrigin::Signed(caller.clone()),193			collection,194			T::CrossAccountId::from_sub(new_admin),195		);196197		Ok(())198	}199200	#[benchmark]201	fn set_collection_sponsor() -> Result<(), BenchmarkError> {202		let caller: T::AccountId = account("caller", 0, SEED);203		let collection = create_nft_collection::<T>(caller.clone())?;204205		#[extrinsic_call]206		_(207			RawOrigin::Signed(caller.clone()),208			collection,209			caller.clone(),210		);211212		Ok(())213	}214215	#[benchmark]216	fn confirm_sponsorship() -> Result<(), BenchmarkError> {217		let caller: T::AccountId = account("caller", 0, SEED);218		let collection = create_nft_collection::<T>(caller.clone())?;219		<Pallet<T>>::set_collection_sponsor(220			RawOrigin::Signed(caller.clone()).into(),221			collection,222			caller.clone(),223		)?;224225		#[extrinsic_call]226		_(RawOrigin::Signed(caller.clone()), collection);227228		Ok(())229	}230231	#[benchmark]232	fn remove_collection_sponsor() -> Result<(), BenchmarkError> {233		let caller: T::AccountId = account("caller", 0, SEED);234		let collection = create_nft_collection::<T>(caller.clone())?;235		<Pallet<T>>::set_collection_sponsor(236			RawOrigin::Signed(caller.clone()).into(),237			collection,238			caller.clone(),239		)?;240		<Pallet<T>>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), collection)?;241242		#[extrinsic_call]243		_(RawOrigin::Signed(caller.clone()), collection);244245		Ok(())246	}247248	#[benchmark]249	fn set_transfers_enabled_flag() -> Result<(), BenchmarkError> {250		let caller: T::AccountId = account("caller", 0, SEED);251		let collection = create_nft_collection::<T>(caller.clone())?;252253		#[extrinsic_call]254		_(RawOrigin::Signed(caller.clone()), collection, false);255256		Ok(())257	}258259	#[benchmark]260	fn set_collection_limits() -> Result<(), BenchmarkError> {261		let caller: T::AccountId = account("caller", 0, SEED);262		let collection = create_nft_collection::<T>(caller.clone())?;263264		let cl = CollectionLimits {265			account_token_ownership_limit: Some(0),266			sponsored_data_size: Some(0),267			token_limit: Some(1),268			sponsor_transfer_timeout: Some(0),269			sponsor_approve_timeout: None,270			owner_can_destroy: Some(true),271			owner_can_transfer: Some(true),272			sponsored_data_rate_limit: None,273			transfers_enabled: Some(true),274		};275276		#[extrinsic_call]277		set_collection_limits(RawOrigin::Signed(caller.clone()), collection, cl);278279		Ok(())280	}281282	#[benchmark]283	fn force_repair_collection() -> Result<(), BenchmarkError> {284		let caller: T::AccountId = account("caller", 0, SEED);285		let collection = create_nft_collection::<T>(caller)?;286287		#[extrinsic_call]288		_(RawOrigin::Root, collection);289290		Ok(())291	}292}
after · pallets/unique/src/benchmarking.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg(feature = "runtime-benchmarks")]1819use frame_benchmarking::v2::{account, benchmarks, BenchmarkError};20use frame_support::traits::{fungible::Balanced, tokens::Precision, Get};21use frame_system::RawOrigin;22use pallet_common::{23	benchmarking::{create_data, create_u16_data},24	erc::CrossAccountId,25	Config as CommonConfig,26};27use sp_std::vec;28use sp_runtime::DispatchError;29use up_data_structs::{30	CollectionId, CollectionLimits, CollectionMode, MAX_COLLECTION_DESCRIPTION_LENGTH,31	MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,32};3334use super::*;35use crate::Pallet;3637const SEED: u32 = 1;3839fn create_collection_helper<T: Config>(40	owner: T::AccountId,41	mode: CollectionMode,42) -> Result<CollectionId, DispatchError> {43	let _ = <T as CommonConfig>::Currency::deposit(44		&owner,45		T::CollectionCreationPrice::get(),46		Precision::Exact,47	)48	.unwrap();49	let col_name = create_u16_data::<{ MAX_COLLECTION_NAME_LENGTH }>();50	let col_desc = create_u16_data::<{ MAX_COLLECTION_DESCRIPTION_LENGTH }>();51	let token_prefix = create_data::<{ MAX_TOKEN_PREFIX_LENGTH }>();52	<Pallet<T>>::create_collection(53		RawOrigin::Signed(owner).into(),54		col_name,55		col_desc,56		token_prefix,57		mode,58	)?;59	Ok(<pallet_common::CreatedCollectionCount<T>>::get())60}61pub fn create_nft_collection<T: Config>(62	owner: T::AccountId,63) -> Result<CollectionId, DispatchError> {64	create_collection_helper::<T>(owner, CollectionMode::NFT)65}6667#[benchmarks]68mod benchmarks {69	use super::*;7071	#[benchmark]72	fn create_collection() -> Result<(), BenchmarkError> {73		let col_name = create_u16_data::<{ MAX_COLLECTION_NAME_LENGTH }>();74		let col_desc = create_u16_data::<{ MAX_COLLECTION_DESCRIPTION_LENGTH }>();75		let token_prefix = create_data::<{ MAX_TOKEN_PREFIX_LENGTH }>();76		let mode: CollectionMode = CollectionMode::NFT;77		let caller: T::AccountId = account("caller", 0, SEED);78		let _ = <T as CommonConfig>::Currency::deposit(79			&caller,80			T::CollectionCreationPrice::get(),81			Precision::Exact,82		)83		.unwrap();8485		#[extrinsic_call]86		_(87			RawOrigin::Signed(caller.clone()),88			col_name,89			col_desc,90			token_prefix,91			mode,92		);9394		assert_eq!(95			<pallet_common::CollectionById<T>>::get(CollectionId(1))96				.unwrap()97				.owner,98			caller99		);100101		Ok(())102	}103104	#[benchmark]105	fn destroy_collection() -> Result<(), BenchmarkError> {106		let caller: T::AccountId = account("caller", 0, SEED);107		let collection = create_nft_collection::<T>(caller.clone())?;108109		#[extrinsic_call]110		_(RawOrigin::Signed(caller.clone()), collection);111112		Ok(())113	}114115	#[benchmark]116	fn add_to_allow_list() -> Result<(), BenchmarkError> {117		let caller: T::AccountId = account("caller", 0, SEED);118		let allowlist_account: T::AccountId = account("admin", 0, SEED);119		let collection = create_nft_collection::<T>(caller.clone())?;120121		#[extrinsic_call]122		_(123			RawOrigin::Signed(caller.clone()),124			collection,125			T::CrossAccountId::from_sub(allowlist_account),126		);127128		Ok(())129	}130131	#[benchmark]132	fn remove_from_allow_list() -> Result<(), BenchmarkError> {133		let caller: T::AccountId = account("caller", 0, SEED);134		let allowlist_account: T::AccountId = account("admin", 0, SEED);135		let collection = create_nft_collection::<T>(caller.clone())?;136		<Pallet<T>>::add_to_allow_list(137			RawOrigin::Signed(caller.clone()).into(),138			collection,139			T::CrossAccountId::from_sub(allowlist_account.clone()),140		)?;141142		#[extrinsic_call]143		_(144			RawOrigin::Signed(caller.clone()),145			collection,146			T::CrossAccountId::from_sub(allowlist_account),147		);148149		Ok(())150	}151152	#[benchmark]153	fn change_collection_owner() -> Result<(), BenchmarkError> {154		let caller: T::AccountId = account("caller", 0, SEED);155		let collection = create_nft_collection::<T>(caller.clone())?;156		let new_owner: T::AccountId = account("admin", 0, SEED);157158		#[extrinsic_call]159		_(RawOrigin::Signed(caller.clone()), collection, new_owner);160161		Ok(())162	}163164	#[benchmark]165	fn add_collection_admin() -> Result<(), BenchmarkError> {166		let caller: T::AccountId = account("caller", 0, SEED);167		let collection = create_nft_collection::<T>(caller.clone())?;168		let new_admin: T::AccountId = account("admin", 0, SEED);169170		#[extrinsic_call]171		_(172			RawOrigin::Signed(caller.clone()),173			collection,174			T::CrossAccountId::from_sub(new_admin),175		);176177		Ok(())178	}179180	#[benchmark]181	fn remove_collection_admin() -> Result<(), BenchmarkError> {182		let caller: T::AccountId = account("caller", 0, SEED);183		let collection = create_nft_collection::<T>(caller.clone())?;184		let new_admin: T::AccountId = account("admin", 0, SEED);185		<Pallet<T>>::add_collection_admin(186			RawOrigin::Signed(caller.clone()).into(),187			collection,188			T::CrossAccountId::from_sub(new_admin.clone()),189		)?;190191		#[extrinsic_call]192		_(193			RawOrigin::Signed(caller.clone()),194			collection,195			T::CrossAccountId::from_sub(new_admin),196		);197198		Ok(())199	}200201	#[benchmark]202	fn set_collection_sponsor() -> Result<(), BenchmarkError> {203		let caller: T::AccountId = account("caller", 0, SEED);204		let collection = create_nft_collection::<T>(caller.clone())?;205206		#[extrinsic_call]207		_(208			RawOrigin::Signed(caller.clone()),209			collection,210			caller.clone(),211		);212213		Ok(())214	}215216	#[benchmark]217	fn confirm_sponsorship() -> Result<(), BenchmarkError> {218		let caller: T::AccountId = account("caller", 0, SEED);219		let collection = create_nft_collection::<T>(caller.clone())?;220		<Pallet<T>>::set_collection_sponsor(221			RawOrigin::Signed(caller.clone()).into(),222			collection,223			caller.clone(),224		)?;225226		#[extrinsic_call]227		_(RawOrigin::Signed(caller.clone()), collection);228229		Ok(())230	}231232	#[benchmark]233	fn remove_collection_sponsor() -> Result<(), BenchmarkError> {234		let caller: T::AccountId = account("caller", 0, SEED);235		let collection = create_nft_collection::<T>(caller.clone())?;236		<Pallet<T>>::set_collection_sponsor(237			RawOrigin::Signed(caller.clone()).into(),238			collection,239			caller.clone(),240		)?;241		<Pallet<T>>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), collection)?;242243		#[extrinsic_call]244		_(RawOrigin::Signed(caller.clone()), collection);245246		Ok(())247	}248249	#[benchmark]250	fn set_transfers_enabled_flag() -> Result<(), BenchmarkError> {251		let caller: T::AccountId = account("caller", 0, SEED);252		let collection = create_nft_collection::<T>(caller.clone())?;253254		#[extrinsic_call]255		_(RawOrigin::Signed(caller.clone()), collection, false);256257		Ok(())258	}259260	#[benchmark]261	fn set_collection_limits() -> Result<(), BenchmarkError> {262		let caller: T::AccountId = account("caller", 0, SEED);263		let collection = create_nft_collection::<T>(caller.clone())?;264265		let cl = CollectionLimits {266			account_token_ownership_limit: Some(0),267			sponsored_data_size: Some(0),268			token_limit: Some(1),269			sponsor_transfer_timeout: Some(0),270			sponsor_approve_timeout: None,271			owner_can_destroy: Some(true),272			owner_can_transfer: Some(true),273			sponsored_data_rate_limit: None,274			transfers_enabled: Some(true),275		};276277		#[extrinsic_call]278		set_collection_limits(RawOrigin::Signed(caller.clone()), collection, cl);279280		Ok(())281	}282283	#[benchmark]284	fn force_repair_collection() -> Result<(), BenchmarkError> {285		let caller: T::AccountId = account("caller", 0, SEED);286		let collection = create_nft_collection::<T>(caller)?;287288		#[extrinsic_call]289		_(RawOrigin::Root, collection);290291		Ok(())292	}293}