git.delta.rocks / unique-network / refs/commits / 369a51ded768

difftreelog

Merge pull request #974 from UniqueNetwork/fix/evm-coder-leftovers

Yaroslav Bolyukin2023-08-30parents: #0ce92f0 #c466f2a.patch.diff
in: master

25 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -528,7 +528,7 @@
 				|r: sc_service::Result<
 					up_data_structs::TokenDataVersion1<CrossAccountId>,
 					sp_runtime::DispatchError,
-				>| r.and_then(|value| Ok(value.into())),
+				>| r.map(|value| value.into()),
 			)
 			.or_else(|_| {
 				Ok(api
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -297,7 +297,7 @@
 				default_runtime,
 				// Sudo account
 				get_account_id_from_seed::<sr25519::Public>("Alice"),
-				vec![
+				[
 					(
 						get_account_id_from_seed::<sr25519::Public>("Alice"),
 						get_from_seed::<AuraId>("Alice"),
@@ -371,7 +371,7 @@
 				default_runtime,
 				// Sudo account
 				get_account_id_from_seed::<sr25519::Public>("Alice"),
-				vec![
+				[
 					(
 						get_account_id_from_seed::<sr25519::Public>("Alice"),
 						get_from_seed::<AuraId>("Alice"),
modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -63,7 +63,7 @@
 	}
 	let bytes = id.to_string();
 	let len = data.len();
-	data[len - bytes.len()..].copy_from_slice(&bytes.as_bytes());
+	data[len - bytes.len()..].copy_from_slice(bytes.as_bytes());
 	data
 }
 pub fn property_value() -> PropertyValue {
@@ -80,7 +80,7 @@
 	cast: impl FnOnce(CollectionHandle<T>) -> R,
 ) -> Result<R, DispatchError> {
 	let imbalance = <T as Config>::Currency::deposit(
-		&owner.as_sub(),
+		owner.as_sub(),
 		T::CollectionCreationPrice::get(),
 		Precision::Exact,
 	)?;
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -2420,7 +2420,8 @@
 	}
 }
 
-#[cfg(feature = "tests")]
+#[cfg(any(feature = "tests", test))]
+#[allow(missing_docs)]
 pub mod tests {
 	use crate::{DispatchResult, DispatchError, LazyValue, Config};
 
@@ -2456,7 +2457,7 @@
 	}
 
 	#[rustfmt::skip]
-	pub const table: [TestCase; 16] = [
+	pub const TABLE: [TestCase; 16] = [
 		//                    ┌╴collection_admin
 		//                    │  ┌╴is_collection_admin
 		//                    │  │   ┌╴token_owner
modifiedpallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth
before · pallets/evm-coder-substrate/src/lib.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_attr(not(feature = "std"), no_std)]1819extern crate self as pallet_evm_coder_substrate;2021#[cfg(not(feature = "std"))]22extern crate alloc;23#[cfg(not(feature = "std"))]24use alloc::format;25use execution::PreDispatch;26use frame_support::dispatch::Weight;2728use core::marker::PhantomData;29use sp_std::{cell::RefCell, vec::Vec};3031use codec::Decode;32use frame_support::pallet_prelude::DispatchError;33use frame_support::traits::PalletInfo;34use frame_support::{ensure, sp_runtime::ModuleError};35use up_data_structs::budget;36use pallet_evm::{37	ExitError, ExitRevert, ExitSucceed, GasWeightMapping, PrecompileFailure, PrecompileOutput,38	PrecompileResult, PrecompileHandle,39};40use sp_core::{Get, H160};41// #[cfg(feature = "runtime-benchmarks")]42// pub mod benchmarking;43pub mod execution;4445#[doc(hidden)]46pub use spez::spez;4748use evm_coder::{49	types::{Msg, Value},50	AbiEncode,51};5253pub use pallet::*;54pub use evm_coder::{ResultWithPostInfoOf, Contract, abi, solidity_interface, ToLog, types};5556#[frame_support::pallet]57pub mod pallet {58	use super::*;5960	pub use frame_support::dispatch::DispatchResult;6162	/// DispatchError is opaque, but we need to somehow extract correct error in case of OutOfGas failure63	/// So we have this pallet, which defines OutOfGas error, and knews its own id to check if DispatchError64	/// is thrown because of it65	///66	/// These errors shouldn't end in extrinsic results, as they only used in evm execution path67	#[pallet::error]68	pub enum Error<T> {69		OutOfGas,70		OutOfFund,71	}7273	#[pallet::config]74	pub trait Config: frame_system::Config + pallet_evm::Config {}7576	#[pallet::pallet]77	pub struct Pallet<T>(_);78}7980// From instabul hardfork configuration: https://github.com/rust-blockchain/evm/blob/fd4fd6acc0ca3208d6770fdb3ba407c94cdf97c6/runtime/src/lib.rs#L28481pub const G_SLOAD_WORD: u64 = 800;82pub const G_SSTORE_WORD: u64 = 20000;8384pub struct GasCallsBudget<'r, T: Config> {85	recorder: &'r SubstrateRecorder<T>,86	gas_per_call: u64,87}88impl<T: Config> budget::Budget for GasCallsBudget<'_, T> {89	fn consume_custom(&self, calls: u32) -> bool {90		let (gas, overflown) = (calls as u64).overflowing_add(self.gas_per_call);91		if overflown {92			return false;93		}94		self.recorder.consume_gas(gas).is_ok()95	}96}9798#[derive(Default)]99pub struct SubstrateRecorder<T: Config> {100	initial_gas: u64,101	gas_limit: RefCell<u64>,102	_phantom: PhantomData<*const T>,103}104105impl<T: Config> SubstrateRecorder<T> {106	pub fn new(gas_limit: u64) -> Self {107		Self {108			initial_gas: gas_limit,109			gas_limit: RefCell::new(gas_limit),110			_phantom: PhantomData,111		}112	}113114	pub fn gas_left(&self) -> u64 {115		*self.gas_limit.borrow()116	}117	pub fn gas_calls_budget(&self, gas_per_call: u64) -> GasCallsBudget<T> {118		GasCallsBudget {119			recorder: self,120			gas_per_call,121		}122	}123	pub fn weight_calls_budget(&self, weight_per_call: Weight) -> GasCallsBudget<T> {124		GasCallsBudget {125			recorder: self,126			gas_per_call: T::GasWeightMapping::weight_to_gas(weight_per_call),127		}128	}129	pub fn consume_sload_sub(&self) -> DispatchResult {130		self.consume_gas_sub(G_SLOAD_WORD)131	}132	pub fn consume_sstores_sub(&self, amount: usize) -> DispatchResult {133		self.consume_gas_sub(G_SSTORE_WORD.saturating_mul(amount as u64))134	}135	pub fn consume_sstore_sub(&self) -> DispatchResult {136		self.consume_gas_sub(G_SSTORE_WORD)137	}138	pub fn consume_gas_sub(&self, gas: u64) -> DispatchResult {139		ensure!(gas != u64::MAX, Error::<T>::OutOfGas);140		let mut gas_limit = self.gas_limit.borrow_mut();141		ensure!(gas <= *gas_limit, Error::<T>::OutOfGas);142		*gas_limit -= gas;143		Ok(())144	}145146	pub fn consume_sload(&self) -> execution::Result<()> {147		self.consume_gas(G_SLOAD_WORD)148	}149	pub fn consume_sstore(&self) -> execution::Result<()> {150		self.consume_gas(G_SSTORE_WORD)151	}152	pub fn consume_gas(&self, gas: u64) -> execution::Result<()> {153		if gas == u64::MAX {154			return Err(execution::Error::Error(ExitError::OutOfGas));155		}156		let mut gas_limit = self.gas_limit.borrow_mut();157		if gas > *gas_limit {158			return Err(execution::Error::Error(ExitError::OutOfGas));159		}160		*gas_limit -= gas;161		Ok(())162	}163	pub fn return_gas(&self, gas: u64) {164		let mut gas_limit = self.gas_limit.borrow_mut();165		*gas_limit += gas;166	}167168	pub fn evm_to_precompile_output(169		self,170		handle: &mut impl PrecompileHandle,171		result: execution::Result<Option<Vec<u8>>>,172	) -> Option<PrecompileResult> {173		use execution::Error;174		// We ignore error here, as it should not occur, as we have our own bookkeeping of gas175		let _ = handle.record_cost(self.initial_gas - self.gas_left());176		Some(match result {177			Ok(Some(v)) => Ok(PrecompileOutput {178				exit_status: ExitSucceed::Returned,179				output: v,180			}),181			Ok(None) => return None,182			Err(Error::Revert(e)) => Err(PrecompileFailure::Revert {183				exit_status: ExitRevert::Reverted,184				output: (&e as &str,).abi_encode_call(evm_coder::fn_selector!(Error(string))),185			}),186			Err(Error::Fatal(f)) => Err(PrecompileFailure::Fatal { exit_status: f }),187			Err(Error::Error(e)) => Err(e.into()),188		})189	}190191	/// Consume gas for reading.192	pub fn consume_store_reads(&self, reads: u64) -> execution::Result<()> {193		self.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(194			<T as frame_system::Config>::DbWeight::get()195				.read196				.saturating_mul(reads),197			// TODO: measure proof198			0,199		)))200	}201202	/// Consume gas for writing.203	pub fn consume_store_writes(&self, writes: u64) -> execution::Result<()> {204		self.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(205			<T as frame_system::Config>::DbWeight::get()206				.write207				.saturating_mul(writes),208			// TODO: measure proof209			0,210		)))211	}212213	/// Consume gas for reading and writing.214	pub fn consume_store_reads_and_writes(&self, reads: u64, writes: u64) -> execution::Result<()> {215		let weight = <T as frame_system::Config>::DbWeight::get();216		let reads = weight.read.saturating_mul(reads);217		let writes = weight.read.saturating_mul(writes);218		self.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(219			reads.saturating_add(writes),220			// TODO: measure proof221			0,222		)))223	}224}225226pub fn dispatch_to_evm<T: Config>(err: DispatchError) -> execution::Error {227	use execution::Error as ExError;228	match err {229		DispatchError::Module(ModuleError { index, error, .. })230			if index231				== T::PalletInfo::index::<Pallet<T>>()232					.expect("evm-coder-substrate is a pallet, which should be added to runtime")233					as u8 =>234		{235			let mut read = &error as &[u8];236			match Error::<T>::decode(&mut read) {237				Ok(Error::<T>::OutOfGas) => ExError::Error(ExitError::OutOfGas),238				Ok(Error::<T>::OutOfFund) => ExError::Error(ExitError::OutOfFund),239				_ => unreachable!("this pallet only defines two possible errors"),240			}241		}242		DispatchError::Module(ModuleError {243			message: Some(msg), ..244		}) => ExError::Revert(msg.into()),245		DispatchError::Module(ModuleError { index, error, .. }) => {246			ExError::Revert(format!("error {error:?} in pallet {index}"))247		}248		e => ExError::Revert(format!("substrate error: {e:?}")),249	}250}251252pub trait WithRecorder<T: Config> {253	fn recorder(&self) -> &SubstrateRecorder<T>;254	fn into_recorder(self) -> SubstrateRecorder<T>;255}256257/// Helper to simplify implementing bridge between evm-coder definitions and pallet-evm258pub fn call<T, C, E, H>(handle: &mut H, mut e: E) -> Option<PrecompileResult>259where260	T: Config,261	C: evm_coder::Call + PreDispatch,262	E: evm_coder::Callable<C> + WithRecorder<T>,263	H: PrecompileHandle,264	execution::ResultWithPostInfo<Vec<u8>>: From<ResultWithPostInfoOf<E, Vec<u8>>>,265{266	let result = call_internal(267		handle.context().caller,268		&mut e,269		handle.context().apparent_value,270		handle.input(),271	);272	e.into_recorder().evm_to_precompile_output(handle, result)273}274275fn call_internal<T, C, E>(276	caller: H160,277	e: &mut E,278	value: Value,279	input: &[u8],280) -> execution::Result<Option<Vec<u8>>>281where282	T: Config,283	C: evm_coder::Call + PreDispatch,284	E: Contract + evm_coder::Callable<C> + WithRecorder<T>,285	execution::ResultWithPostInfo<Vec<u8>>: From<ResultWithPostInfoOf<E, Vec<u8>>>,286{287	let call = C::parse_full(input)?;288	if call.is_none() {289		return Err("unrecognized selector".into());290	}291	let call = call.unwrap();292293	let dispatch_info = call.dispatch_info();294	e.recorder()295		.consume_gas(T::GasWeightMapping::weight_to_gas(dispatch_info.weight))?;296297	match execution::ResultWithPostInfo::from(e.call(Msg {298		call,299		caller,300		value,301	})) {302		Ok(v) => {303			let unspent = v.post_info.calc_unspent(&dispatch_info);304			e.recorder()305				.return_gas(T::GasWeightMapping::weight_to_gas(unspent));306			Ok(Some(v.data))307		}308		Err(v) => {309			let unspent = v.post_info.calc_unspent(&dispatch_info);310			e.recorder()311				.return_gas(T::GasWeightMapping::weight_to_gas(unspent));312			Err(v.data)313		}314	}315}316317#[cfg(test)]318#[allow(dead_code)]319mod tests {320	use core::marker::PhantomData;321322	use evm_coder::ERC165Call;323	use frame_support::weights::Weight;324325	use crate::execution::PreDispatch;326327	#[derive(PreDispatch)]328	enum ExampleCall<T: super::Config> {329		ERC165Call(ERC165Call, PhantomData<fn() -> T>),330		OtherCall(ERC165Call),331332		#[weight(Weight::from_ref_time(a + b))]333		Example {334			a: u64,335			b: u64,336		},337	}338}
modifiedpallets/fungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -53,7 +53,7 @@
 		let data = (0..b).map(|i| {
 			bench_init!(to: cross_sub(i););
 			(to, 200)
-		}).collect::<BTreeMap<_, _>>().try_into().unwrap();
+		}).collect::<BTreeMap<_, _>>();
 	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
 
 	burn_item {
modifiedpallets/identity/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/identity/src/benchmarking.rs
+++ b/pallets/identity/src/benchmarking.rs
@@ -35,6 +35,7 @@
 //! Identity pallet benchmarking.
 
 #![cfg(feature = "runtime-benchmarks")]
+#![allow(clippy::no_effect)]
 
 use super::*;
 
modifiedpallets/identity/src/tests.rsdiffbeforeafterboth
--- a/pallets/identity/src/tests.rs
+++ b/pallets/identity/src/tests.rs
@@ -67,7 +67,7 @@
 
 parameter_types! {
 	pub BlockWeights: frame_system::limits::BlockWeights =
-		frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024));
+		frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_parts(1024, 0));
 }
 impl frame_system::Config for Test {
 	type BaseCallFilter = frame_support::traits::Everything;
modifiedpallets/identity/src/types.rsdiffbeforeafterboth
--- a/pallets/identity/src/types.rs
+++ b/pallets/identity/src/types.rs
@@ -481,7 +481,7 @@
 		let mut registry = scale_info::Registry::new();
 		let type_id = registry.register_type(&scale_info::meta_type::<Data>());
 		let registry: scale_info::PortableRegistry = registry.into();
-		let type_info = registry.resolve(type_id.id()).unwrap();
+		let type_info = registry.resolve(type_id.id).unwrap();
 
 		let check_type_info = |data: &Data| {
 			let variant_name = match data {
@@ -492,20 +492,20 @@
 				Data::ShaThree256(_) => "ShaThree256".to_string(),
 				Data::Raw(bytes) => format!("Raw{}", bytes.len()),
 			};
-			if let scale_info::TypeDef::Variant(variant) = type_info.type_def() {
+			if let scale_info::TypeDef::Variant(variant) = &type_info.type_def {
 				let variant = variant
-					.variants()
+					.variants
 					.iter()
-					.find(|v| v.name() == &variant_name)
+					.find(|v| v.name == variant_name)
 					.expect(&format!("Expected to find variant {}", variant_name));
 
 				let field_arr_len = variant
-					.fields()
+					.fields
 					.first()
-					.and_then(|f| registry.resolve(f.ty().id()))
+					.and_then(|f| registry.resolve(f.ty.id))
 					.map(|ty| {
-						if let scale_info::TypeDef::Array(arr) = ty.type_def() {
-							arr.len()
+						if let scale_info::TypeDef::Array(arr) = &ty.type_def {
+							arr.len
 						} else {
 							panic!("Should be an array type")
 						}
@@ -513,7 +513,7 @@
 					.unwrap_or(0);
 
 				let encoded = data.encode();
-				assert_eq!(encoded[0], variant.index());
+				assert_eq!(encoded[0], variant.index);
 				assert_eq!(encoded.len() as u32 - 1, field_arr_len);
 			} else {
 				panic!("Should be a variant type")
modifiedpallets/inflation/src/tests.rsdiffbeforeafterboth
--- a/pallets/inflation/src/tests.rs
+++ b/pallets/inflation/src/tests.rs
@@ -78,7 +78,7 @@
 parameter_types! {
 	pub const BlockHashCount: u64 = 250;
 	pub BlockWeights: frame_system::limits::BlockWeights =
-		frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(1024));
+		frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0));
 	pub const SS58Prefix: u8 = 42;
 }
 
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -43,12 +43,12 @@
 	owner: T::CrossAccountId,
 ) -> Result<TokenId, DispatchError> {
 	<Pallet<T>>::create_item(
-		&collection,
+		collection,
 		sender,
 		create_max_item_data::<T>(owner),
 		&Unlimited,
 	)?;
-	Ok(TokenId(<TokensMinted<T>>::get(&collection.id)))
+	Ok(TokenId(<TokensMinted<T>>::get(collection.id)))
 }
 
 fn create_collection<T: Config>(
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -51,8 +51,8 @@
 	users: impl IntoIterator<Item = (T::CrossAccountId, u128)>,
 ) -> Result<TokenId, DispatchError> {
 	let data: CreateItemData<T> = create_max_item_data::<T>(users);
-	<Pallet<T>>::create_item(&collection, sender, data, &Unlimited)?;
-	Ok(TokenId(<TokensMinted<T>>::get(&collection.id)))
+	<Pallet<T>>::create_item(collection, sender, data, &Unlimited)?;
+	Ok(TokenId(<TokensMinted<T>>::get(collection.id)))
 }
 
 fn create_collection<T: Config>(
@@ -104,7 +104,7 @@
 		let data = vec![create_max_item_data::<T>((0..b).map(|u| {
 			bench_init!(to: cross_sub(u););
 			(to, 200)
-		}))].try_into().unwrap();
+		}))];
 	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
 
 	// Other user left, token data is kept
modifiedpallets/scheduler-v2/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/scheduler-v2/src/benchmarking.rs
+++ b/pallets/scheduler-v2/src/benchmarking.rs
@@ -83,11 +83,11 @@
 ///
 /// # Arguments
 /// * `periodic` - makes the task periodic.
-/// 	Sets the task's period and repetition count to `100`.
+///     Sets the task's period and repetition count to `100`.
 /// * `named` - gives a name to the task: `u32_to_name(0)`.
 /// * `signed` - determines the origin of the task.
-/// 	If true, it will have the Signed origin. Otherwise it will have the Root origin.
-/// 	See [`make_origin`] for details.
+///     If true, it will have the Signed origin. Otherwise it will have the Root origin.
+///     See [`make_origin`] for details.
 /// * maybe_lookup_len - sets optional lookup length. It is used to benchmark task fetching from the `Preimages` store.
 /// * priority - the task's priority.
 fn make_task<T: Config>(
@@ -155,12 +155,10 @@
 		}
 		if maybe_lookup_len.is_some() {
 			len += 1;
+		} else if len > 0 {
+			len -= 1;
 		} else {
-			if len > 0 {
-				len -= 1;
-			} else {
-				break c;
-			}
+			break c;
 		}
 	}
 }
modifiedpallets/scheduler-v2/src/mock.rsdiffbeforeafterboth
--- a/pallets/scheduler-v2/src/mock.rs
+++ b/pallets/scheduler-v2/src/mock.rs
@@ -33,6 +33,7 @@
 // limitations under the License.
 
 //! # Scheduler test environment.
+#![allow(deprecated)]
 
 use super::*;
 
@@ -229,6 +230,10 @@
 			r => Err(O::from(r)),
 		})
 	}
+	#[cfg(feature = "runtime-benchmarks")]
+	fn try_successful_origin() -> Result<O, ()> {
+		Ok(O::from(RawOrigin::Root))
+	}
 }
 
 pub struct Executor;
modifiedpallets/scheduler-v2/src/tests.rsdiffbeforeafterboth
--- a/pallets/scheduler-v2/src/tests.rs
+++ b/pallets/scheduler-v2/src/tests.rs
@@ -33,6 +33,7 @@
 // limitations under the License.
 
 //! # Scheduler tests.
+#![allow(deprecated)]
 
 use super::*;
 use crate::mock::{
modifiedpallets/structure/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/structure/src/benchmarking.rs
+++ b/pallets/structure/src/benchmarking.rs
@@ -19,8 +19,7 @@
 use frame_benchmarking::{benchmarks, account};
 use frame_support::traits::{fungible::Balanced, Get, tokens::Precision};
 use up_data_structs::{
-	CreateCollectionData, CollectionMode, CreateItemData, CollectionFlags, CreateNftData,
-	budget::Unlimited,
+	CreateCollectionData, CollectionMode, CreateItemData, CreateNftData, budget::Unlimited,
 };
 use pallet_common::Config as CommonConfig;
 use pallet_evm::account::CrossAccountId;
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -24,8 +24,7 @@
 		weights::CommonWeights,
 		RelayChainBlockNumberProvider,
 	},
-	Runtime, RuntimeEvent, RuntimeCall, RUNTIME_NAME, TOKEN_SYMBOL, DECIMALS,
-	Balances,
+	Runtime, RuntimeEvent, RuntimeCall, RUNTIME_NAME, TOKEN_SYMBOL, DECIMALS, Balances,
 };
 use frame_support::traits::{ConstU32, ConstU64, Currency};
 use up_common::{
modifiedruntime/common/ethereum/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/sponsoring.rs
+++ b/runtime/common/ethereum/sponsoring.rs
@@ -161,7 +161,8 @@
 					}
 				}
 				CollectionMode::ReFungible => {
-					let call = <UniqueRefungibleCall<T>>::parse_full(&call_context.input).ok()??;
+					let call =
+						<UniqueRefungibleCall<T>>::parse_full(&call_context.input).ok()??;
 					refungible::call_sponsor(call, collection, who).map(|()| sponsor)
 				}
 				CollectionMode::Fungible(_) => {
modifiedruntime/common/tests/mod.rsdiffbeforeafterboth
--- a/runtime/common/tests/mod.rs
+++ b/runtime/common/tests/mod.rs
@@ -16,7 +16,6 @@
 
 use sp_runtime::{BuildStorage, Storage};
 use sp_core::{Public, Pair};
-use sp_std::vec;
 use up_common::types::AuraId;
 use crate::{Runtime, GenesisConfig, ParachainInfoConfig, RuntimeEvent, System};
 
@@ -76,7 +75,7 @@
 		AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
 	}
 
-	let accounts = vec!["Alice", "Bob"];
+	let accounts = ["Alice", "Bob"];
 	let keys = accounts
 		.iter()
 		.map(|&acc| {
@@ -104,7 +103,7 @@
 		..GenesisConfig::default()
 	};
 
-	cfg.build_storage().unwrap().into()
+	cfg.build_storage().unwrap()
 }
 
 #[cfg(not(feature = "collator-selection"))]
modifiedruntime/common/tests/xcm.rsdiffbeforeafterboth
--- a/runtime/common/tests/xcm.rs
+++ b/runtime/common/tests/xcm.rs
@@ -26,7 +26,7 @@
 const ALICE: AccountId = AccountId::new([0u8; 32]);
 const BOB: AccountId = AccountId::new([1u8; 32]);
 
-const INITIAL_BALANCE: u128 = 1000000000000000000_0000; // 1000 UNQ
+const INITIAL_BALANCE: u128 = 10_000_000_000_000_000_000_000; // 10_000 UNQ
 
 #[test]
 pub fn xcm_transact_is_forbidden() {
modifiedruntime/tests/Cargo.tomldiffbeforeafterboth
--- a/runtime/tests/Cargo.toml
+++ b/runtime/tests/Cargo.toml
@@ -5,7 +5,6 @@
 
 [features]
 default = ['refungible']
-tests = ['pallet-common/tests']
 
 refungible = []
 
@@ -44,3 +43,6 @@
 evm-coder = { workspace = true }
 up-sponsorship = { workspace = true }
 xcm = { workspace = true }
+
+[dev-dependencies]
+pallet-common = { workspace = true, features = ["tests"] }
modifiedruntime/tests/src/tests.rsdiffbeforeafterboth
--- a/runtime/tests/src/tests.rs
+++ b/runtime/tests/src/tests.rs
@@ -99,7 +99,7 @@
 	.try_into()
 	.unwrap();
 
-	let data: CreateCollectionData<u64> = CreateCollectionData {
+	let data = CreateCollectionData {
 		name: col_name1.try_into().unwrap(),
 		description: col_desc1.try_into().unwrap(),
 		token_prefix: token_prefix1.try_into().unwrap(),
@@ -204,14 +204,13 @@
 		let description: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();
 		let token_prefix: Vec<u8> = b"token_prefix1\0".to_vec();
 
-		let data: CreateCollectionData<<Test as frame_system::Config>::AccountId> =
-			CreateCollectionData {
-				name: name.try_into().unwrap(),
-				description: description.try_into().unwrap(),
-				token_prefix: token_prefix.try_into().unwrap(),
-				mode: CollectionMode::NFT,
-				..Default::default()
-			};
+		let data = CreateCollectionData {
+			name: name.try_into().unwrap(),
+			description: description.try_into().unwrap(),
+			token_prefix: token_prefix.try_into().unwrap(),
+			mode: CollectionMode::NFT,
+			..Default::default()
+		};
 
 		let result = Unique::create_collection_ex(RuntimeOrigin::signed(acc), data);
 		assert_err!(result, <CommonError<Test>>::NotSufficientFounds);
@@ -225,7 +224,7 @@
 		let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();
 		let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();
 
-		let data: CreateCollectionData<u64> = CreateCollectionData {
+		let data = CreateCollectionData {
 			name: col_name1.try_into().unwrap(),
 			description: col_desc1.try_into().unwrap(),
 			token_prefix: token_prefix1.try_into().unwrap(),
@@ -2364,7 +2363,7 @@
 		let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();
 		let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();
 
-		let data: CreateCollectionData<u64> = CreateCollectionData {
+		let data = CreateCollectionData {
 			name: col_name1.try_into().unwrap(),
 			description: col_desc1.try_into().unwrap(),
 			token_prefix: token_prefix1.try_into().unwrap(),
@@ -2618,9 +2617,7 @@
 
 mod check_token_permissions {
 	use super::*;
-	use frame_support::once_cell::sync::Lazy;
 	use pallet_common::LazyValue;
-	use sp_runtime::DispatchError;
 
 	fn test<FTE: FnOnce() -> bool>(
 		i: usize,
@@ -2662,7 +2659,7 @@
 	fn no_permission_only() {
 		new_test_ext().execute_with(|| {
 			let mut check_token_existence = LazyValue::new(|| true);
-			for (i, row) in pallet_common::tests::table.iter().enumerate() {
+			for (i, row) in pallet_common::tests::TABLE.iter().enumerate() {
 				test(i, row, &mut check_token_existence);
 			}
 		});
@@ -2671,7 +2668,7 @@
 	#[test]
 	fn no_permission_and_token_not_found() {
 		new_test_ext().execute_with(|| {
-			for (i, row) in pallet_common::tests::table.iter().enumerate() {
+			for (i, row) in pallet_common::tests::TABLE.iter().enumerate() {
 				// This is inside the loop to keep track of whether the lambda was called
 				let mut check_token_existence = LazyValue::new(|| false);
 				test(i, row, &mut check_token_existence);
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -106,15 +106,17 @@
       flags: [CollectionFlag.Erc721metadata],
     }, 'nft');
 
-    await mintCollectionHelper(helper, alice, {
+    // User can not set Foreign flag itself
+
+    await expect(mintCollectionHelper(helper, alice, {
       name: 'name', description: 'descr', tokenPrefix: 'COL',
       flags: [CollectionFlag.Foreign],
-    }, 'nft');
+    }, 'nft')).to.be.rejectedWith(/common.NoPermission/);
 
-    await mintCollectionHelper(helper, alice, {
+    await expect(mintCollectionHelper(helper, alice, {
       name: 'name', description: 'descr', tokenPrefix: 'COL',
       flags: [CollectionFlag.Erc721metadata, CollectionFlag.Foreign],
-    }, 'nft');
+    }, 'nft')).to.be.rejectedWith(/common.NoPermission/);
   });
 
   itSub('Create new collection with extra fields', async ({helper}) => {
modifiedtests/src/eth/collectionLimits.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionLimits.test.ts
+++ b/tests/src/eth/collectionLimits.test.ts
@@ -106,7 +106,7 @@
 
       // Cannot disable limits
       await expect(collectionEvm.methods
-        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: false, value: 200}})
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: false, value: 0}})
         .call()).to.be.rejectedWith('user can\'t disable limits');
 
       await expect(collectionEvm.methods
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -41,7 +41,7 @@
       for(const arg of args) {
         if(typeof arg !== 'string')
           continue;
-        const skippedWarnings = ['1000:: Normal connection closure', 'Not decorating unknown runtime apis:', 'RPC methods not decorated:', 'Not decorating runtime apis'];
+        const skippedWarnings = ['1000:: Normal connection closure', 'Not decorating unknown runtime apis:', 'RPC methods not decorated:', 'Not decorating runtime apis', 'Bad input data provided to validate_transaction', 'account balance too low', '1006:: Abnormal Closure'];
         const needToSkip = skippedWarnings.reduce((a,  b) => a || arg.includes(b), false);
         if(needToSkip || arg === 'Normal connection closure')
           return;