git.delta.rocks / unique-network / refs/commits / 1b80f30d6749

difftreelog

Transaction payment and weights fix

str-mv2020-10-29parent: #e85b652.patch.diff
in: master

4 files changed

addedpallets/nft/src/default_weights.rsdiffbeforeafterboth
--- /dev/null
+++ b/pallets/nft/src/default_weights.rs
@@ -0,0 +1,95 @@
+use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
+
+impl crate::WeightInfo for () {
+	fn create_collection() -> Weight {
+		(70_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(7 as Weight))
+			.saturating_add(DbWeight::get().writes(5 as Weight))
+	}
+	fn destroy_collection() -> Weight {
+		(90_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(2 as Weight))
+			.saturating_add(DbWeight::get().writes(5 as Weight))
+	}
+	fn add_to_white_list() -> Weight {
+		(30_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(3 as Weight))
+			.saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn remove_from_white_list() -> Weight {
+		(35_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(3 as Weight))
+			.saturating_add(DbWeight::get().writes(1 as Weight))
+	}
+	fn set_public_access_mode() -> Weight {
+		(27_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(1 as Weight))
+			.saturating_add(DbWeight::get().writes(1 as Weight))
+	}
+	fn set_mint_permission() -> Weight {
+		(27_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(1 as Weight))
+			.saturating_add(DbWeight::get().writes(1 as Weight))
+	}
+	fn change_collection_owner() -> Weight {
+		(27_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(1 as Weight))
+			.saturating_add(DbWeight::get().writes(1 as Weight))
+	}
+	fn add_collection_admin() -> Weight {
+        (32_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(3 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+	}
+	fn remove_collection_admin() -> Weight {
+		(50_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn set_collection_sponsor() -> Weight {
+		(32_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }  
+    fn confirm_sponsorship() -> Weight {
+		(22_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }  
+    fn remove_collection_sponsor() -> Weight {
+		(24_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }  
+    fn create_item(s: usize, ) -> Weight {
+        (130_000_000 as Weight)
+            .saturating_add((2135 as Weight).saturating_mul(s as Weight))
+            .saturating_add(DbWeight::get().reads(10 as Weight))
+            .saturating_add(DbWeight::get().writes(8 as Weight))
+    }  
+    fn burn_item() -> Weight {
+		(170_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(9 as Weight))
+            .saturating_add(DbWeight::get().writes(7 as Weight))
+    }  
+    fn transfer() -> Weight {
+        (125_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(7 as Weight))
+            .saturating_add(DbWeight::get().writes(7 as Weight))
+    }  
+    fn approve() -> Weight {
+        (45_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(3 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn transfer_from() -> Weight {
+        (150_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(9 as Weight))
+            .saturating_add(DbWeight::get().writes(8 as Weight))
+    }
+    fn set_offchain_schema() -> Weight {
+        (33_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+}
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -44,6 +44,8 @@
 #[cfg(test)]
 mod tests;
 
+mod default_weights;
+
 // Structs
 // #region
 
@@ -182,8 +184,32 @@
     pub refungible_sponsor_transfer_timeout: u32,
 }
 
-pub trait Trait: system::Trait {
+pub trait WeightInfo {
+	fn create_collection() -> Weight;
+	fn destroy_collection() -> Weight;
+	fn add_to_white_list() -> Weight;
+	fn remove_from_white_list() -> Weight;
+    fn set_public_access_mode() -> Weight;
+    fn set_mint_permission() -> Weight;
+    fn change_collection_owner() -> Weight;
+    fn add_collection_admin() -> Weight;
+    fn remove_collection_admin() -> Weight;
+    fn set_collection_sponsor() -> Weight;
+    fn confirm_sponsorship() -> Weight;
+    fn remove_collection_sponsor() -> Weight;
+    fn create_item(s: usize, ) -> Weight;
+    fn burn_item() -> Weight;
+    fn transfer() -> Weight;
+    fn approve() -> Weight;
+    fn transfer_from() -> Weight;
+    fn set_offchain_schema() -> Weight;
+}
+
+pub trait Trait: system::Trait + Sized  {
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+
+    /// Weight information for extrinsics in this pallet.
+	type WeightInfo: WeightInfo;
 }
 
 #[cfg(feature = "runtime-benchmarks")]
@@ -326,10 +352,7 @@
         /// 
         /// * mode: [CollectionMode] collection type and type dependent data.
         // returns collection ID
-        #[weight =
-        (70_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(7 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(5 as Weight))]
+        #[weight = T::WeightInfo::create_collection()]
         pub fn create_collection(origin,
                                  collection_name: Vec<u16>,
                                  collection_description: Vec<u16>,
@@ -425,10 +448,7 @@
         /// # Arguments
         /// 
         /// * collection_id: collection to destroy.
-        #[weight =
-        (90_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(2 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(5 as Weight))]
+        #[weight = T::WeightInfo::destroy_collection()]
         pub fn destroy_collection(origin, collection_id: u64) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -475,10 +495,7 @@
         /// * collection_id.
         /// 
         /// * address.
-        #[weight =
-        (30_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(3 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::add_to_white_list()]
         pub fn add_to_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{
 
             let sender = ensure_signed(origin)?;
@@ -513,10 +530,7 @@
         /// * collection_id.
         /// 
         /// * address.
-        #[weight =
-        (35_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(3 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::remove_from_white_list()]
         pub fn remove_from_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{
 
             let sender = ensure_signed(origin)?;
@@ -545,10 +559,7 @@
         /// * collection_id.
         /// 
         /// * mode: [AccessMode]
-        #[weight =
-        (27_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(1 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::set_public_access_mode()]
         pub fn set_public_access_mode(origin, collection_id: u64, mode: AccessMode) -> DispatchResult
         {
             let sender = ensure_signed(origin)?;
@@ -574,10 +585,7 @@
         /// * collection_id.
         /// 
         /// * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.
-        #[weight =
-        (27_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(1 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::set_mint_permission()]
         pub fn set_mint_permission(origin, collection_id: u64, mint_permission: bool) -> DispatchResult
         {
             let sender = ensure_signed(origin)?;
@@ -601,10 +609,7 @@
         /// * collection_id.
         /// 
         /// * new_owner.
-        #[weight =
-        (27_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(1 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::change_collection_owner()]
         pub fn change_collection_owner(origin, collection_id: u64, new_owner: T::AccountId) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -629,10 +634,7 @@
         /// * collection_id: ID of the Collection to add admin for.
         /// 
         /// * new_admin_id: Address of new admin to add.
-        #[weight =
-        (32_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(3 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::add_collection_admin()]
         pub fn add_collection_admin(origin, collection_id: u64, new_admin_id: T::AccountId) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -666,10 +668,7 @@
         /// * collection_id: ID of the Collection to remove admin for.
         /// 
         /// * account_id: Address of admin to remove.
-        #[weight =
-        (50_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(2 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::remove_collection_admin()]
         pub fn remove_collection_admin(origin, collection_id: u64, account_id: T::AccountId) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -694,10 +693,7 @@
         /// * collection_id.
         /// 
         /// * new_sponsor.
-        #[weight =
-        (32_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(2 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::set_collection_sponsor()]
         pub fn set_collection_sponsor(origin, collection_id: u64, new_sponsor: T::AccountId) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -719,10 +715,7 @@
         /// # Arguments
         /// 
         /// * collection_id.
-        #[weight =
-        (22_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(1 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::confirm_sponsorship()]
         pub fn confirm_sponsorship(origin, collection_id: u64) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -747,10 +740,7 @@
         /// # Arguments
         /// 
         /// * collection_id.
-        #[weight =
-        (24_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(1 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::remove_collection_sponsor()]
         pub fn remove_collection_sponsor(origin, collection_id: u64) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -783,11 +773,13 @@
         /// * properties: Array of bytes that contains NFT properties. Since NFT Module is agnostic of properties meaning, it is treated purely as an array of bytes.
         /// 
         /// * owner: Address, initial owner of the NFT.
-        #[weight =
-        (130_000_000 as Weight)
-        .saturating_add((2135 as Weight).saturating_mul((properties.len() as u64) as Weight))
-        .saturating_add(RocksDbWeight::get().reads(10 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(8 as Weight))]
+        // #[weight =
+        // (130_000_000 as Weight)
+        // .saturating_add((2135 as Weight).saturating_mul((properties.len() as u64) as Weight))
+        // .saturating_add(RocksDbWeight::get().reads(10 as Weight))
+        // .saturating_add(RocksDbWeight::get().writes(8 as Weight))]
+
+        #[weight = T::WeightInfo::create_item(properties.len())]
         pub fn create_item(origin, collection_id: u64, properties: Vec<u8>, owner: T::AccountId) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -870,10 +862,7 @@
         /// * collection_id: ID of the collection.
         /// 
         /// * item_id: ID of NFT to burn.
-        #[weight =
-        (170_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(9 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(7 as Weight))]
+        #[weight = T::WeightInfo::burn_item()]
         pub fn burn_item(origin, collection_id: u64, item_id: u64) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -926,10 +915,7 @@
         ///     * Non-Fungible Mode: Ignored
         ///     * Fungible Mode: Must specify transferred amount
         ///     * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)
-        #[weight =
-        (125_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(7 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(7 as Weight))]
+        #[weight = T::WeightInfo::transfer()]
         pub fn transfer(origin, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -971,10 +957,7 @@
         /// * collection_id.
         /// 
         /// * item_id: ID of the item.
-        #[weight =
-        (45_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(3 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::approve()]
         pub fn approve(origin, approved: T::AccountId, collection_id: u64, item_id: u64) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -1032,10 +1015,7 @@
         /// * item_id: ID of the item.
         /// 
         /// * value: Amount to transfer.
-        #[weight =
-        (150_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(9 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(8 as Weight))]
+        #[weight = T::WeightInfo::transfer_from()]
         pub fn transfer_from(origin, from: T::AccountId, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64 ) -> DispatchResult {
 
             let sender = ensure_signed(origin)?;
@@ -1107,10 +1087,7 @@
         /// * collection_id.
         /// 
         /// * schema: String representing the offchain data schema.
-        #[weight =
-        (33_000_000 as Weight)
-        .saturating_add(RocksDbWeight::get().reads(2 as Weight))
-        .saturating_add(RocksDbWeight::get().writes(1 as Weight))]
+        #[weight = T::WeightInfo::set_offchain_schema()]
         pub fn set_offchain_schema(
             origin,
             collection_id: u64,
modifiedruntime/src/lib.rsdiffbeforeafterboth
before · runtime/src/lib.rs
1//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.23#![cfg_attr(not(feature = "std"), no_std)]4// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.5#![recursion_limit = "256"]67// Make the WASM binary available.8#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use pallet_contracts_rpc_runtime_api::ContractExecResult;12use pallet_grandpa::fg_primitives;13use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};14use sp_api::impl_runtime_apis;15use sp_consensus_aura::sr25519::AuthorityId as AuraId;16use sp_core::{crypto::KeyTypeId, OpaqueMetadata};17use sp_runtime::{18    create_runtime_str, generic, impl_opaque_keys,19    traits::{20        BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, Saturating,21        Verify,22    },23    transaction_validity::{TransactionSource, TransactionValidity},24    ApplyExtrinsicResult, MultiSignature,25};26use sp_std::prelude::*;27#[cfg(feature = "std")]28use sp_version::NativeVersion;29use sp_version::RuntimeVersion;3031// A few exports that help ease life for downstream crates.32pub use pallet_balances::Call as BalancesCall;33pub use pallet_contracts::Schedule as ContractsSchedule;34pub use frame_support::{35    construct_runtime,36    dispatch::DispatchResult,37    parameter_types,38    traits::{39        Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,40        WithdrawReason,41    },42    weights::{43        constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},44        DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,45        WeightToFeePolynomial,46    },47    StorageValue,48};49#[cfg(any(feature = "std", test))]50pub use sp_runtime::BuildStorage;51use sp_runtime::Perbill;52use frame_system::{self as system};5354pub use pallet_timestamp::Call as TimestampCall;5556/// Re-export a nft pallet57/// TODO: Check this re-export. Is this safe and good style?58extern crate pallet_nft;59pub use pallet_nft::*;6061/// An index to a block.62pub type BlockNumber = u32;6364/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.65pub type Signature = MultiSignature;6667/// Some way of identifying an account on the chain. We intentionally make it equivalent68/// to the public key of our transaction signing scheme.69pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;7071/// The type for looking up accounts. We don't expect more than 4 billion of them, but you72/// never know...73pub type AccountIndex = u32;7475/// Balance of an account.76pub type Balance = u128;7778/// Index of a transaction in the chain.79pub type Index = u32;8081/// A hash of some data used by the chain.82pub type Hash = sp_core::H256;8384/// Digest item type.85pub type DigestItem = generic::DigestItem<Hash>;868788/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know89/// the specifics of the runtime. They can then be made to be agnostic over specific formats90/// of data like extrinsics, allowing for them to continue syncing the network through upgrades91/// to even the core data structures.92pub mod opaque {93    use super::*;9495    pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;9697    /// Opaque block header type.98    pub type Header = generic::Header<BlockNumber, BlakeTwo256>;99    /// Opaque block type.100    pub type Block = generic::Block<Header, UncheckedExtrinsic>;101    /// Opaque block identifier type.102    pub type BlockId = generic::BlockId<Block>;103104    impl_opaque_keys! {105        pub struct SessionKeys {106            pub aura: Aura,107            pub grandpa: Grandpa,108        }109    }110}111112/// This runtime version.113pub const VERSION: RuntimeVersion = RuntimeVersion {114    spec_name: create_runtime_str!("nft"),115    impl_name: create_runtime_str!("nft"),116    authoring_version: 1,117    spec_version: 2,118    impl_version: 1,119    apis: RUNTIME_API_VERSIONS,120    transaction_version: 1,121};122123pub const MILLISECS_PER_BLOCK: u64 = 6000;124125pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;126127// These time units are defined in number of blocks.128pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);129pub const HOURS: BlockNumber = MINUTES * 60;130pub const DAYS: BlockNumber = HOURS * 24;131132/// The version information used to identify this runtime when compiled natively.133#[cfg(feature = "std")]134pub fn native_version() -> NativeVersion {135    NativeVersion {136        runtime_version: VERSION,137        can_author_with: Default::default(),138    }139}140141parameter_types! {142    pub const BlockHashCount: BlockNumber = 2400;143    /// We allow for 2 seconds of compute with a 6 second average block time.144    pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;145    pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);146    /// Assume 10% of weight for average on_initialize calls.147    pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()148        .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();149    pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;150    pub const Version: RuntimeVersion = VERSION;151}152153impl system::Trait for Runtime {154    /// The basic call filter to use in dispatchable.155    type BaseCallFilter = ();156    /// The identifier used to distinguish between accounts.157    type AccountId = AccountId;158    /// The aggregated dispatch type that is available for extrinsics.159    type Call = Call;160    /// The lookup mechanism to get account ID from whatever is passed in dispatchers.161    type Lookup = IdentityLookup<AccountId>;162    /// The index type for storing how many extrinsics an account has signed.163    type Index = Index;164    /// The index type for blocks.165    type BlockNumber = BlockNumber;166    /// The type for hashing blocks and tries.167    type Hash = Hash;168    /// The hashing algorithm used.169    type Hashing = BlakeTwo256;170    /// The header type.171    type Header = generic::Header<BlockNumber, BlakeTwo256>;172    /// The ubiquitous event type.173    type Event = Event;174    /// The ubiquitous origin type.175    type Origin = Origin;176    /// Maximum number of block number to block hash mappings to keep (oldest pruned first).177    type BlockHashCount = BlockHashCount;178    /// Maximum weight of each block.179    type MaximumBlockWeight = MaximumBlockWeight;180    /// The weight of database operations that the runtime can invoke.181    type DbWeight = RocksDbWeight;182    /// The weight of the overhead invoked on the block import process, independent of the183    /// extrinsics included in that block.184    type BlockExecutionWeight = BlockExecutionWeight;185    /// The base weight of any extrinsic processed by the runtime, independent of the186    /// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)187    type ExtrinsicBaseWeight = ExtrinsicBaseWeight;188    /// The maximum weight that a single extrinsic of `Normal` dispatch class can have,189    /// idependent of the logic of that extrinsics. (Roughly max block weight - average on190    /// initialize cost).191    type MaximumExtrinsicWeight = MaximumExtrinsicWeight;192    /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.193    type MaximumBlockLength = MaximumBlockLength;194    /// Portion of the block weight that is available to all normal transactions.195    type AvailableBlockRatio = AvailableBlockRatio;196    /// Version of the runtime.197    type Version = Version;198 	/// This type is being generated by `construct_runtime!`.199    type PalletInfo = PalletInfo;200    /// What to do if a new account is created.201    type OnNewAccount = ();202    /// What to do if an account is fully reaped from the system.203    type OnKilledAccount = ();204    /// The data to be stored in an account.205    type AccountData = pallet_balances::AccountData<Balance>;206	/// Weight information for the extrinsics of this pallet.207	type SystemWeightInfo = ();208}209210impl pallet_aura::Trait for Runtime {211    type AuthorityId = AuraId;212}213214impl pallet_grandpa::Trait for Runtime {215	type Event = Event;216	type Call = Call;217218	type KeyOwnerProofSystem = ();219220	type KeyOwnerProof =221		<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;222223	type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(224		KeyTypeId,225		GrandpaId,226	)>>::IdentificationTuple;227228	type HandleEquivocation = ();229230	type WeightInfo = ();231}232233parameter_types! {234    pub const MinimumPeriod: u64 = SLOT_DURATION / 2;235}236237impl pallet_timestamp::Trait for Runtime {238	/// A timestamp: milliseconds since the unix epoch.239	type Moment = u64;240	type OnTimestampSet = Aura;241	type MinimumPeriod = MinimumPeriod;242	type WeightInfo = ();243}244245parameter_types! {246    // pub const ExistentialDeposit: u128 = 500;247    pub const ExistentialDeposit: u128 = 0;248	pub const MaxLocks: u32 = 50;249}250251impl pallet_balances::Trait for Runtime {252	type MaxLocks = MaxLocks;253	/// The type for recording an account's balance.254	type Balance = Balance;255	/// The ubiquitous event type.256	type Event = Event;257	type DustRemoval = ();258	type ExistentialDeposit = ExistentialDeposit;259	type AccountStore = System;260	type WeightInfo = ();261}262263pub const MILLICENTS: Balance = 1_000_000_000;264pub const CENTS: Balance = 1_000 * MILLICENTS;265pub const DOLLARS: Balance = 100 * CENTS;266267parameter_types! {268    pub const TombstoneDeposit: Balance = 16 * MILLICENTS;269    pub const RentByteFee: Balance = 4 * MILLICENTS;270    pub const RentDepositOffset: Balance = 1000 * MILLICENTS;271    pub const SurchargeReward: Balance = 150 * MILLICENTS;272}273274impl pallet_contracts::Trait for Runtime {275	type Time = Timestamp;276	type Randomness = RandomnessCollectiveFlip;277	type Currency = Balances;278	type Event = Event;279	type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminer<Runtime>;280	type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter<Runtime>;281	type RentPayment = ();282	type SignedClaimHandicap = pallet_contracts::DefaultSignedClaimHandicap;283	type TombstoneDeposit = TombstoneDeposit;284	type StorageSizeOffset = pallet_contracts::DefaultStorageSizeOffset;285	type RentByteFee = RentByteFee;286	type RentDepositOffset = RentDepositOffset;287	type SurchargeReward = SurchargeReward;288	type MaxDepth = pallet_contracts::DefaultMaxDepth;289	type MaxValueSize = pallet_contracts::DefaultMaxValueSize;290	type WeightPrice = pallet_transaction_payment::Module<Self>;291}292293parameter_types! {294    pub const TransactionByteFee: Balance = 1;295}296297impl pallet_transaction_payment::Trait for Runtime {298    type Currency = pallet_balances::Module<Runtime>;299    type OnTransactionPayment = ();300    type TransactionByteFee = TransactionByteFee;301    type WeightToFee = IdentityFee<Balance>;302    type FeeMultiplierUpdate = ();303}304305impl pallet_sudo::Trait for Runtime {306    type Event = Event;307    type Call = Call;308}309310/// Used for the module nft in `./nft.rs`311impl pallet_nft::Trait for Runtime {312    type Event = Event;313}314315construct_runtime!(316    pub enum Runtime where317        Block = Block,318        NodeBlock = opaque::Block,319        UncheckedExtrinsic = UncheckedExtrinsic320    {321        System: system::{Module, Call, Config, Storage, Event<T>},322        RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},323        Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},324        Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},325        Aura: pallet_aura::{Module, Config<T>, Inherent},326        Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},327        Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},328        TransactionPayment: pallet_transaction_payment::{Module, Storage},329        Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},330        Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},331    }332);333334/// The address format for describing accounts.335pub type Address = AccountId;336/// Block header type as expected by this runtime.337pub type Header = generic::Header<BlockNumber, BlakeTwo256>;338/// Block type as expected by this runtime.339pub type Block = generic::Block<Header, UncheckedExtrinsic>;340/// A Block signed with a Justification341pub type SignedBlock = generic::SignedBlock<Block>;342/// BlockId type as expected by this runtime.343pub type BlockId = generic::BlockId<Block>;344/// The SignedExtension to the basic transaction logic.345pub type SignedExtra = (346    system::CheckSpecVersion<Runtime>,347    system::CheckTxVersion<Runtime>,348    system::CheckGenesis<Runtime>,349    system::CheckEra<Runtime>,350    system::CheckNonce<Runtime>,351    system::CheckWeight<Runtime>,352    pallet_nft::ChargeTransactionPayment<Runtime>,353);354/// Unchecked extrinsic type as expected by this runtime.355pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;356/// Extrinsic type that has already been checked.357pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;358/// Executive: handles dispatch to the various modules.359pub type Executive =360    frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;361362impl_runtime_apis! {363364    impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>365    for Runtime366    {367        fn call(368            origin: AccountId,369            dest: AccountId,370            value: Balance,371            gas_limit: u64,372            input_data: Vec<u8>,373        ) -> ContractExecResult {374			let (exec_result, gas_consumed) =375				Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);376			match exec_result {377				Ok(v) => ContractExecResult::Success {378					flags: v.flags.bits(),379					data: v.data,380					gas_consumed: gas_consumed,381				},382				Err(_) => ContractExecResult::Error,383			}384        }385386        fn get_storage(387            address: AccountId,388            key: [u8; 32],389        ) -> pallet_contracts_primitives::GetStorageResult {390            Contracts::get_storage(address, key)391        }392393        fn rent_projection(394            address: AccountId,395        ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {396            Contracts::rent_projection(address)397        }398    }399400    impl sp_api::Core<Block> for Runtime {401        fn version() -> RuntimeVersion {402            VERSION403        }404405        fn execute_block(block: Block) {406            Executive::execute_block(block)407        }408409        fn initialize_block(header: &<Block as BlockT>::Header) {410            Executive::initialize_block(header)411        }412    }413414    impl sp_api::Metadata<Block> for Runtime {415        fn metadata() -> OpaqueMetadata {416            Runtime::metadata().into()417        }418    }419420    impl sp_block_builder::BlockBuilder<Block> for Runtime {421        fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {422            Executive::apply_extrinsic(extrinsic)423        }424425        fn finalize_block() -> <Block as BlockT>::Header {426            Executive::finalize_block()427        }428429        fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {430            data.create_extrinsics()431        }432433        fn check_inherents(434            block: Block,435            data: sp_inherents::InherentData,436        ) -> sp_inherents::CheckInherentsResult {437            data.check_extrinsics(&block)438        }439440        fn random_seed() -> <Block as BlockT>::Hash {441            RandomnessCollectiveFlip::random_seed()442        }443    }444445    impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {446        fn validate_transaction(447            source: TransactionSource,448            tx: <Block as BlockT>::Extrinsic,449        ) -> TransactionValidity {450            Executive::validate_transaction(source, tx)451        }452    }453454    impl sp_offchain::OffchainWorkerApi<Block> for Runtime {455        fn offchain_worker(header: &<Block as BlockT>::Header) {456            Executive::offchain_worker(header)457        }458    }459460    impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {461        fn slot_duration() -> u64 {462            Aura::slot_duration()463        }464465        fn authorities() -> Vec<AuraId> {466            Aura::authorities()467        }468    }469470    impl sp_session::SessionKeys<Block> for Runtime {471        fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {472            opaque::SessionKeys::generate(seed)473        }474475        fn decode_session_keys(476            encoded: Vec<u8>,477        ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {478            opaque::SessionKeys::decode_into_raw_public_keys(&encoded)479        }480    }481482	impl fg_primitives::GrandpaApi<Block> for Runtime {483		fn grandpa_authorities() -> GrandpaAuthorityList {484			Grandpa::grandpa_authorities()485		}486487		fn submit_report_equivocation_unsigned_extrinsic(488			_equivocation_proof: fg_primitives::EquivocationProof<489				<Block as BlockT>::Hash,490				NumberFor<Block>,491			>,492			_key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,493		) -> Option<()> {494			None495		}496497		fn generate_key_ownership_proof(498			_set_id: fg_primitives::SetId,499			_authority_id: GrandpaId,500		) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {501			// NOTE: this is the only implementation possible since we've502			// defined our key owner proof type as a bottom type (i.e. a type503			// with no values).504			None505		}506    }507    508	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {509		fn account_nonce(account: AccountId) -> Index {510			System::account_nonce(account)511		}512	}513514	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {515		fn query_info(516			uxt: <Block as BlockT>::Extrinsic,517			len: u32,518		) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {519			TransactionPayment::query_info(uxt, len)520		}521	}522523    #[cfg(feature = "runtime-benchmarks")]524	impl frame_benchmarking::Benchmark<Block> for Runtime {525		fn dispatch_benchmark(526			config: frame_benchmarking::BenchmarkConfig527		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {528			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};529530			let whitelist: Vec<TrackedStorageKey> = vec![531				// Alice account532				hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),533				// // Total Issuance534				// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),535				// // Execution Phase536				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),537				// // Event Count538				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),539				// // System Events540				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),541            ];542543			let mut batches = Vec::<BenchmarkBatch>::new();544			let params = (&config, &whitelist);545546			add_benchmark!(params, batches, pallet_nft, Nft);547548			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }549			Ok(batches)550		}551	}552}
after · runtime/src/lib.rs
1//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.23#![cfg_attr(not(feature = "std"), no_std)]4// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.5#![recursion_limit = "256"]67// Make the WASM binary available.8#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use pallet_contracts_rpc_runtime_api::ContractExecResult;12use pallet_grandpa::fg_primitives;13use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};14use sp_api::impl_runtime_apis;15use sp_consensus_aura::sr25519::AuthorityId as AuraId;16use sp_core::{crypto::KeyTypeId, OpaqueMetadata};17use sp_runtime::{18    create_runtime_str, generic, impl_opaque_keys,19    traits::{20        BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, Saturating,21        Verify,22    },23    transaction_validity::{TransactionSource, TransactionValidity},24    ApplyExtrinsicResult, MultiSignature,25};26use sp_std::prelude::*;27#[cfg(feature = "std")]28use sp_version::NativeVersion;29use sp_version::RuntimeVersion;3031// A few exports that help ease life for downstream crates.32pub use pallet_balances::Call as BalancesCall;33pub use pallet_contracts::Schedule as ContractsSchedule;34pub use frame_support::{35    construct_runtime,36    dispatch::DispatchResult,37    parameter_types,38    traits::{39        Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,40        WithdrawReason,41    },42    weights::{43        constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},44        DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,45        WeightToFeePolynomial,46    },47    StorageValue,48};49#[cfg(any(feature = "std", test))]50pub use sp_runtime::BuildStorage;51use sp_runtime::Perbill;52use frame_system::{self as system};5354pub use pallet_timestamp::Call as TimestampCall;5556/// Re-export a nft pallet57/// TODO: Check this re-export. Is this safe and good style?58extern crate pallet_nft;59pub use pallet_nft::*;6061/// An index to a block.62pub type BlockNumber = u32;6364/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.65pub type Signature = MultiSignature;6667/// Some way of identifying an account on the chain. We intentionally make it equivalent68/// to the public key of our transaction signing scheme.69pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;7071/// The type for looking up accounts. We don't expect more than 4 billion of them, but you72/// never know...73pub type AccountIndex = u32;7475/// Balance of an account.76pub type Balance = u128;7778/// Index of a transaction in the chain.79pub type Index = u32;8081/// A hash of some data used by the chain.82pub type Hash = sp_core::H256;8384/// Digest item type.85pub type DigestItem = generic::DigestItem<Hash>;8687mod nft_weights;8889/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know90/// the specifics of the runtime. They can then be made to be agnostic over specific formats91/// of data like extrinsics, allowing for them to continue syncing the network through upgrades92/// to even the core data structures.93pub mod opaque {94    use super::*;9596    pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;9798    /// Opaque block header type.99    pub type Header = generic::Header<BlockNumber, BlakeTwo256>;100    /// Opaque block type.101    pub type Block = generic::Block<Header, UncheckedExtrinsic>;102    /// Opaque block identifier type.103    pub type BlockId = generic::BlockId<Block>;104105    impl_opaque_keys! {106        pub struct SessionKeys {107            pub aura: Aura,108            pub grandpa: Grandpa,109        }110    }111}112113/// This runtime version.114pub const VERSION: RuntimeVersion = RuntimeVersion {115    spec_name: create_runtime_str!("nft"),116    impl_name: create_runtime_str!("nft"),117    authoring_version: 1,118    spec_version: 2,119    impl_version: 1,120    apis: RUNTIME_API_VERSIONS,121    transaction_version: 1,122};123124pub const MILLISECS_PER_BLOCK: u64 = 6000;125126pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;127128// These time units are defined in number of blocks.129pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);130pub const HOURS: BlockNumber = MINUTES * 60;131pub const DAYS: BlockNumber = HOURS * 24;132133/// The version information used to identify this runtime when compiled natively.134#[cfg(feature = "std")]135pub fn native_version() -> NativeVersion {136    NativeVersion {137        runtime_version: VERSION,138        can_author_with: Default::default(),139    }140}141142parameter_types! {143    pub const BlockHashCount: BlockNumber = 2400;144    /// We allow for 2 seconds of compute with a 6 second average block time.145    pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;146    pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);147    /// Assume 10% of weight for average on_initialize calls.148    // pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()149    //     .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();150151    pub MaximumExtrinsicWeight: Weight = 4_294_967_295; 152    //pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;153    pub const MaximumBlockLength: u32 = 4_294_967_295;154    pub const Version: RuntimeVersion = VERSION;155}156157impl system::Trait for Runtime {158    /// The basic call filter to use in dispatchable.159    type BaseCallFilter = ();160    /// The identifier used to distinguish between accounts.161    type AccountId = AccountId;162    /// The aggregated dispatch type that is available for extrinsics.163    type Call = Call;164    /// The lookup mechanism to get account ID from whatever is passed in dispatchers.165    type Lookup = IdentityLookup<AccountId>;166    /// The index type for storing how many extrinsics an account has signed.167    type Index = Index;168    /// The index type for blocks.169    type BlockNumber = BlockNumber;170    /// The type for hashing blocks and tries.171    type Hash = Hash;172    /// The hashing algorithm used.173    type Hashing = BlakeTwo256;174    /// The header type.175    type Header = generic::Header<BlockNumber, BlakeTwo256>;176    /// The ubiquitous event type.177    type Event = Event;178    /// The ubiquitous origin type.179    type Origin = Origin;180    /// Maximum number of block number to block hash mappings to keep (oldest pruned first).181    type BlockHashCount = BlockHashCount;182    /// Maximum weight of each block.183    type MaximumBlockWeight = MaximumBlockWeight;184    /// The weight of database operations that the runtime can invoke.185    type DbWeight = RocksDbWeight;186    /// The weight of the overhead invoked on the block import process, independent of the187    /// extrinsics included in that block.188    type BlockExecutionWeight = BlockExecutionWeight;189    /// The base weight of any extrinsic processed by the runtime, independent of the190    /// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)191    type ExtrinsicBaseWeight = ExtrinsicBaseWeight;192    /// The maximum weight that a single extrinsic of `Normal` dispatch class can have,193    /// idependent of the logic of that extrinsics. (Roughly max block weight - average on194    /// initialize cost).195    type MaximumExtrinsicWeight = MaximumExtrinsicWeight;196    /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.197    type MaximumBlockLength = MaximumBlockLength;198    /// Portion of the block weight that is available to all normal transactions.199    type AvailableBlockRatio = AvailableBlockRatio;200    /// Version of the runtime.201    type Version = Version;202 	/// This type is being generated by `construct_runtime!`.203    type PalletInfo = PalletInfo;204    /// What to do if a new account is created.205    type OnNewAccount = ();206    /// What to do if an account is fully reaped from the system.207    type OnKilledAccount = ();208    /// The data to be stored in an account.209    type AccountData = pallet_balances::AccountData<Balance>;210	/// Weight information for the extrinsics of this pallet.211	type SystemWeightInfo = ();212}213214impl pallet_aura::Trait for Runtime {215    type AuthorityId = AuraId;216}217218impl pallet_grandpa::Trait for Runtime {219	type Event = Event;220	type Call = Call;221222	type KeyOwnerProofSystem = ();223224	type KeyOwnerProof =225		<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;226227	type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(228		KeyTypeId,229		GrandpaId,230	)>>::IdentificationTuple;231232	type HandleEquivocation = ();233234	type WeightInfo = ();235}236237parameter_types! {238    pub const MinimumPeriod: u64 = SLOT_DURATION / 2;239}240241impl pallet_timestamp::Trait for Runtime {242	/// A timestamp: milliseconds since the unix epoch.243	type Moment = u64;244	type OnTimestampSet = Aura;245	type MinimumPeriod = MinimumPeriod;246	type WeightInfo = ();247}248249parameter_types! {250    // pub const ExistentialDeposit: u128 = 500;251    pub const ExistentialDeposit: u128 = 0;252	pub const MaxLocks: u32 = 50;253}254255impl pallet_balances::Trait for Runtime {256	type MaxLocks = MaxLocks;257	/// The type for recording an account's balance.258	type Balance = Balance;259	/// The ubiquitous event type.260	type Event = Event;261	type DustRemoval = ();262	type ExistentialDeposit = ExistentialDeposit;263	type AccountStore = System;264	type WeightInfo = ();265}266267pub const MILLICENTS: Balance = 1_000_000_000;268pub const CENTS: Balance = 1_000 * MILLICENTS;269pub const DOLLARS: Balance = 100 * CENTS;270271parameter_types! {272    pub const TombstoneDeposit: Balance = 16 * MILLICENTS;273    pub const RentByteFee: Balance = 4 * MILLICENTS;274    pub const RentDepositOffset: Balance = 1000 * MILLICENTS;275    pub const SurchargeReward: Balance = 150 * MILLICENTS;276}277278impl pallet_contracts::Trait for Runtime {279	type Time = Timestamp;280	type Randomness = RandomnessCollectiveFlip;281	type Currency = Balances;282	type Event = Event;283	type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminer<Runtime>;284	type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter<Runtime>;285	type RentPayment = ();286	type SignedClaimHandicap = pallet_contracts::DefaultSignedClaimHandicap;287	type TombstoneDeposit = TombstoneDeposit;288	type StorageSizeOffset = pallet_contracts::DefaultStorageSizeOffset;289	type RentByteFee = RentByteFee;290	type RentDepositOffset = RentDepositOffset;291	type SurchargeReward = SurchargeReward;292	type MaxDepth = pallet_contracts::DefaultMaxDepth;293	type MaxValueSize = pallet_contracts::DefaultMaxValueSize;294	type WeightPrice = pallet_transaction_payment::Module<Self>;295}296297parameter_types! {298	pub const TransactionByteFee: Balance = 10 * MILLICENTS;299}300301impl pallet_transaction_payment::Trait for Runtime {302    type Currency = pallet_balances::Module<Runtime>;303    type OnTransactionPayment = ();304    type TransactionByteFee = TransactionByteFee;305    type WeightToFee = IdentityFee<Balance>;306    type FeeMultiplierUpdate =  ();307}308309impl pallet_sudo::Trait for Runtime {310    type Event = Event;311    type Call = Call;312}313314/// Used for the module nft in `./nft.rs`315impl pallet_nft::Trait for Runtime {316    type Event = Event;317    type WeightInfo = nft_weights::WeightInfo;318}319320construct_runtime!(321    pub enum Runtime where322        Block = Block,323        NodeBlock = opaque::Block,324        UncheckedExtrinsic = UncheckedExtrinsic325    {326        System: system::{Module, Call, Config, Storage, Event<T>},327        RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},328        Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},329        Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},330        Aura: pallet_aura::{Module, Config<T>, Inherent},331        Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},332        Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},333        TransactionPayment: pallet_transaction_payment::{Module, Storage},334        Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},335        Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},336    }337);338339/// The address format for describing accounts.340pub type Address = AccountId;341/// Block header type as expected by this runtime.342pub type Header = generic::Header<BlockNumber, BlakeTwo256>;343/// Block type as expected by this runtime.344pub type Block = generic::Block<Header, UncheckedExtrinsic>;345/// A Block signed with a Justification346pub type SignedBlock = generic::SignedBlock<Block>;347/// BlockId type as expected by this runtime.348pub type BlockId = generic::BlockId<Block>;349/// The SignedExtension to the basic transaction logic.350pub type SignedExtra = (351    system::CheckSpecVersion<Runtime>,352    system::CheckTxVersion<Runtime>,353    system::CheckGenesis<Runtime>,354    system::CheckEra<Runtime>,355    system::CheckNonce<Runtime>,356    system::CheckWeight<Runtime>,357    pallet_nft::ChargeTransactionPayment<Runtime>,358);359/// Unchecked extrinsic type as expected by this runtime.360pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;361/// Extrinsic type that has already been checked.362pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;363/// Executive: handles dispatch to the various modules.364pub type Executive =365    frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;366367impl_runtime_apis! {368369    impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>370    for Runtime371    {372        fn call(373            origin: AccountId,374            dest: AccountId,375            value: Balance,376            gas_limit: u64,377            input_data: Vec<u8>,378        ) -> ContractExecResult {379			let (exec_result, gas_consumed) =380				Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);381			match exec_result {382				Ok(v) => ContractExecResult::Success {383					flags: v.flags.bits(),384					data: v.data,385					gas_consumed: gas_consumed,386				},387				Err(_) => ContractExecResult::Error,388			}389        }390391        fn get_storage(392            address: AccountId,393            key: [u8; 32],394        ) -> pallet_contracts_primitives::GetStorageResult {395            Contracts::get_storage(address, key)396        }397398        fn rent_projection(399            address: AccountId,400        ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {401            Contracts::rent_projection(address)402        }403    }404405    impl sp_api::Core<Block> for Runtime {406        fn version() -> RuntimeVersion {407            VERSION408        }409410        fn execute_block(block: Block) {411            Executive::execute_block(block)412        }413414        fn initialize_block(header: &<Block as BlockT>::Header) {415            Executive::initialize_block(header)416        }417    }418419    impl sp_api::Metadata<Block> for Runtime {420        fn metadata() -> OpaqueMetadata {421            Runtime::metadata().into()422        }423    }424425    impl sp_block_builder::BlockBuilder<Block> for Runtime {426        fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {427            Executive::apply_extrinsic(extrinsic)428        }429430        fn finalize_block() -> <Block as BlockT>::Header {431            Executive::finalize_block()432        }433434        fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {435            data.create_extrinsics()436        }437438        fn check_inherents(439            block: Block,440            data: sp_inherents::InherentData,441        ) -> sp_inherents::CheckInherentsResult {442            data.check_extrinsics(&block)443        }444445        fn random_seed() -> <Block as BlockT>::Hash {446            RandomnessCollectiveFlip::random_seed()447        }448    }449450    impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {451        fn validate_transaction(452            source: TransactionSource,453            tx: <Block as BlockT>::Extrinsic,454        ) -> TransactionValidity {455            Executive::validate_transaction(source, tx)456        }457    }458459    impl sp_offchain::OffchainWorkerApi<Block> for Runtime {460        fn offchain_worker(header: &<Block as BlockT>::Header) {461            Executive::offchain_worker(header)462        }463    }464465    impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {466        fn slot_duration() -> u64 {467            Aura::slot_duration()468        }469470        fn authorities() -> Vec<AuraId> {471            Aura::authorities()472        }473    }474475    impl sp_session::SessionKeys<Block> for Runtime {476        fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {477            opaque::SessionKeys::generate(seed)478        }479480        fn decode_session_keys(481            encoded: Vec<u8>,482        ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {483            opaque::SessionKeys::decode_into_raw_public_keys(&encoded)484        }485    }486487	impl fg_primitives::GrandpaApi<Block> for Runtime {488		fn grandpa_authorities() -> GrandpaAuthorityList {489			Grandpa::grandpa_authorities()490		}491492		fn submit_report_equivocation_unsigned_extrinsic(493			_equivocation_proof: fg_primitives::EquivocationProof<494				<Block as BlockT>::Hash,495				NumberFor<Block>,496			>,497			_key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,498		) -> Option<()> {499			None500		}501502		fn generate_key_ownership_proof(503			_set_id: fg_primitives::SetId,504			_authority_id: GrandpaId,505		) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {506			// NOTE: this is the only implementation possible since we've507			// defined our key owner proof type as a bottom type (i.e. a type508			// with no values).509			None510		}511    }512    513	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {514		fn account_nonce(account: AccountId) -> Index {515			System::account_nonce(account)516		}517	}518519	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {520		fn query_info(521			uxt: <Block as BlockT>::Extrinsic,522			len: u32,523		) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {524			TransactionPayment::query_info(uxt, len)525		}526	}527528    #[cfg(feature = "runtime-benchmarks")]529	impl frame_benchmarking::Benchmark<Block> for Runtime {530		fn dispatch_benchmark(531			config: frame_benchmarking::BenchmarkConfig532		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {533			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};534535			let whitelist: Vec<TrackedStorageKey> = vec![536				// Alice account537				hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),538				// // Total Issuance539				// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),540				// // Execution Phase541				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),542				// // Event Count543				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),544				// // System Events545				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),546            ];547548			let mut batches = Vec::<BenchmarkBatch>::new();549			let params = (&config, &whitelist);550551			add_benchmark!(params, batches, pallet_nft, Nft);552553			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }554			Ok(batches)555		}556	}557}
addedruntime/src/nft_weights.rsdiffbeforeafterboth
--- /dev/null
+++ b/runtime/src/nft_weights.rs
@@ -0,0 +1,96 @@
+use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
+
+pub struct WeightInfo;
+impl pallet_nft::WeightInfo for WeightInfo {
+	fn create_collection() -> Weight {
+		(70_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(7 as Weight))
+			.saturating_add(DbWeight::get().writes(5 as Weight))
+	}
+	fn destroy_collection() -> Weight {
+		(90_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(2 as Weight))
+			.saturating_add(DbWeight::get().writes(5 as Weight))
+	}
+	fn add_to_white_list() -> Weight {
+		(30_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(3 as Weight))
+			.saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn remove_from_white_list() -> Weight {
+		(35_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(3 as Weight))
+			.saturating_add(DbWeight::get().writes(1 as Weight))
+	}
+	fn set_public_access_mode() -> Weight {
+		(27_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(1 as Weight))
+			.saturating_add(DbWeight::get().writes(1 as Weight))
+	}
+	fn set_mint_permission() -> Weight {
+		(27_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(1 as Weight))
+			.saturating_add(DbWeight::get().writes(1 as Weight))
+	}
+	fn change_collection_owner() -> Weight {
+		(27_000_000 as Weight)
+			.saturating_add(DbWeight::get().reads(1 as Weight))
+			.saturating_add(DbWeight::get().writes(1 as Weight))
+	}
+	fn add_collection_admin() -> Weight {
+        (32_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(3 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+	}
+	fn remove_collection_admin() -> Weight {
+		(50_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn set_collection_sponsor() -> Weight {
+		(32_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }  
+    fn confirm_sponsorship() -> Weight {
+		(22_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }  
+    fn remove_collection_sponsor() -> Weight {
+		(24_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }  
+    fn create_item(s: usize, ) -> Weight {
+        (130_000_000 as Weight)
+            .saturating_add((2135 as Weight).saturating_mul(s as Weight))
+            .saturating_add(DbWeight::get().reads(10 as Weight))
+            .saturating_add(DbWeight::get().writes(8 as Weight))
+    }  
+    fn burn_item() -> Weight {
+		(170_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(9 as Weight))
+            .saturating_add(DbWeight::get().writes(7 as Weight))
+    }  
+    fn transfer() -> Weight {
+        (125_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(7 as Weight))
+            .saturating_add(DbWeight::get().writes(7 as Weight))
+    }  
+    fn approve() -> Weight {
+        (45_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(3 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn transfer_from() -> Weight {
+        (150_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(9 as Weight))
+            .saturating_add(DbWeight::get().writes(8 as Weight))
+    }
+    fn set_offchain_schema() -> Weight {
+        (33_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+}