lib.rs 112 KiB
Newer Older
Xiliang Chen's avatar
Xiliang Chen committed
parameter_types! {
	pub const MaxFellows: u32 = AllianceMaxMembers::get();
Xiliang Chen's avatar
Xiliang Chen committed
	pub const MaxAllies: u32 = 100;
	pub const AllyDeposit: Balance = 10 * DOLLARS;
	pub const RetirementPeriod: BlockNumber = ALLIANCE_MOTION_DURATION_IN_BLOCKS + (1 * DAYS);
Xiliang Chen's avatar
Xiliang Chen committed
}

impl pallet_alliance::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type Proposal = RuntimeCall;
Xiliang Chen's avatar
Xiliang Chen committed
	type AdminOrigin = EitherOfDiverse<
		EnsureRoot<AccountId>,
		pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
	>;
	type MembershipManager = EitherOfDiverse<
		EnsureRoot<AccountId>,
		pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
	>;
	type AnnouncementOrigin = EitherOfDiverse<
		EnsureRoot<AccountId>,
		pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
	>;
	type Currency = Balances;
	type Slashed = Treasury;
	type InitializeMembers = AllianceMotion;
	type MembershipChanged = AllianceMotion;
	#[cfg(not(feature = "runtime-benchmarks"))]
	type IdentityVerifier = AllianceIdentityVerifier;
	#[cfg(feature = "runtime-benchmarks")]
	type IdentityVerifier = ();
	type ProposalProvider = AllianceProposalProvider;
	type MaxProposals = AllianceMaxProposals;
	type MaxFellows = MaxFellows;
	type MaxAllies = MaxAllies;
	type MaxUnscrupulousItems = ConstU32<100>;
	type MaxWebsiteUrlLength = ConstU32<255>;
	type MaxAnnouncementsCount = ConstU32<100>;
	type MaxMembersCount = AllianceMaxMembers;
	type AllyDeposit = AllyDeposit;
	type WeightInfo = pallet_alliance::weights::SubstrateWeight<Runtime>;
	type RetirementPeriod = RetirementPeriod;
impl frame_benchmarking_pallet_pov::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
}

parameter_types! {
	pub StatementCost: Balance = 1 * DOLLARS;
	pub StatementByteCost: Balance = 100 * MILLICENTS;
	pub const MinAllowedStatements: u32 = 4;
	pub const MaxAllowedStatements: u32 = 10;
	pub const MinAllowedBytes: u32 = 1024;
	pub const MaxAllowedBytes: u32 = 4096;
}

impl pallet_statement::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type Currency = Balances;
	type StatementCost = StatementCost;
	type ByteCost = StatementByteCost;
	type MinAllowedStatements = MinAllowedStatements;
	type MaxAllowedStatements = MaxAllowedStatements;
	type MinAllowedBytes = MinAllowedBytes;
	type MaxAllowedBytes = MaxAllowedBytes;
}

parameter_types! {
	pub MbmServiceWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
}

impl pallet_migrations::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
	#[cfg(not(feature = "runtime-benchmarks"))]
	type Migrations = ();
	// Benchmarks need mocked migrations to guarantee that they succeed.
	#[cfg(feature = "runtime-benchmarks")]
	type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
	type CursorMaxLen = ConstU32<65_536>;
	type IdentifierMaxLen = ConstU32<256>;
	type MigrationStatusHandler = ();
	type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
	type MaxServiceWeight = MbmServiceWeight;
	type WeightInfo = pallet_migrations::weights::SubstrateWeight<Runtime>;
}

parameter_types! {
	pub const BrokerPalletId: PalletId = PalletId(*b"py/broke");
}

pub struct IntoAuthor;
impl OnUnbalanced<Credit<AccountId, Balances>> for IntoAuthor {
	fn on_nonzero_unbalanced(credit: Credit<AccountId, Balances>) {
		if let Some(author) = Authorship::author() {
			let _ = <Balances as Balanced<_>>::resolve(&author, credit);
		}
	}
}

parameter_types! {
	pub storage CoretimeRevenue: Option<(BlockNumber, Balance)> = None;
}

pub struct CoretimeProvider;
impl CoretimeInterface for CoretimeProvider {
	type AccountId = AccountId;
	type Balance = Balance;
	type RelayChainBlockNumberProvider = System;
	fn request_core_count(_count: CoreIndex) {}
	fn request_revenue_info_at(_when: u32) {}
	fn credit_account(_who: Self::AccountId, _amount: Self::Balance) {}
	fn assign_core(
		_core: CoreIndex,
		_begin: u32,
		_assignment: Vec<(CoreAssignment, PartsOf57600)>,
		_end_hint: Option<u32>,
	fn check_notify_revenue_info() -> Option<(u32, Self::Balance)> {
		let revenue = CoretimeRevenue::get();
		CoretimeRevenue::set(&None);
		revenue
	}
	#[cfg(feature = "runtime-benchmarks")]
	fn ensure_notify_revenue_info(when: u32, revenue: Self::Balance) {
		CoretimeRevenue::set(&Some((when, revenue)));
	}
}

impl pallet_broker::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type Currency = Balances;
	type OnRevenue = IntoAuthor;
	type TimeslicePeriod = ConstU32<2>;
	type MaxLeasedCores = ConstU32<5>;
	type MaxReservedCores = ConstU32<5>;
	type Coretime = CoretimeProvider;
	type ConvertBalance = traits::Identity;
	type WeightInfo = ();
	type PalletId = BrokerPalletId;
	type AdminOrigin = EnsureRoot<AccountId>;
	type PriceAdapter = pallet_broker::Linear;
}

David Emett's avatar
David Emett committed
parameter_types! {
	pub const MixnetNumCoverToCurrentBlocks: BlockNumber = 3;
	pub const MixnetNumRequestsToCurrentBlocks: BlockNumber = 3;
	pub const MixnetNumCoverToPrevBlocks: BlockNumber = 3;
	pub const MixnetNumRegisterStartSlackBlocks: BlockNumber = 3;
	pub const MixnetNumRegisterEndSlackBlocks: BlockNumber = 3;
	pub const MixnetRegistrationPriority: TransactionPriority = ImOnlineUnsignedPriority::get() - 1;
}

impl pallet_mixnet::Config for Runtime {
	type MaxAuthorities = MaxAuthorities;
	type MaxExternalAddressSize = ConstU32<128>;
	type MaxExternalAddressesPerMixnode = ConstU32<16>;
	type NextSessionRotation = Babe;
	type NumCoverToCurrentBlocks = MixnetNumCoverToCurrentBlocks;
	type NumRequestsToCurrentBlocks = MixnetNumRequestsToCurrentBlocks;
	type NumCoverToPrevBlocks = MixnetNumCoverToPrevBlocks;
	type NumRegisterStartSlackBlocks = MixnetNumRegisterStartSlackBlocks;
	type NumRegisterEndSlackBlocks = MixnetNumRegisterEndSlackBlocks;
	type RegistrationPriority = MixnetRegistrationPriority;
	type MinMixnodes = ConstU32<7>; // Low to allow small testing networks
}

/// Dynamic parameters that can be changed at runtime through the
/// `pallet_parameters::set_parameter`.
#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::<Runtime>)]
pub mod dynamic_params {
	use super::*;

	#[dynamic_pallet_params]
	#[codec(index = 0)]
	pub mod storage {
		/// Configures the base deposit of storing some data.
		#[codec(index = 0)]
		pub static BaseDeposit: Balance = 1 * DOLLARS;

		/// Configures the per-byte deposit of storing some data.
		#[codec(index = 1)]
		pub static ByteDeposit: Balance = 1 * CENTS;
	}

	#[dynamic_pallet_params]
	#[codec(index = 1)]
	pub mod contracts {
		#[codec(index = 0)]
		pub static DepositPerItem: Balance = deposit(1, 0);

		#[codec(index = 1)]
		pub static DepositPerByte: Balance = deposit(0, 1);

		#[codec(index = 2)]
		pub static DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024);
	}
}

#[cfg(feature = "runtime-benchmarks")]
impl Default for RuntimeParameters {
	fn default() -> Self {
		RuntimeParameters::Storage(dynamic_params::storage::Parameters::BaseDeposit(
			dynamic_params::storage::BaseDeposit,
			Some(1 * DOLLARS),
		))
	}
}

pub struct DynamicParametersManagerOrigin;
impl EnsureOriginWithArg<RuntimeOrigin, RuntimeParametersKey> for DynamicParametersManagerOrigin {
	type Success = ();

	fn try_origin(
		origin: RuntimeOrigin,
		key: &RuntimeParametersKey,
	) -> Result<Self::Success, RuntimeOrigin> {
		match key {
			RuntimeParametersKey::Storage(_) => {
				frame_system::ensure_root(origin.clone()).map_err(|_| origin)?;
				return Ok(())
			},
				frame_system::ensure_root(origin.clone()).map_err(|_| origin)?;
				return Ok(())
			},
		}
	}

	#[cfg(feature = "runtime-benchmarks")]
	fn try_successful_origin(_key: &RuntimeParametersKey) -> Result<RuntimeOrigin, ()> {
		Ok(RuntimeOrigin::root())
	}
}

impl pallet_parameters::Config for Runtime {
	type RuntimeParameters = RuntimeParameters;
	type RuntimeEvent = RuntimeEvent;
	type AdminOrigin = DynamicParametersManagerOrigin;
	type WeightInfo = ();
}

gupnik's avatar
gupnik committed
#[frame_support::runtime]
mod runtime {
	#[runtime::runtime]
	#[runtime::derive(
		RuntimeCall,
		RuntimeEvent,
		RuntimeError,
		RuntimeOrigin,
		RuntimeFreezeReason,
		RuntimeHoldReason,
		RuntimeSlashReason,
		RuntimeLockId,
		RuntimeTask
	)]
	pub struct Runtime;

	#[runtime::pallet_index(0)]
	pub type System = frame_system;

	#[runtime::pallet_index(1)]
	pub type Utility = pallet_utility;

	#[runtime::pallet_index(2)]
	pub type Babe = pallet_babe;

	#[runtime::pallet_index(3)]
	pub type Timestamp = pallet_timestamp;

	// Authorship must be before session in order to note author in the correct session and era
	// for im-online and staking.
	#[runtime::pallet_index(4)]
	pub type Authorship = pallet_authorship;

	#[runtime::pallet_index(5)]
	pub type Indices = pallet_indices;

	#[runtime::pallet_index(6)]
	pub type Balances = pallet_balances;

	#[runtime::pallet_index(7)]
	pub type TransactionPayment = pallet_transaction_payment;

	#[runtime::pallet_index(8)]
	pub type AssetTxPayment = pallet_asset_tx_payment;

	#[runtime::pallet_index(9)]
	pub type AssetConversionTxPayment = pallet_asset_conversion_tx_payment;

	#[runtime::pallet_index(10)]
	pub type ElectionProviderMultiPhase = pallet_election_provider_multi_phase;

	#[runtime::pallet_index(11)]
	pub type Staking = pallet_staking;

	#[runtime::pallet_index(12)]
	pub type Session = pallet_session;

	#[runtime::pallet_index(13)]
	pub type Democracy = pallet_democracy;

	#[runtime::pallet_index(14)]
	pub type Council = pallet_collective<Instance1>;

	#[runtime::pallet_index(15)]
	pub type TechnicalCommittee = pallet_collective<Instance2>;

	#[runtime::pallet_index(16)]
	pub type Elections = pallet_elections_phragmen;

	#[runtime::pallet_index(17)]
	pub type TechnicalMembership = pallet_membership<Instance1>;

	#[runtime::pallet_index(18)]
	pub type Grandpa = pallet_grandpa;

	#[runtime::pallet_index(19)]
	pub type Treasury = pallet_treasury;

	#[runtime::pallet_index(20)]
	pub type AssetRate = pallet_asset_rate;

	#[runtime::pallet_index(21)]
	pub type Contracts = pallet_contracts;

	#[runtime::pallet_index(22)]
	pub type Sudo = pallet_sudo;

	#[runtime::pallet_index(23)]
	pub type ImOnline = pallet_im_online;

	#[runtime::pallet_index(24)]
	pub type AuthorityDiscovery = pallet_authority_discovery;

	#[runtime::pallet_index(25)]
	pub type Offences = pallet_offences;

	#[runtime::pallet_index(26)]
	pub type Historical = pallet_session_historical;

	#[runtime::pallet_index(27)]
	pub type RandomnessCollectiveFlip = pallet_insecure_randomness_collective_flip;

	#[runtime::pallet_index(28)]
	pub type Identity = pallet_identity;

	#[runtime::pallet_index(29)]
	pub type Society = pallet_society;

	#[runtime::pallet_index(30)]
	pub type Recovery = pallet_recovery;

	#[runtime::pallet_index(31)]
	pub type Vesting = pallet_vesting;

	#[runtime::pallet_index(32)]
	pub type Scheduler = pallet_scheduler;

	#[runtime::pallet_index(33)]
	pub type Glutton = pallet_glutton;

	#[runtime::pallet_index(34)]
	pub type Preimage = pallet_preimage;

	#[runtime::pallet_index(35)]
	pub type Proxy = pallet_proxy;

	#[runtime::pallet_index(36)]
	pub type Multisig = pallet_multisig;

	#[runtime::pallet_index(37)]
	pub type Bounties = pallet_bounties;

	#[runtime::pallet_index(38)]
	pub type Tips = pallet_tips;

	#[runtime::pallet_index(39)]
	pub type Assets = pallet_assets<Instance1>;

	#[runtime::pallet_index(40)]
	pub type PoolAssets = pallet_assets<Instance2>;

	#[runtime::pallet_index(41)]
	pub type Beefy = pallet_beefy;

	// MMR leaf construction must be after session in order to have a leaf's next_auth_set
	// refer to block<N>. See issue polkadot-fellows/runtimes#160 for details.
	#[runtime::pallet_index(42)]
	pub type Mmr = pallet_mmr;

	#[runtime::pallet_index(43)]
	pub type MmrLeaf = pallet_beefy_mmr;

	#[runtime::pallet_index(44)]
	pub type Lottery = pallet_lottery;

	#[runtime::pallet_index(45)]
	pub type Nis = pallet_nis;

	#[runtime::pallet_index(46)]
	pub type Uniques = pallet_uniques;

	#[runtime::pallet_index(47)]
	pub type Nfts = pallet_nfts;

	#[runtime::pallet_index(48)]
	pub type NftFractionalization = pallet_nft_fractionalization;

	#[runtime::pallet_index(49)]
	pub type Salary = pallet_salary;

	#[runtime::pallet_index(50)]
	pub type CoreFellowship = pallet_core_fellowship;

	#[runtime::pallet_index(51)]
	pub type TransactionStorage = pallet_transaction_storage;

	#[runtime::pallet_index(52)]
	pub type VoterList = pallet_bags_list<Instance1>;

	#[runtime::pallet_index(53)]
	pub type StateTrieMigration = pallet_state_trie_migration;

	#[runtime::pallet_index(54)]
	pub type ChildBounties = pallet_child_bounties;

	#[runtime::pallet_index(55)]
	pub type Referenda = pallet_referenda;

	#[runtime::pallet_index(56)]
	pub type Remark = pallet_remark;

	#[runtime::pallet_index(57)]
	pub type RootTesting = pallet_root_testing;

	#[runtime::pallet_index(58)]
	pub type ConvictionVoting = pallet_conviction_voting;

	#[runtime::pallet_index(59)]
	pub type Whitelist = pallet_whitelist;

	#[runtime::pallet_index(60)]
	pub type AllianceMotion = pallet_collective<Instance3>;

	#[runtime::pallet_index(61)]
	pub type Alliance = pallet_alliance;

	#[runtime::pallet_index(62)]
	pub type NominationPools = pallet_nomination_pools;

	#[runtime::pallet_index(63)]
	pub type RankedPolls = pallet_referenda<Instance2>;

	#[runtime::pallet_index(64)]
	pub type RankedCollective = pallet_ranked_collective;

	#[runtime::pallet_index(65)]
	pub type AssetConversion = pallet_asset_conversion;

	#[runtime::pallet_index(66)]
	pub type FastUnstake = pallet_fast_unstake;

	#[runtime::pallet_index(67)]
	pub type MessageQueue = pallet_message_queue;

	#[runtime::pallet_index(68)]
	pub type Pov = frame_benchmarking_pallet_pov;

	#[runtime::pallet_index(69)]
	pub type TxPause = pallet_tx_pause;

	#[runtime::pallet_index(70)]
	pub type SafeMode = pallet_safe_mode;

	#[runtime::pallet_index(71)]
	pub type Statement = pallet_statement;

	#[runtime::pallet_index(72)]
	pub type MultiBlockMigrations = pallet_migrations;

	#[runtime::pallet_index(73)]
	pub type Broker = pallet_broker;

	#[runtime::pallet_index(74)]
	pub type TasksExample = pallet_example_tasks;

	#[runtime::pallet_index(75)]
	pub type Mixnet = pallet_mixnet;

	#[runtime::pallet_index(76)]
	pub type Parameters = pallet_parameters;

	#[runtime::pallet_index(77)]
	pub type SkipFeelessPayment = pallet_skip_feeless_payment;

	#[runtime::pallet_index(78)]
	pub type PalletExampleMbms = pallet_example_mbm;

	#[runtime::pallet_index(79)]
	pub type AssetConversionMigration = pallet_asset_conversion_ops;
gupnik's avatar
gupnik committed
}
/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, AccountIndex>;
Gav Wood's avatar
Gav Wood committed
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
Gav Wood's avatar
Gav Wood committed
/// Block type as expected by this runtime.
Gav Wood's avatar
Gav Wood committed
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification
pub type SignedBlock = generic::SignedBlock<Block>;
/// BlockId type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic.
///
/// When you change this, you **MUST** modify [`sign`] in `bin/node/testing/src/keyring.rs`!
///
/// [`sign`]: <../../testing/src/keyring.rs.html>
pub type SignedExtra = (
	frame_system::CheckNonZeroSender<Runtime>,
	frame_system::CheckSpecVersion<Runtime>,
	frame_system::CheckTxVersion<Runtime>,
	frame_system::CheckGenesis<Runtime>,
	frame_system::CheckEra<Runtime>,
	frame_system::CheckNonce<Runtime>,
	frame_system::CheckWeight<Runtime>,
	pallet_skip_feeless_payment::SkipCheckIfFeeless<
		Runtime,
		pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
	>,
Gav Wood's avatar
Gav Wood committed
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
Gav Wood's avatar
Gav Wood committed
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
	Runtime,
	Block,
	frame_system::ChainContext<Runtime>,
	Runtime,
	AllPalletsWithSystem,
// We don't have a limit in the Relay Chain.
const IDENTITY_MIGRATION_KEY_LIMIT: u64 = u64::MAX;

// All migrations executed on runtime upgrade as a nested tuple of types implementing
// `OnRuntimeUpgrade`. Note: These are examples and do not need to be run directly
// after the genesis block.
	pallet_nomination_pools::migration::versioned::V6ToV7<Runtime>,
	pallet_alliance::migration::Migration<Runtime>,
	pallet_identity::migration::versioned::V0ToV1<Runtime, IDENTITY_MIGRATION_KEY_LIMIT>,
type EventRecord = frame_system::EventRecord<
	<Runtime as frame_system::Config>::RuntimeEvent,
	<Runtime as frame_system::Config>::Hash,
>;

parameter_types! {
	pub const BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
}

impl pallet_beefy::Config for Runtime {
	type BeefyId = BeefyId;
	type MaxAuthorities = MaxAuthorities;
	type MaxNominators = ConstU32<0>;
	type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
	type OnNewValidatorSet = MmrLeaf;
	type WeightInfo = ();
	type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, BeefyId)>>::Proof;
	type EquivocationReportSystem =
		pallet_beefy::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
}

/// MMR helper types.
mod mmr {
	use super::Runtime;
	pub use pallet_mmr::primitives::*;

	pub type Leaf = <<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider>::LeafData;
	pub type Hash = <Hashing as sp_runtime::traits::Hash>::Output;
	pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
}

#[cfg(feature = "runtime-benchmarks")]
mod benches {
	frame_benchmarking::define_benchmarks!(
		[frame_benchmarking, BaselineBench::<Runtime>]
		[frame_benchmarking_pallet_pov, Pov]
		[pallet_alliance, Alliance]
		[pallet_assets, Assets]
		[pallet_babe, Babe]
		[pallet_bags_list, VoterList]
		[pallet_balances, Balances]
		[pallet_bounties, Bounties]
		[pallet_broker, Broker]
		[pallet_child_bounties, ChildBounties]
		[pallet_collective, Council]
		[pallet_conviction_voting, ConvictionVoting]
		[pallet_contracts, Contracts]
		[pallet_core_fellowship, CoreFellowship]
		[pallet_democracy, Democracy]
		[pallet_asset_conversion, AssetConversion]
		[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
		[pallet_election_provider_support_benchmarking, EPSBench::<Runtime>]
		[pallet_elections_phragmen, Elections]
		[pallet_fast_unstake, FastUnstake]
		[pallet_nis, Nis]
		[pallet_parameters, Parameters]
		[pallet_grandpa, Grandpa]
		[pallet_identity, Identity]
		[pallet_im_online, ImOnline]
		[pallet_indices, Indices]
		[pallet_lottery, Lottery]
		[pallet_membership, TechnicalMembership]
		[pallet_message_queue, MessageQueue]
		[pallet_migrations, MultiBlockMigrations]
		[pallet_mmr, Mmr]
		[pallet_multisig, Multisig]
Zeke Mostov's avatar
Zeke Mostov committed
		[pallet_nomination_pools, NominationPoolsBench::<Runtime>]
		[pallet_offences, OffencesBench::<Runtime>]
		[pallet_preimage, Preimage]
		[pallet_proxy, Proxy]
		[pallet_ranked_collective, RankedCollective]
		[pallet_referenda, Referenda]
		[pallet_recovery, Recovery]
		[pallet_remark, Remark]
Gavin Wood's avatar
Gavin Wood committed
		[pallet_salary, Salary]
		[pallet_scheduler, Scheduler]
Sergej Sakac's avatar
Sergej Sakac committed
		[pallet_glutton, Glutton]
		[pallet_session, SessionBench::<Runtime>]
Gavin Wood's avatar
Gavin Wood committed
		[pallet_society, Society]
		[pallet_staking, Staking]
		[pallet_state_trie_migration, StateTrieMigration]
		[pallet_sudo, Sudo]
		[frame_system, SystemBench::<Runtime>]
		[pallet_timestamp, Timestamp]
		[pallet_tips, Tips]
		[pallet_transaction_storage, TransactionStorage]
		[pallet_treasury, Treasury]
		[pallet_asset_rate, AssetRate]
		[pallet_uniques, Uniques]
Jegor Sidorenko's avatar
Jegor Sidorenko committed
		[pallet_nfts, Nfts]
		[pallet_nft_fractionalization, NftFractionalization]
		[pallet_utility, Utility]
		[pallet_vesting, Vesting]
		[pallet_whitelist, Whitelist]
		[pallet_tx_pause, TxPause]
		[pallet_safe_mode, SafeMode]
		[pallet_example_mbm, PalletExampleMbms]
		[pallet_asset_conversion_ops, AssetConversionMigration]
	impl sp_api::Core<Block> for Runtime {
		fn version() -> RuntimeVersion {
			VERSION
		}
		fn execute_block(block: Block) {
		fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
			Executive::initialize_block(header)
	impl sp_api::Metadata<Block> for Runtime {
		fn metadata() -> OpaqueMetadata {
			OpaqueMetadata::new(Runtime::metadata().into())

		fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
			Runtime::metadata_at_version(version)
		}

		fn metadata_versions() -> sp_std::vec::Vec<u32> {
			Runtime::metadata_versions()
		}
	impl sp_block_builder::BlockBuilder<Block> for Runtime {
		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
			Executive::apply_extrinsic(extrinsic)
		}

		fn finalize_block() -> <Block as BlockT>::Header {
			Executive::finalize_block()
		fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
			data.create_extrinsics()
		fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
			data.check_extrinsics(&block)
	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
		fn validate_transaction(
			source: TransactionSource,
			tx: <Block as BlockT>::Extrinsic,
			block_hash: <Block as BlockT>::Hash,
		) -> TransactionValidity {
			Executive::validate_transaction(source, tx, block_hash)
	impl sp_statement_store::runtime_api::ValidateStatement<Block> for Runtime {
		fn validate_statement(
			source: sp_statement_store::runtime_api::StatementSource,
			statement: sp_statement_store::Statement,
		) -> Result<sp_statement_store::runtime_api::ValidStatement, sp_statement_store::runtime_api::InvalidStatement> {
			Statement::validate_statement(source, statement)
		}
	}

	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
		fn offchain_worker(header: &<Block as BlockT>::Header) {
			Executive::offchain_worker(header)
	impl sp_consensus_grandpa::GrandpaApi<Block> for Runtime {
		fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList {
		fn current_set_id() -> sp_consensus_grandpa::SetId {
			Grandpa::current_set_id()
		}

		fn submit_report_equivocation_unsigned_extrinsic(
			equivocation_proof: sp_consensus_grandpa::EquivocationProof<
				<Block as BlockT>::Hash,
				NumberFor<Block>,
			>,
			key_owner_proof: sp_consensus_grandpa::OpaqueKeyOwnershipProof,
		) -> Option<()> {
			let key_owner_proof = key_owner_proof.decode()?;

			Grandpa::submit_unsigned_equivocation_report(
				equivocation_proof,
				key_owner_proof,
			)
		}

		fn generate_key_ownership_proof(
			_set_id: sp_consensus_grandpa::SetId,
			authority_id: GrandpaId,
		) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
			use codec::Encode;

			Historical::prove((sp_consensus_grandpa::KEY_TYPE, authority_id))
				.map(|p| p.encode())
				.map(sp_consensus_grandpa::OpaqueKeyOwnershipProof::new)
	impl pallet_nomination_pools_runtime_api::NominationPoolsApi<Block, AccountId, Balance> for Runtime {
		fn pending_rewards(who: AccountId) -> Balance {
			NominationPools::api_pending_rewards(who).unwrap_or_default()
		}

		fn points_to_balance(pool_id: pallet_nomination_pools::PoolId, points: Balance) -> Balance {
			NominationPools::api_points_to_balance(pool_id, points)
		}

		fn balance_to_points(pool_id: pallet_nomination_pools::PoolId, new_funds: Balance) -> Balance {
			NominationPools::api_balance_to_points(pool_id, new_funds)
		}
	}

	impl pallet_staking_runtime_api::StakingApi<Block, Balance, AccountId> for Runtime {
		fn nominations_quota(balance: Balance) -> u32 {
			Staking::api_nominations_quota(balance)

		fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
			Staking::api_eras_stakers_page_count(era, account)
		}
	impl sp_consensus_babe::BabeApi<Block> for Runtime {
		fn configuration() -> sp_consensus_babe::BabeConfiguration {
			let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
			sp_consensus_babe::BabeConfiguration {
				slot_duration: Babe::slot_duration(),
				epoch_length: EpochDuration::get(),
				c: epoch_config.c,
				authorities: Babe::authorities().to_vec(),
				randomness: Babe::randomness(),
				allowed_slots: epoch_config.allowed_slots,
		fn current_epoch_start() -> sp_consensus_babe::Slot {
			Babe::current_epoch_start()
		}
		fn current_epoch() -> sp_consensus_babe::Epoch {
			Babe::current_epoch()
		}

		fn next_epoch() -> sp_consensus_babe::Epoch {
			Babe::next_epoch()
		}

		fn generate_key_ownership_proof(
			_slot: sp_consensus_babe::Slot,
			authority_id: sp_consensus_babe::AuthorityId,
		) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
			use codec::Encode;

			Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id))
				.map(|p| p.encode())
				.map(sp_consensus_babe::OpaqueKeyOwnershipProof::new)
		}

		fn submit_report_equivocation_unsigned_extrinsic(
			equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>,
			key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
		) -> Option<()> {
			let key_owner_proof = key_owner_proof.decode()?;

			Babe::submit_unsigned_equivocation_report(
				equivocation_proof,
				key_owner_proof,
			)
		}
	impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
		fn authorities() -> Vec<AuthorityDiscoveryId> {
			AuthorityDiscovery::authorities()
		}
	}

	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
		fn account_nonce(account: AccountId) -> Nonce {
	impl assets_api::AssetsApi<
		Block,
		AccountId,
		Balance,
		u32,
	> for Runtime
	{
		fn account_balances(account: AccountId) -> Vec<(u32, Balance)> {
			Assets::account_balances(account)
		}
	}

	impl pallet_contracts::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash, EventRecord> for Runtime
		fn call(
			origin: AccountId,
			dest: AccountId,
			value: Balance,
			gas_limit: Option<Weight>,
			storage_deposit_limit: Option<Balance>,
		) -> pallet_contracts::ContractExecResult<Balance, EventRecord> {
			let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
			Contracts::bare_call(
				origin,
				dest,
				value,
				gas_limit,
				storage_deposit_limit,
				input_data,
				pallet_contracts::DebugInfo::UnsafeDebug,
				pallet_contracts::CollectEvents::UnsafeCollect,
				pallet_contracts::Determinism::Enforced,
			gas_limit: Option<Weight>,
			storage_deposit_limit: Option<Balance>,
			code: pallet_contracts::Code<Hash>,
		) -> pallet_contracts::ContractInstantiateResult<AccountId, Balance, EventRecord>
			let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
			Contracts::bare_instantiate(
				origin,
				value,
				gas_limit,
				storage_deposit_limit,
				code,
				data,
				salt,
				pallet_contracts::DebugInfo::UnsafeDebug,
				pallet_contracts::CollectEvents::UnsafeCollect,
		}

		fn upload_code(
			origin: AccountId,
			code: Vec<u8>,
			storage_deposit_limit: Option<Balance>,
			determinism: pallet_contracts::Determinism,
		) -> pallet_contracts::CodeUploadResult<Hash, Balance>
			Contracts::bare_upload_code(
				origin,
				code,
				storage_deposit_limit,
				determinism,
			)
		fn get_storage(
			address: AccountId,
		) -> pallet_contracts::GetStorageResult {
	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
		Block,
		Balance,
	> for Runtime {
		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
			TransactionPayment::query_info(uxt, len)
		}
		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
			TransactionPayment::query_fee_details(uxt, len)
		}
		fn query_weight_to_fee(weight: Weight) -> Balance {
			TransactionPayment::weight_to_fee(weight)
		}
		fn query_length_to_fee(length: u32) -> Balance {
			TransactionPayment::length_to_fee(length)
		}
	impl pallet_asset_conversion::AssetConversionApi<
		Block,
		Balance,
	> for Runtime
	{
		fn quote_price_exact_tokens_for_tokens(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>, amount: Balance, include_fee: bool) -> Option<Balance> {
			AssetConversion::quote_price_exact_tokens_for_tokens(asset1, asset2, amount, include_fee)
		}

		fn quote_price_tokens_for_exact_tokens(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>, amount: Balance, include_fee: bool) -> Option<Balance> {
			AssetConversion::quote_price_tokens_for_exact_tokens(asset1, asset2, amount, include_fee)
		}

		fn get_reserves(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>) -> Option<(Balance, Balance)> {
			AssetConversion::get_reserves(asset1, asset2).ok()
	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
		fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo<Balance> {
			TransactionPayment::query_call_info(call, len)
		}
		fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails<Balance> {
			TransactionPayment::query_call_fee_details(call, len)
		}
		fn query_weight_to_fee(weight: Weight) -> Balance {
			TransactionPayment::weight_to_fee(weight)
		}
		fn query_length_to_fee(length: u32) -> Balance {
			TransactionPayment::length_to_fee(length)
		}
	impl pallet_nfts_runtime_api::NftsApi<Block, AccountId, u32, u32> for Runtime {
		fn owner(collection: u32, item: u32) -> Option<AccountId> {
			<Nfts as Inspect<AccountId>>::owner(&collection, &item)