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

difftreelog

source

runtime/src/lib.rs25.0 KiBsourcehistory
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.78#![cfg_attr(not(feature = "std"), no_std)]9// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.10#![recursion_limit = "256"]1112// Make the WASM binary available.13#[cfg(feature = "std")]14include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1516use pallet_grandpa::fg_primitives;17use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};18use sp_api::impl_runtime_apis;19use sp_consensus_aura::sr25519::AuthorityId as AuraId;20use sp_core::{ crypto::KeyTypeId, crypto::Public, OpaqueMetadata };21use sp_runtime::{22    Permill, Perbill, Percent,23    ModuleId,24    create_runtime_str, generic, impl_opaque_keys,25    traits::{26        Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, 27        IdentityLookup, NumberFor, Verify,28    },29    transaction_validity::{TransactionSource, TransactionValidity},30    ApplyExtrinsicResult, MultiSignature,31};32#[cfg(feature = "std")]33use sp_version::NativeVersion;34use sp_version::RuntimeVersion;35pub use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment, CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};36// A few exports that help ease life for downstream crates.37pub use pallet_balances::Call as BalancesCall;38pub use pallet_contracts::{Schedule as ContractsSchedule, WeightInfo};39pub use frame_support::{40    construct_runtime,41    dispatch::DispatchResult,42    parameter_types,43    StorageValue,44    traits::{45        Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,46        LockIdentifier,47    },48    weights::{49        constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},50        DispatchInfo, GetDispatchInfo, Pays, PostDispatchInfo, Weight,51        WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients52    },53};54// #[cfg(any(feature = "std", test))]55use frame_system::{56    self as system,57    EnsureRoot, 58	limits::{BlockWeights, BlockLength},59};60use sp_std::{prelude::*, marker::PhantomData};61use sp_arithmetic::{traits::{BaseArithmetic, Unsigned}};62use smallvec::smallvec;6364pub use pallet_timestamp::Call as TimestampCall;6566mod chain_extension;67use crate::chain_extension::NFTExtension;6869/// Struct that handles the conversion of Balance -> `u64`. This is used for70/// staking's election calculation.71pub struct CurrencyToVoteHandler;7273impl CurrencyToVoteHandler {74	fn factor() -> Balance {75		(Balances::total_issuance() / u64::max_value() as Balance).max(1)76	}77}7879impl Convert<Balance, u64> for CurrencyToVoteHandler {80	fn convert(x: Balance) -> u64 {81		(x / Self::factor()) as u6482	}83}8485impl Convert<u128, Balance> for CurrencyToVoteHandler {86	fn convert(x: u128) -> Balance {87		x * Self::factor()88	}89}9091/// Re-export a nft pallet92/// TODO: Check this re-export. Is this safe and good style?93extern crate pallet_nft;94pub use pallet_nft::*;9596/// An index to a block.97pub type BlockNumber = u32;9899/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.100pub type Signature = MultiSignature;101102/// Some way of identifying an account on the chain. We intentionally make it equivalent103/// to the public key of our transaction signing scheme.104pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;105106/// The type for looking up accounts. We don't expect more than 4 billion of them, but you107/// never know...108pub type AccountIndex = u32;109110/// Balance of an account.111pub type Balance = u128;112113/// Index of a transaction in the chain.114pub type Index = u32;115116/// A hash of some data used by the chain.117pub type Hash = sp_core::H256;118119/// Digest item type.120pub type DigestItem = generic::DigestItem<Hash>;121122mod nft_weights;123124/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know125/// the specifics of the runtime. They can then be made to be agnostic over specific formats126/// of data like extrinsics, allowing for them to continue syncing the network through upgrades127/// to even the core data structures.128pub mod opaque {129    use super::*;130131    pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;132133    /// Opaque block header type.134    pub type Header = generic::Header<BlockNumber, BlakeTwo256>;135    /// Opaque block type.136    pub type Block = generic::Block<Header, UncheckedExtrinsic>;137    /// Opaque block identifier type.138    pub type BlockId = generic::BlockId<Block>;139140    impl_opaque_keys! {141        pub struct SessionKeys {142            pub aura: Aura,143            pub grandpa: Grandpa,144        }145    }146}147148/// This runtime version.149pub const VERSION: RuntimeVersion = RuntimeVersion {150    spec_name: create_runtime_str!("nft"),151    impl_name: create_runtime_str!("nft"),152    authoring_version: 1,153    spec_version: 3,154    impl_version: 1,155    apis: RUNTIME_API_VERSIONS,156    transaction_version: 1,157};158159pub const MILLISECS_PER_BLOCK: u64 = 6000;160161pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;162163// These time units are defined in number of blocks.164pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);165pub const HOURS: BlockNumber = MINUTES * 60;166pub const DAYS: BlockNumber = HOURS * 24;167168/// The version information used to identify this runtime when compiled natively.169#[cfg(feature = "std")]170pub fn native_version() -> NativeVersion {171    NativeVersion {172        runtime_version: VERSION,173        can_author_with: Default::default(),174    }175}176177/// Provides a membership set with only the configured aura users178pub struct ValiudatorsOnly<Runtime: pallet_aura::Config>(PhantomData<Runtime>);179impl frame_support::traits::Contains<AccountId> for ValiudatorsOnly<Runtime> {180	fn contains(t: &AccountId) -> bool {181        let arr: [u8; 32] = *t.as_ref();182        let raw_key: Vec<u8> = Vec::from(arr);183184        match pallet_aura::Module::<Runtime>::authorities().iter().find(|auth| auth.to_raw_vec() == raw_key) {185            Some(_) => true,186            None => false,187        }  188	}189	fn sorted_members() -> Vec<AccountId> {190        let mut members: Vec<AccountId> = Vec::new();191        for auth in pallet_aura::Module::<Runtime>::authorities() {192            let mut arr: [u8; 32] = Default::default(); 193            let bor_arr = auth.clone().to_raw_vec();194            let slice = bor_arr.as_slice();195            arr.copy_from_slice(slice);196            members.push(AccountId::from(arr));197        }198        members  199	}200	fn count() -> usize {201        pallet_aura::Module::<Runtime>::authorities().len()202	}203}204205impl frame_support::traits::ContainsLengthBound for ValiudatorsOnly<Runtime> {206	fn min_len() -> usize {207		1208	}209	fn max_len() -> usize {210		100211	}212}213214type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;215216pub struct DealWithFees;217impl OnUnbalanced<NegativeImbalance> for DealWithFees {218	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {219		if let Some(fees) = fees_then_tips.next() {220			// for fees, 100% to treasury221			let mut split = fees.ration(100, 0);222			if let Some(tips) = fees_then_tips.next() {223				// for tips, if any, 100% to treasury224				tips.ration_merge_into(100, 0, &mut split);225			}226			Treasury::on_unbalanced(split.0);227			// Author::on_unbalanced(split.1);228		}229	}230}231232/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.233/// This is used to limit the maximal weight of a single extrinsic.234const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);235/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used236/// by  Operational  extrinsics.237const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);238/// We allow for 2 seconds of compute with a 6 second average block time.239const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;240241parameter_types! {242    pub const BlockHashCount: BlockNumber = 2400;243	pub RuntimeBlockLength: BlockLength =244		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);245    pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);246    pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;247	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()248		.base_block(BlockExecutionWeight::get())249		.for_class(DispatchClass::all(), |weights| {250			weights.base_extrinsic = ExtrinsicBaseWeight::get();251		})252		.for_class(DispatchClass::Normal, |weights| {253			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);254		})255		.for_class(DispatchClass::Operational, |weights| {256			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);257			// Operational transactions have some extra reserved space, so that they258			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.259			weights.reserved = Some(260				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT261			);262		})263		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)264		.build_or_panic();265    pub const Version: RuntimeVersion = VERSION;266    pub const SS58Prefix: u8 = 42;267}268269impl system::Config for Runtime {270    /// The basic call filter to use in dispatchable.271    type BaseCallFilter = ();272    /// The identifier used to distinguish between accounts.273    type AccountId = AccountId;274    /// The aggregated dispatch type that is available for extrinsics.275    type Call = Call;276    /// The lookup mechanism to get account ID from whatever is passed in dispatchers.277    type Lookup = IdentityLookup<AccountId>;278    /// The index type for storing how many extrinsics an account has signed.279    type Index = Index;280    /// The index type for blocks.281    type BlockNumber = BlockNumber;282    /// The type for hashing blocks and tries.283    type Hash = Hash;284    /// The hashing algorithm used.285    type Hashing = BlakeTwo256;286    /// The header type.287    type Header = generic::Header<BlockNumber, BlakeTwo256>;288    /// The ubiquitous event type.289    type Event = Event;290    /// The ubiquitous origin type.291    type Origin = Origin;292    /// Maximum number of block number to block hash mappings to keep (oldest pruned first).293    type BlockHashCount = BlockHashCount;294    /// The weight of database operations that the runtime can invoke.295    type DbWeight = RocksDbWeight;296    /// The weight of the overhead invoked on the block import process, independent of the297    /// extrinsics included in that block.298	type BlockWeights = RuntimeBlockWeights;299    /// Version of the runtime.300    type Version = Version;301 	/// This type is being generated by `construct_runtime!`.302    type PalletInfo = PalletInfo;303    /// What to do if a new account is created.304    type OnNewAccount = ();305    /// What to do if an account is fully reaped from the system.306    type OnKilledAccount = ();307    /// The data to be stored in an account.308    type AccountData = pallet_balances::AccountData<Balance>;309	/// Weight information for the extrinsics of this pallet.310    type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;311    312	type BlockLength = RuntimeBlockLength;313	type SS58Prefix = SS58Prefix;314}315316impl pallet_aura::Config for Runtime {317    type AuthorityId = AuraId;318}319320impl pallet_grandpa::Config for Runtime {321	type Event = Event;322	type Call = Call;323324	type KeyOwnerProofSystem = ();325326	type KeyOwnerProof =327		<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;328329	type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(330		KeyTypeId,331		GrandpaId,332	)>>::IdentificationTuple;333334	type HandleEquivocation = ();335336	type WeightInfo = ();337}338339parameter_types! {340    pub const MinimumPeriod: u64 = SLOT_DURATION / 2;341}342343impl pallet_timestamp::Config for Runtime {344	/// A timestamp: milliseconds since the unix epoch.345	type Moment = u64;346	type OnTimestampSet = Aura;347	type MinimumPeriod = MinimumPeriod;348	type WeightInfo = ();349}350351parameter_types! {352    // pub const ExistentialDeposit: u128 = 500;353    pub const ExistentialDeposit: u128 = 0;354	pub const MaxLocks: u32 = 50;355}356357impl pallet_balances::Config for Runtime {358	type MaxLocks = MaxLocks;359	/// The type for recording an account's balance.360	type Balance = Balance;361	/// The ubiquitous event type.362	type Event = Event;363	type DustRemoval = Treasury;364	type ExistentialDeposit = ExistentialDeposit;365	type AccountStore = System;366	type WeightInfo = ();367}368369pub const MICROUNIQUE: Balance = 1_000_000_000;370pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;371pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;372pub const UNIQUE: Balance      = 100 * CENTIUNIQUE;373374pub const fn deposit(items: u32, bytes: u32) -> Balance {375    items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE376}377378parameter_types! {379	pub const TombstoneDeposit: Balance = deposit(380		0,381		sp_std::mem::size_of::<pallet_contracts::ContractInfo<Runtime>>() as u32382	);383	pub const DepositPerContract: Balance = TombstoneDeposit::get();384	pub const DepositPerStorageByte: Balance = deposit(0, 1);385	pub const DepositPerStorageItem: Balance = deposit(1, 0);386	pub RentFraction: Perbill = Perbill::from_rational_approximation(1u32, 30 * DAYS);387	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;388	pub const SignedClaimHandicap: u32 = 2;389	pub const MaxDepth: u32 = 32;390	pub const MaxValueSize: u32 = 16 * 1024;391	// The lazy deletion runs inside on_initialize.392	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *393		RuntimeBlockWeights::get().max_block;394	// The weight needed for decoding the queue should be less or equal than a fifth395	// of the overall weight dedicated to the lazy deletion.396	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (397			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -398			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)399		)) / 5) as u32;400}401402403impl pallet_contracts::Config for Runtime {404	type Time = Timestamp;405	type Randomness = RandomnessCollectiveFlip;406	type Currency = Balances;407	type Event = Event;408	type RentPayment = ();409	type SignedClaimHandicap = SignedClaimHandicap;410	type TombstoneDeposit = TombstoneDeposit;411	type DepositPerContract = DepositPerContract;412	type DepositPerStorageByte = DepositPerStorageByte;413	type DepositPerStorageItem = DepositPerStorageItem;414	type RentFraction = RentFraction;415	type SurchargeReward = SurchargeReward;416	type MaxDepth = MaxDepth;417	type MaxValueSize = MaxValueSize;418	type WeightPrice = pallet_transaction_payment::Module<Self>;419	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;420	type ChainExtension = NFTExtension;421	type DeletionQueueDepth = DeletionQueueDepth;422	type DeletionWeightLimit = DeletionWeightLimit;423}424425parameter_types! {426	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer 427}428429/// Linear implementor of `WeightToFeePolynomial` 430pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);431432impl<T> WeightToFeePolynomial for LinearFee<T> where433	T: BaseArithmetic + From<u32> + Copy + Unsigned434{435	type Balance = T;436437	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {438		smallvec!(WeightToFeeCoefficient {439			coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer440			coeff_frac: Perbill::zero(),441			negative: false,442			degree: 1,443		})444	}445}446447impl pallet_transaction_payment::Config for Runtime {448	type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees>;449	type TransactionByteFee = TransactionByteFee;450	type WeightToFee = LinearFee<Balance>;451	type FeeMultiplierUpdate = ();452}453454parameter_types! {455	pub const ProposalBond: Permill = Permill::from_percent(5);456	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;457	pub const SpendPeriod: BlockNumber = 5 * MINUTES;458	pub const Burn: Permill = Permill::from_percent(0);459	pub const TipCountdown: BlockNumber = 1 * DAYS;460	pub const TipFindersFee: Percent = Percent::from_percent(20);461	pub const TipReportDepositBase: Balance = 1 * UNIQUE;462	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;463	pub const BountyDepositBase: Balance = 1 * UNIQUE;464	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;465	pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");466	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;467	pub const MaximumReasonLength: u32 = 16384;468	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);469	pub const BountyValueMinimum: Balance = 5 * UNIQUE;470}471472impl pallet_treasury::Config for Runtime {473	type ModuleId = TreasuryModuleId;474	type Currency = Balances;475	type ApproveOrigin = EnsureRoot<AccountId>;476	type RejectOrigin = EnsureRoot<AccountId>;477	type Event = Event;478	type OnSlash = ();479	type ProposalBond = ProposalBond;480	type ProposalBondMinimum = ProposalBondMinimum;481	type SpendPeriod = SpendPeriod;482	type Burn = Burn;483	type BurnDestination = ();484	type SpendFunds = ();485	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;486}487488impl pallet_sudo::Config for Runtime {489    type Event = Event;490    type Call = Call;491}492493parameter_types! {494	pub const MinVestedTransfer: Balance = 10 * UNIQUE;495}496497impl pallet_vesting::Config for Runtime {498	type Event = Event;499	type Currency = Balances;500	type BlockNumberToBalance = ConvertInto;501	type MinVestedTransfer = MinVestedTransfer;502	type WeightInfo = ();503}504505/// Used for the module nft in `./nft.rs`506impl pallet_nft::Config for Runtime {507    type Event = Event;508    type WeightInfo = nft_weights::WeightInfo;509}510511construct_runtime!(512    pub enum Runtime where513        Block = Block,514        NodeBlock = opaque::Block,515        UncheckedExtrinsic = UncheckedExtrinsic516    {517        System: system::{Module, Call, Config, Storage, Event<T>},518        RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},519        Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},520        Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},521        Aura: pallet_aura::{Module, Config<T>, Inherent},522        Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},523        Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},524        TransactionPayment: pallet_transaction_payment::{Module, Storage},525        Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},526        Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},527        Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},528        Vesting: pallet_vesting::{Module, Call, Config<T>, Storage, Event<T>},529    }530);531532/// The address format for describing accounts.533pub type Address = AccountId;534/// Block header type as expected by this runtime.535pub type Header = generic::Header<BlockNumber, BlakeTwo256>;536/// Block type as expected by this runtime.537pub type Block = generic::Block<Header, UncheckedExtrinsic>;538/// A Block signed with a Justification539pub type SignedBlock = generic::SignedBlock<Block>;540/// BlockId type as expected by this runtime.541pub type BlockId = generic::BlockId<Block>;542/// The SignedExtension to the basic transaction logic.543pub type SignedExtra = (544    system::CheckSpecVersion<Runtime>,545    system::CheckTxVersion<Runtime>,546    system::CheckGenesis<Runtime>,547    system::CheckEra<Runtime>,548    system::CheckNonce<Runtime>,549    system::CheckWeight<Runtime>,550    pallet_nft::ChargeTransactionPayment<Runtime>,551);552/// Unchecked extrinsic type as expected by this runtime.553pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;554/// Extrinsic type that has already been checked.555pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;556/// Executive: handles dispatch to the various modules.557pub type Executive =558    frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;559560impl_runtime_apis! {561562	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>563		for Runtime564	{565		fn call(566			origin: AccountId,567			dest: AccountId,568			value: Balance,569			gas_limit: u64,570			input_data: Vec<u8>,571		) -> pallet_contracts_primitives::ContractExecResult {572			Contracts::bare_call(origin, dest, value, gas_limit, input_data)573		}574575		fn get_storage(576			address: AccountId,577			key: [u8; 32],578		) -> pallet_contracts_primitives::GetStorageResult {579			Contracts::get_storage(address, key)580		}581582		fn rent_projection(583			address: AccountId,584		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {585			Contracts::rent_projection(address)586		}587	}588589    impl sp_api::Core<Block> for Runtime {590        fn version() -> RuntimeVersion {591            VERSION592        }593594        fn execute_block(block: Block) {595            Executive::execute_block(block)596        }597598        fn initialize_block(header: &<Block as BlockT>::Header) {599            Executive::initialize_block(header)600        }601    }602603    impl sp_api::Metadata<Block> for Runtime {604        fn metadata() -> OpaqueMetadata {605            Runtime::metadata().into()606        }607    }608609    impl sp_block_builder::BlockBuilder<Block> for Runtime {610        fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {611            Executive::apply_extrinsic(extrinsic)612        }613614        fn finalize_block() -> <Block as BlockT>::Header {615            Executive::finalize_block()616        }617618        fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {619            data.create_extrinsics()620        }621622        fn check_inherents(623            block: Block,624            data: sp_inherents::InherentData,625        ) -> sp_inherents::CheckInherentsResult {626            data.check_extrinsics(&block)627        }628629        fn random_seed() -> <Block as BlockT>::Hash {630            RandomnessCollectiveFlip::random_seed()631        }632    }633634    impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {635        fn validate_transaction(636            source: TransactionSource,637            tx: <Block as BlockT>::Extrinsic,638        ) -> TransactionValidity {639            Executive::validate_transaction(source, tx)640        }641    }642643    impl sp_offchain::OffchainWorkerApi<Block> for Runtime {644        fn offchain_worker(header: &<Block as BlockT>::Header) {645            Executive::offchain_worker(header)646        }647    }648649    impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {650        fn slot_duration() -> u64 {651            Aura::slot_duration()652        }653654        fn authorities() -> Vec<AuraId> {655            Aura::authorities()656        }657    }658659    impl sp_session::SessionKeys<Block> for Runtime {660        fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {661            opaque::SessionKeys::generate(seed)662        }663664        fn decode_session_keys(665            encoded: Vec<u8>,666        ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {667            opaque::SessionKeys::decode_into_raw_public_keys(&encoded)668        }669    }670671	impl fg_primitives::GrandpaApi<Block> for Runtime {672		fn grandpa_authorities() -> GrandpaAuthorityList {673			Grandpa::grandpa_authorities()674		}675676		fn submit_report_equivocation_unsigned_extrinsic(677			_equivocation_proof: fg_primitives::EquivocationProof<678				<Block as BlockT>::Hash,679				NumberFor<Block>,680			>,681			_key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,682		) -> Option<()> {683			None684		}685686		fn generate_key_ownership_proof(687			_set_id: fg_primitives::SetId,688			_authority_id: GrandpaId,689		) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {690			// NOTE: this is the only implementation possible since we've691			// defined our key owner proof type as a bottom type (i.e. a type692			// with no values).693			None694		}695    }696    697	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {698		fn account_nonce(account: AccountId) -> Index {699			System::account_nonce(account)700		}701	}702703	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {704		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {705			TransactionPayment::query_info(uxt, len)706		}707		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {708			TransactionPayment::query_fee_details(uxt, len)709		}710	}711712    #[cfg(feature = "runtime-benchmarks")]713	impl frame_benchmarking::Benchmark<Block> for Runtime {714		fn dispatch_benchmark(715			config: frame_benchmarking::BenchmarkConfig716		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {717			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};718719			let whitelist: Vec<TrackedStorageKey> = vec![720				// Alice account721				hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),722				// // Total Issuance723				// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),724				// // Execution Phase725				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),726				// // Event Count727				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),728				// // System Events729				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),730            ];731732			let mut batches = Vec::<BenchmarkBatch>::new();733			let params = (&config, &whitelist);734735			add_benchmark!(params, batches, pallet_nft, Nft);736737			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }738			Ok(batches)739		}740	}741}