123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904 |
- #![cfg_attr(not(feature = "std"), no_std)]
- #![recursion_limit = "256"]
- #![allow(array_into_iter)]
- mod tests;
- #[cfg(feature = "std")]
- include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
- mod integration;
- use authority_discovery_primitives::{
- AuthorityId as EncodedAuthorityId, Signature as EncodedSignature,
- };
- use babe_primitives::{AuthorityId as BabeId, AuthoritySignature as BabeSignature};
- use codec::{Decode, Encode};
- use grandpa::fg_primitives;
- use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight};
- use im_online::sr25519::AuthorityId as ImOnlineId;
- use primitives::OpaqueMetadata;
- use rstd::prelude::*;
- use sr_primitives::curve::PiecewiseLinear;
- use sr_primitives::traits::{
- BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, StaticLookup, Verify,
- };
- use sr_primitives::weights::Weight;
- use sr_primitives::{
- create_runtime_str, generic, impl_opaque_keys, transaction_validity::TransactionValidity,
- ApplyResult, MultiSignature,
- };
- use substrate_client::{
- block_builder::api::{self as block_builder_api, CheckInherentsResult, InherentData},
- impl_runtime_apis, runtime_api as client_api,
- };
- use system::offchain::TransactionSubmitter;
- #[cfg(feature = "std")]
- use version::NativeVersion;
- use version::RuntimeVersion;
- pub use balances::Call as BalancesCall;
- #[cfg(any(feature = "std", test))]
- pub use sr_primitives::BuildStorage;
- pub use sr_primitives::{Perbill, Permill};
- pub use srml_support::{
- construct_runtime, parameter_types, traits::Currency, traits::Imbalance, traits::Randomness,
- StorageLinkedMap, StorageMap, StorageValue,
- };
- pub use staking::StakerStatus;
- pub use timestamp::Call as TimestampCall;
- use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator};
- pub use proposals_codex::ProposalsConfigParameters;
- pub use common;
- pub use forum;
- pub use working_group;
- pub use governance::election_params::ElectionParameters;
- use governance::{council, election};
- use membership::members;
- use storage::{data_directory, data_object_storage_registry, data_object_type_registry};
- pub use versioned_store;
- pub use content_working_group as content_wg;
- mod migration;
- pub type ContentId = primitives::H256;
- pub type BlockNumber = u32;
- pub type Signature = MultiSignature;
- pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
- pub type AccountIndex = u32;
- pub type Balance = u128;
- pub type Index = u32;
- pub type Hash = primitives::H256;
- pub type DigestItem = generic::DigestItem<Hash>;
- pub type Moment = u64;
- pub type Credential = u64;
- pub type ThreadId = u64;
- pub type PostId = u64;
- pub type ActorId = u64;
- pub mod opaque {
- use super::*;
- pub use sr_primitives::OpaqueExtrinsic as UncheckedExtrinsic;
-
- pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
-
- pub type Block = generic::Block<Header, UncheckedExtrinsic>;
-
- pub type BlockId = generic::BlockId<Block>;
- pub type SessionHandlers = (Grandpa, Babe, ImOnline);
- impl_opaque_keys! {
- pub struct SessionKeys {
- pub grandpa: Grandpa,
- pub babe: Babe,
- pub im_online: ImOnline,
- }
- }
- }
- pub const VERSION: RuntimeVersion = RuntimeVersion {
- spec_name: create_runtime_str!("joystream-node"),
- impl_name: create_runtime_str!("joystream-node"),
- authoring_version: 6,
- spec_version: 17,
- impl_version: 0,
- apis: RUNTIME_API_VERSIONS,
- };
- pub const MILLISECS_PER_BLOCK: Moment = 6000;
- pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000;
- pub const SLOT_DURATION: Moment = 6000;
- pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES;
- pub const EPOCH_DURATION_IN_SLOTS: u64 = {
- const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64;
- (EPOCH_DURATION_IN_BLOCKS as f64 * SLOT_FILL_RATE) as u64
- };
- pub const MINUTES: BlockNumber = 60 / (SECS_PER_BLOCK as BlockNumber);
- pub const HOURS: BlockNumber = MINUTES * 60;
- pub const DAYS: BlockNumber = HOURS * 24;
- pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
- #[cfg(feature = "std")]
- pub fn native_version() -> NativeVersion {
- NativeVersion {
- runtime_version: VERSION,
- can_author_with: Default::default(),
- }
- }
- parameter_types! {
- pub const BlockHashCount: BlockNumber = 250;
- pub const MaximumBlockWeight: Weight = 1_000_000_000;
- pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
- pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
- pub const Version: RuntimeVersion = VERSION;
- }
- impl system::Trait for Runtime {
-
- type AccountId = AccountId;
-
- type Call = Call;
-
- type Lookup = Indices;
-
- type Index = Index;
-
- type BlockNumber = BlockNumber;
-
- type Hash = Hash;
-
- type Hashing = BlakeTwo256;
-
- type Header = generic::Header<BlockNumber, BlakeTwo256>;
-
- type Event = Event;
-
- type Origin = Origin;
-
- type BlockHashCount = BlockHashCount;
-
- type MaximumBlockWeight = MaximumBlockWeight;
-
- type MaximumBlockLength = MaximumBlockLength;
-
- type AvailableBlockRatio = AvailableBlockRatio;
- type Version = Version;
- }
- parameter_types! {
- pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64;
- pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
- }
- impl babe::Trait for Runtime {
- type EpochDuration = EpochDuration;
- type ExpectedBlockTime = ExpectedBlockTime;
- type EpochChangeTrigger = babe::ExternalTrigger;
- }
- impl grandpa::Trait for Runtime {
- type Event = Event;
- }
- impl indices::Trait for Runtime {
-
-
- type AccountIndex = u32;
-
- type ResolveHint = indices::SimpleResolveHint<Self::AccountId, Self::AccountIndex>;
-
- type IsDeadAccount = Balances;
-
- type Event = Event;
- }
- parameter_types! {
- pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
- }
- impl timestamp::Trait for Runtime {
-
- type Moment = Moment;
- type OnTimestampSet = Babe;
- type MinimumPeriod = MinimumPeriod;
- }
- parameter_types! {
- pub const ExistentialDeposit: u128 = 0;
- pub const TransferFee: u128 = 0;
- pub const CreationFee: u128 = 0;
- pub const TransactionBaseFee: u128 = 1;
- pub const TransactionByteFee: u128 = 0;
- pub const InitialMembersBalance: u32 = 2000;
- }
- impl balances::Trait for Runtime {
-
- type Balance = Balance;
-
- type OnFreeBalanceZero = (Staking, Session);
-
- type OnNewAccount = ();
-
- type Event = Event;
- type DustRemoval = ();
- type TransferPayment = ();
- type ExistentialDeposit = ExistentialDeposit;
- type TransferFee = TransferFee;
- type CreationFee = CreationFee;
- }
- impl transaction_payment::Trait for Runtime {
- type Currency = Balances;
- type OnTransactionPayment = ();
- type TransactionBaseFee = TransactionBaseFee;
- type TransactionByteFee = TransactionByteFee;
- type WeightToFee = ();
- type FeeMultiplierUpdate = ();
- }
- impl sudo::Trait for Runtime {
- type Event = Event;
- type Proposal = Call;
- }
- parameter_types! {
- pub const UncleGenerations: BlockNumber = 5;
- }
- impl authorship::Trait for Runtime {
- type FindAuthor = session::FindAccountFromAuthorIndex<Self, Babe>;
- type UncleGenerations = UncleGenerations;
- type FilterUncle = ();
- type EventHandler = Staking;
- }
- type SessionHandlers = (Grandpa, Babe, ImOnline);
- impl_opaque_keys! {
- pub struct SessionKeys {
- pub grandpa: Grandpa,
- pub babe: Babe,
- pub im_online: ImOnline,
- }
- }
- parameter_types! {
- pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
- }
- impl session::Trait for Runtime {
- type OnSessionEnding = Staking;
- type SessionHandler = SessionHandlers;
- type ShouldEndSession = Babe;
- type Event = Event;
- type Keys = SessionKeys;
- type ValidatorId = AccountId;
- type ValidatorIdOf = staking::StashOf<Self>;
- type SelectInitialValidators = Staking;
- type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
- }
- impl session::historical::Trait for Runtime {
- type FullIdentification = staking::Exposure<AccountId, Balance>;
- type FullIdentificationOf = staking::ExposureOf<Runtime>;
- }
- srml_staking_reward_curve::build! {
- const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
- min_inflation: 0_025_000,
- max_inflation: 0_300_000,
- ideal_stake: 0_300_000,
- falloff: 0_050_000,
- max_piece_count: 100,
- test_precision: 0_005_000,
- );
- }
- parameter_types! {
- pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6;
- pub const BondingDuration: staking::EraIndex = 24;
- pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
- }
- impl staking::Trait for Runtime {
- type Currency = Balances;
- type Time = Timestamp;
- type CurrencyToVote = common::currency::CurrencyToVoteHandler;
- type RewardRemainder = ();
- type Event = Event;
- type Slash = ();
- type Reward = ();
- type SessionsPerEra = SessionsPerEra;
- type BondingDuration = BondingDuration;
- type SessionInterface = Self;
- type RewardCurve = RewardCurve;
- }
- type SubmitTransaction = TransactionSubmitter<ImOnlineId, Runtime, UncheckedExtrinsic>;
- parameter_types! {
- pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_SLOTS as _;
- }
- impl im_online::Trait for Runtime {
- type AuthorityId = ImOnlineId;
- type Call = Call;
- type Event = Event;
- type SubmitTransaction = SubmitTransaction;
- type ReportUnresponsiveness = Offences;
- type SessionDuration = SessionDuration;
- }
- impl offences::Trait for Runtime {
- type Event = Event;
- type IdentificationTuple = session::historical::IdentificationTuple<Self>;
- type OnOffenceHandler = Staking;
- }
- impl authority_discovery::Trait for Runtime {
- type AuthorityId = BabeId;
- }
- parameter_types! {
- pub const WindowSize: BlockNumber = 101;
- pub const ReportLatency: BlockNumber = 1000;
- }
- impl finality_tracker::Trait for Runtime {
- type OnFinalizationStalled = Grandpa;
- type WindowSize = WindowSize;
- type ReportLatency = ReportLatency;
- }
- impl versioned_store::Trait for Runtime {
- type Event = Event;
- }
- impl versioned_store_permissions::Trait for Runtime {
- type Credential = Credential;
- type CredentialChecker = (
- integration::content_working_group::ContentWorkingGroupCredentials,
- SudoKeyHasAllCredentials,
- );
- type CreateClassPermissionsChecker = ContentLeadOrSudoKeyCanCreateClasses;
- }
- pub struct SudoKeyHasAllCredentials {}
- impl versioned_store_permissions::CredentialChecker<Runtime> for SudoKeyHasAllCredentials {
- fn account_has_credential(
- account: &AccountId,
- _credential: <Runtime as versioned_store_permissions::Trait>::Credential,
- ) -> bool {
- <sudo::Module<Runtime>>::key() == *account
- }
- }
- pub struct SudoKeyCanCreateClasses {}
- impl versioned_store_permissions::CreateClassPermissionsChecker<Runtime>
- for SudoKeyCanCreateClasses
- {
- fn account_can_create_class_permissions(account: &AccountId) -> bool {
- <sudo::Module<Runtime>>::key() == *account
- }
- }
- pub struct ContentLeadOrSudoKeyCanCreateClasses {}
- impl versioned_store_permissions::CreateClassPermissionsChecker<Runtime>
- for ContentLeadOrSudoKeyCanCreateClasses
- {
- fn account_can_create_class_permissions(account: &AccountId) -> bool {
- ContentLeadCanCreateClasses::account_can_create_class_permissions(account)
- || SudoKeyCanCreateClasses::account_can_create_class_permissions(account)
- }
- }
- pub struct ContentLeadCanCreateClasses {}
- impl versioned_store_permissions::CreateClassPermissionsChecker<Runtime>
- for ContentLeadCanCreateClasses
- {
- fn account_can_create_class_permissions(account: &AccountId) -> bool {
-
- let maybe_current_lead_id = content_wg::CurrentLeadId::<Runtime>::get();
- if let Some(lead_id) = maybe_current_lead_id {
- let lead = content_wg::LeadById::<Runtime>::get(lead_id);
- lead.role_account == *account
- } else {
- false
- }
- }
- }
- impl hiring::Trait for Runtime {
- type OpeningId = u64;
- type ApplicationId = u64;
- type ApplicationDeactivatedHandler = ();
- type StakeHandlerProvider = hiring::Module<Self>;
- }
- impl minting::Trait for Runtime {
- type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
- type MintId = u64;
- }
- impl recurringrewards::Trait for Runtime {
- type PayoutStatusHandler = ();
- type RecipientId = u64;
- type RewardRelationshipId = u64;
- }
- parameter_types! {
- pub const StakePoolId: [u8; 8] = *b"joystake";
- }
- impl stake::Trait for Runtime {
- type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
- type StakePoolId = StakePoolId;
- type StakingEventsHandler = (
- crate::integration::content_working_group::ContentWorkingGroupStakingEventHandler,
- (
- crate::integration::proposals::StakingEventsHandler<Self>,
- crate::integration::working_group::StakingEventsHandler<Self>,
- ),
- );
- type StakeId = u64;
- type SlashId = u64;
- }
- impl content_wg::Trait for Runtime {
- type Event = Event;
- }
- impl common::currency::GovernanceCurrency for Runtime {
- type Currency = balances::Module<Self>;
- }
- impl governance::election::Trait for Runtime {
- type Event = Event;
- type CouncilElected = (Council, integration::proposals::CouncilElectedHandler);
- }
- impl governance::council::Trait for Runtime {
- type Event = Event;
- type CouncilTermEnded = (CouncilElection,);
- }
- impl memo::Trait for Runtime {
- type Event = Event;
- }
- impl storage::data_object_type_registry::Trait for Runtime {
- type Event = Event;
- type DataObjectTypeId = u64;
- }
- impl storage::data_directory::Trait for Runtime {
- type Event = Event;
- type ContentId = ContentId;
- type StorageProviderHelper = integration::storage::StorageProviderHelper;
- type IsActiveDataObjectType = DataObjectTypeRegistry;
- type MemberOriginValidator = MembershipOriginValidator<Self>;
- }
- impl storage::data_object_storage_registry::Trait for Runtime {
- type Event = Event;
- type DataObjectStorageRelationshipId = u64;
- type ContentIdExists = DataDirectory;
- }
- impl members::Trait for Runtime {
- type Event = Event;
- type MemberId = u64;
- type PaidTermId = u64;
- type SubscriptionId = u64;
- type ActorId = ActorId;
- type InitialMembersBalance = InitialMembersBalance;
- }
- pub struct ShimMembershipRegistry {}
- impl forum::ForumUserRegistry<AccountId> for ShimMembershipRegistry {
- fn get_forum_user(id: &AccountId) -> Option<forum::ForumUser<AccountId>> {
- if members::Module::<Runtime>::is_member_account(id) {
-
-
-
-
-
- Some(forum::ForumUser { id: id.clone() })
- } else {
- None
- }
- }
- }
- impl forum::Trait for Runtime {
- type Event = Event;
- type MembershipRegistry = ShimMembershipRegistry;
- type ThreadId = ThreadId;
- type PostId = PostId;
- }
- impl migration::Trait for Runtime {
- type Event = Event;
- }
- pub type StorageWorkingGroupInstance = working_group::Instance2;
- parameter_types! {
- pub const MaxWorkerNumberLimit: u32 = 100;
- }
- impl working_group::Trait<StorageWorkingGroupInstance> for Runtime {
- type Event = Event;
- type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
- }
- impl service_discovery::Trait for Runtime {
- type Event = Event;
- }
- parameter_types! {
- pub const ProposalCancellationFee: u64 = 10000;
- pub const ProposalRejectionFee: u64 = 5000;
- pub const ProposalTitleMaxLength: u32 = 40;
- pub const ProposalDescriptionMaxLength: u32 = 3000;
- pub const ProposalMaxActiveProposalLimit: u32 = 5;
- }
- impl proposals_engine::Trait for Runtime {
- type Event = Event;
- type ProposerOriginValidator = MembershipOriginValidator<Self>;
- type VoterOriginValidator = CouncilManager<Self>;
- type TotalVotersCounter = CouncilManager<Self>;
- type ProposalId = u32;
- type StakeHandlerProvider = proposals_engine::DefaultStakeHandlerProvider;
- type CancellationFee = ProposalCancellationFee;
- type RejectionFee = ProposalRejectionFee;
- type TitleMaxLength = ProposalTitleMaxLength;
- type DescriptionMaxLength = ProposalDescriptionMaxLength;
- type MaxActiveProposalLimit = ProposalMaxActiveProposalLimit;
- type DispatchableCallCode = Call;
- }
- impl Default for Call {
- fn default() -> Self {
- panic!("shouldn't call default for Call");
- }
- }
- parameter_types! {
- pub const ProposalMaxPostEditionNumber: u32 = 0;
- pub const ProposalMaxThreadInARowNumber: u32 = 100_000;
- pub const ProposalThreadTitleLengthLimit: u32 = 40;
- pub const ProposalPostLengthLimit: u32 = 1000;
- }
- impl proposals_discussion::Trait for Runtime {
- type Event = Event;
- type PostAuthorOriginValidator = MembershipOriginValidator<Self>;
- type ThreadId = ThreadId;
- type PostId = PostId;
- type MaxPostEditionNumber = ProposalMaxPostEditionNumber;
- type ThreadTitleLengthLimit = ProposalThreadTitleLengthLimit;
- type PostLengthLimit = ProposalPostLengthLimit;
- type MaxThreadInARowNumber = ProposalMaxThreadInARowNumber;
- }
- parameter_types! {
- pub const TextProposalMaxLength: u32 = 5_000;
- pub const RuntimeUpgradeWasmProposalMaxLength: u32 = 2_000_000;
- }
- impl proposals_codex::Trait for Runtime {
- type MembershipOriginValidator = MembershipOriginValidator<Self>;
- type TextProposalMaxLength = TextProposalMaxLength;
- type RuntimeUpgradeWasmProposalMaxLength = RuntimeUpgradeWasmProposalMaxLength;
- type ProposalEncoder = ExtrinsicProposalEncoder;
- }
- construct_runtime!(
- pub enum Runtime where
- Block = Block,
- NodeBlock = opaque::Block,
- UncheckedExtrinsic = UncheckedExtrinsic
- {
-
- System: system::{Module, Call, Storage, Config, Event},
- Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
- Timestamp: timestamp::{Module, Call, Storage, Inherent},
- Authorship: authorship::{Module, Call, Storage, Inherent},
- Indices: indices,
- Balances: balances,
- TransactionPayment: transaction_payment::{Module, Storage},
- Staking: staking::{default, OfflineWorker},
- Session: session::{Module, Call, Storage, Event, Config<T>},
- FinalityTracker: finality_tracker::{Module, Call, Inherent},
- Grandpa: grandpa::{Module, Call, Storage, Config, Event},
- ImOnline: im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
- AuthorityDiscovery: authority_discovery::{Module, Call, Config<T>},
- Offences: offences::{Module, Call, Storage, Event},
- RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},
- Sudo: sudo,
-
- Migration: migration::{Module, Call, Storage, Event<T>, Config},
- CouncilElection: election::{Module, Call, Storage, Event<T>, Config<T>},
- Council: council::{Module, Call, Storage, Event<T>, Config<T>},
- Memo: memo::{Module, Call, Storage, Event<T>},
- Members: members::{Module, Call, Storage, Event<T>, Config<T>},
- Forum: forum::{Module, Call, Storage, Event<T>, Config<T>},
- VersionedStore: versioned_store::{Module, Call, Storage, Event<T>, Config},
- VersionedStorePermissions: versioned_store_permissions::{Module, Call, Storage},
- Stake: stake::{Module, Call, Storage},
- Minting: minting::{Module, Call, Storage},
- RecurringRewards: recurringrewards::{Module, Call, Storage},
- Hiring: hiring::{Module, Call, Storage},
- ContentWorkingGroup: content_wg::{Module, Call, Storage, Event<T>, Config<T>},
-
- DataObjectTypeRegistry: data_object_type_registry::{Module, Call, Storage, Event<T>, Config<T>},
- DataDirectory: data_directory::{Module, Call, Storage, Event<T>},
- DataObjectStorageRegistry: data_object_storage_registry::{Module, Call, Storage, Event<T>, Config<T>},
- Discovery: service_discovery::{Module, Call, Storage, Event<T>},
-
- ProposalsEngine: proposals_engine::{Module, Call, Storage, Event<T>},
- ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event<T>},
- ProposalsCodex: proposals_codex::{Module, Call, Storage, Error, Config<T>},
-
-
- StorageWorkingGroup: working_group::<Instance2>::{Module, Call, Storage, Config<T>, Error, Event<T>},
- }
- );
- pub type Address = <Indices as StaticLookup>::Source;
- pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
- pub type Block = generic::Block<Header, UncheckedExtrinsic>;
- pub type SignedBlock = generic::SignedBlock<Block>;
- pub type BlockId = generic::BlockId<Block>;
- pub type SignedExtra = (
- system::CheckVersion<Runtime>,
- system::CheckGenesis<Runtime>,
- system::CheckEra<Runtime>,
- system::CheckNonce<Runtime>,
- system::CheckWeight<Runtime>,
- transaction_payment::ChargeTransactionPayment<Runtime>,
- );
- pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
- pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
- pub type Executive =
- executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
- impl_runtime_apis! {
- impl client_api::Core<Block> for Runtime {
- fn version() -> RuntimeVersion {
- VERSION
- }
- fn execute_block(block: Block) {
- Executive::execute_block(block)
- }
- fn initialize_block(header: &<Block as BlockT>::Header) {
- Executive::initialize_block(header)
- }
- }
- impl client_api::Metadata<Block> for Runtime {
- fn metadata() -> OpaqueMetadata {
- Runtime::metadata().into()
- }
- }
- impl block_builder_api::BlockBuilder<Block> for Runtime {
- fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyResult {
- 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)
- }
- fn random_seed() -> <Block as BlockT>::Hash {
- RandomnessCollectiveFlip::random_seed()
- }
- }
- impl client_api::TaggedTransactionQueue<Block> for Runtime {
- fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity {
- Executive::validate_transaction(tx)
- }
- }
- impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
- fn offchain_worker(number: NumberFor<Block>) {
- Executive::offchain_worker(number)
- }
- }
- impl fg_primitives::GrandpaApi<Block> for Runtime {
- fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> {
- Grandpa::grandpa_authorities()
- }
- }
- impl babe_primitives::BabeApi<Block> for Runtime {
- fn configuration() -> babe_primitives::BabeConfiguration {
-
-
-
-
-
- babe_primitives::BabeConfiguration {
- slot_duration: Babe::slot_duration(),
- epoch_length: EpochDuration::get(),
- c: PRIMARY_PROBABILITY,
- genesis_authorities: Babe::authorities(),
- randomness: Babe::randomness(),
- secondary_slots: true,
- }
- }
- }
- impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
- fn authorities() -> Vec<EncodedAuthorityId> {
- AuthorityDiscovery::authorities().into_iter()
- .map(|id| id.encode())
- .map(EncodedAuthorityId)
- .collect()
- }
- fn sign(payload: &Vec<u8>) -> Option<(EncodedSignature, EncodedAuthorityId)> {
- AuthorityDiscovery::sign(payload).map(|(sig, id)| {
- (EncodedSignature(sig.encode()), EncodedAuthorityId(id.encode()))
- })
- }
- fn verify(payload: &Vec<u8>, signature: &EncodedSignature, authority_id: &EncodedAuthorityId) -> bool {
- let signature = match BabeSignature::decode(&mut &signature.0[..]) {
- Ok(s) => s,
- _ => return false,
- };
- let authority_id = match BabeId::decode(&mut &authority_id.0[..]) {
- Ok(id) => id,
- _ => return false,
- };
- AuthorityDiscovery::verify(payload, signature, authority_id)
- }
- }
- impl system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
- fn account_nonce(account: AccountId) -> Index {
- System::account_nonce(account)
- }
- }
- impl substrate_session::SessionKeys<Block> for Runtime {
- fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
- let seed = seed.as_ref().map(|s| rstd::str::from_utf8(&s).expect("Seed is an utf8 string"));
- opaque::SessionKeys::generate(seed)
- }
- }
- }
|