lib.rs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. //! The Joystream Substrate Node runtime.
  2. #![cfg_attr(not(feature = "std"), no_std)]
  3. // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
  4. #![recursion_limit = "256"]
  5. //Substrate internal issues.
  6. #![allow(clippy::large_enum_variant)]
  7. #![allow(clippy::unnecessary_mut_passed)]
  8. // Make the WASM binary available.
  9. // This is required only by the node build.
  10. // A dummy wasm_binary.rs will be built for the IDE.
  11. #[cfg(feature = "std")]
  12. include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
  13. mod constants;
  14. mod integration;
  15. pub mod primitives;
  16. mod runtime_api;
  17. #[cfg(test)]
  18. mod tests; // Runtime integration tests
  19. use frame_support::traits::KeyOwnerProofSystem;
  20. use frame_support::weights::{
  21. constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
  22. Weight,
  23. };
  24. use frame_support::{construct_runtime, parameter_types};
  25. use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
  26. use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
  27. use pallet_session::historical as pallet_session_historical;
  28. use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
  29. use sp_core::crypto::KeyTypeId;
  30. use sp_runtime::curve::PiecewiseLinear;
  31. use sp_runtime::traits::{BlakeTwo256, Block as BlockT, IdentityLookup, OpaqueKeys, Saturating};
  32. use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, Perbill};
  33. use sp_std::boxed::Box;
  34. use sp_std::vec::Vec;
  35. #[cfg(feature = "std")]
  36. use sp_version::NativeVersion;
  37. use sp_version::RuntimeVersion;
  38. use system::EnsureRoot;
  39. pub use constants::*;
  40. pub use primitives::*;
  41. pub use runtime_api::*;
  42. use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator};
  43. use governance::{council, election};
  44. use storage::data_object_storage_registry;
  45. // Node dependencies
  46. pub use common;
  47. pub use content_working_group as content_wg;
  48. pub use forum;
  49. pub use governance::election_params::ElectionParameters;
  50. pub use membership;
  51. #[cfg(any(feature = "std", test))]
  52. pub use pallet_balances::Call as BalancesCall;
  53. pub use pallet_staking::StakerStatus;
  54. pub use proposals_codex::ProposalsConfigParameters;
  55. pub use storage::{data_directory, data_object_type_registry};
  56. pub use versioned_store;
  57. pub use versioned_store_permissions;
  58. pub use working_group;
  59. /// This runtime version.
  60. pub const VERSION: RuntimeVersion = RuntimeVersion {
  61. spec_name: create_runtime_str!("joystream-node"),
  62. impl_name: create_runtime_str!("joystream-node"),
  63. authoring_version: 7,
  64. spec_version: 4,
  65. impl_version: 0,
  66. apis: crate::runtime_api::EXPORTED_RUNTIME_API_VERSIONS,
  67. transaction_version: 1,
  68. };
  69. /// The version information used to identify this runtime when compiled natively.
  70. #[cfg(feature = "std")]
  71. pub fn native_version() -> NativeVersion {
  72. NativeVersion {
  73. runtime_version: VERSION,
  74. can_author_with: Default::default(),
  75. }
  76. }
  77. parameter_types! {
  78. pub const BlockHashCount: BlockNumber = 250;
  79. /// We allow for 2 seconds of compute with a 6 second average block time.
  80. pub const MaximumBlockWeight: Weight = 2 * frame_support::weights::constants::WEIGHT_PER_SECOND;
  81. pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
  82. pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
  83. pub const Version: RuntimeVersion = VERSION;
  84. /// Assume 10% of weight for average on_initialize calls.
  85. pub MaximumExtrinsicWeight: Weight =
  86. AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT)
  87. * MaximumBlockWeight::get();
  88. }
  89. const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10);
  90. // TODO: adjust weight
  91. impl system::Trait for Runtime {
  92. type BaseCallFilter = ();
  93. type Origin = Origin;
  94. type Call = Call;
  95. type Index = Index;
  96. type BlockNumber = BlockNumber;
  97. type Hash = Hash;
  98. type Hashing = BlakeTwo256;
  99. type AccountId = AccountId;
  100. type Lookup = IdentityLookup<AccountId>;
  101. type Header = generic::Header<BlockNumber, BlakeTwo256>;
  102. type Event = Event;
  103. type BlockHashCount = BlockHashCount;
  104. type MaximumBlockWeight = MaximumBlockWeight;
  105. type DbWeight = RocksDbWeight;
  106. type BlockExecutionWeight = BlockExecutionWeight;
  107. type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
  108. type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
  109. type MaximumBlockLength = MaximumBlockLength;
  110. type AvailableBlockRatio = AvailableBlockRatio;
  111. type Version = Version;
  112. type ModuleToIndex = ModuleToIndex;
  113. type AccountData = pallet_balances::AccountData<Balance>;
  114. type OnNewAccount = ();
  115. type OnKilledAccount = ();
  116. }
  117. impl pallet_utility::Trait for Runtime {
  118. type Event = Event;
  119. type Call = Call;
  120. }
  121. parameter_types! {
  122. pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64;
  123. pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
  124. }
  125. impl pallet_babe::Trait for Runtime {
  126. type EpochDuration = EpochDuration;
  127. type ExpectedBlockTime = ExpectedBlockTime;
  128. type EpochChangeTrigger = pallet_babe::ExternalTrigger;
  129. }
  130. impl pallet_grandpa::Trait for Runtime {
  131. type Event = Event;
  132. type Call = Call;
  133. type KeyOwnerProof =
  134. <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
  135. type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
  136. KeyTypeId,
  137. GrandpaId,
  138. )>>::IdentificationTuple;
  139. type KeyOwnerProofSystem = Historical;
  140. type HandleEquivocation = pallet_grandpa::EquivocationHandler<
  141. Self::KeyOwnerIdentification,
  142. primitives::report::ReporterAppCrypto,
  143. Runtime,
  144. Offences,
  145. >;
  146. }
  147. impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Runtime
  148. where
  149. Call: From<LocalCall>,
  150. {
  151. fn create_transaction<C: system::offchain::AppCrypto<Self::Public, Self::Signature>>(
  152. call: Call,
  153. public: <Signature as sp_runtime::traits::Verify>::Signer,
  154. account: AccountId,
  155. nonce: Index,
  156. ) -> Option<(
  157. Call,
  158. <UncheckedExtrinsic as sp_runtime::traits::Extrinsic>::SignaturePayload,
  159. )> {
  160. integration::transactions::create_transaction::<C>(call, public, account, nonce)
  161. }
  162. }
  163. impl system::offchain::SigningTypes for Runtime {
  164. type Public = <Signature as sp_runtime::traits::Verify>::Signer;
  165. type Signature = Signature;
  166. }
  167. impl<C> system::offchain::SendTransactionTypes<C> for Runtime
  168. where
  169. Call: From<C>,
  170. {
  171. type Extrinsic = UncheckedExtrinsic;
  172. type OverarchingCall = Call;
  173. }
  174. parameter_types! {
  175. pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
  176. }
  177. impl pallet_timestamp::Trait for Runtime {
  178. type Moment = Moment;
  179. type OnTimestampSet = Babe;
  180. type MinimumPeriod = MinimumPeriod;
  181. }
  182. parameter_types! {
  183. pub const ExistentialDeposit: u128 = 0;
  184. pub const TransferFee: u128 = 0;
  185. pub const CreationFee: u128 = 0;
  186. pub const InitialMembersBalance: u32 = 2000;
  187. }
  188. impl pallet_balances::Trait for Runtime {
  189. type Balance = Balance;
  190. type DustRemoval = ();
  191. type Event = Event;
  192. type ExistentialDeposit = ExistentialDeposit;
  193. type AccountStore = System;
  194. }
  195. parameter_types! {
  196. pub const TransactionByteFee: Balance = 0; // TODO: adjust fee
  197. }
  198. impl pallet_transaction_payment::Trait for Runtime {
  199. type Currency = Balances;
  200. type OnTransactionPayment = ();
  201. type TransactionByteFee = TransactionByteFee;
  202. type WeightToFee = integration::transactions::NoWeights; // TODO: adjust weight
  203. type FeeMultiplierUpdate = (); // TODO: adjust fee
  204. }
  205. impl pallet_sudo::Trait for Runtime {
  206. type Event = Event;
  207. type Call = Call;
  208. }
  209. parameter_types! {
  210. pub const UncleGenerations: BlockNumber = 0;
  211. }
  212. impl pallet_authorship::Trait for Runtime {
  213. type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
  214. type UncleGenerations = UncleGenerations;
  215. type FilterUncle = ();
  216. type EventHandler = (Staking, ImOnline);
  217. }
  218. impl_opaque_keys! {
  219. pub struct SessionKeys {
  220. pub grandpa: Grandpa,
  221. pub babe: Babe,
  222. pub im_online: ImOnline,
  223. pub authority_discovery: AuthorityDiscovery,
  224. }
  225. }
  226. // NOTE: `SessionHandler` and `SessionKeys` are co-dependent: One key will be used for each handler.
  227. // The number and order of items in `SessionHandler` *MUST* be the same number and order of keys in
  228. // `SessionKeys`.
  229. // TODO: Introduce some structure to tie these together to make it a bit less of a footgun. This
  230. // should be easy, since OneSessionHandler trait provides the `Key` as an associated type. #2858
  231. parameter_types! {
  232. pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
  233. }
  234. impl pallet_session::Trait for Runtime {
  235. type Event = Event;
  236. type ValidatorId = AccountId;
  237. type ValidatorIdOf = pallet_staking::StashOf<Self>;
  238. type ShouldEndSession = Babe;
  239. type NextSessionRotation = Babe;
  240. type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
  241. type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
  242. type Keys = SessionKeys;
  243. type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
  244. }
  245. impl pallet_session::historical::Trait for Runtime {
  246. type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
  247. type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
  248. }
  249. pallet_staking_reward_curve::build! {
  250. const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
  251. min_inflation: 0_050_000,
  252. max_inflation: 0_750_000,
  253. ideal_stake: 0_250_000,
  254. falloff: 0_050_000,
  255. max_piece_count: 100,
  256. test_precision: 0_005_000,
  257. );
  258. }
  259. parameter_types! {
  260. pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_SLOTS as _;
  261. pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
  262. /// We prioritize im-online heartbeats over election solution submission.
  263. pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2;
  264. }
  265. parameter_types! {
  266. pub const SessionsPerEra: sp_staking::SessionIndex = 6;
  267. pub const BondingDuration: pallet_staking::EraIndex = BONDING_DURATION;
  268. pub const SlashDeferDuration: pallet_staking::EraIndex = BONDING_DURATION - 1; // 'slightly less' than the bonding duration.
  269. pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
  270. pub const MaxNominatorRewardedPerValidator: u32 = 64;
  271. pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4;
  272. pub const MaxIterations: u32 = 10;
  273. // 0.05%. The higher the value, the more strict solution acceptance becomes.
  274. pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000);
  275. }
  276. impl pallet_staking::Trait for Runtime {
  277. type Currency = Balances;
  278. type UnixTime = Timestamp;
  279. type CurrencyToVote = common::currency::CurrencyToVoteHandler;
  280. type RewardRemainder = (); // Could be Treasury.
  281. type Event = Event;
  282. type Slash = (); // Where to send the slashed funds. Could be Treasury.
  283. type Reward = (); // Rewards are minted from the void.
  284. type SessionsPerEra = SessionsPerEra;
  285. type BondingDuration = BondingDuration;
  286. type SlashDeferDuration = SlashDeferDuration;
  287. type SlashCancelOrigin = EnsureRoot<AccountId>; // Requires sudo. Parity recommends: a super-majority of the council can cancel the slash.
  288. type SessionInterface = Self;
  289. type RewardCurve = RewardCurve;
  290. type NextNewSession = Session;
  291. type ElectionLookahead = MaxIterations;
  292. type Call = Call;
  293. type MaxIterations = MaxIterations;
  294. type MinSolutionScoreBump = MinSolutionScoreBump;
  295. type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
  296. type UnsignedPriority = StakingUnsignedPriority;
  297. }
  298. impl pallet_im_online::Trait for Runtime {
  299. type AuthorityId = ImOnlineId;
  300. type Event = Event;
  301. type SessionDuration = SessionDuration;
  302. type ReportUnresponsiveness = Offences;
  303. type UnsignedPriority = ImOnlineUnsignedPriority;
  304. }
  305. parameter_types! {
  306. pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
  307. }
  308. impl pallet_offences::Trait for Runtime {
  309. type Event = Event;
  310. type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
  311. type OnOffenceHandler = Staking;
  312. type WeightSoftLimit = OffencesWeightSoftLimit;
  313. }
  314. impl pallet_authority_discovery::Trait for Runtime {}
  315. parameter_types! {
  316. pub const WindowSize: BlockNumber = 101;
  317. pub const ReportLatency: BlockNumber = 1000;
  318. }
  319. impl pallet_finality_tracker::Trait for Runtime {
  320. type OnFinalizationStalled = Grandpa;
  321. type WindowSize = WindowSize;
  322. type ReportLatency = ReportLatency;
  323. }
  324. impl versioned_store::Trait for Runtime {
  325. type Event = Event;
  326. }
  327. impl versioned_store_permissions::Trait for Runtime {
  328. type Credential = Credential;
  329. type CredentialChecker = (
  330. integration::content_working_group::ContentWorkingGroupCredentials,
  331. integration::versioned_store_permissions::SudoKeyHasAllCredentials,
  332. );
  333. type CreateClassPermissionsChecker =
  334. integration::versioned_store_permissions::ContentLeadOrSudoKeyCanCreateClasses;
  335. }
  336. impl hiring::Trait for Runtime {
  337. type OpeningId = u64;
  338. type ApplicationId = u64;
  339. type ApplicationDeactivatedHandler = (); // TODO - what needs to happen?
  340. type StakeHandlerProvider = hiring::Module<Self>;
  341. }
  342. impl minting::Trait for Runtime {
  343. type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
  344. type MintId = u64;
  345. }
  346. impl recurring_rewards::Trait for Runtime {
  347. type PayoutStatusHandler = (); // TODO - deal with successful and failed payouts
  348. type RecipientId = u64;
  349. type RewardRelationshipId = u64;
  350. }
  351. parameter_types! {
  352. pub const StakePoolId: [u8; 8] = *b"joystake";
  353. }
  354. impl stake::Trait for Runtime {
  355. type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
  356. type StakePoolId = StakePoolId;
  357. type StakingEventsHandler = (
  358. crate::integration::content_working_group::ContentWorkingGroupStakingEventHandler,
  359. (
  360. crate::integration::proposals::StakingEventsHandler<Self>,
  361. crate::integration::working_group::StakingEventsHandler<Self>,
  362. ),
  363. );
  364. type StakeId = u64;
  365. type SlashId = u64;
  366. }
  367. impl content_wg::Trait for Runtime {
  368. type Event = Event;
  369. }
  370. impl common::currency::GovernanceCurrency for Runtime {
  371. type Currency = pallet_balances::Module<Self>;
  372. }
  373. impl governance::election::Trait for Runtime {
  374. type Event = Event;
  375. type CouncilElected = (Council, integration::proposals::CouncilElectedHandler);
  376. }
  377. impl governance::council::Trait for Runtime {
  378. type Event = Event;
  379. type CouncilTermEnded = (CouncilElection,);
  380. }
  381. impl memo::Trait for Runtime {
  382. type Event = Event;
  383. }
  384. parameter_types! {
  385. pub const MaxObjectsPerInjection: u32 = 100;
  386. }
  387. impl storage::data_object_type_registry::Trait for Runtime {
  388. type Event = Event;
  389. type DataObjectTypeId = u64;
  390. }
  391. impl storage::data_directory::Trait for Runtime {
  392. type Event = Event;
  393. type ContentId = ContentId;
  394. type StorageProviderHelper = integration::storage::StorageProviderHelper;
  395. type IsActiveDataObjectType = DataObjectTypeRegistry;
  396. type MemberOriginValidator = MembershipOriginValidator<Self>;
  397. type MaxObjectsPerInjection = MaxObjectsPerInjection;
  398. }
  399. impl storage::data_object_storage_registry::Trait for Runtime {
  400. type Event = Event;
  401. type DataObjectStorageRelationshipId = u64;
  402. type ContentIdExists = DataDirectory;
  403. }
  404. impl membership::Trait for Runtime {
  405. type Event = Event;
  406. type MemberId = u64;
  407. type PaidTermId = u64;
  408. type SubscriptionId = u64;
  409. type ActorId = ActorId;
  410. }
  411. impl forum::Trait for Runtime {
  412. type Event = Event;
  413. type MembershipRegistry = integration::forum::ShimMembershipRegistry;
  414. type ThreadId = ThreadId;
  415. type PostId = PostId;
  416. }
  417. // The storage working group instance alias.
  418. pub type StorageWorkingGroupInstance = working_group::Instance2;
  419. parameter_types! {
  420. pub const MaxWorkerNumberLimit: u32 = 100;
  421. }
  422. impl working_group::Trait<StorageWorkingGroupInstance> for Runtime {
  423. type Event = Event;
  424. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  425. }
  426. impl service_discovery::Trait for Runtime {
  427. type Event = Event;
  428. }
  429. parameter_types! {
  430. pub const ProposalCancellationFee: u64 = 10000;
  431. pub const ProposalRejectionFee: u64 = 5000;
  432. pub const ProposalTitleMaxLength: u32 = 40;
  433. pub const ProposalDescriptionMaxLength: u32 = 3000;
  434. pub const ProposalMaxActiveProposalLimit: u32 = 5;
  435. }
  436. impl proposals_engine::Trait for Runtime {
  437. type Event = Event;
  438. type ProposerOriginValidator = MembershipOriginValidator<Self>;
  439. type VoterOriginValidator = CouncilManager<Self>;
  440. type TotalVotersCounter = CouncilManager<Self>;
  441. type ProposalId = u32;
  442. type StakeHandlerProvider = proposals_engine::DefaultStakeHandlerProvider;
  443. type CancellationFee = ProposalCancellationFee;
  444. type RejectionFee = ProposalRejectionFee;
  445. type TitleMaxLength = ProposalTitleMaxLength;
  446. type DescriptionMaxLength = ProposalDescriptionMaxLength;
  447. type MaxActiveProposalLimit = ProposalMaxActiveProposalLimit;
  448. type DispatchableCallCode = Call;
  449. }
  450. impl Default for Call {
  451. fn default() -> Self {
  452. panic!("shouldn't call default for Call");
  453. }
  454. }
  455. parameter_types! {
  456. pub const ProposalMaxPostEditionNumber: u32 = 0; // post update is disabled
  457. pub const ProposalMaxThreadInARowNumber: u32 = 100_000; // will not be used
  458. pub const ProposalThreadTitleLengthLimit: u32 = 40;
  459. pub const ProposalPostLengthLimit: u32 = 1000;
  460. }
  461. impl proposals_discussion::Trait for Runtime {
  462. type Event = Event;
  463. type PostAuthorOriginValidator = MembershipOriginValidator<Self>;
  464. type ThreadId = ThreadId;
  465. type PostId = PostId;
  466. type MaxPostEditionNumber = ProposalMaxPostEditionNumber;
  467. type ThreadTitleLengthLimit = ProposalThreadTitleLengthLimit;
  468. type PostLengthLimit = ProposalPostLengthLimit;
  469. type MaxThreadInARowNumber = ProposalMaxThreadInARowNumber;
  470. }
  471. parameter_types! {
  472. pub const TextProposalMaxLength: u32 = 5_000;
  473. pub const RuntimeUpgradeWasmProposalMaxLength: u32 = 3_000_000;
  474. }
  475. impl proposals_codex::Trait for Runtime {
  476. type MembershipOriginValidator = MembershipOriginValidator<Self>;
  477. type TextProposalMaxLength = TextProposalMaxLength;
  478. type RuntimeUpgradeWasmProposalMaxLength = RuntimeUpgradeWasmProposalMaxLength;
  479. type ProposalEncoder = ExtrinsicProposalEncoder;
  480. }
  481. parameter_types! {
  482. pub const TombstoneDeposit: Balance = 1; // TODO: adjust fee
  483. pub const RentByteFee: Balance = 1; // TODO: adjust fee
  484. pub const RentDepositOffset: Balance = 0; // no rent deposit
  485. pub const SurchargeReward: Balance = 0; // no reward
  486. }
  487. /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
  488. /// the specifics of the runtime. They can then be made to be agnostic over specific formats
  489. /// of data like extrinsics, allowing for them to continue syncing the network through upgrades
  490. /// to even the core datastructures.
  491. pub mod opaque {
  492. use super::*;
  493. pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
  494. /// Opaque block header type.
  495. pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
  496. /// Opaque block type.
  497. pub type Block = generic::Block<Header, UncheckedExtrinsic>;
  498. /// Opaque block identifier type.
  499. pub type BlockId = generic::BlockId<Block>;
  500. }
  501. construct_runtime!(
  502. pub enum Runtime where
  503. Block = Block,
  504. NodeBlock = opaque::Block,
  505. UncheckedExtrinsic = UncheckedExtrinsic
  506. {
  507. // Substrate
  508. System: system::{Module, Call, Storage, Config, Event<T>},
  509. Utility: pallet_utility::{Module, Call, Event},
  510. Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
  511. Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
  512. Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
  513. Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
  514. TransactionPayment: pallet_transaction_payment::{Module, Storage},
  515. Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
  516. Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
  517. Historical: pallet_session_historical::{Module},
  518. FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent},
  519. Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
  520. ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
  521. AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
  522. Offences: pallet_offences::{Module, Call, Storage, Event},
  523. RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
  524. Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
  525. // Joystream
  526. CouncilElection: election::{Module, Call, Storage, Event<T>, Config<T>},
  527. Council: council::{Module, Call, Storage, Event<T>, Config<T>},
  528. Memo: memo::{Module, Call, Storage, Event<T>},
  529. Members: membership::{Module, Call, Storage, Event<T>, Config<T>},
  530. Forum: forum::{Module, Call, Storage, Event<T>, Config<T>},
  531. VersionedStore: versioned_store::{Module, Call, Storage, Event<T>, Config},
  532. VersionedStorePermissions: versioned_store_permissions::{Module, Call, Storage, Config<T>},
  533. Stake: stake::{Module, Call, Storage},
  534. Minting: minting::{Module, Call, Storage},
  535. RecurringRewards: recurring_rewards::{Module, Call, Storage},
  536. Hiring: hiring::{Module, Call, Storage},
  537. ContentWorkingGroup: content_wg::{Module, Call, Storage, Event<T>, Config<T>},
  538. // --- Storage
  539. DataObjectTypeRegistry: data_object_type_registry::{Module, Call, Storage, Event<T>, Config<T>},
  540. DataDirectory: data_directory::{Module, Call, Storage, Event<T>, Config<T>},
  541. DataObjectStorageRegistry: data_object_storage_registry::{Module, Call, Storage, Event<T>, Config<T>},
  542. Discovery: service_discovery::{Module, Call, Storage, Event<T>},
  543. // --- Proposals
  544. ProposalsEngine: proposals_engine::{Module, Call, Storage, Event<T>},
  545. ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event<T>},
  546. ProposalsCodex: proposals_codex::{Module, Call, Storage, Config<T>},
  547. // --- Working groups
  548. // reserved for the future use: ForumWorkingGroup: working_group::<Instance1>::{Module, Call, Storage, Event<T>},
  549. StorageWorkingGroup: working_group::<Instance2>::{Module, Call, Storage, Config<T>, Event<T>},
  550. }
  551. );