git.delta.rocks / unique-network / refs/commits / b1f22167a941

difftreelog

fix remove from_ref_time usages

Yaroslav Bolyukin2023-04-17parent: #07a293d.patch.diff
in: master

9 files changed

modifiedpallets/common/src/dispatch.rsdiffbeforeafterboth
--- a/pallets/common/src/dispatch.rs
+++ b/pallets/common/src/dispatch.rs
@@ -19,7 +19,7 @@
 	// Read collection
 	<T as frame_system::Config>::DbWeight::get().reads(1)
 	// Dynamic dispatch?
-	+ Weight::from_ref_time(6_000_000)
+	+ Weight::from_parts(6_000_000, 0)
 	// submit_logs is measured as part of collection pallets
 }
 
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -92,6 +92,7 @@
 pub mod dispatch;
 pub mod erc;
 pub mod eth;
+#[allow(missing_docs)]
 pub mod weights;
 
 /// Weight info.
@@ -157,10 +158,12 @@
 		reads: u64,
 	) -> pallet_evm_coder_substrate::execution::Result<()> {
 		self.recorder
-			.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_ref_time(
+			.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(
 				<T as frame_system::Config>::DbWeight::get()
 					.read
 					.saturating_mul(reads),
+				// TODO: measure proof
+				0,
 			)))
 	}
 
@@ -170,10 +173,12 @@
 		writes: u64,
 	) -> pallet_evm_coder_substrate::execution::Result<()> {
 		self.recorder
-			.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_ref_time(
+			.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(
 				<T as frame_system::Config>::DbWeight::get()
 					.write
 					.saturating_mul(writes),
+				// TODO: measure proof
+				0,
 			)))
 	}
 
@@ -187,8 +192,10 @@
 		let reads = weight.read.saturating_mul(reads);
 		let writes = weight.read.saturating_mul(writes);
 		self.recorder
-			.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_ref_time(
+			.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(
 				reads.saturating_add(writes),
+				// TODO: measure proof
+				0,
 			)))
 	}
 
modifiedpallets/evm-coder-substrate/src/execution.rsdiffbeforeafterboth
--- a/pallets/evm-coder-substrate/src/execution.rs
+++ b/pallets/evm-coder-substrate/src/execution.rs
@@ -61,7 +61,7 @@
 	fn dispatch_info(&self) -> DispatchInfo {
 		DispatchInfo {
 			// ERC165 impl should be cheap
-			weight: Weight::from_ref_time(200),
+			weight: Weight::from_parts(200, 0),
 		}
 	}
 }
@@ -77,10 +77,11 @@
 		Self { weight }
 	}
 }
+// TODO: use 2-dimensional weight after frontier upgrade
 impl From<u64> for DispatchInfo {
 	fn from(weight: u64) -> Self {
 		Self {
-			weight: Weight::from_ref_time(weight),
+			weight: Weight::from_parts(weight, 0),
 		}
 	}
 }
modifiedpallets/evm-migration/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-migration/src/lib.rs
+++ b/pallets/evm-migration/src/lib.rs
@@ -21,6 +21,7 @@
 pub use pallet::*;
 #[cfg(feature = "runtime-benchmarks")]
 pub mod benchmarking;
+#[allow(missing_docs)]
 pub mod weights;
 
 #[frame_support::pallet]
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 super::*;20use crate::Pallet;21use frame_system::RawOrigin;22use frame_support::traits::{tokens::currency::Currency, Get};23use frame_benchmarking::{benchmarks, account};24use sp_runtime::DispatchError;25use pallet_common::{26	Config as CommonConfig,27	benchmarking::{create_data, create_u16_data},28};2930const SEED: u32 = 1;3132fn create_collection_helper<T: Config>(33	owner: T::AccountId,34	mode: CollectionMode,35) -> Result<CollectionId, DispatchError> {36	<T as CommonConfig>::Currency::deposit_creating(&owner, T::CollectionCreationPrice::get());37	let col_name = create_u16_data::<MAX_COLLECTION_NAME_LENGTH>();38	let col_desc = create_u16_data::<MAX_COLLECTION_DESCRIPTION_LENGTH>();39	let token_prefix = create_data::<MAX_TOKEN_PREFIX_LENGTH>();40	<Pallet<T>>::create_collection(41		RawOrigin::Signed(owner).into(),42		col_name,43		col_desc,44		token_prefix,45		mode,46	)?;47	Ok(<pallet_common::CreatedCollectionCount<T>>::get())48}49pub fn create_nft_collection<T: Config>(50	owner: T::AccountId,51) -> Result<CollectionId, DispatchError> {52	create_collection_helper::<T>(owner, CollectionMode::NFT)53}5455benchmarks! {56	create_collection {57		let col_name = create_u16_data::<MAX_COLLECTION_NAME_LENGTH>();58		let col_desc = create_u16_data::<MAX_COLLECTION_DESCRIPTION_LENGTH>();59		let token_prefix = create_data::<MAX_TOKEN_PREFIX_LENGTH>();60		let mode: CollectionMode = CollectionMode::NFT;61		let caller: T::AccountId = account("caller", 0, SEED);62		<T as CommonConfig>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());63	}: _(RawOrigin::Signed(caller.clone()), col_name.clone(), col_desc.clone(), token_prefix.clone(), mode)64	verify {65		assert_eq!(<pallet_common::CollectionById<T>>::get(CollectionId(1)).unwrap().owner, caller);66	}6768	destroy_collection {69		let caller: T::AccountId = account("caller", 0, SEED);70		let collection = create_nft_collection::<T>(caller.clone())?;71	}: _(RawOrigin::Signed(caller.clone()), collection)7273	add_to_allow_list {74		let caller: T::AccountId = account("caller", 0, SEED);75		let allowlist_account: T::AccountId = account("admin", 0, SEED);76		let collection = create_nft_collection::<T>(caller.clone())?;77	}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(allowlist_account))7879	remove_from_allow_list {80		let caller: T::AccountId = account("caller", 0, SEED);81		let allowlist_account: T::AccountId = account("admin", 0, SEED);82		let collection = create_nft_collection::<T>(caller.clone())?;83		<Pallet<T>>::add_to_allow_list(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(allowlist_account.clone()))?;84	}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(allowlist_account))8586	change_collection_owner {87		let caller: T::AccountId = account("caller", 0, SEED);88		let collection = create_nft_collection::<T>(caller.clone())?;89		let new_owner: T::AccountId = account("admin", 0, SEED);90	}: _(RawOrigin::Signed(caller.clone()), collection, new_owner)9192	add_collection_admin {93		let caller: T::AccountId = account("caller", 0, SEED);94		let collection = create_nft_collection::<T>(caller.clone())?;95		let new_admin: T::AccountId = account("admin", 0, SEED);96	}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(new_admin))9798	remove_collection_admin {99		let caller: T::AccountId = account("caller", 0, SEED);100		let collection = create_nft_collection::<T>(caller.clone())?;101		let new_admin: T::AccountId = account("admin", 0, SEED);102		<Pallet<T>>::add_collection_admin(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(new_admin.clone()))?;103	}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(new_admin))104105	set_collection_sponsor {106		let caller: T::AccountId = account("caller", 0, SEED);107		let collection = create_nft_collection::<T>(caller.clone())?;108	}: _(RawOrigin::Signed(caller.clone()), collection, caller.clone())109110	confirm_sponsorship {111		let caller: T::AccountId = account("caller", 0, SEED);112		let collection = create_nft_collection::<T>(caller.clone())?;113		<Pallet<T>>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), collection, caller.clone())?;114	}: _(RawOrigin::Signed(caller.clone()), collection)115116	remove_collection_sponsor {117		let caller: T::AccountId = account("caller", 0, SEED);118		let collection = create_nft_collection::<T>(caller.clone())?;119		<Pallet<T>>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), collection, caller.clone())?;120		<Pallet<T>>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), collection)?;121	}: _(RawOrigin::Signed(caller.clone()), collection)122123	set_transfers_enabled_flag {124		let caller: T::AccountId = account("caller", 0, SEED);125		let collection = create_nft_collection::<T>(caller.clone())?;126	}: _(RawOrigin::Signed(caller.clone()), collection, false)127128129	set_collection_limits {130		let caller: T::AccountId = account("caller", 0, SEED);131		let collection = create_nft_collection::<T>(caller.clone())?;132133		let cl = CollectionLimits {134			account_token_ownership_limit: Some(0),135			sponsored_data_size: Some(0),136			token_limit: Some(1),137			sponsor_transfer_timeout: Some(0),138			sponsor_approve_timeout: None,139			owner_can_destroy: Some(true),140			owner_can_transfer: Some(true),141			sponsored_data_rate_limit: None,142			transfers_enabled: Some(true),143		};144	}: set_collection_limits(RawOrigin::Signed(caller.clone()), collection, cl)145146	force_repair_collection {147		let caller: T::AccountId = account("caller", 0, SEED);148		let collection = create_nft_collection::<T>(caller.clone())?;149	}: _(RawOrigin::Root, collection)150}
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 super::*;20use crate::Pallet;21use frame_system::RawOrigin;22use frame_support::traits::{tokens::currency::Currency, Get};23use frame_benchmarking::{benchmarks, account};24use sp_runtime::DispatchError;25use pallet_common::{26	Config as CommonConfig,27	benchmarking::{create_data, create_u16_data},28};29use up_data_structs::{30	CollectionId, CollectionMode, MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,31	MAX_COLLECTION_DESCRIPTION_LENGTH, CollectionLimits,32};33use pallet_common::erc::CrossAccountId;3435const SEED: u32 = 1;3637fn create_collection_helper<T: Config>(38	owner: T::AccountId,39	mode: CollectionMode,40) -> Result<CollectionId, DispatchError> {41	<T as CommonConfig>::Currency::deposit_creating(&owner, T::CollectionCreationPrice::get());42	let col_name = create_u16_data::<{ MAX_COLLECTION_NAME_LENGTH }>();43	let col_desc = create_u16_data::<{ MAX_COLLECTION_DESCRIPTION_LENGTH }>();44	let token_prefix = create_data::<{ MAX_TOKEN_PREFIX_LENGTH }>();45	<Pallet<T>>::create_collection(46		RawOrigin::Signed(owner).into(),47		col_name,48		col_desc,49		token_prefix,50		mode,51	)?;52	Ok(<pallet_common::CreatedCollectionCount<T>>::get())53}54pub fn create_nft_collection<T: Config>(55	owner: T::AccountId,56) -> Result<CollectionId, DispatchError> {57	create_collection_helper::<T>(owner, CollectionMode::NFT)58}5960benchmarks! {61	create_collection {62		let col_name = create_u16_data::<{MAX_COLLECTION_NAME_LENGTH}>();63		let col_desc = create_u16_data::<{MAX_COLLECTION_DESCRIPTION_LENGTH}>();64		let token_prefix = create_data::<{MAX_TOKEN_PREFIX_LENGTH}>();65		let mode: CollectionMode = CollectionMode::NFT;66		let caller: T::AccountId = account("caller", 0, SEED);67		<T as CommonConfig>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());68	}: _(RawOrigin::Signed(caller.clone()), col_name.clone(), col_desc.clone(), token_prefix.clone(), mode)69	verify {70		assert_eq!(<pallet_common::CollectionById<T>>::get(CollectionId(1)).unwrap().owner, caller);71	}7273	destroy_collection {74		let caller: T::AccountId = account("caller", 0, SEED);75		let collection = create_nft_collection::<T>(caller.clone())?;76	}: _(RawOrigin::Signed(caller.clone()), collection)7778	add_to_allow_list {79		let caller: T::AccountId = account("caller", 0, SEED);80		let allowlist_account: T::AccountId = account("admin", 0, SEED);81		let collection = create_nft_collection::<T>(caller.clone())?;82	}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(allowlist_account))8384	remove_from_allow_list {85		let caller: T::AccountId = account("caller", 0, SEED);86		let allowlist_account: T::AccountId = account("admin", 0, SEED);87		let collection = create_nft_collection::<T>(caller.clone())?;88		<Pallet<T>>::add_to_allow_list(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(allowlist_account.clone()))?;89	}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(allowlist_account))9091	change_collection_owner {92		let caller: T::AccountId = account("caller", 0, SEED);93		let collection = create_nft_collection::<T>(caller.clone())?;94		let new_owner: T::AccountId = account("admin", 0, SEED);95	}: _(RawOrigin::Signed(caller.clone()), collection, new_owner)9697	add_collection_admin {98		let caller: T::AccountId = account("caller", 0, SEED);99		let collection = create_nft_collection::<T>(caller.clone())?;100		let new_admin: T::AccountId = account("admin", 0, SEED);101	}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(new_admin))102103	remove_collection_admin {104		let caller: T::AccountId = account("caller", 0, SEED);105		let collection = create_nft_collection::<T>(caller.clone())?;106		let new_admin: T::AccountId = account("admin", 0, SEED);107		<Pallet<T>>::add_collection_admin(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(new_admin.clone()))?;108	}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(new_admin))109110	set_collection_sponsor {111		let caller: T::AccountId = account("caller", 0, SEED);112		let collection = create_nft_collection::<T>(caller.clone())?;113	}: _(RawOrigin::Signed(caller.clone()), collection, caller.clone())114115	confirm_sponsorship {116		let caller: T::AccountId = account("caller", 0, SEED);117		let collection = create_nft_collection::<T>(caller.clone())?;118		<Pallet<T>>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), collection, caller.clone())?;119	}: _(RawOrigin::Signed(caller.clone()), collection)120121	remove_collection_sponsor {122		let caller: T::AccountId = account("caller", 0, SEED);123		let collection = create_nft_collection::<T>(caller.clone())?;124		<Pallet<T>>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), collection, caller.clone())?;125		<Pallet<T>>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), collection)?;126	}: _(RawOrigin::Signed(caller.clone()), collection)127128	set_transfers_enabled_flag {129		let caller: T::AccountId = account("caller", 0, SEED);130		let collection = create_nft_collection::<T>(caller.clone())?;131	}: _(RawOrigin::Signed(caller.clone()), collection, false)132133134	set_collection_limits {135		let caller: T::AccountId = account("caller", 0, SEED);136		let collection = create_nft_collection::<T>(caller.clone())?;137138		let cl = CollectionLimits {139			account_token_ownership_limit: Some(0),140			sponsored_data_size: Some(0),141			token_limit: Some(1),142			sponsor_transfer_timeout: Some(0),143			sponsor_approve_timeout: None,144			owner_can_destroy: Some(true),145			owner_can_transfer: Some(true),146			sponsored_data_rate_limit: None,147			transfers_enabled: Some(true),148		};149	}: set_collection_limits(RawOrigin::Signed(caller.clone()), collection, cl)150151	force_repair_collection {152		let caller: T::AccountId = account("caller", 0, SEED);153		let collection = create_nft_collection::<T>(caller.clone())?;154	}: _(RawOrigin::Root, collection)155}
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -89,14 +89,11 @@
 	use frame_support::{
 		dispatch::DispatchResult,
 		ensure, fail,
-		weights::{Weight},
-		pallet_prelude::{*},
 		BoundedVec,
 		storage::Key,
 	};
-	use frame_system::pallet_prelude::*;
 	use scale_info::TypeInfo;
-	use frame_system::{self as system, ensure_signed, ensure_root};
+	use frame_system::{ensure_signed, ensure_root};
 	use sp_std::{vec, vec::Vec};
 	use up_data_structs::{
 		MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
modifiedprimitives/common/src/constants.rsdiffbeforeafterboth
--- a/primitives/common/src/constants.rs
+++ b/primitives/common/src/constants.rs
@@ -64,9 +64,10 @@
 /// by  Operational  extrinsics.
 pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
 /// We allow for 2 seconds of compute with a 6 second average block time.
-pub const MAXIMUM_BLOCK_WEIGHT: Weight =
-	Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(2))
-		.set_proof_size(MAX_POV_SIZE as u64);
+pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
+	WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
+	MAX_POV_SIZE as u64,
+);
 
 parameter_types! {
 	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE / 2;
modifiedruntime/common/config/ethereum.rsdiffbeforeafterboth
--- a/runtime/common/config/ethereum.rs
+++ b/runtime/common/config/ethereum.rs
@@ -28,7 +28,7 @@
 	pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;
 	pub const WeightTimePerGas: u64 = WEIGHT_REF_TIME_PER_SECOND / GasPerSecond::get();
 
-	pub const WeightPerGas: Weight = Weight::from_ref_time(WeightTimePerGas::get());
+	pub const WeightPerGas: Weight = Weight::from_parts(WeightTimePerGas::get(), 0);
 }
 
 /// Limiting EVM execution to 50% of block for substrate users and management tasks
modifiedruntime/common/mod.rsdiffbeforeafterboth
--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -27,6 +27,7 @@
 pub mod scheduler;
 
 pub mod sponsoring;
+#[allow(missing_docs)]
 pub mod weights;
 
 #[cfg(test)]
@@ -152,7 +153,7 @@
 	}
 	#[cfg(feature = "runtime-benchmarks")]
 	fn set_block_number(block: Self::BlockNumber) {
-		cumulus_pallet_parachain_system::RelaychainBlockNumberProvider::<T>::set_block_number(block)
+		cumulus_pallet_parachain_system::RelaychainDataProvider::<T>::set_block_number(block)
 	}
 }