git.delta.rocks / unique-network / refs/commits / 59e224731e80

difftreelog

feat benchmark property calls

Yaroslav Bolyukin2022-05-23parent: #fd1b071.patch.diff
in: master

30 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5913,6 +5913,7 @@
 dependencies = [
  "evm-coder",
  "fp-evm-mapping",
+ "frame-benchmarking",
  "frame-support",
  "frame-system",
  "pallet-evm",
@@ -6649,6 +6650,7 @@
  "frame-support",
  "frame-system",
  "pallet-common",
+ "pallet-evm",
  "parity-scale-codec 3.1.2",
  "scale-info",
  "sp-std",
modifiedMakefilediffbeforeafterboth
--- a/Makefile
+++ b/Makefile
@@ -41,6 +41,10 @@
 bench-evm-migration:
 	make _bench PALLET=evm-migration
 
+.PHONY: bench-common
+bench-common:
+	make _bench PALLET=common
+
 .PHONY: bench-unique
 bench-unique:
 	make _bench PALLET=unique
modifiedpallets/common/Cargo.tomldiffbeforeafterboth
--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -25,6 +25,7 @@
 scale-info = { version = "2.0.1", default-features = false, features = [
     "derive",
 ] }
+frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 
 [features]
 default = ["std"]
@@ -37,4 +38,6 @@
     "up-data-structs/std",
     "pallet-evm/std",
 ]
-runtime-benchmarks = []
+runtime-benchmarks = [
+    "frame-benchmarking"
+]
modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -15,11 +15,13 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use sp_std::vec::Vec;
-use crate::{Config, CollectionHandle};
+use crate::{Config, CollectionHandle, Pallet};
+use pallet_evm::account::CrossAccountId;
+use frame_benchmarking::{benchmarks, account};
 use up_data_structs::{
-	CollectionMode, CreateCollectionData, CollectionId, MAX_COLLECTION_NAME_LENGTH,
-	MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH, OFFCHAIN_SCHEMA_LIMIT,
-	CONST_ON_CHAIN_SCHEMA_LIMIT,
+	CollectionMode, CreateCollectionData, CollectionId, Property, PropertyKey, PropertyValue,
+	MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
+	OFFCHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT, MAX_PROPERTIES_PER_ITEM,
 };
 use frame_support::{
 	traits::{Currency, Get},
@@ -29,6 +31,8 @@
 use core::convert::TryInto;
 use sp_runtime::DispatchError;
 
+const SEED: u32 = 1;
+
 pub fn create_data<const S: u32>() -> BoundedVec<u8, ConstU32<S>> {
 	create_var_data::<S>(S)
 }
@@ -52,6 +56,22 @@
 		.try_into()
 		.unwrap()
 }
+pub fn property_key(id: usize) -> PropertyKey {
+	#[cfg(not(feature = "std"))]
+	use alloc::string::ToString;
+	let mut data = create_data();
+	// No DerefMut available for .fill
+	for i in 0..data.len() {
+		data[i] = b'0';
+	}
+	let bytes = id.to_string();
+	let len = data.len();
+	data[len - bytes.len()..].copy_from_slice(&bytes.as_bytes());
+	data
+}
+pub fn property_value() -> PropertyValue {
+	create_data()
+}
 
 pub fn create_collection_raw<T: Config, R>(
 	owner: T::AccountId,
@@ -83,6 +103,14 @@
 	.and_then(CollectionHandle::try_get)
 	.map(cast)
 }
+fn create_collection<T: Config>(owner: T::AccountId) -> Result<CollectionHandle<T>, DispatchError> {
+	create_collection_raw(
+		owner,
+		CollectionMode::NFT,
+		|owner, data| <Pallet<T>>::init_collection(owner, data),
+		|h| h,
+	)
+}
 
 /// Helper macros, which handles all benchmarking preparation in semi-declarative way
 ///
@@ -125,3 +153,31 @@
 	};
 	() => {}
 }
+
+benchmarks! {
+	set_collection_properties {
+		let b in 0..MAX_PROPERTIES_PER_ITEM;
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			owner: cross_from_sub;
+		};
+		let props = (0..b).map(|p| Property {
+			key: property_key(p as usize),
+			value: property_value(),
+		}).collect::<Vec<_>>();
+	}: {<Pallet<T>>::set_collection_properties(&collection, &owner, props)?}
+
+	delete_collection_properties {
+		let b in 0..MAX_PROPERTIES_PER_ITEM;
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			owner: cross_from_sub;
+		};
+		let props = (0..b).map(|p| Property {
+			key: property_key(p as usize),
+			value: property_value(),
+		}).collect::<Vec<_>>();
+		<Pallet<T>>::set_collection_properties(&collection, &owner, props)?;
+		let to_delete = (0..b).map(|p| property_key(p as usize)).collect::<Vec<_>>();
+	}: {<Pallet<T>>::delete_collection_properties(&collection, &owner, to_delete)?}
+}
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -16,6 +16,8 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
+extern crate alloc;
+
 use core::ops::{Deref, DerefMut};
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
 use sp_std::vec::Vec;
@@ -85,6 +87,9 @@
 pub mod dispatch;
 pub mod erc;
 pub mod eth;
+pub mod weights;
+
+pub type SelfWeightOf<T> = <T as Config>::WeightInfo;
 
 #[must_use = "Should call submit_logs or save, otherwise some data will be lost for evm side"]
 pub struct CollectionHandle<T: Config> {
@@ -186,11 +191,13 @@
 	use frame_support::traits::Currency;
 	use up_data_structs::{TokenId, mapping::TokenAddressMapping};
 	use scale_info::TypeInfo;
+	use weights::WeightInfo;
 
 	#[pallet::config]
 	pub trait Config:
 		frame_system::Config + pallet_evm_coder_substrate::Config + TypeInfo + account::Config
 	{
+		type WeightInfo: WeightInfo;
 		type Event: IsType<<Self as frame_system::Config>::Event> + From<Event<Self>>;
 
 		type Currency: Currency<Self::AccountId>;
@@ -804,7 +811,7 @@
 	pub fn set_scoped_collection_properties(
 		collection: &CollectionHandle<T>,
 		scope: PropertyScope,
-		properties: impl Iterator<Item=Property>,
+		properties: impl Iterator<Item = Property>,
 	) -> DispatchResult {
 		CollectionProperties::<T>::try_mutate(collection.id, |stored_properties| {
 			stored_properties.try_scoped_set_from_iter(scope, properties)
@@ -903,10 +910,11 @@
 		Ok(())
 	}
 
-	pub fn get_collection_property(collection_id: CollectionId, key: &PropertyKey) -> Option<PropertyValue> {
-		Self::collection_properties(collection_id)
-			.get(key)
-			.cloned()
+	pub fn get_collection_property(
+		collection_id: CollectionId,
+		key: &PropertyKey,
+	) -> Option<PropertyValue> {
+		Self::collection_properties(collection_id).get(key).cloned()
 	}
 
 	pub fn bytes_keys_to_property_keys(
@@ -1131,7 +1139,7 @@
 /// Worst cases
 pub trait CommonWeightInfo<CrossAccountId> {
 	fn create_item() -> Weight;
-	fn create_multiple_items(amount: u32) -> Weight;
+	fn create_multiple_items(amount: &[CreateItemData]) -> Weight;
 	fn create_multiple_items_ex(cost: &CreateItemExData<CrossAccountId>) -> Weight;
 	fn burn_item() -> Weight;
 	fn set_collection_properties(amount: u32) -> Weight;
addedpallets/common/src/weights.rsdiffbeforeafterboth
--- /dev/null
+++ b/pallets/common/src/weights.rs
@@ -0,0 +1,79 @@
+// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs
+
+//! Autogenerated weights for pallet_common
+//!
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
+//! DATE: 2022-05-23, STEPS: `50`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
+
+// Executed Command:
+// target/release/unique-collator
+// benchmark
+// pallet
+// --pallet
+// pallet-common
+// --wasm-execution
+// compiled
+// --extrinsic
+// *
+// --template
+// .maintain/frame-weight-template.hbs
+// --steps=50
+// --repeat=1
+// --heap-pages=4096
+// --output=./pallets/common/src/weights.rs
+
+#![cfg_attr(rustfmt, rustfmt_skip)]
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
+
+use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
+use sp_std::marker::PhantomData;
+
+/// Weight functions needed for pallet_common.
+pub trait WeightInfo {
+	fn set_collection_properties(b: u32, ) -> Weight;
+	fn delete_collection_properties(b: u32, ) -> Weight;
+}
+
+/// Weights for pallet_common using the Substrate node and recommended hardware.
+pub struct SubstrateWeight<T>(PhantomData<T>);
+impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
+	// Storage: Common CollectionProperties (r:1 w:1)
+	fn set_collection_properties(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 142_818_000
+			.saturating_add((2_786_252_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(T::DbWeight::get().reads(1 as Weight))
+			.saturating_add(T::DbWeight::get().writes(1 as Weight))
+	}
+	// Storage: Common CollectionProperties (r:1 w:1)
+	fn delete_collection_properties(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 101_087_000
+			.saturating_add((2_739_521_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(T::DbWeight::get().reads(1 as Weight))
+			.saturating_add(T::DbWeight::get().writes(1 as Weight))
+	}
+}
+
+// For backwards compatibility and tests
+impl WeightInfo for () {
+	// Storage: Common CollectionProperties (r:1 w:1)
+	fn set_collection_properties(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 142_818_000
+			.saturating_add((2_786_252_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(RocksDbWeight::get().reads(1 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
+	}
+	// Storage: Common CollectionProperties (r:1 w:1)
+	fn delete_collection_properties(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 101_087_000
+			.saturating_add((2_739_521_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(RocksDbWeight::get().reads(1 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
+	}
+}
modifiedpallets/fungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -40,7 +40,7 @@
 			owner: sub; collection: collection(owner);
 			sender: cross_from_sub(owner); to: cross_sub;
 		};
-	}: {<Pallet<T>>::create_item(&collection, &sender, (to, 200))?}
+	}: {<Pallet<T>>::create_item(&collection, &sender, (to, 200), &Unlimited)?}
 
 	create_multiple_items_ex {
 		let b in 0..MAX_ITEMS_PER_BATCH;
@@ -52,14 +52,14 @@
 			bench_init!(to: cross_sub(i););
 			(to, 200)
 		}).collect::<BTreeMap<_, _>>().try_into().unwrap();
-	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
 
 	burn_item {
 		bench_init!{
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub; burner: cross_sub;
 		};
-		<Pallet<T>>::create_item(&collection, &owner, (burner.clone(), 200))?;
+		<Pallet<T>>::create_item(&collection, &owner, (burner.clone(), 200), &Unlimited)?;
 	}: {<Pallet<T>>::burn(&collection, &burner, 100)?}
 
 	transfer {
@@ -67,15 +67,15 @@
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub; sender: cross_sub; to: cross_sub;
 		};
-		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200))?;
-	}: {<Pallet<T>>::transfer(&collection, &sender, &to, 200)?}
+		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
+	}: {<Pallet<T>>::transfer(&collection, &sender, &to, 200, &Unlimited)?}
 
 	approve {
 		bench_init!{
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
 		};
-		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200))?;
+		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
 	}: {<Pallet<T>>::set_allowance(&collection, &sender, &spender, 100)?}
 
 	transfer_from {
@@ -83,7 +83,7 @@
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;
 		};
-		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200))?;
+		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
 		<Pallet<T>>::set_allowance(&collection, &sender, &spender, 200)?;
 	}: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, 100, &Unlimited)?}
 
@@ -92,7 +92,7 @@
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub; sender: cross_sub; burner: cross_sub;
 		};
-		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200))?;
+		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
 		<Pallet<T>>::set_allowance(&collection, &sender, &burner, 200)?;
 	}: {<Pallet<T>>::burn_from(&collection, &burner, &sender, 100, &Unlimited)?}
 }
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -17,7 +17,7 @@
 use core::marker::PhantomData;
 
 use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
-use up_data_structs::{TokenId, CollectionId, CreateItemExData, budget::Budget};
+use up_data_structs::{TokenId, CollectionId, CreateItemExData, budget::Budget, CreateItemData};
 use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
 use sp_runtime::ArithmeticError;
 use sp_std::{vec::Vec, vec};
@@ -33,7 +33,8 @@
 		<SelfWeightOf<T>>::create_item()
 	}
 
-	fn create_multiple_items(_amount: u32) -> Weight {
+	fn create_multiple_items(_data: &[CreateItemData]) -> Weight {
+		// All items minted for the same user, so it works same as create_item
 		Self::create_item()
 	}
 
@@ -51,23 +52,28 @@
 	}
 
 	fn set_collection_properties(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::set_collection_properties(amount)
+		// Error
+		0
 	}
 
 	fn delete_collection_properties(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::delete_collection_properties(amount)
+		// Error
+		0
 	}
 
 	fn set_token_properties(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::set_token_properties(amount)
+		// Error
+		0
 	}
 
 	fn delete_token_properties(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::delete_token_properties(amount)
+		// Error
+		0
 	}
 
 	fn set_property_permissions(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::set_property_permissions(amount)
+		// Error
+		0
 	}
 
 	fn transfer() -> Weight {
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -35,11 +35,6 @@
 	fn create_item() -> Weight;
 	fn create_multiple_items_ex(b: u32, ) -> Weight;
 	fn burn_item() -> Weight;
-	fn set_collection_properties(amount: u32) -> Weight;
-	fn delete_collection_properties(amount: u32) -> Weight;
-	fn set_token_properties(amount: u32) -> Weight;
-	fn delete_token_properties(amount: u32) -> Weight;
-	fn set_property_permissions(amount: u32) -> Weight;
 	fn transfer() -> Weight;
 	fn approve() -> Weight;
 	fn transfer_from() -> Weight;
@@ -73,33 +68,8 @@
 		(15_565_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(2 as Weight))
 			.saturating_add(T::DbWeight::get().writes(2 as Weight))
-	}
-
-	fn set_collection_properties(_amount: u32) -> Weight {
-		// Error
-		0
-	}
-
-	fn delete_collection_properties(_amount: u32) -> Weight {
-		// Error
-		0
-	}
-
-	fn set_token_properties(_amount: u32) -> Weight {
-		// Error
-		0
-	}
-
-	fn delete_token_properties(_amount: u32) -> Weight {
-		// Error
-		0
 	}
 
-	fn set_property_permissions(_amount: u32) -> Weight {
-		// Error
-		0
-	}
-
 	// Storage: Fungible Balance (r:2 w:2)
 	fn transfer() -> Weight {
 		(17_713_000 as Weight)
@@ -156,31 +126,6 @@
 		(15_565_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(2 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(2 as Weight))
-	}
-
-	fn set_collection_properties(_amount: u32) -> Weight {
-		// Error
-		0
-	}
-
-	fn delete_collection_properties(_amount: u32) -> Weight {
-		// Error
-		0
-	}
-
-	fn set_token_properties(_amount: u32) -> Weight {
-		// Error
-		0
-	}
-
-	fn delete_token_properties(_amount: u32) -> Weight {
-		// Error
-		0
-	}
-
-	fn set_property_permissions(_amount: u32) -> Weight {
-		// Error
-		0
 	}
 
 	// Storage: Fungible Balance (r:2 w:2)
modifiedpallets/nonfungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -49,4 +49,5 @@
     'frame-benchmarking',
     'frame-support/runtime-benchmarks',
     'frame-system/runtime-benchmarks',
+    'up-data-structs/runtime-benchmarks',
 ]
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -18,24 +18,35 @@
 use crate::{Pallet, Config, NonfungibleHandle};
 
 use sp_std::prelude::*;
-use pallet_common::benchmarking::{create_collection_raw, create_data, create_var_data};
+use pallet_common::benchmarking::{create_collection_raw, create_data, property_key, property_value};
 use frame_benchmarking::{benchmarks, account};
-use up_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH, CUSTOM_DATA_LIMIT, budget::Unlimited};
+use up_data_structs::{
+	CollectionMode, MAX_ITEMS_PER_BATCH, MAX_PROPERTIES_PER_ITEM, CUSTOM_DATA_LIMIT,
+	budget::Unlimited,
+};
 use pallet_common::bench_init;
-use core::convert::TryInto;
 
 const SEED: u32 = 1;
 
 fn create_max_item_data<T: Config>(owner: T::CrossAccountId) -> CreateItemData<T> {
 	let const_data = create_data::<CUSTOM_DATA_LIMIT>();
-	CreateItemData::<T> { const_data, owner }
+	CreateItemData::<T> {
+		const_data,
+		owner,
+		properties: Default::default(),
+	}
 }
 fn create_max_item<T: Config>(
 	collection: &NonfungibleHandle<T>,
 	sender: &T::CrossAccountId,
 	owner: T::CrossAccountId,
 ) -> Result<TokenId, DispatchError> {
-	<Pallet<T>>::create_item(&collection, sender, create_max_item_data::<T>(owner))?;
+	<Pallet<T>>::create_item(
+		&collection,
+		sender,
+		create_max_item_data::<T>(owner),
+		&Unlimited,
+	)?;
 	Ok(TokenId(<TokensMinted<T>>::get(&collection.id)))
 }
 
@@ -65,7 +76,7 @@
 			sender: cross_from_sub(owner); to: cross_sub;
 		};
 		let data = (0..b).map(|_| create_max_item_data::<T>(to.clone())).collect();
-	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
 
 	create_multiple_items_ex {
 		let b in 0..MAX_ITEMS_PER_BATCH;
@@ -77,7 +88,7 @@
 			bench_init!(to: cross_sub(i););
 			create_max_item_data::<T>(to)
 		}).collect();
-	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
 
 	burn_item {
 		bench_init!{
@@ -93,7 +104,7 @@
 			owner: cross_from_sub; sender: cross_sub; receiver: cross_sub;
 		};
 		let item = create_max_item(&collection, &owner, sender.clone())?;
-	}: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item)?}
+	}: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, &Unlimited)?}
 
 	approve {
 		bench_init!{
@@ -120,4 +131,66 @@
 		let item = create_max_item(&collection, &owner, sender.clone())?;
 		<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&burner))?;
 	}: {<Pallet<T>>::burn_from(&collection, &burner, &sender, item, &Unlimited)?}
+
+	set_property_permissions {
+		let b in 0..MAX_PROPERTIES_PER_ITEM;
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			owner: cross_from_sub;
+		};
+		let perms = (0..b).map(|k| PropertyKeyPermission {
+			key: property_key(k as usize),
+			permission: PropertyPermission {
+				mutable: false,
+				collection_admin: false,
+				token_owner: false,
+			},
+		}).collect::<Vec<_>>();
+	}: {<Pallet<T>>::set_property_permissions(&collection, &owner, perms)?}
+
+	set_token_properties {
+		let b in 0..MAX_PROPERTIES_PER_ITEM;
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			owner: cross_from_sub;
+		};
+		let perms = (0..b).map(|k| PropertyKeyPermission {
+			key: property_key(k as usize),
+			permission: PropertyPermission {
+				mutable: false,
+				collection_admin: true,
+				token_owner: true,
+			},
+		}).collect::<Vec<_>>();
+		<Pallet<T>>::set_property_permissions(&collection, &owner, perms)?;
+		let props = (0..b).map(|k| Property {
+			key: property_key(k as usize),
+			value: property_value(),
+		}).collect::<Vec<_>>();
+		let item = create_max_item(&collection, &owner, owner.clone())?;
+	}: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props)?}
+
+	delete_token_properties {
+		let b in 0..MAX_PROPERTIES_PER_ITEM;
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			owner: cross_from_sub;
+		};
+		let perms = (0..b).map(|k| PropertyKeyPermission {
+			key: property_key(k as usize),
+			permission: PropertyPermission {
+				mutable: true,
+				collection_admin: true,
+				token_owner: true,
+			},
+		}).collect::<Vec<_>>();
+		<Pallet<T>>::set_property_permissions(&collection, &owner, perms)?;
+		let props = (0..b).map(|k| Property {
+			key: property_key(k as usize),
+			value: property_value(),
+		}).collect::<Vec<_>>();
+		let item = create_max_item(&collection, &owner, owner.clone())?;
+		<Pallet<T>>::set_token_properties(&collection, &owner, item, props)?;
+		let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();
+	}: {<Pallet<T>>::delete_token_properties(&collection, &owner, item, to_delete)?}
 }
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -21,7 +21,9 @@
 	TokenId, CreateItemExData, CollectionId, budget::Budget, Property, PropertyKey,
 	PropertyKeyPermission, PropertyValue,
 };
-use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
+use pallet_common::{
+	CommonCollectionOperations, CommonWeightInfo, with_weight, weights::WeightInfo as _,
+};
 use sp_runtime::DispatchError;
 use sp_std::vec::Vec;
 
@@ -38,13 +40,33 @@
 
 	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
 		match data {
-			CreateItemExData::NFT(t) => <SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32),
+			CreateItemExData::NFT(t) => {
+				<SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)
+					+ t.iter()
+						.map(|t| {
+							if t.properties.len() > 0 {
+								Self::set_token_properties(t.properties.len() as u32)
+							} else {
+								0
+							}
+						})
+						.sum::<u64>()
+			}
 			_ => 0,
 		}
 	}
 
-	fn create_multiple_items(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::create_multiple_items(amount)
+	fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {
+		<SelfWeightOf<T>>::create_multiple_items(data.len() as u32)
+			+ data
+				.iter()
+				.filter_map(|t| match t {
+					up_data_structs::CreateItemData::NFT(n) if n.properties.len() > 0 => {
+						Some(Self::set_token_properties(n.properties.len() as u32))
+					}
+					_ => None,
+				})
+				.sum::<u64>()
 	}
 
 	fn burn_item() -> Weight {
@@ -52,11 +74,11 @@
 	}
 
 	fn set_collection_properties(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::set_collection_properties(amount)
+		<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)
 	}
 
 	fn delete_collection_properties(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::delete_collection_properties(amount)
+		<pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)
 	}
 
 	fn set_token_properties(amount: u32) -> Weight {
@@ -128,15 +150,15 @@
 		data: Vec<up_data_structs::CreateItemData>,
 		nesting_budget: &dyn Budget,
 	) -> DispatchResultWithPostInfo {
+		let weight = <CommonWeights<T>>::create_multiple_items(&data);
 		let data = data
 			.into_iter()
 			.map(|d| map_create_data::<T>(d, &to))
 			.collect::<Result<Vec<_>, DispatchError>>()?;
 
-		let amount = data.len();
 		with_weight(
 			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),
-			<CommonWeights<T>>::create_multiple_items(amount as u32),
+			weight,
 		)
 	}
 
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -18,7 +18,7 @@
 
 use erc::ERC721Events;
 use evm_coder::ToLog;
-use frame_support::{BoundedVec, ensure, fail, transactional};
+use frame_support::{BoundedVec, ensure, fail, transactional, storage::with_transaction};
 use up_data_structs::{
 	AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,
 	mapping::TokenAddressMapping, NestingRule, budget::Budget, Property, PropertyPermission,
@@ -32,7 +32,7 @@
 use pallet_structure::Pallet as PalletStructure;
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
 use sp_core::H160;
-use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
+use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
 use sp_std::{vec::Vec, vec};
 use core::ops::Deref;
 use sp_std::collections::btree_map::BTreeMap;
@@ -600,28 +600,37 @@
 
 		// =========
 
+		with_transaction(|| {
+			for (i, data) in data.iter().enumerate() {
+				let token = first_token + i as u32 + 1;
+
+				<TokenData<T>>::insert(
+					(collection.id, token),
+					ItemData {
+						const_data: data.const_data.clone(),
+						owner: data.owner.clone(),
+					},
+				);
+
+				if let Err(e) = Self::set_token_properties(
+					collection,
+					sender,
+					TokenId(token),
+					data.properties.clone().into_inner(),
+				) {
+					return TransactionOutcome::Rollback(Err(e));
+				}
+			}
+			TransactionOutcome::Commit(Ok(()))
+		})?;
+
 		<TokensMinted<T>>::insert(collection.id, tokens_minted);
 		for (account, balance) in balances {
 			<AccountBalance<T>>::insert((collection.id, account), balance);
 		}
 		for (i, data) in data.into_iter().enumerate() {
 			let token = first_token + i as u32 + 1;
-
-			<TokenData<T>>::insert(
-				(collection.id, token),
-				ItemData {
-					const_data: data.const_data,
-					owner: data.owner.clone(),
-				},
-			);
 			<Owned<T>>::insert((collection.id, &data.owner, token), true);
-
-			Self::set_token_properties(
-				collection,
-				sender,
-				TokenId(token),
-				data.properties.into_inner(),
-			)?;
 
 			<PalletEvm<T>>::deposit_log(
 				ERC721Events::Transfer {
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -151,10 +151,35 @@
 	// Storage: Nonfungible AccountBalance (r:1 w:1)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn burn_from() -> Weight {
-		(27_580_000 as Weight)
-			.saturating_add(T::DbWeight::get().reads(4 as Weight))
-			.saturating_add(T::DbWeight::get().writes(5 as Weight))
 	}
+	// Storage: Common CollectionPropertyPermissions (r:1 w:1)
+	fn set_property_permissions(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 3_432_000
+			.saturating_add((126_888_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(T::DbWeight::get().reads(1 as Weight))
+			.saturating_add(T::DbWeight::get().writes(1 as Weight))
+	}
+	// Storage: Common CollectionPropertyPermissions (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:1 w:0)
+	// Storage: Nonfungible TokenProperties (r:1 w:1)
+	fn set_token_properties(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 158_583_000
+			.saturating_add((4_707_700_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(T::DbWeight::get().reads(3 as Weight))
+			.saturating_add(T::DbWeight::get().writes(1 as Weight))
+	}
+	// Storage: Common CollectionPropertyPermissions (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:1 w:0)
+	// Storage: Nonfungible TokenProperties (r:1 w:1)
+	fn delete_token_properties(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 169_018_000
+			.saturating_add((4_783_967_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(T::DbWeight::get().reads(3 as Weight))
+			.saturating_add(T::DbWeight::get().writes(1 as Weight))
+	}
 }
 
 // For backwards compatibility and tests
@@ -260,8 +285,33 @@
 	// Storage: Nonfungible AccountBalance (r:1 w:1)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn burn_from() -> Weight {
-		(27_580_000 as Weight)
-			.saturating_add(RocksDbWeight::get().reads(4 as Weight))
-			.saturating_add(RocksDbWeight::get().writes(5 as Weight))
 	}
+	// Storage: Common CollectionPropertyPermissions (r:1 w:1)
+	fn set_property_permissions(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 3_432_000
+			.saturating_add((126_888_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(RocksDbWeight::get().reads(1 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
+	}
+	// Storage: Common CollectionPropertyPermissions (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:1 w:0)
+	// Storage: Nonfungible TokenProperties (r:1 w:1)
+	fn set_token_properties(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 158_583_000
+			.saturating_add((4_707_700_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(RocksDbWeight::get().reads(3 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
+	}
+	// Storage: Common CollectionPropertyPermissions (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:1 w:0)
+	// Storage: Nonfungible TokenProperties (r:1 w:1)
+	fn delete_token_properties(b: u32, ) -> Weight {
+		(0 as Weight)
+			// Standard Error: 169_018_000
+			.saturating_add((4_783_967_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(RocksDbWeight::get().reads(3 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
+	}
 }
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -18,7 +18,7 @@
 use crate::{Pallet, Config, RefungibleHandle};
 
 use sp_std::prelude::*;
-use pallet_common::benchmarking::{create_collection_raw, create_data, create_var_data};
+use pallet_common::benchmarking::{create_collection_raw, create_data};
 use frame_benchmarking::{benchmarks, account};
 use up_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH, CUSTOM_DATA_LIMIT, budget::Unlimited};
 use pallet_common::bench_init;
@@ -46,7 +46,7 @@
 	users: impl IntoIterator<Item = (T::CrossAccountId, u128)>,
 ) -> Result<TokenId, DispatchError> {
 	let data: CreateRefungibleExData<T::CrossAccountId> = create_max_item_data(users);
-	<Pallet<T>>::create_item(&collection, sender, data)?;
+	<Pallet<T>>::create_item(&collection, sender, data, &Unlimited)?;
 	Ok(TokenId(<TokensMinted<T>>::get(&collection.id)))
 }
 
@@ -73,7 +73,7 @@
 			sender: cross_from_sub(owner); to: cross_sub;
 		};
 		let data = (0..b).map(|_| create_max_item_data([(to.clone(), 200)])).collect();
-	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
 
 	create_multiple_items_ex_multiple_items {
 		let b in 0..MAX_ITEMS_PER_BATCH;
@@ -85,7 +85,7 @@
 			bench_init!(to: cross_sub(t););
 			create_max_item_data([(to, 200)])
 		}).collect();
-	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
 
 	create_multiple_items_ex_multiple_owners {
 		let b in 0..MAX_ITEMS_PER_BATCH;
@@ -97,7 +97,7 @@
 			bench_init!(to: cross_sub(u););
 			(to, 200)
 		}))].try_into().unwrap();
-	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
 
 	// Other user left, token data is kept
 	burn_item_partial {
@@ -122,7 +122,7 @@
 			sender: cross_from_sub(owner); receiver: cross_sub;
 		};
 		let item = create_max_item(&collection, &sender, [(sender.clone(), 200), (receiver.clone(), 200)])?;
-	}: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 100)?}
+	}: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 100, &Unlimited)?}
 	// Target account is created
 	transfer_creating {
 		bench_init!{
@@ -130,7 +130,7 @@
 			sender: cross_from_sub(owner); receiver: cross_sub;
 		};
 		let item = create_max_item(&collection, &sender, [(sender.clone(), 200)])?;
-	}: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 100)?}
+	}: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 100, &Unlimited)?}
 	// Source account is destroyed
 	transfer_removing {
 		bench_init!{
@@ -138,7 +138,7 @@
 			sender: cross_from_sub(owner); receiver: cross_sub;
 		};
 		let item = create_max_item(&collection, &sender, [(sender.clone(), 200), (receiver.clone(), 200)])?;
-	}: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 200)?}
+	}: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 200, &Unlimited)?}
 	// Source account destroyed, target created
 	transfer_creating_removing {
 		bench_init!{
@@ -146,7 +146,7 @@
 			sender: cross_from_sub(owner); receiver: cross_sub;
 		};
 		let item = create_max_item(&collection, &sender, [(sender.clone(), 200)])?;
-	}: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 200)?}
+	}: {<Pallet<T>>::transfer(&collection, &sender, &receiver, item, 200, &Unlimited)?}
 
 	approve {
 		bench_init!{
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -20,7 +20,7 @@
 use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};
 use up_data_structs::{
 	CollectionId, TokenId, CreateItemExData, CreateRefungibleExData, budget::Budget, Property,
-	PropertyKey, PropertyValue, PropertyKeyPermission,
+	PropertyKey, PropertyValue, PropertyKeyPermission, CreateItemData,
 };
 use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
 use sp_runtime::DispatchError;
@@ -46,8 +46,8 @@
 		<SelfWeightOf<T>>::create_item()
 	}
 
-	fn create_multiple_items(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::create_multiple_items(amount)
+	fn create_multiple_items(data: &[CreateItemData]) -> Weight {
+		<SelfWeightOf<T>>::create_multiple_items(data.len() as u32)
 	}
 
 	fn create_multiple_items_ex(call: &CreateItemExData<T::CrossAccountId>) -> Weight {
@@ -66,12 +66,14 @@
 		max_weight_of!(burn_item_partial(), burn_item_fully())
 	}
 
-	fn set_collection_properties(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::set_collection_properties(amount)
+	fn set_collection_properties(_amount: u32) -> Weight {
+		// Error
+		0
 	}
 
-	fn delete_collection_properties(amount: u32) -> Weight {
-		<SelfWeightOf<T>>::delete_collection_properties(amount)
+	fn delete_collection_properties(_amount: u32) -> Weight {
+		// Error
+		0
 	}
 
 	fn set_token_properties(amount: u32) -> Weight {
@@ -156,15 +158,15 @@
 		data: Vec<up_data_structs::CreateItemData>,
 		nesting_budget: &dyn Budget,
 	) -> DispatchResultWithPostInfo {
+		let weight = <CommonWeights<T>>::create_multiple_items(&data);
 		let data = data
 			.into_iter()
 			.map(|d| map_create_data::<T>(d, &to))
 			.collect::<Result<Vec<_>, DispatchError>>()?;
 
-		let amount = data.len();
 		with_weight(
 			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),
-			<CommonWeights<T>>::create_multiple_items(amount as u32),
+			weight,
 		)
 	}
 
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -38,8 +38,6 @@
 	fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight;
 	fn burn_item_partial() -> Weight;
 	fn burn_item_fully() -> Weight;
-	fn set_collection_properties(amount: u32) -> Weight;
-	fn delete_collection_properties(amount: u32) -> Weight;
 	fn set_token_properties(amount: u32) -> Weight;
 	fn delete_token_properties(amount: u32) -> Weight;
 	fn set_property_permissions(amount: u32) -> Weight;
@@ -132,16 +130,6 @@
 		(32_489_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(4 as Weight))
 			.saturating_add(T::DbWeight::get().writes(6 as Weight))
-	}
-
-	fn set_collection_properties(_amount: u32) -> Weight {
-		// Error
-		0
-	}
-
-	fn delete_collection_properties(_amount: u32) -> Weight {
-		// Error
-		0
 	}
 
 	fn set_token_properties(_amount: u32) -> Weight {
@@ -320,16 +308,6 @@
 		(32_489_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(4 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
-	}
-
-	fn set_collection_properties(_amount: u32) -> Weight {
-		// Error
-		0
-	}
-
-	fn delete_collection_properties(_amount: u32) -> Weight {
-		// Error
-		0
 	}
 
 	fn set_token_properties(_amount: u32) -> Weight {
modifiedpallets/structure/Cargo.tomldiffbeforeafterboth
--- a/pallets/structure/Cargo.toml
+++ b/pallets/structure/Cargo.toml
@@ -16,6 +16,7 @@
 	"derive",
 ] }
 up-data-structs = { path = "../../primitives/data-structs", default-features = false }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 [features]
 default = ["std"]
@@ -28,5 +29,6 @@
 	"scale-info/std",
 	"parity-scale-codec/std",
 	"up-data-structs/std",
+	"pallet-evm/std",
 ]
 runtime-benchmarks = ['frame-benchmarking', 'pallet-common/runtime-benchmarks']
modifiedpallets/structure/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/structure/src/benchmarking.rs
+++ b/pallets/structure/src/benchmarking.rs
@@ -2,8 +2,10 @@
 
 use frame_benchmarking::{benchmarks, account};
 use frame_support::traits::{Currency, Get};
-use up_data_structs::{CreateCollectionData, CollectionMode, CreateItemData, CreateNftData};
-use pallet_common::CrossAccountId;
+use up_data_structs::{
+	CreateCollectionData, CollectionMode, CreateItemData, CreateNftData, budget::Unlimited,
+};
+use pallet_evm::account::CrossAccountId;
 
 const SEED: u32 = 1;
 
@@ -20,9 +22,9 @@
 		let dispatch = T::CollectionDispatch::dispatch(CollectionHandle::try_get(CollectionId(1))?);
 		let dispatch = dispatch.as_dyn();
 
-		dispatch.create_item(caller_cross.clone(), caller_cross.clone(), CreateItemData::NFT(CreateNftData::default()))?;
+		dispatch.create_item(caller_cross.clone(), caller_cross.clone(), CreateItemData::NFT(CreateNftData::default()), &Unlimited)?;
 	}: {
 		let parent = <Pallet<T>>::find_parent(CollectionId(1), TokenId(1))?;
-		assert!(matches!(parent, Parent::Normal(_)))
+		assert!(matches!(parent, Parent::User(_)))
 	}
 }
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -687,7 +687,7 @@
 		/// * itemsData: Array items properties. Each property is an array of bytes itself, see [create_item].
 		///
 		/// * owner: Address, initial owner of the NFT.
-		#[weight = T::CommonWeightInfo::create_multiple_items(items_data.len() as u32)]
+		#[weight = T::CommonWeightInfo::create_multiple_items(&items_data)]
 		#[transactional]
 		pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {
 			ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);
modifiedprimitives/data-structs/Cargo.tomldiffbeforeafterboth
--- a/primitives/data-structs/Cargo.toml
+++ b/primitives/data-structs/Cargo.toml
@@ -42,3 +42,4 @@
 ]
 serde1 = ["serde"]
 limit-testing = []
+runtime-benchmarks = []
\ No newline at end of file
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -861,7 +861,9 @@
 	) -> Result<(), PropertiesError> {
 		let value_len = value.len();
 
-		if self.consumed_space as usize + value_len > self.space_limit as usize {
+		if self.consumed_space as usize + value_len > self.space_limit as usize
+			&& !cfg!(feature = "runtime-benchmarks")
+		{
 			return Err(PropertiesError::NoSpaceForProperty);
 		}
 
modifiedruntime/common/src/eth_sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/src/eth_sponsoring.rs
+++ b/runtime/common/src/eth_sponsoring.rs
@@ -50,16 +50,20 @@
 			CollectionMode::NFT => {
 				let call = <UniqueNFTCall<T>>::parse(method_id, &mut reader).ok()??;
 				match call {
-					UniqueNFTCall::TokenProperties(
-						TokenPropertiesCall::SetProperty { token_id, key, value, .. },
-					) => {
+					UniqueNFTCall::TokenProperties(TokenPropertiesCall::SetProperty {
+						token_id,
+						key,
+						value,
+						..
+					}) => {
 						let token_id: TokenId = token_id.try_into().ok()?;
 						withdraw_set_token_property::<T>(
 							&collection,
 							&who,
 							&token_id,
 							key.len() + value.len(),
-						).map(|()| sponsor)
+						)
+						.map(|()| sponsor)
 					}
 					UniqueNFTCall::ERC721UniqueExtensions(
 						ERC721UniqueExtensionsCall::Transfer { token_id, .. },
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -776,6 +776,7 @@
                     let mut list = Vec::<BenchmarkList>::new();
 
                     list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
+                    list_benchmark!(list, extra, pallet_common, Common);
                     list_benchmark!(list, extra, pallet_unique, Unique);
                     list_benchmark!(list, extra, pallet_structure, Structure);
                     list_benchmark!(list, extra, pallet_inflation, Inflation);
@@ -814,6 +815,7 @@
                     let params = (&config, &allowlist);
 
                     add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
+                    add_benchmark!(params, batches, pallet_common, Common);
                     add_benchmark!(params, batches, pallet_unique, Unique);
                     add_benchmark!(params, batches, pallet_structure, Structure);
                     add_benchmark!(params, batches, pallet_inflation, Inflation);
modifiedruntime/common/src/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/src/sponsoring.rs
+++ b/runtime/common/src/sponsoring.rs
@@ -29,8 +29,8 @@
 use pallet_evm::account::CrossAccountId;
 use pallet_unique::{
 	Call as UniqueCall, Config as UniqueConfig, FungibleApproveBasket, RefungibleApproveBasket,
-	NftApproveBasket, CreateItemBasket, ReFungibleTransferBasket,
-	FungibleTransferBasket, NftTransferBasket, TokenPropertyBasket,
+	NftApproveBasket, CreateItemBasket, ReFungibleTransferBasket, FungibleTransferBasket,
+	NftTransferBasket, TokenPropertyBasket,
 };
 use pallet_fungible::Config as FungibleConfig;
 use pallet_nonfungible::Config as NonfungibleConfig;
@@ -247,7 +247,7 @@
 					&T::CrossAccountId::from_sub(who.clone()),
 					&token_id,
 					// No overflow may happen, as data larger than usize can't reach here
-					properties.iter().map(|p| p.key.len() + p.value.len()).sum()
+					properties.iter().map(|p| p.key.len() + p.value.len()).sum(),
 				)
 				.map(|()| sponsor)
 			}
modifiedruntime/common/src/weights.rsdiffbeforeafterboth
--- a/runtime/common/src/weights.rs
+++ b/runtime/common/src/weights.rs
@@ -21,7 +21,7 @@
 use pallet_fungible::{Config as FungibleConfig, common::CommonWeights as FungibleWeights};
 use pallet_nonfungible::{Config as NonfungibleConfig, common::CommonWeights as NonfungibleWeights};
 use pallet_refungible::{Config as RefungibleConfig, common::CommonWeights as RefungibleWeights};
-use up_data_structs::CreateItemExData;
+use up_data_structs::{CreateItemExData, CreateItemData};
 
 macro_rules! max_weight_of {
 	($method:ident ( $($args:tt)* )) => {
@@ -42,8 +42,8 @@
 		dispatch_weight::<T>() + max_weight_of!(create_item())
 	}
 
-	fn create_multiple_items(amount: u32) -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(create_multiple_items(amount))
+	fn create_multiple_items(data: &[CreateItemData]) -> Weight {
+		dispatch_weight::<T>() + max_weight_of!(create_multiple_items(data))
 	}
 
 	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
before · runtime/opal/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//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.1819#![cfg_attr(not(feature = "std"), no_std)]20// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.21#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]24// Make the WASM binary available.25#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;3334use sp_runtime::{35	Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36	traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37	transaction_validity::{TransactionSource, TransactionValidity},38	ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47	Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};49// A few exports that help ease life for downstream crates.50pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52	EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53};54pub use frame_support::{55	construct_runtime, match_types,56	dispatch::DispatchResult,57	PalletId, parameter_types, StorageValue, ConsensusEngineId,58	traits::{59		tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,60		Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,61		OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,62	},63	weights::{64		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65		DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66		WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67	},68};69use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};70use up_data_structs::*;71// use pallet_contracts::weights::WeightInfo;72// #[cfg(any(feature = "std", test))]73use frame_system::{74	self as frame_system, EnsureRoot, EnsureSigned,75	limits::{BlockWeights, BlockLength},76};77use sp_arithmetic::{78	traits::{BaseArithmetic, Unsigned},79};80use smallvec::smallvec;81use codec::{Encode, Decode};82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};83use fp_rpc::TransactionStatus;84use sp_runtime::{85	traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86	transaction_validity::TransactionValidityError,87	SaturatedConversion,88};8990// pub use pallet_timestamp::Call as TimestampCall;91pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9293// Polkadot imports94use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm_builder::{98	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99	EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,100	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,101	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,102	ParentIsPreset,103};104use xcm_executor::{Config, XcmExecutor, Assets};105use sp_std::{marker::PhantomData};106107use xcm::latest::{108	//	Xcm,109	AssetId::{Concrete},110	Fungibility::Fungible as XcmFungible,111	MultiAsset,112	Error as XcmError,113};114use xcm_executor::traits::{MatchesFungible, WeightTrader};115//use xcm_executor::traits::MatchesFungible;116use sp_runtime::traits::CheckedConversion;117118use unique_runtime_common::{119	impl_common_runtime_apis,120	types::*,121	constants::*,122	dispatch::{CollectionDispatchT, CollectionDispatch},123	sponsoring::UniqueSponsorshipHandler,124	eth_sponsoring::UniqueEthSponsorshipHandler,125	weights::CommonWeights,126};127128pub const RUNTIME_NAME: &str = "opal";129pub const TOKEN_SYMBOL: &str = "OPL";130131type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;132133impl RuntimeInstance for Runtime {134	type CrossAccountId = self::CrossAccountId;135	type TransactionConverter = self::TransactionConverter;136137	fn get_transaction_converter() -> TransactionConverter {138		TransactionConverter139	}140}141142/// The type for looking up accounts. We don't expect more than 4 billion of them, but you143/// never know...144pub type AccountIndex = u32;145146/// Balance of an account.147pub type Balance = u128;148149/// Index of a transaction in the chain.150pub type Index = u32;151152/// A hash of some data used by the chain.153pub type Hash = sp_core::H256;154155/// Digest item type.156pub type DigestItem = generic::DigestItem;157158/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know159/// the specifics of the runtime. They can then be made to be agnostic over specific formats160/// of data like extrinsics, allowing for them to continue syncing the network through upgrades161/// to even the core data structures.162pub mod opaque {163	use sp_std::prelude::*;164	use sp_runtime::impl_opaque_keys;165	use super::Aura;166167	pub use unique_runtime_common::types::*;168169	impl_opaque_keys! {170		pub struct SessionKeys {171			pub aura: Aura,172		}173	}174}175176/// This runtime version.177pub const VERSION: RuntimeVersion = RuntimeVersion {178	spec_name: create_runtime_str!(RUNTIME_NAME),179	impl_name: create_runtime_str!(RUNTIME_NAME),180	authoring_version: 1,181	spec_version: 920000,182	impl_version: 0,183	apis: RUNTIME_API_VERSIONS,184	transaction_version: 1,185	state_version: 0,186};187188#[derive(codec::Encode, codec::Decode)]189pub enum XCMPMessage<XAccountId, XBalance> {190	/// Transfer tokens to the given account from the Parachain account.191	TransferToken(XAccountId, XBalance),192}193194/// The version information used to identify this runtime when compiled natively.195#[cfg(feature = "std")]196pub fn native_version() -> NativeVersion {197	NativeVersion {198		runtime_version: VERSION,199		can_author_with: Default::default(),200	}201}202203type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;204205pub struct DealWithFees;206impl OnUnbalanced<NegativeImbalance> for DealWithFees {207	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {208		if let Some(fees) = fees_then_tips.next() {209			// for fees, 100% to treasury210			let mut split = fees.ration(100, 0);211			if let Some(tips) = fees_then_tips.next() {212				// for tips, if any, 100% to treasury213				tips.ration_merge_into(100, 0, &mut split);214			}215			Treasury::on_unbalanced(split.0);216			// Author::on_unbalanced(split.1);217		}218	}219}220221parameter_types! {222	pub const BlockHashCount: BlockNumber = 2400;223	pub RuntimeBlockLength: BlockLength =224		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);225	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);226	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;227	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()228		.base_block(BlockExecutionWeight::get())229		.for_class(DispatchClass::all(), |weights| {230			weights.base_extrinsic = ExtrinsicBaseWeight::get();231		})232		.for_class(DispatchClass::Normal, |weights| {233			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);234		})235		.for_class(DispatchClass::Operational, |weights| {236			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);237			// Operational transactions have some extra reserved space, so that they238			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.239			weights.reserved = Some(240				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT241			);242		})243		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)244		.build_or_panic();245	pub const Version: RuntimeVersion = VERSION;246	pub const SS58Prefix: u8 = 42;247}248249parameter_types! {250	pub const ChainId: u64 = 8882;251}252253pub struct FixedFee;254impl FeeCalculator for FixedFee {255	fn min_gas_price() -> U256 {256		MIN_GAS_PRICE.into()257	}258}259260// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case261// (contract, which only writes a lot of data),262// approximating on top of our real store write weight263parameter_types! {264	pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;265	pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;266	pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();267}268269/// Limiting EVM execution to 50% of block for substrate users and management tasks270/// EVM transaction consumes more weight than substrate's, so we can't rely on them being271/// scheduled fairly272const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);273parameter_types! {274	pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());275}276277pub enum FixedGasWeightMapping {}278impl GasWeightMapping for FixedGasWeightMapping {279	fn gas_to_weight(gas: u64) -> Weight {280		gas.saturating_mul(WeightPerGas::get())281	}282	fn weight_to_gas(weight: Weight) -> u64 {283		weight / WeightPerGas::get()284	}285}286287impl pallet_evm::account::Config for Runtime {288	type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;289	type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;290	type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;291}292293impl pallet_evm::Config for Runtime {294	type BlockGasLimit = BlockGasLimit;295	type FeeCalculator = FixedFee;296	type GasWeightMapping = FixedGasWeightMapping;297	type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;298	type CallOrigin = EnsureAddressTruncated<Self>;299	type WithdrawOrigin = EnsureAddressTruncated<Self>;300	type AddressMapping = HashedAddressMapping<Self::Hashing>;301	type PrecompilesType = ();302	type PrecompilesValue = ();303	type Currency = Balances;304	type Event = Event;305	type OnMethodCall = (306		pallet_evm_migration::OnMethodCall<Self>,307		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,308		CollectionDispatchT<Self>,309	);310	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;311	type ChainId = ChainId;312	type Runner = pallet_evm::runner::stack::Runner<Self>;313	type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;314	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;315	type FindAuthor = EthereumFindAuthor<Aura>;316}317318impl pallet_evm_migration::Config for Runtime {319	type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;320}321322pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);323impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {324	fn find_author<'a, I>(digests: I) -> Option<H160>325	where326		I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,327	{328		if let Some(author_index) = F::find_author(digests) {329			let authority_id = Aura::authorities()[author_index as usize].clone();330			return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));331		}332		None333	}334}335336impl pallet_ethereum::Config for Runtime {337	type Event = Event;338	type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;339}340341impl pallet_randomness_collective_flip::Config for Runtime {}342343impl frame_system::Config for Runtime {344	/// The data to be stored in an account.345	type AccountData = pallet_balances::AccountData<Balance>;346	/// The identifier used to distinguish between accounts.347	type AccountId = AccountId;348	/// The basic call filter to use in dispatchable.349	type BaseCallFilter = Everything;350	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).351	type BlockHashCount = BlockHashCount;352	/// The maximum length of a block (in bytes).353	type BlockLength = RuntimeBlockLength;354	/// The index type for blocks.355	type BlockNumber = BlockNumber;356	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.357	type BlockWeights = RuntimeBlockWeights;358	/// The aggregated dispatch type that is available for extrinsics.359	type Call = Call;360	/// The weight of database operations that the runtime can invoke.361	type DbWeight = RocksDbWeight;362	/// The ubiquitous event type.363	type Event = Event;364	/// The type for hashing blocks and tries.365	type Hash = Hash;366	/// The hashing algorithm used.367	type Hashing = BlakeTwo256;368	/// The header type.369	type Header = generic::Header<BlockNumber, BlakeTwo256>;370	/// The index type for storing how many extrinsics an account has signed.371	type Index = Index;372	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.373	type Lookup = AccountIdLookup<AccountId, ()>;374	/// What to do if an account is fully reaped from the system.375	type OnKilledAccount = ();376	/// What to do if a new account is created.377	type OnNewAccount = ();378	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;379	/// The ubiquitous origin type.380	type Origin = Origin;381	/// This type is being generated by `construct_runtime!`.382	type PalletInfo = PalletInfo;383	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.384	type SS58Prefix = SS58Prefix;385	/// Weight information for the extrinsics of this pallet.386	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;387	/// Version of the runtime.388	type Version = Version;389	type MaxConsumers = ConstU32<16>;390}391392parameter_types! {393	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;394}395396impl pallet_timestamp::Config for Runtime {397	/// A timestamp: milliseconds since the unix epoch.398	type Moment = u64;399	type OnTimestampSet = ();400	type MinimumPeriod = MinimumPeriod;401	type WeightInfo = ();402}403404parameter_types! {405	// pub const ExistentialDeposit: u128 = 500;406	pub const ExistentialDeposit: u128 = 0;407	pub const MaxLocks: u32 = 50;408}409410impl pallet_balances::Config for Runtime {411	type MaxLocks = MaxLocks;412	type MaxReserves = ();413	type ReserveIdentifier = [u8; 8];414	/// The type for recording an account's balance.415	type Balance = Balance;416	/// The ubiquitous event type.417	type Event = Event;418	type DustRemoval = Treasury;419	type ExistentialDeposit = ExistentialDeposit;420	type AccountStore = System;421	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;422}423424pub const fn deposit(items: u32, bytes: u32) -> Balance {425	items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE426}427428/*429parameter_types! {430	pub TombstoneDeposit: Balance = deposit(431		1,432		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,433	);434	pub DepositPerContract: Balance = TombstoneDeposit::get();435	pub const DepositPerStorageByte: Balance = deposit(0, 1);436	pub const DepositPerStorageItem: Balance = deposit(1, 0);437	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);438	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;439	pub const SignedClaimHandicap: u32 = 2;440	pub const MaxDepth: u32 = 32;441	pub const MaxValueSize: u32 = 16 * 1024;442	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb443	// The lazy deletion runs inside on_initialize.444	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *445		RuntimeBlockWeights::get().max_block;446	// The weight needed for decoding the queue should be less or equal than a fifth447	// of the overall weight dedicated to the lazy deletion.448	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (449			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -450			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)451		)) / 5) as u32;452	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();453}454455impl pallet_contracts::Config for Runtime {456	type Time = Timestamp;457	type Randomness = RandomnessCollectiveFlip;458	type Currency = Balances;459	type Event = Event;460	type RentPayment = ();461	type SignedClaimHandicap = SignedClaimHandicap;462	type TombstoneDeposit = TombstoneDeposit;463	type DepositPerContract = DepositPerContract;464	type DepositPerStorageByte = DepositPerStorageByte;465	type DepositPerStorageItem = DepositPerStorageItem;466	type RentFraction = RentFraction;467	type SurchargeReward = SurchargeReward;468	type WeightPrice = pallet_transaction_payment::Pallet<Self>;469	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;470	type ChainExtension = NFTExtension;471	type DeletionQueueDepth = DeletionQueueDepth;472	type DeletionWeightLimit = DeletionWeightLimit;473	type Schedule = Schedule;474	type CallStack = [pallet_contracts::Frame<Self>; 31];475}476*/477478parameter_types! {479	/// This value increases the priority of `Operational` transactions by adding480	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.481	pub const OperationalFeeMultiplier: u8 = 5;482}483484/// Linear implementor of `WeightToFeePolynomial`485pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);486487impl<T> WeightToFeePolynomial for LinearFee<T>488where489	T: BaseArithmetic + From<u32> + Copy + Unsigned,490{491	type Balance = T;492493	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {494		smallvec!(WeightToFeeCoefficient {495			// Targeting 0.1 Unique per NFT transfer496			coeff_integer: WEIGHT_TO_FEE_COEFF.into(),497			coeff_frac: Perbill::zero(),498			negative: false,499			degree: 1,500		})501	}502}503504impl pallet_transaction_payment::Config for Runtime {505	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;506	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;507	type OperationalFeeMultiplier = OperationalFeeMultiplier;508	type WeightToFee = LinearFee<Balance>;509	type FeeMultiplierUpdate = ();510}511512parameter_types! {513	pub const ProposalBond: Permill = Permill::from_percent(5);514	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;515	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;516	pub const SpendPeriod: BlockNumber = 5 * MINUTES;517	pub const Burn: Permill = Permill::from_percent(0);518	pub const TipCountdown: BlockNumber = 1 * DAYS;519	pub const TipFindersFee: Percent = Percent::from_percent(20);520	pub const TipReportDepositBase: Balance = 1 * UNIQUE;521	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;522	pub const BountyDepositBase: Balance = 1 * UNIQUE;523	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;524	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");525	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;526	pub const MaximumReasonLength: u32 = 16384;527	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);528	pub const BountyValueMinimum: Balance = 5 * UNIQUE;529	pub const MaxApprovals: u32 = 100;530}531532impl pallet_treasury::Config for Runtime {533	type PalletId = TreasuryModuleId;534	type Currency = Balances;535	type ApproveOrigin = EnsureRoot<AccountId>;536	type RejectOrigin = EnsureRoot<AccountId>;537	type Event = Event;538	type OnSlash = ();539	type ProposalBond = ProposalBond;540	type ProposalBondMinimum = ProposalBondMinimum;541	type ProposalBondMaximum = ProposalBondMaximum;542	type SpendPeriod = SpendPeriod;543	type Burn = Burn;544	type BurnDestination = ();545	type SpendFunds = ();546	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;547	type MaxApprovals = MaxApprovals;548}549550impl pallet_sudo::Config for Runtime {551	type Event = Event;552	type Call = Call;553}554555pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);556557impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider558	for RelayChainBlockNumberProvider<T>559{560	type BlockNumber = BlockNumber;561562	fn current_block_number() -> Self::BlockNumber {563		cumulus_pallet_parachain_system::Pallet::<T>::validation_data()564			.map(|d| d.relay_parent_number)565			.unwrap_or_default()566	}567}568569parameter_types! {570	pub const MinVestedTransfer: Balance = 10 * UNIQUE;571	pub const MaxVestingSchedules: u32 = 28;572}573574impl orml_vesting::Config for Runtime {575	type Event = Event;576	type Currency = pallet_balances::Pallet<Runtime>;577	type MinVestedTransfer = MinVestedTransfer;578	type VestedTransferOrigin = EnsureSigned<AccountId>;579	type WeightInfo = ();580	type MaxVestingSchedules = MaxVestingSchedules;581	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;582}583584parameter_types! {585	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;586	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;587}588589impl cumulus_pallet_parachain_system::Config for Runtime {590	type Event = Event;591	type SelfParaId = parachain_info::Pallet<Self>;592	type OnSystemEvent = ();593	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<594	// 	MaxDownwardMessageWeight,595	// 	XcmExecutor<XcmConfig>,596	// 	Call,597	// >;598	type OutboundXcmpMessageSource = XcmpQueue;599	type DmpMessageHandler = DmpQueue;600	type ReservedDmpWeight = ReservedDmpWeight;601	type ReservedXcmpWeight = ReservedXcmpWeight;602	type XcmpMessageHandler = XcmpQueue;603}604605impl parachain_info::Config for Runtime {}606607impl cumulus_pallet_aura_ext::Config for Runtime {}608609parameter_types! {610	pub const RelayLocation: MultiLocation = MultiLocation::parent();611	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;612	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();613	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();614}615616/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used617/// when determining ownership of accounts for asset transacting and when attempting to use XCM618/// `Transact` in order to determine the dispatch Origin.619pub type LocationToAccountId = (620	// The parent (Relay-chain) origin converts to the default `AccountId`.621	ParentIsPreset<AccountId>,622	// Sibling parachain origins convert to AccountId via the `ParaId::into`.623	SiblingParachainConvertsVia<Sibling, AccountId>,624	// Straight up local `AccountId32` origins just alias directly to `AccountId`.625	AccountId32Aliases<RelayNetwork, AccountId>,626);627628pub struct OnlySelfCurrency;629impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {630	fn matches_fungible(a: &MultiAsset) -> Option<B> {631		match (&a.id, &a.fun) {632			(Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),633			_ => None,634		}635	}636}637638/// Means for transacting assets on this chain.639pub type LocalAssetTransactor = CurrencyAdapter<640	// Use this currency:641	Balances,642	// Use this currency when it is a fungible asset matching the given location or name:643	OnlySelfCurrency,644	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:645	LocationToAccountId,646	// Our chain's account ID type (we can't get away without mentioning it explicitly):647	AccountId,648	// We don't track any teleports.649	(),650>;651652/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,653/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can654/// biases the kind of local `Origin` it will become.655pub type XcmOriginToTransactDispatchOrigin = (656	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location657	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for658	// foreign chains who want to have a local sovereign account on this chain which they control.659	SovereignSignedViaLocation<LocationToAccountId, Origin>,660	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when661	// recognised.662	RelayChainAsNative<RelayOrigin, Origin>,663	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when664	// recognised.665	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,666	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a667	// transaction from the Root origin.668	ParentAsSuperuser<Origin>,669	// Native signed account converter; this just converts an `AccountId32` origin into a normal670	// `Origin::Signed` origin of the same 32-byte value.671	SignedAccountId32AsNative<RelayNetwork, Origin>,672	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.673	XcmPassthrough<Origin>,674);675676parameter_types! {677	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.678	pub UnitWeightCost: Weight = 1_000_000;679	// 1200 UNIQUEs buy 1 second of weight.680	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);681	pub const MaxInstructions: u32 = 100;682	pub const MaxAuthorities: u32 = 100_000;683}684685match_types! {686	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {687		MultiLocation { parents: 1, interior: Here } |688		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }689	};690}691692pub type Barrier = (693	TakeWeightCredit,694	AllowTopLevelPaidExecutionFrom<Everything>,695	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,696	// ^^^ Parent & its unit plurality gets free execution697);698699pub struct UsingOnlySelfCurrencyComponents<700	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,701	AssetId: Get<MultiLocation>,702	AccountId,703	Currency: CurrencyT<AccountId>,704	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,705>(706	Weight,707	Currency::Balance,708	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,709);710impl<711		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,712		AssetId: Get<MultiLocation>,713		AccountId,714		Currency: CurrencyT<AccountId>,715		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,716	> WeightTrader717	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>718{719	fn new() -> Self {720		Self(0, Zero::zero(), PhantomData)721	}722723	fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {724		let amount = WeightToFee::calc(&weight);725		let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;726727		// location to this parachain through relay chain728		let option1: xcm::v1::AssetId = Concrete(MultiLocation {729			parents: 1,730			interior: X1(Parachain(ParachainInfo::parachain_id().into())),731		});732		// direct location733		let option2: xcm::v1::AssetId = Concrete(MultiLocation {734			parents: 0,735			interior: Here,736		});737738		let required = if payment.fungible.contains_key(&option1) {739			(option1, u128_amount).into()740		} else if payment.fungible.contains_key(&option2) {741			(option2, u128_amount).into()742		} else {743			(Concrete(MultiLocation::default()), u128_amount).into()744		};745746		let unused = payment747			.checked_sub(required)748			.map_err(|_| XcmError::TooExpensive)?;749		self.0 = self.0.saturating_add(weight);750		self.1 = self.1.saturating_add(amount);751		Ok(unused)752	}753754	fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {755		let weight = weight.min(self.0);756		let amount = WeightToFee::calc(&weight);757		self.0 -= weight;758		self.1 = self.1.saturating_sub(amount);759		let amount: u128 = amount.saturated_into();760		if amount > 0 {761			Some((AssetId::get(), amount).into())762		} else {763			None764		}765	}766}767impl<768		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,769		AssetId: Get<MultiLocation>,770		AccountId,771		Currency: CurrencyT<AccountId>,772		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,773	> Drop774	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>775{776	fn drop(&mut self) {777		OnUnbalanced::on_unbalanced(Currency::issue(self.1));778	}779}780781pub struct XcmConfig;782impl Config for XcmConfig {783	type Call = Call;784	type XcmSender = XcmRouter;785	// How to withdraw and deposit an asset.786	type AssetTransactor = LocalAssetTransactor;787	type OriginConverter = XcmOriginToTransactDispatchOrigin;788	type IsReserve = NativeAsset;789	type IsTeleporter = (); // Teleportation is disabled790	type LocationInverter = LocationInverter<Ancestry>;791	type Barrier = Barrier;792	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;793	type Trader = UsingOnlySelfCurrencyComponents<794		IdentityFee<Balance>,795		RelayLocation,796		AccountId,797		Balances,798		(),799	>;800	type ResponseHandler = (); // Don't handle responses for now.801	type SubscriptionService = PolkadotXcm;802803	type AssetTrap = PolkadotXcm;804	type AssetClaims = PolkadotXcm;805}806807// parameter_types! {808// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;809// }810811/// No local origins on this chain are allowed to dispatch XCM sends/executions.812pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);813814/// The means for routing XCM messages which are not for local execution into the right message815/// queues.816pub type XcmRouter = (817	// Two routers - use UMP to communicate with the relay chain:818	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,819	// ..and XCMP to communicate with the sibling chains.820	XcmpQueue,821);822823impl pallet_evm_coder_substrate::Config for Runtime {824	type GasWeightMapping = FixedGasWeightMapping;825}826827impl pallet_xcm::Config for Runtime {828	type Event = Event;829	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;830	type XcmRouter = XcmRouter;831	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;832	type XcmExecuteFilter = Everything;833	type XcmExecutor = XcmExecutor<XcmConfig>;834	type XcmTeleportFilter = Everything;835	type XcmReserveTransferFilter = Everything;836	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;837	type LocationInverter = LocationInverter<Ancestry>;838	type Origin = Origin;839	type Call = Call;840	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;841	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;842}843844impl cumulus_pallet_xcm::Config for Runtime {845	type Event = Event;846	type XcmExecutor = XcmExecutor<XcmConfig>;847}848849impl cumulus_pallet_xcmp_queue::Config for Runtime {850	type WeightInfo = ();851	type Event = Event;852	type XcmExecutor = XcmExecutor<XcmConfig>;853	type ChannelInfo = ParachainSystem;854	type VersionWrapper = ();855	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;856	type ControllerOrigin = EnsureRoot<AccountId>;857	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;858}859860impl cumulus_pallet_dmp_queue::Config for Runtime {861	type Event = Event;862	type XcmExecutor = XcmExecutor<XcmConfig>;863	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;864}865866impl pallet_aura::Config for Runtime {867	type AuthorityId = AuraId;868	type DisabledValidators = ();869	type MaxAuthorities = MaxAuthorities;870}871872parameter_types! {873	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();874	pub const CollectionCreationPrice: Balance = 2 * UNIQUE;875}876877impl pallet_common::Config for Runtime {878	type Event = Event;879	type Currency = Balances;880	type CollectionCreationPrice = CollectionCreationPrice;881	type TreasuryAccountId = TreasuryAccountId;882	type CollectionDispatch = CollectionDispatchT<Self>;883884	type EvmTokenAddressMapping = EvmTokenAddressMapping;885	type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;886}887888impl pallet_structure::Config for Runtime {889	type Event = Event;890	type Call = Call;891	type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;892}893894impl pallet_fungible::Config for Runtime {895	type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;896}897impl pallet_refungible::Config for Runtime {898	type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;899}900impl pallet_nonfungible::Config for Runtime {901	type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;902}903904impl pallet_proxy_rmrk_core::Config for Runtime {905	type Event = Event;906}907908impl pallet_unique::Config for Runtime {909	type Event = Event;910	type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;911	type CommonWeightInfo = CommonWeights<Self>;912}913914parameter_types! {915	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied916}917918/// Used for the pallet inflation919impl pallet_inflation::Config for Runtime {920	type Currency = Balances;921	type TreasuryAccountId = TreasuryAccountId;922	type InflationBlockInterval = InflationBlockInterval;923	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;924}925926// parameter_types! {927// 	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *928// 		RuntimeBlockWeights::get().max_block;929// 	pub const MaxScheduledPerBlock: u32 = 50;930// }931932type EvmSponsorshipHandler = (933	UniqueEthSponsorshipHandler<Runtime>,934	pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,935);936type SponsorshipHandler = (937	UniqueSponsorshipHandler<Runtime>,938	//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,939	pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,940);941942// impl pallet_unq_scheduler::Config for Runtime {943// 	type Event = Event;944// 	type Origin = Origin;945// 	type PalletsOrigin = OriginCaller;946// 	type Call = Call;947// 	type MaximumWeight = MaximumSchedulerWeight;948// 	type ScheduleOrigin = EnsureSigned<AccountId>;949// 	type MaxScheduledPerBlock = MaxScheduledPerBlock;950// 	type SponsorshipHandler = SponsorshipHandler;951// 	type WeightInfo = ();952// }953954impl pallet_evm_transaction_payment::Config for Runtime {955	type EvmSponsorshipHandler = EvmSponsorshipHandler;956	type Currency = Balances;957}958959impl pallet_charge_transaction::Config for Runtime {960	type SponsorshipHandler = SponsorshipHandler;961}962963// impl pallet_contract_helpers::Config for Runtime {964//	 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;965// }966967parameter_types! {968	// 0x842899ECF380553E8a4de75bF534cdf6fBF64049969	pub const HelpersContractAddress: H160 = H160([970		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,971	]);972}973974impl pallet_evm_contract_helpers::Config for Runtime {975	type ContractAddress = HelpersContractAddress;976	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;977}978979construct_runtime!(980	pub enum Runtime where981		Block = Block,982		NodeBlock = opaque::Block,983		UncheckedExtrinsic = UncheckedExtrinsic984	{985		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,986		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,987988		Aura: pallet_aura::{Pallet, Config<T>} = 22,989		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,990991		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,992		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,993		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,994		TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,995		Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,996		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,997		System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,998		Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,999		// Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,1000		// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,10011002		// XCM helpers.1003		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1004		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1005		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1006		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10071008		// Unique Pallets1009		Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1010		Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1011		// Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1012		// free = 631013		Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1014		// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1015		Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1016		Fungible: pallet_fungible::{Pallet, Storage} = 67,1017		Refungible: pallet_refungible::{Pallet, Storage} = 68,1018		Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1019		Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1020		ProxyRmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,10211022		// Frontier1023		EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1024		Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10251026		EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1027		EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1028		EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1029		EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1030	}1031);10321033pub struct TransactionConverter;10341035impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1036	fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1037		UncheckedExtrinsic::new_unsigned(1038			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1039		)1040	}1041}10421043impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1044	fn convert_transaction(1045		&self,1046		transaction: pallet_ethereum::Transaction,1047	) -> opaque::UncheckedExtrinsic {1048		let extrinsic = UncheckedExtrinsic::new_unsigned(1049			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1050		);1051		let encoded = extrinsic.encode();1052		opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1053			.expect("Encoded extrinsic is always valid")1054	}1055}10561057/// The address format for describing accounts.1058pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1059/// Block header type as expected by this runtime.1060pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1061/// Block type as expected by this runtime.1062pub type Block = generic::Block<Header, UncheckedExtrinsic>;1063/// A Block signed with a Justification1064pub type SignedBlock = generic::SignedBlock<Block>;1065/// BlockId type as expected by this runtime.1066pub type BlockId = generic::BlockId<Block>;1067/// The SignedExtension to the basic transaction logic.1068pub type SignedExtra = (1069	frame_system::CheckSpecVersion<Runtime>,1070	// system::CheckTxVersion<Runtime>,1071	frame_system::CheckGenesis<Runtime>,1072	frame_system::CheckEra<Runtime>,1073	frame_system::CheckNonce<Runtime>,1074	frame_system::CheckWeight<Runtime>,1075	pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1076	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,1077	pallet_ethereum::FakeTransactionFinalizer<Runtime>,1078);1079/// Unchecked extrinsic type as expected by this runtime.1080pub type UncheckedExtrinsic =1081	fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1082/// Extrinsic type that has already been checked.1083pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1084/// Executive: handles dispatch to the various modules.1085pub type Executive = frame_executive::Executive<1086	Runtime,1087	Block,1088	frame_system::ChainContext<Runtime>,1089	Runtime,1090	AllPalletsReversedWithSystemFirst,1091>;10921093impl_opaque_keys! {1094	pub struct SessionKeys {1095		pub aura: Aura,1096	}1097}10981099impl fp_self_contained::SelfContainedCall for Call {1100	type SignedInfo = H160;11011102	fn is_self_contained(&self) -> bool {1103		match self {1104			Call::Ethereum(call) => call.is_self_contained(),1105			_ => false,1106		}1107	}11081109	fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1110		match self {1111			Call::Ethereum(call) => call.check_self_contained(),1112			_ => None,1113		}1114	}11151116	fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1117		match self {1118			Call::Ethereum(call) => call.validate_self_contained(info),1119			_ => None,1120		}1121	}11221123	fn pre_dispatch_self_contained(1124		&self,1125		info: &Self::SignedInfo,1126	) -> Option<Result<(), TransactionValidityError>> {1127		match self {1128			Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1129			_ => None,1130		}1131	}11321133	fn apply_self_contained(1134		self,1135		info: Self::SignedInfo,1136	) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1137		match self {1138			call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1139				Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1140			)),1141			_ => None,1142		}1143	}1144}11451146macro_rules! dispatch_unique_runtime {1147	($collection:ident.$method:ident($($name:ident),*)) => {{1148		let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1149		let dispatch = collection.as_dyn();11501151		Ok(dispatch.$method($($name),*))1152	}};1153}11541155impl_common_runtime_apis!();11561157struct CheckInherents;11581159impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1160	fn check_inherents(1161		block: &Block,1162		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1163	) -> sp_inherents::CheckInherentsResult {1164		let relay_chain_slot = relay_state_proof1165			.read_slot()1166			.expect("Could not read the relay chain slot from the proof");11671168		let inherent_data =1169			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1170				relay_chain_slot,1171				sp_std::time::Duration::from_secs(6),1172			)1173			.create_inherent_data()1174			.expect("Could not create the timestamp inherent data");11751176		inherent_data.check_extrinsics(block)1177	}1178}11791180cumulus_pallet_parachain_system::register_validate_block!(1181	Runtime = Runtime,1182	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1183	CheckInherents = CheckInherents,1184);
after · runtime/opal/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//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.1819#![cfg_attr(not(feature = "std"), no_std)]20// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.21#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]24// Make the WASM binary available.25#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;3334use sp_runtime::{35	Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36	traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37	transaction_validity::{TransactionSource, TransactionValidity},38	ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47	Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};49// A few exports that help ease life for downstream crates.50pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52	EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53};54pub use frame_support::{55	construct_runtime, match_types,56	dispatch::DispatchResult,57	PalletId, parameter_types, StorageValue, ConsensusEngineId,58	traits::{59		tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,60		Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,61		OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,62	},63	weights::{64		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65		DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66		WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67	},68};69use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};70use up_data_structs::*;71// use pallet_contracts::weights::WeightInfo;72// #[cfg(any(feature = "std", test))]73use frame_system::{74	self as frame_system, EnsureRoot, EnsureSigned,75	limits::{BlockWeights, BlockLength},76};77use sp_arithmetic::{78	traits::{BaseArithmetic, Unsigned},79};80use smallvec::smallvec;81use codec::{Encode, Decode};82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};83use fp_rpc::TransactionStatus;84use sp_runtime::{85	traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86	transaction_validity::TransactionValidityError,87	SaturatedConversion,88};8990// pub use pallet_timestamp::Call as TimestampCall;91pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9293// Polkadot imports94use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm_builder::{98	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99	EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,100	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,101	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,102	ParentIsPreset,103};104use xcm_executor::{Config, XcmExecutor, Assets};105use sp_std::{marker::PhantomData};106107use xcm::latest::{108	//	Xcm,109	AssetId::{Concrete},110	Fungibility::Fungible as XcmFungible,111	MultiAsset,112	Error as XcmError,113};114use xcm_executor::traits::{MatchesFungible, WeightTrader};115//use xcm_executor::traits::MatchesFungible;116use sp_runtime::traits::CheckedConversion;117118use unique_runtime_common::{119	impl_common_runtime_apis,120	types::*,121	constants::*,122	dispatch::{CollectionDispatchT, CollectionDispatch},123	sponsoring::UniqueSponsorshipHandler,124	eth_sponsoring::UniqueEthSponsorshipHandler,125	weights::CommonWeights,126};127128pub const RUNTIME_NAME: &str = "opal";129pub const TOKEN_SYMBOL: &str = "OPL";130131type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;132133impl RuntimeInstance for Runtime {134	type CrossAccountId = self::CrossAccountId;135	type TransactionConverter = self::TransactionConverter;136137	fn get_transaction_converter() -> TransactionConverter {138		TransactionConverter139	}140}141142/// The type for looking up accounts. We don't expect more than 4 billion of them, but you143/// never know...144pub type AccountIndex = u32;145146/// Balance of an account.147pub type Balance = u128;148149/// Index of a transaction in the chain.150pub type Index = u32;151152/// A hash of some data used by the chain.153pub type Hash = sp_core::H256;154155/// Digest item type.156pub type DigestItem = generic::DigestItem;157158/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know159/// the specifics of the runtime. They can then be made to be agnostic over specific formats160/// of data like extrinsics, allowing for them to continue syncing the network through upgrades161/// to even the core data structures.162pub mod opaque {163	use sp_std::prelude::*;164	use sp_runtime::impl_opaque_keys;165	use super::Aura;166167	pub use unique_runtime_common::types::*;168169	impl_opaque_keys! {170		pub struct SessionKeys {171			pub aura: Aura,172		}173	}174}175176/// This runtime version.177pub const VERSION: RuntimeVersion = RuntimeVersion {178	spec_name: create_runtime_str!(RUNTIME_NAME),179	impl_name: create_runtime_str!(RUNTIME_NAME),180	authoring_version: 1,181	spec_version: 920000,182	impl_version: 0,183	apis: RUNTIME_API_VERSIONS,184	transaction_version: 1,185	state_version: 0,186};187188#[derive(codec::Encode, codec::Decode)]189pub enum XCMPMessage<XAccountId, XBalance> {190	/// Transfer tokens to the given account from the Parachain account.191	TransferToken(XAccountId, XBalance),192}193194/// The version information used to identify this runtime when compiled natively.195#[cfg(feature = "std")]196pub fn native_version() -> NativeVersion {197	NativeVersion {198		runtime_version: VERSION,199		can_author_with: Default::default(),200	}201}202203type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;204205pub struct DealWithFees;206impl OnUnbalanced<NegativeImbalance> for DealWithFees {207	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {208		if let Some(fees) = fees_then_tips.next() {209			// for fees, 100% to treasury210			let mut split = fees.ration(100, 0);211			if let Some(tips) = fees_then_tips.next() {212				// for tips, if any, 100% to treasury213				tips.ration_merge_into(100, 0, &mut split);214			}215			Treasury::on_unbalanced(split.0);216			// Author::on_unbalanced(split.1);217		}218	}219}220221parameter_types! {222	pub const BlockHashCount: BlockNumber = 2400;223	pub RuntimeBlockLength: BlockLength =224		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);225	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);226	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;227	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()228		.base_block(BlockExecutionWeight::get())229		.for_class(DispatchClass::all(), |weights| {230			weights.base_extrinsic = ExtrinsicBaseWeight::get();231		})232		.for_class(DispatchClass::Normal, |weights| {233			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);234		})235		.for_class(DispatchClass::Operational, |weights| {236			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);237			// Operational transactions have some extra reserved space, so that they238			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.239			weights.reserved = Some(240				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT241			);242		})243		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)244		.build_or_panic();245	pub const Version: RuntimeVersion = VERSION;246	pub const SS58Prefix: u8 = 42;247}248249parameter_types! {250	pub const ChainId: u64 = 8882;251}252253pub struct FixedFee;254impl FeeCalculator for FixedFee {255	fn min_gas_price() -> U256 {256		MIN_GAS_PRICE.into()257	}258}259260// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case261// (contract, which only writes a lot of data),262// approximating on top of our real store write weight263parameter_types! {264	pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;265	pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;266	pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();267}268269/// Limiting EVM execution to 50% of block for substrate users and management tasks270/// EVM transaction consumes more weight than substrate's, so we can't rely on them being271/// scheduled fairly272const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);273parameter_types! {274	pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());275}276277pub enum FixedGasWeightMapping {}278impl GasWeightMapping for FixedGasWeightMapping {279	fn gas_to_weight(gas: u64) -> Weight {280		gas.saturating_mul(WeightPerGas::get())281	}282	fn weight_to_gas(weight: Weight) -> u64 {283		weight / WeightPerGas::get()284	}285}286287impl pallet_evm::account::Config for Runtime {288	type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;289	type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;290	type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;291}292293impl pallet_evm::Config for Runtime {294	type BlockGasLimit = BlockGasLimit;295	type FeeCalculator = FixedFee;296	type GasWeightMapping = FixedGasWeightMapping;297	type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;298	type CallOrigin = EnsureAddressTruncated<Self>;299	type WithdrawOrigin = EnsureAddressTruncated<Self>;300	type AddressMapping = HashedAddressMapping<Self::Hashing>;301	type PrecompilesType = ();302	type PrecompilesValue = ();303	type Currency = Balances;304	type Event = Event;305	type OnMethodCall = (306		pallet_evm_migration::OnMethodCall<Self>,307		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,308		CollectionDispatchT<Self>,309	);310	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;311	type ChainId = ChainId;312	type Runner = pallet_evm::runner::stack::Runner<Self>;313	type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;314	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;315	type FindAuthor = EthereumFindAuthor<Aura>;316}317318impl pallet_evm_migration::Config for Runtime {319	type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;320}321322pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);323impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {324	fn find_author<'a, I>(digests: I) -> Option<H160>325	where326		I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,327	{328		if let Some(author_index) = F::find_author(digests) {329			let authority_id = Aura::authorities()[author_index as usize].clone();330			return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));331		}332		None333	}334}335336impl pallet_ethereum::Config for Runtime {337	type Event = Event;338	type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;339}340341impl pallet_randomness_collective_flip::Config for Runtime {}342343impl frame_system::Config for Runtime {344	/// The data to be stored in an account.345	type AccountData = pallet_balances::AccountData<Balance>;346	/// The identifier used to distinguish between accounts.347	type AccountId = AccountId;348	/// The basic call filter to use in dispatchable.349	type BaseCallFilter = Everything;350	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).351	type BlockHashCount = BlockHashCount;352	/// The maximum length of a block (in bytes).353	type BlockLength = RuntimeBlockLength;354	/// The index type for blocks.355	type BlockNumber = BlockNumber;356	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.357	type BlockWeights = RuntimeBlockWeights;358	/// The aggregated dispatch type that is available for extrinsics.359	type Call = Call;360	/// The weight of database operations that the runtime can invoke.361	type DbWeight = RocksDbWeight;362	/// The ubiquitous event type.363	type Event = Event;364	/// The type for hashing blocks and tries.365	type Hash = Hash;366	/// The hashing algorithm used.367	type Hashing = BlakeTwo256;368	/// The header type.369	type Header = generic::Header<BlockNumber, BlakeTwo256>;370	/// The index type for storing how many extrinsics an account has signed.371	type Index = Index;372	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.373	type Lookup = AccountIdLookup<AccountId, ()>;374	/// What to do if an account is fully reaped from the system.375	type OnKilledAccount = ();376	/// What to do if a new account is created.377	type OnNewAccount = ();378	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;379	/// The ubiquitous origin type.380	type Origin = Origin;381	/// This type is being generated by `construct_runtime!`.382	type PalletInfo = PalletInfo;383	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.384	type SS58Prefix = SS58Prefix;385	/// Weight information for the extrinsics of this pallet.386	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;387	/// Version of the runtime.388	type Version = Version;389	type MaxConsumers = ConstU32<16>;390}391392parameter_types! {393	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;394}395396impl pallet_timestamp::Config for Runtime {397	/// A timestamp: milliseconds since the unix epoch.398	type Moment = u64;399	type OnTimestampSet = ();400	type MinimumPeriod = MinimumPeriod;401	type WeightInfo = ();402}403404parameter_types! {405	// pub const ExistentialDeposit: u128 = 500;406	pub const ExistentialDeposit: u128 = 0;407	pub const MaxLocks: u32 = 50;408}409410impl pallet_balances::Config for Runtime {411	type MaxLocks = MaxLocks;412	type MaxReserves = ();413	type ReserveIdentifier = [u8; 8];414	/// The type for recording an account's balance.415	type Balance = Balance;416	/// The ubiquitous event type.417	type Event = Event;418	type DustRemoval = Treasury;419	type ExistentialDeposit = ExistentialDeposit;420	type AccountStore = System;421	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;422}423424pub const fn deposit(items: u32, bytes: u32) -> Balance {425	items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE426}427428/*429parameter_types! {430	pub TombstoneDeposit: Balance = deposit(431		1,432		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,433	);434	pub DepositPerContract: Balance = TombstoneDeposit::get();435	pub const DepositPerStorageByte: Balance = deposit(0, 1);436	pub const DepositPerStorageItem: Balance = deposit(1, 0);437	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);438	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;439	pub const SignedClaimHandicap: u32 = 2;440	pub const MaxDepth: u32 = 32;441	pub const MaxValueSize: u32 = 16 * 1024;442	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb443	// The lazy deletion runs inside on_initialize.444	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *445		RuntimeBlockWeights::get().max_block;446	// The weight needed for decoding the queue should be less or equal than a fifth447	// of the overall weight dedicated to the lazy deletion.448	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (449			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -450			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)451		)) / 5) as u32;452	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();453}454455impl pallet_contracts::Config for Runtime {456	type Time = Timestamp;457	type Randomness = RandomnessCollectiveFlip;458	type Currency = Balances;459	type Event = Event;460	type RentPayment = ();461	type SignedClaimHandicap = SignedClaimHandicap;462	type TombstoneDeposit = TombstoneDeposit;463	type DepositPerContract = DepositPerContract;464	type DepositPerStorageByte = DepositPerStorageByte;465	type DepositPerStorageItem = DepositPerStorageItem;466	type RentFraction = RentFraction;467	type SurchargeReward = SurchargeReward;468	type WeightPrice = pallet_transaction_payment::Pallet<Self>;469	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;470	type ChainExtension = NFTExtension;471	type DeletionQueueDepth = DeletionQueueDepth;472	type DeletionWeightLimit = DeletionWeightLimit;473	type Schedule = Schedule;474	type CallStack = [pallet_contracts::Frame<Self>; 31];475}476*/477478parameter_types! {479	/// This value increases the priority of `Operational` transactions by adding480	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.481	pub const OperationalFeeMultiplier: u8 = 5;482}483484/// Linear implementor of `WeightToFeePolynomial`485pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);486487impl<T> WeightToFeePolynomial for LinearFee<T>488where489	T: BaseArithmetic + From<u32> + Copy + Unsigned,490{491	type Balance = T;492493	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {494		smallvec!(WeightToFeeCoefficient {495			// Targeting 0.1 Unique per NFT transfer496			coeff_integer: WEIGHT_TO_FEE_COEFF.into(),497			coeff_frac: Perbill::zero(),498			negative: false,499			degree: 1,500		})501	}502}503504impl pallet_transaction_payment::Config for Runtime {505	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;506	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;507	type OperationalFeeMultiplier = OperationalFeeMultiplier;508	type WeightToFee = LinearFee<Balance>;509	type FeeMultiplierUpdate = ();510}511512parameter_types! {513	pub const ProposalBond: Permill = Permill::from_percent(5);514	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;515	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;516	pub const SpendPeriod: BlockNumber = 5 * MINUTES;517	pub const Burn: Permill = Permill::from_percent(0);518	pub const TipCountdown: BlockNumber = 1 * DAYS;519	pub const TipFindersFee: Percent = Percent::from_percent(20);520	pub const TipReportDepositBase: Balance = 1 * UNIQUE;521	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;522	pub const BountyDepositBase: Balance = 1 * UNIQUE;523	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;524	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");525	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;526	pub const MaximumReasonLength: u32 = 16384;527	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);528	pub const BountyValueMinimum: Balance = 5 * UNIQUE;529	pub const MaxApprovals: u32 = 100;530}531532impl pallet_treasury::Config for Runtime {533	type PalletId = TreasuryModuleId;534	type Currency = Balances;535	type ApproveOrigin = EnsureRoot<AccountId>;536	type RejectOrigin = EnsureRoot<AccountId>;537	type Event = Event;538	type OnSlash = ();539	type ProposalBond = ProposalBond;540	type ProposalBondMinimum = ProposalBondMinimum;541	type ProposalBondMaximum = ProposalBondMaximum;542	type SpendPeriod = SpendPeriod;543	type Burn = Burn;544	type BurnDestination = ();545	type SpendFunds = ();546	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;547	type MaxApprovals = MaxApprovals;548}549550impl pallet_sudo::Config for Runtime {551	type Event = Event;552	type Call = Call;553}554555pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);556557impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider558	for RelayChainBlockNumberProvider<T>559{560	type BlockNumber = BlockNumber;561562	fn current_block_number() -> Self::BlockNumber {563		cumulus_pallet_parachain_system::Pallet::<T>::validation_data()564			.map(|d| d.relay_parent_number)565			.unwrap_or_default()566	}567}568569parameter_types! {570	pub const MinVestedTransfer: Balance = 10 * UNIQUE;571	pub const MaxVestingSchedules: u32 = 28;572}573574impl orml_vesting::Config for Runtime {575	type Event = Event;576	type Currency = pallet_balances::Pallet<Runtime>;577	type MinVestedTransfer = MinVestedTransfer;578	type VestedTransferOrigin = EnsureSigned<AccountId>;579	type WeightInfo = ();580	type MaxVestingSchedules = MaxVestingSchedules;581	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;582}583584parameter_types! {585	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;586	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;587}588589impl cumulus_pallet_parachain_system::Config for Runtime {590	type Event = Event;591	type SelfParaId = parachain_info::Pallet<Self>;592	type OnSystemEvent = ();593	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<594	// 	MaxDownwardMessageWeight,595	// 	XcmExecutor<XcmConfig>,596	// 	Call,597	// >;598	type OutboundXcmpMessageSource = XcmpQueue;599	type DmpMessageHandler = DmpQueue;600	type ReservedDmpWeight = ReservedDmpWeight;601	type ReservedXcmpWeight = ReservedXcmpWeight;602	type XcmpMessageHandler = XcmpQueue;603}604605impl parachain_info::Config for Runtime {}606607impl cumulus_pallet_aura_ext::Config for Runtime {}608609parameter_types! {610	pub const RelayLocation: MultiLocation = MultiLocation::parent();611	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;612	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();613	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();614}615616/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used617/// when determining ownership of accounts for asset transacting and when attempting to use XCM618/// `Transact` in order to determine the dispatch Origin.619pub type LocationToAccountId = (620	// The parent (Relay-chain) origin converts to the default `AccountId`.621	ParentIsPreset<AccountId>,622	// Sibling parachain origins convert to AccountId via the `ParaId::into`.623	SiblingParachainConvertsVia<Sibling, AccountId>,624	// Straight up local `AccountId32` origins just alias directly to `AccountId`.625	AccountId32Aliases<RelayNetwork, AccountId>,626);627628pub struct OnlySelfCurrency;629impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {630	fn matches_fungible(a: &MultiAsset) -> Option<B> {631		match (&a.id, &a.fun) {632			(Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),633			_ => None,634		}635	}636}637638/// Means for transacting assets on this chain.639pub type LocalAssetTransactor = CurrencyAdapter<640	// Use this currency:641	Balances,642	// Use this currency when it is a fungible asset matching the given location or name:643	OnlySelfCurrency,644	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:645	LocationToAccountId,646	// Our chain's account ID type (we can't get away without mentioning it explicitly):647	AccountId,648	// We don't track any teleports.649	(),650>;651652/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,653/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can654/// biases the kind of local `Origin` it will become.655pub type XcmOriginToTransactDispatchOrigin = (656	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location657	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for658	// foreign chains who want to have a local sovereign account on this chain which they control.659	SovereignSignedViaLocation<LocationToAccountId, Origin>,660	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when661	// recognised.662	RelayChainAsNative<RelayOrigin, Origin>,663	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when664	// recognised.665	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,666	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a667	// transaction from the Root origin.668	ParentAsSuperuser<Origin>,669	// Native signed account converter; this just converts an `AccountId32` origin into a normal670	// `Origin::Signed` origin of the same 32-byte value.671	SignedAccountId32AsNative<RelayNetwork, Origin>,672	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.673	XcmPassthrough<Origin>,674);675676parameter_types! {677	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.678	pub UnitWeightCost: Weight = 1_000_000;679	// 1200 UNIQUEs buy 1 second of weight.680	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);681	pub const MaxInstructions: u32 = 100;682	pub const MaxAuthorities: u32 = 100_000;683}684685match_types! {686	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {687		MultiLocation { parents: 1, interior: Here } |688		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }689	};690}691692pub type Barrier = (693	TakeWeightCredit,694	AllowTopLevelPaidExecutionFrom<Everything>,695	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,696	// ^^^ Parent & its unit plurality gets free execution697);698699pub struct UsingOnlySelfCurrencyComponents<700	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,701	AssetId: Get<MultiLocation>,702	AccountId,703	Currency: CurrencyT<AccountId>,704	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,705>(706	Weight,707	Currency::Balance,708	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,709);710impl<711		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,712		AssetId: Get<MultiLocation>,713		AccountId,714		Currency: CurrencyT<AccountId>,715		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,716	> WeightTrader717	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>718{719	fn new() -> Self {720		Self(0, Zero::zero(), PhantomData)721	}722723	fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {724		let amount = WeightToFee::calc(&weight);725		let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;726727		// location to this parachain through relay chain728		let option1: xcm::v1::AssetId = Concrete(MultiLocation {729			parents: 1,730			interior: X1(Parachain(ParachainInfo::parachain_id().into())),731		});732		// direct location733		let option2: xcm::v1::AssetId = Concrete(MultiLocation {734			parents: 0,735			interior: Here,736		});737738		let required = if payment.fungible.contains_key(&option1) {739			(option1, u128_amount).into()740		} else if payment.fungible.contains_key(&option2) {741			(option2, u128_amount).into()742		} else {743			(Concrete(MultiLocation::default()), u128_amount).into()744		};745746		let unused = payment747			.checked_sub(required)748			.map_err(|_| XcmError::TooExpensive)?;749		self.0 = self.0.saturating_add(weight);750		self.1 = self.1.saturating_add(amount);751		Ok(unused)752	}753754	fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {755		let weight = weight.min(self.0);756		let amount = WeightToFee::calc(&weight);757		self.0 -= weight;758		self.1 = self.1.saturating_sub(amount);759		let amount: u128 = amount.saturated_into();760		if amount > 0 {761			Some((AssetId::get(), amount).into())762		} else {763			None764		}765	}766}767impl<768		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,769		AssetId: Get<MultiLocation>,770		AccountId,771		Currency: CurrencyT<AccountId>,772		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,773	> Drop774	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>775{776	fn drop(&mut self) {777		OnUnbalanced::on_unbalanced(Currency::issue(self.1));778	}779}780781pub struct XcmConfig;782impl Config for XcmConfig {783	type Call = Call;784	type XcmSender = XcmRouter;785	// How to withdraw and deposit an asset.786	type AssetTransactor = LocalAssetTransactor;787	type OriginConverter = XcmOriginToTransactDispatchOrigin;788	type IsReserve = NativeAsset;789	type IsTeleporter = (); // Teleportation is disabled790	type LocationInverter = LocationInverter<Ancestry>;791	type Barrier = Barrier;792	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;793	type Trader = UsingOnlySelfCurrencyComponents<794		IdentityFee<Balance>,795		RelayLocation,796		AccountId,797		Balances,798		(),799	>;800	type ResponseHandler = (); // Don't handle responses for now.801	type SubscriptionService = PolkadotXcm;802803	type AssetTrap = PolkadotXcm;804	type AssetClaims = PolkadotXcm;805}806807// parameter_types! {808// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;809// }810811/// No local origins on this chain are allowed to dispatch XCM sends/executions.812pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);813814/// The means for routing XCM messages which are not for local execution into the right message815/// queues.816pub type XcmRouter = (817	// Two routers - use UMP to communicate with the relay chain:818	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,819	// ..and XCMP to communicate with the sibling chains.820	XcmpQueue,821);822823impl pallet_evm_coder_substrate::Config for Runtime {824	type GasWeightMapping = FixedGasWeightMapping;825}826827impl pallet_xcm::Config for Runtime {828	type Event = Event;829	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;830	type XcmRouter = XcmRouter;831	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;832	type XcmExecuteFilter = Everything;833	type XcmExecutor = XcmExecutor<XcmConfig>;834	type XcmTeleportFilter = Everything;835	type XcmReserveTransferFilter = Everything;836	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;837	type LocationInverter = LocationInverter<Ancestry>;838	type Origin = Origin;839	type Call = Call;840	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;841	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;842}843844impl cumulus_pallet_xcm::Config for Runtime {845	type Event = Event;846	type XcmExecutor = XcmExecutor<XcmConfig>;847}848849impl cumulus_pallet_xcmp_queue::Config for Runtime {850	type WeightInfo = ();851	type Event = Event;852	type XcmExecutor = XcmExecutor<XcmConfig>;853	type ChannelInfo = ParachainSystem;854	type VersionWrapper = ();855	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;856	type ControllerOrigin = EnsureRoot<AccountId>;857	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;858}859860impl cumulus_pallet_dmp_queue::Config for Runtime {861	type Event = Event;862	type XcmExecutor = XcmExecutor<XcmConfig>;863	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;864}865866impl pallet_aura::Config for Runtime {867	type AuthorityId = AuraId;868	type DisabledValidators = ();869	type MaxAuthorities = MaxAuthorities;870}871872parameter_types! {873	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();874	pub const CollectionCreationPrice: Balance = 2 * UNIQUE;875}876877impl pallet_common::Config for Runtime {878	type WeightInfo = pallet_common::weights::SubstrateWeight<Self>;879	type Event = Event;880	type Currency = Balances;881	type CollectionCreationPrice = CollectionCreationPrice;882	type TreasuryAccountId = TreasuryAccountId;883	type CollectionDispatch = CollectionDispatchT<Self>;884885	type EvmTokenAddressMapping = EvmTokenAddressMapping;886	type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;887}888889impl pallet_structure::Config for Runtime {890	type Event = Event;891	type Call = Call;892	type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;893}894895impl pallet_fungible::Config for Runtime {896	type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;897}898impl pallet_refungible::Config for Runtime {899	type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;900}901impl pallet_nonfungible::Config for Runtime {902	type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;903}904905impl pallet_proxy_rmrk_core::Config for Runtime {906	type Event = Event;907}908909impl pallet_unique::Config for Runtime {910	type Event = Event;911	type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;912	type CommonWeightInfo = CommonWeights<Self>;913}914915parameter_types! {916	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied917}918919/// Used for the pallet inflation920impl pallet_inflation::Config for Runtime {921	type Currency = Balances;922	type TreasuryAccountId = TreasuryAccountId;923	type InflationBlockInterval = InflationBlockInterval;924	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;925}926927// parameter_types! {928// 	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *929// 		RuntimeBlockWeights::get().max_block;930// 	pub const MaxScheduledPerBlock: u32 = 50;931// }932933type EvmSponsorshipHandler = (934	UniqueEthSponsorshipHandler<Runtime>,935	pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,936);937type SponsorshipHandler = (938	UniqueSponsorshipHandler<Runtime>,939	//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,940	pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,941);942943// impl pallet_unq_scheduler::Config for Runtime {944// 	type Event = Event;945// 	type Origin = Origin;946// 	type PalletsOrigin = OriginCaller;947// 	type Call = Call;948// 	type MaximumWeight = MaximumSchedulerWeight;949// 	type ScheduleOrigin = EnsureSigned<AccountId>;950// 	type MaxScheduledPerBlock = MaxScheduledPerBlock;951// 	type SponsorshipHandler = SponsorshipHandler;952// 	type WeightInfo = ();953// }954955impl pallet_evm_transaction_payment::Config for Runtime {956	type EvmSponsorshipHandler = EvmSponsorshipHandler;957	type Currency = Balances;958}959960impl pallet_charge_transaction::Config for Runtime {961	type SponsorshipHandler = SponsorshipHandler;962}963964// impl pallet_contract_helpers::Config for Runtime {965//	 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;966// }967968parameter_types! {969	// 0x842899ECF380553E8a4de75bF534cdf6fBF64049970	pub const HelpersContractAddress: H160 = H160([971		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,972	]);973}974975impl pallet_evm_contract_helpers::Config for Runtime {976	type ContractAddress = HelpersContractAddress;977	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;978}979980construct_runtime!(981	pub enum Runtime where982		Block = Block,983		NodeBlock = opaque::Block,984		UncheckedExtrinsic = UncheckedExtrinsic985	{986		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,987		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,988989		Aura: pallet_aura::{Pallet, Config<T>} = 22,990		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,991992		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,993		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,994		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,995		TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,996		Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,997		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,998		System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,999		Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,1000		// Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,1001		// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,10021003		// XCM helpers.1004		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1005		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1006		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1007		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10081009		// Unique Pallets1010		Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1011		Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1012		// Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1013		// free = 631014		Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1015		// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1016		Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1017		Fungible: pallet_fungible::{Pallet, Storage} = 67,1018		Refungible: pallet_refungible::{Pallet, Storage} = 68,1019		Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1020		Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1021		ProxyRmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,10221023		// Frontier1024		EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1025		Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10261027		EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1028		EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1029		EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1030		EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1031	}1032);10331034pub struct TransactionConverter;10351036impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1037	fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1038		UncheckedExtrinsic::new_unsigned(1039			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1040		)1041	}1042}10431044impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1045	fn convert_transaction(1046		&self,1047		transaction: pallet_ethereum::Transaction,1048	) -> opaque::UncheckedExtrinsic {1049		let extrinsic = UncheckedExtrinsic::new_unsigned(1050			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1051		);1052		let encoded = extrinsic.encode();1053		opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1054			.expect("Encoded extrinsic is always valid")1055	}1056}10571058/// The address format for describing accounts.1059pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1060/// Block header type as expected by this runtime.1061pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1062/// Block type as expected by this runtime.1063pub type Block = generic::Block<Header, UncheckedExtrinsic>;1064/// A Block signed with a Justification1065pub type SignedBlock = generic::SignedBlock<Block>;1066/// BlockId type as expected by this runtime.1067pub type BlockId = generic::BlockId<Block>;1068/// The SignedExtension to the basic transaction logic.1069pub type SignedExtra = (1070	frame_system::CheckSpecVersion<Runtime>,1071	// system::CheckTxVersion<Runtime>,1072	frame_system::CheckGenesis<Runtime>,1073	frame_system::CheckEra<Runtime>,1074	frame_system::CheckNonce<Runtime>,1075	frame_system::CheckWeight<Runtime>,1076	pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1077	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,1078	pallet_ethereum::FakeTransactionFinalizer<Runtime>,1079);1080/// Unchecked extrinsic type as expected by this runtime.1081pub type UncheckedExtrinsic =1082	fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1083/// Extrinsic type that has already been checked.1084pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1085/// Executive: handles dispatch to the various modules.1086pub type Executive = frame_executive::Executive<1087	Runtime,1088	Block,1089	frame_system::ChainContext<Runtime>,1090	Runtime,1091	AllPalletsReversedWithSystemFirst,1092>;10931094impl_opaque_keys! {1095	pub struct SessionKeys {1096		pub aura: Aura,1097	}1098}10991100impl fp_self_contained::SelfContainedCall for Call {1101	type SignedInfo = H160;11021103	fn is_self_contained(&self) -> bool {1104		match self {1105			Call::Ethereum(call) => call.is_self_contained(),1106			_ => false,1107		}1108	}11091110	fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1111		match self {1112			Call::Ethereum(call) => call.check_self_contained(),1113			_ => None,1114		}1115	}11161117	fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1118		match self {1119			Call::Ethereum(call) => call.validate_self_contained(info),1120			_ => None,1121		}1122	}11231124	fn pre_dispatch_self_contained(1125		&self,1126		info: &Self::SignedInfo,1127	) -> Option<Result<(), TransactionValidityError>> {1128		match self {1129			Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1130			_ => None,1131		}1132	}11331134	fn apply_self_contained(1135		self,1136		info: Self::SignedInfo,1137	) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1138		match self {1139			call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1140				Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1141			)),1142			_ => None,1143		}1144	}1145}11461147macro_rules! dispatch_unique_runtime {1148	($collection:ident.$method:ident($($name:ident),*)) => {{1149		let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1150		let dispatch = collection.as_dyn();11511152		Ok(dispatch.$method($($name),*))1153	}};1154}11551156impl_common_runtime_apis!();11571158struct CheckInherents;11591160impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1161	fn check_inherents(1162		block: &Block,1163		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1164	) -> sp_inherents::CheckInherentsResult {1165		let relay_chain_slot = relay_state_proof1166			.read_slot()1167			.expect("Could not read the relay chain slot from the proof");11681169		let inherent_data =1170			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1171				relay_chain_slot,1172				sp_std::time::Duration::from_secs(6),1173			)1174			.create_inherent_data()1175			.expect("Could not create the timestamp inherent data");11761177		inherent_data.check_extrinsics(block)1178	}1179}11801181cumulus_pallet_parachain_system::register_validate_block!(1182	Runtime = Runtime,1183	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1184	CheckInherents = CheckInherents,1185);
modifiedruntime/tests/src/lib.rsdiffbeforeafterboth
--- a/runtime/tests/src/lib.rs
+++ b/runtime/tests/src/lib.rs
@@ -212,6 +212,7 @@
 }
 
 impl pallet_common::Config for Test {
+	type WeightInfo = ();
 	type Event = ();
 	type Currency = Balances;
 	type CollectionCreationPrice = CollectionCreationPrice;
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -39,6 +39,7 @@
     'pallet-xcm/runtime-benchmarks',
     'sp-runtime/runtime-benchmarks',
     'xcm-builder/runtime-benchmarks',
+    'up-data-structs/runtime-benchmarks',
 ]
 try-runtime = [
     'frame-try-runtime',
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -66,7 +66,12 @@
 		WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,
 	},
 };
-use unique_runtime_common::dispatch::{CollectionDispatchT, CollectionDispatch};
+use unique_runtime_common::{
+	dispatch::{CollectionDispatchT, CollectionDispatch},
+	weights::CommonWeights,
+	sponsoring::UniqueSponsorshipHandler,
+	eth_sponsoring::UniqueEthSponsorshipHandler,
+};
 use up_data_structs::*;
 // use pallet_contracts::weights::WeightInfo;
 // #[cfg(any(feature = "std", test))]
@@ -846,6 +851,7 @@
 }
 
 impl pallet_common::Config for Runtime {
+	type WeightInfo = pallet_common::weights::SubstrateWeight<Self>;
 	type Event = Event;
 	type Currency = Balances;
 	type CollectionCreationPrice = CollectionCreationPrice;
@@ -881,6 +887,7 @@
 impl pallet_unique::Config for Runtime {
 	type Event = Event;
 	type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
+	type CommonWeightInfo = CommonWeights<Self>;
 }
 
 parameter_types! {
@@ -902,11 +909,11 @@
 // }
 
 type EvmSponsorshipHandler = (
-	pallet_unique::UniqueEthSponsorshipHandler<Runtime>,
+	UniqueEthSponsorshipHandler<Runtime>,
 	pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,
 );
 type SponsorshipHandler = (
-	pallet_unique::UniqueSponsorshipHandler<Runtime>,
+	UniqueSponsorshipHandler<Runtime>,
 	//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,
 	pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,
 );