Newer
Older
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>;
}
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
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,
_assignment: Vec<(CoreAssignment, PartsOf57600)>,
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;
}
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
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
}
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
/// 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(())
},
RuntimeParametersKey::Contract(_) => {
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 = ();
}
pub enum Runtime {
System: frame_system,
Utility: pallet_utility,
Babe: pallet_babe,
Timestamp: pallet_timestamp,
// Authorship must be before session in order to note author in the correct session and era
// for im-online and staking.
Authorship: pallet_authorship,
Indices: pallet_indices,
Balances: pallet_balances,
TransactionPayment: pallet_transaction_payment,
AssetTxPayment: pallet_asset_tx_payment,
AssetConversionTxPayment: pallet_asset_conversion_tx_payment,
ElectionProviderMultiPhase: pallet_election_provider_multi_phase,
Staking: pallet_staking,
Session: pallet_session,
Democracy: pallet_democracy,
Council: pallet_collective::<Instance1>,
TechnicalCommittee: pallet_collective::<Instance2>,
Gonçalo Pestana
committed
Elections: pallet_elections_phragmen,
TechnicalMembership: pallet_membership::<Instance1>,
Grandpa: pallet_grandpa,
Treasury: pallet_treasury,
Contracts: pallet_contracts,
Sudo: pallet_sudo,
ImOnline: pallet_im_online,
AuthorityDiscovery: pallet_authority_discovery,
Offences: pallet_offences,
Historical: pallet_session_historical,
RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip,
Identity: pallet_identity,
Society: pallet_society,
Recovery: pallet_recovery,
Vesting: pallet_vesting,
Scheduler: pallet_scheduler,
Preimage: pallet_preimage,
Proxy: pallet_proxy,
Multisig: pallet_multisig,
Bounties: pallet_bounties,
Tips: pallet_tips,
Assets: pallet_assets::<Instance1>,
PoolAssets: pallet_assets::<Instance2>,
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.
Mmr: pallet_mmr,
MmrLeaf: pallet_beefy_mmr,
Lottery: pallet_lottery,
Uniques: pallet_uniques,
NftFractionalization: pallet_nft_fractionalization,
CoreFellowship: pallet_core_fellowship,
TransactionStorage: pallet_transaction_storage,
VoterList: pallet_bags_list::<Instance1>,
StateTrieMigration: pallet_state_trie_migration,
ChildBounties: pallet_child_bounties,
Referenda: pallet_referenda,
ConvictionVoting: pallet_conviction_voting,
AllianceMotion: pallet_collective::<Instance3>,
Alliance: pallet_alliance,
RankedPolls: pallet_referenda::<Instance2>,
RankedCollective: pallet_ranked_collective,
Pov: frame_benchmarking_pallet_pov,
TxPause: pallet_tx_pause,
SafeMode: pallet_safe_mode,
MultiBlockMigrations: pallet_migrations,
Broker: pallet_broker,
TasksExample: pallet_example_tasks,
SkipFeelessPayment: pallet_skip_feeless_payment,
/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, AccountIndex>;
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
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>;
Gavin Wood
committed
/// The TransactionExtension 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>
Gavin Wood
committed
pub type TxExtension = (
(
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>,
>,
/// Unchecked extrinsic type as expected by this runtime.
Gavin Wood
committed
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
/// The payload being signed in transactions.
Gavin Wood
committed
pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
/// Extrinsic type that has already been checked.
Gavin Wood
committed
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, TxExtension>;
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
// 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.
type Migrations = (
pallet_nomination_pools::migration::versioned::V6ToV7<Runtime>,
pallet_alliance::migration::Migration<Runtime>,
Alexander Theißen
committed
pallet_contracts::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;
}
Gavin Wood
committed
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
#[cfg(feature = "runtime-benchmarks")]
pub struct AssetConversionTxHelper;
#[cfg(feature = "runtime-benchmarks")]
impl pallet_asset_conversion_tx_payment::BenchmarkHelperTrait<AccountId, u32, u32>
for AssetConversionTxHelper
{
fn create_asset_id_parameter(seed: u32) -> (u32, u32) {
(seed, seed)
}
fn setup_balances_and_pool(asset_id: u32, account: AccountId) {
use frame_support::{assert_ok, traits::fungibles::Mutate};
assert_ok!(Assets::force_create(
RuntimeOrigin::root(),
asset_id.into(),
account.clone().into(), /* owner */
true, /* is_sufficient */
1,
));
let lp_provider = account.clone();
let _ = Balances::deposit_creating(&lp_provider, ((u64::MAX as u128) * 100).into());
assert_ok!(Assets::mint_into(
asset_id.into(),
&lp_provider,
((u64::MAX as u128) * 100).into()
));
let token_native = Box::new(NativeOrWithId::Native);
let token_second = Box::new(NativeOrWithId::WithId(asset_id));
assert_ok!(AssetConversion::create_pool(
RuntimeOrigin::signed(lp_provider.clone()),
token_native.clone(),
token_second.clone()
));
assert_ok!(AssetConversion::add_liquidity(
RuntimeOrigin::signed(lp_provider.clone()),
token_native,
token_second,
u64::MAX.into(), // 1 desired
u64::MAX.into(), // 2 desired
1, // 1 min
1, // 2 min
lp_provider,
));
}
}
#[cfg(feature = "runtime-benchmarks")]
pub struct AssetTxHelper;
#[cfg(feature = "runtime-benchmarks")]
impl pallet_asset_tx_payment::BenchmarkHelperTrait<AccountId, u32, u32> for AssetTxHelper {
fn create_asset_id_parameter(seed: u32) -> (u32, u32) {
(seed, seed)
}
fn setup_balances_and_pool(asset_id: u32, account: AccountId) {
use frame_support::{assert_ok, traits::fungibles::Mutate};
assert_ok!(Assets::force_create(
RuntimeOrigin::root(),
asset_id.into(),
account.clone().into(), /* owner */
true, /* is_sufficient */
1,
));
let lp_provider = account.clone();
let _ = Balances::deposit_creating(&lp_provider, ((u64::MAX as u128) * 100).into());
assert_ok!(Assets::mint_into(
asset_id.into(),
&lp_provider,
((u64::MAX as u128) * 100).into()
));
let token_native = Box::new(NativeOrWithId::Native);
let token_second = Box::new(NativeOrWithId::WithId(asset_id));
assert_ok!(AssetConversion::create_pool(
RuntimeOrigin::signed(lp_provider.clone()),
token_native.clone(),
token_second.clone()
));
assert_ok!(AssetConversion::add_liquidity(
RuntimeOrigin::signed(lp_provider.clone()),
token_native,
token_second,
u64::MAX.into(), // 1 desired
u64::MAX.into(), // 2 desired
1, // 1 min
1, // 2 min
lp_provider,
));
}
}
#[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]
[tasks_example, TasksExample]
[pallet_democracy, Democracy]
Gavin Wood
committed
[pallet_asset_conversion_tx_payment, AssetConversionTxPayment]
[pallet_asset_tx_payment, AssetTxPayment]
[pallet_transaction_payment, TransactionPayment]
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
Gonçalo Pestana
committed
[pallet_election_provider_support_benchmarking, EPSBench::<Runtime>]
[pallet_elections_phragmen, Elections]
[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]
[pallet_nomination_pools, NominationPoolsBench::<Runtime>]
[pallet_offences, OffencesBench::<Runtime>]
[pallet_preimage, Preimage]
[pallet_proxy, Proxy]
[pallet_ranked_collective, RankedCollective]
[pallet_referenda, Referenda]
[pallet_scheduler, Scheduler]
[pallet_session, SessionBench::<Runtime>]
[pallet_staking, Staking]
[pallet_state_trie_migration, StateTrieMigration]
[frame_system, SystemBench::<Runtime>]
Gavin Wood
committed
[frame_system_extensions, SystemExtensionsBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_tips, Tips]
[pallet_transaction_storage, TransactionStorage]
[pallet_treasury, Treasury]
[pallet_asset_rate, AssetRate]
[pallet_uniques, Uniques]
[pallet_nft_fractionalization, NftFractionalization]
[pallet_utility, Utility]
[pallet_vesting, Vesting]
[pallet_tx_pause, TxPause]
[pallet_safe_mode, SafeMode]
);
}
impl_runtime_apis! {
fn version() -> RuntimeVersion {
VERSION
}
fn execute_block(block: Block) {
Executive::execute_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 {
![Sergey Pepyakin Sergey Pepyakin's avatar](/assets/no_avatar-849f9c04a3a0d0cea2424ae97b27447dc64a7dbfae83c036c45b403392f0e8ba.png)
Sergey Pepyakin
committed
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 {
Tomasz Drwięga
committed
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 {
Grandpa::grandpa_authorities()
}
fn current_set_id() -> sp_consensus_grandpa::SetId {
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,
) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
Historical::prove((sp_consensus_grandpa::KEY_TYPE, authority_id))
.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(),
allowed_slots: epoch_config.allowed_slots,
fn current_epoch_start() -> sp_consensus_babe::Slot {
fn current_epoch() -> sp_consensus_babe::Epoch {
Babe::current_epoch()
}
fn next_epoch() -> sp_consensus_babe::Epoch {
Babe::next_epoch()
}
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 {
System::account_nonce(account)
}
}
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>,
input_data: Vec<u8>,
) -> 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,
fn instantiate(
origin: AccountId,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
code: pallet_contracts::Code<Hash>,
data: Vec<u8>,
salt: Vec<u8>,
) -> 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,
key: Vec<u8>,
) -> pallet_contracts::GetStorageResult {
Contracts::get_storage(
address,
key
)
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)
}
Stephen Shelton
committed
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,
NativeOrWithId<u32>
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>
Muharem Ismailov
committed
for Runtime
{
fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo<Balance> {
Muharem Ismailov
committed
TransactionPayment::query_call_info(call, len)
}
fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails<Balance> {
Muharem Ismailov
committed
TransactionPayment::query_call_fee_details(call, len)
}
Stephen Shelton
committed
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)
}
Muharem Ismailov
committed
}
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
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)
}
fn collection_owner(collection: u32) -> Option<AccountId> {
<Nfts as Inspect<AccountId>>::collection_owner(&collection)
}
fn attribute(
collection: u32,
item: u32,
key: Vec<u8>,
) -> Option<Vec<u8>> {
<Nfts as Inspect<AccountId>>::attribute(&collection, &item, &key)
}
fn custom_attribute(
account: AccountId,
collection: u32,
item: u32,
key: Vec<u8>,
) -> Option<Vec<u8>> {
<Nfts as Inspect<AccountId>>::custom_attribute(
&account,
&collection,
&item,
&key,
)
}
fn system_attribute(
collection: u32,
key: Vec<u8>,
) -> Option<Vec<u8>> {
<Nfts as Inspect<AccountId>>::system_attribute(&collection, item.as_ref(), &key)
}
fn collection_attribute(collection: u32, key: Vec<u8>) -> Option<Vec<u8>> {
<Nfts as Inspect<AccountId>>::collection_attribute(&collection, &key)
}
}
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
#[api_version(3)]
impl sp_consensus_beefy::BeefyApi<Block, BeefyId> for Runtime {
fn beefy_genesis() -> Option<BlockNumber> {
Beefy::genesis_block()
}
fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<BeefyId>> {
Beefy::validator_set()
}
fn submit_report_equivocation_unsigned_extrinsic(
equivocation_proof: sp_consensus_beefy::EquivocationProof<
BlockNumber,
BeefyId,
BeefySignature,
>,
key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
) -> Option<()> {
let key_owner_proof = key_owner_proof.decode()?;
Beefy::submit_unsigned_equivocation_report(
equivocation_proof,
key_owner_proof,
)
}
fn generate_key_ownership_proof(
_set_id: sp_consensus_beefy::ValidatorSetId,
authority_id: BeefyId,
) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> {
Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id))
.map(|p| p.encode())
.map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new)
}
}
impl pallet_mmr::primitives::MmrApi<
Block,
mmr::Hash,
BlockNumber,
> for Runtime {
fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
Ok(Mmr::mmr_root())
}
Web3 Smith
committed
fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
Ok(Mmr::mmr_leaves())
}
fn generate_proof(
block_numbers: Vec<BlockNumber>,
best_known_block_number: Option<BlockNumber>,
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::Proof<mmr::Hash>), mmr::Error> {
Mmr::generate_proof(block_numbers, best_known_block_number).map(
|(leaves, proof)| {
(
leaves
.into_iter()
.map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
.collect(),
proof,
)
},
)
Web3 Smith
committed
}
fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::Proof<mmr::Hash>)
Web3 Smith
committed
-> Result<(), mmr::Error>
{
let leaves = leaves.into_iter().map(|leaf|
leaf.into_opaque_leaf()
.try_decode()
.ok_or(mmr::Error::Verify)).collect::<Result<Vec<mmr::Leaf>, mmr::Error>>()?;