lib.rs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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 forum;
  48. pub use governance::election_params::ElectionParameters;
  49. pub use membership;
  50. #[cfg(any(feature = "std", test))]
  51. pub use pallet_balances::Call as BalancesCall;
  52. pub use pallet_staking::StakerStatus;
  53. pub use proposals_codex::ProposalsConfigParameters;
  54. use storage::data_directory::Voucher;
  55. pub use storage::{data_directory, data_object_type_registry};
  56. pub use working_group;
  57. pub use content;
  58. pub use content::MaxNumber;
  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: 16,
  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. parameter_types! {
  325. pub const MaxNumberOfCuratorsPerGroup: MaxNumber = 50;
  326. pub const ChannelOwnershipPaymentEscrowId: [u8; 8] = *b"chescrow";
  327. }
  328. impl content::Trait for Runtime {
  329. type Event = Event;
  330. type ChannelOwnershipPaymentEscrowId = ChannelOwnershipPaymentEscrowId;
  331. type ChannelCategoryId = ChannelCategoryId;
  332. type VideoId = VideoId;
  333. type VideoCategoryId = VideoCategoryId;
  334. type PlaylistId = PlaylistId;
  335. type PersonId = PersonId;
  336. type SeriesId = SeriesId;
  337. type ChannelOwnershipTransferRequestId = ChannelOwnershipTransferRequestId;
  338. type MaxNumberOfCuratorsPerGroup = MaxNumberOfCuratorsPerGroup;
  339. type StorageSystem = data_directory::Module<Self>;
  340. }
  341. impl hiring::Trait for Runtime {
  342. type OpeningId = u64;
  343. type ApplicationId = u64;
  344. type ApplicationDeactivatedHandler = (); // TODO - what needs to happen?
  345. type StakeHandlerProvider = hiring::Module<Self>;
  346. }
  347. impl minting::Trait for Runtime {
  348. type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
  349. type MintId = u64;
  350. }
  351. impl recurring_rewards::Trait for Runtime {
  352. type PayoutStatusHandler = (); // TODO - deal with successful and failed payouts
  353. type RecipientId = u64;
  354. type RewardRelationshipId = u64;
  355. }
  356. parameter_types! {
  357. pub const StakePoolId: [u8; 8] = *b"joystake";
  358. }
  359. impl stake::Trait for Runtime {
  360. type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
  361. type StakePoolId = StakePoolId;
  362. type StakingEventsHandler = (
  363. crate::integration::proposals::StakingEventsHandler<Self>,
  364. (
  365. crate::integration::working_group::ContentDirectoryWGStakingEventsHandler<Self>,
  366. crate::integration::working_group::StorageWgStakingEventsHandler<Self>,
  367. ),
  368. );
  369. type StakeId = u64;
  370. type SlashId = u64;
  371. }
  372. impl common::currency::GovernanceCurrency for Runtime {
  373. type Currency = pallet_balances::Module<Self>;
  374. }
  375. impl common::MembershipTypes for Runtime {
  376. type MemberId = MemberId;
  377. type ActorId = ActorId;
  378. }
  379. impl common::StorageOwnership for Runtime {
  380. type ChannelId = ChannelId;
  381. type DAOId = DAOId;
  382. type ContentId = ContentId;
  383. type DataObjectTypeId = DataObjectTypeId;
  384. }
  385. impl governance::election::Trait for Runtime {
  386. type Event = Event;
  387. type CouncilElected = (Council, integration::proposals::CouncilElectedHandler);
  388. }
  389. impl governance::council::Trait for Runtime {
  390. type Event = Event;
  391. type CouncilTermEnded = (CouncilElection,);
  392. }
  393. impl memo::Trait for Runtime {
  394. type Event = Event;
  395. }
  396. parameter_types! {
  397. pub const DefaultVoucher: Voucher = Voucher::new(5000, 50);
  398. }
  399. impl storage::data_object_type_registry::Trait for Runtime {
  400. type Event = Event;
  401. }
  402. impl storage::data_directory::Trait for Runtime {
  403. type Event = Event;
  404. type IsActiveDataObjectType = DataObjectTypeRegistry;
  405. type MemberOriginValidator = MembershipOriginValidator<Self>;
  406. }
  407. impl storage::data_object_storage_registry::Trait for Runtime {
  408. type Event = Event;
  409. type DataObjectStorageRelationshipId = u64;
  410. type ContentIdExists = DataDirectory;
  411. }
  412. parameter_types! {
  413. pub const ScreenedMemberMaxInitialBalance: u128 = 5000;
  414. }
  415. impl membership::Trait for Runtime {
  416. type Event = Event;
  417. type MemberId = MemberId;
  418. type PaidTermId = u64;
  419. type SubscriptionId = u64;
  420. type ActorId = ActorId;
  421. type ScreenedMemberMaxInitialBalance = ScreenedMemberMaxInitialBalance;
  422. }
  423. impl forum::Trait for Runtime {
  424. type Event = Event;
  425. type MembershipRegistry = integration::forum::ShimMembershipRegistry;
  426. type ThreadId = ThreadId;
  427. type PostId = PostId;
  428. }
  429. // The storage working group instance alias.
  430. pub type StorageWorkingGroupInstance = working_group::Instance2;
  431. // The content directory working group instance alias.
  432. pub type ContentDirectoryWorkingGroupInstance = working_group::Instance3;
  433. // The builder working group instance alias.
  434. pub type BuilderWorkingGroupInstance = working_group::Instance4;
  435. // The gateway working group instance alias.
  436. pub type GatewayWorkingGroupInstance = working_group::Instance5;
  437. parameter_types! {
  438. pub const MaxWorkerNumberLimit: u32 = 100;
  439. }
  440. impl working_group::Trait<StorageWorkingGroupInstance> for Runtime {
  441. type Event = Event;
  442. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  443. }
  444. impl working_group::Trait<ContentDirectoryWorkingGroupInstance> for Runtime {
  445. type Event = Event;
  446. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  447. }
  448. impl working_group::Trait<BuilderWorkingGroupInstance> for Runtime {
  449. type Event = Event;
  450. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  451. }
  452. impl working_group::Trait<GatewayWorkingGroupInstance> for Runtime {
  453. type Event = Event;
  454. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  455. }
  456. parameter_types! {
  457. pub const ProposalCancellationFee: u64 = 10000;
  458. pub const ProposalRejectionFee: u64 = 5000;
  459. pub const ProposalTitleMaxLength: u32 = 40;
  460. pub const ProposalDescriptionMaxLength: u32 = 3000;
  461. pub const ProposalMaxActiveProposalLimit: u32 = 20;
  462. }
  463. impl proposals_engine::Trait for Runtime {
  464. type Event = Event;
  465. type ProposerOriginValidator = MembershipOriginValidator<Self>;
  466. type VoterOriginValidator = CouncilManager<Self>;
  467. type TotalVotersCounter = CouncilManager<Self>;
  468. type ProposalId = u32;
  469. type StakeHandlerProvider = proposals_engine::DefaultStakeHandlerProvider;
  470. type CancellationFee = ProposalCancellationFee;
  471. type RejectionFee = ProposalRejectionFee;
  472. type TitleMaxLength = ProposalTitleMaxLength;
  473. type DescriptionMaxLength = ProposalDescriptionMaxLength;
  474. type MaxActiveProposalLimit = ProposalMaxActiveProposalLimit;
  475. type DispatchableCallCode = Call;
  476. }
  477. impl Default for Call {
  478. fn default() -> Self {
  479. panic!("shouldn't call default for Call");
  480. }
  481. }
  482. parameter_types! {
  483. pub const ProposalMaxPostEditionNumber: u32 = 0; // post update is disabled
  484. pub const ProposalMaxThreadInARowNumber: u32 = 100_000; // will not be used
  485. pub const ProposalThreadTitleLengthLimit: u32 = 40;
  486. pub const ProposalPostLengthLimit: u32 = 1000;
  487. }
  488. impl proposals_discussion::Trait for Runtime {
  489. type Event = Event;
  490. type PostAuthorOriginValidator = MembershipOriginValidator<Self>;
  491. type ThreadId = ThreadId;
  492. type PostId = PostId;
  493. type MaxPostEditionNumber = ProposalMaxPostEditionNumber;
  494. type ThreadTitleLengthLimit = ProposalThreadTitleLengthLimit;
  495. type PostLengthLimit = ProposalPostLengthLimit;
  496. type MaxThreadInARowNumber = ProposalMaxThreadInARowNumber;
  497. }
  498. parameter_types! {
  499. pub const TextProposalMaxLength: u32 = 5_000;
  500. pub const RuntimeUpgradeWasmProposalMaxLength: u32 = 3_000_000;
  501. }
  502. impl proposals_codex::Trait for Runtime {
  503. type MembershipOriginValidator = MembershipOriginValidator<Self>;
  504. type TextProposalMaxLength = TextProposalMaxLength;
  505. type RuntimeUpgradeWasmProposalMaxLength = RuntimeUpgradeWasmProposalMaxLength;
  506. type ProposalEncoder = ExtrinsicProposalEncoder;
  507. }
  508. parameter_types! {
  509. pub const TombstoneDeposit: Balance = 1; // TODO: adjust fee
  510. pub const RentByteFee: Balance = 1; // TODO: adjust fee
  511. pub const RentDepositOffset: Balance = 0; // no rent deposit
  512. pub const SurchargeReward: Balance = 0; // no reward
  513. }
  514. /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
  515. /// the specifics of the runtime. They can then be made to be agnostic over specific formats
  516. /// of data like extrinsics, allowing for them to continue syncing the network through upgrades
  517. /// to even the core datastructures.
  518. pub mod opaque {
  519. use super::*;
  520. pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
  521. /// Opaque block header type.
  522. pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
  523. /// Opaque block type.
  524. pub type Block = generic::Block<Header, UncheckedExtrinsic>;
  525. /// Opaque block identifier type.
  526. pub type BlockId = generic::BlockId<Block>;
  527. }
  528. construct_runtime!(
  529. pub enum Runtime where
  530. Block = Block,
  531. NodeBlock = opaque::Block,
  532. UncheckedExtrinsic = UncheckedExtrinsic
  533. {
  534. // Substrate
  535. System: system::{Module, Call, Storage, Config, Event<T>},
  536. Utility: pallet_utility::{Module, Call, Event},
  537. Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
  538. Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
  539. Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
  540. Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
  541. TransactionPayment: pallet_transaction_payment::{Module, Storage},
  542. Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
  543. Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
  544. Historical: pallet_session_historical::{Module},
  545. FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent},
  546. Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
  547. ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
  548. AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
  549. Offences: pallet_offences::{Module, Call, Storage, Event},
  550. RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
  551. Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
  552. // Joystream
  553. CouncilElection: election::{Module, Call, Storage, Event<T>, Config<T>},
  554. Council: council::{Module, Call, Storage, Event<T>, Config<T>},
  555. Memo: memo::{Module, Call, Storage, Event<T>},
  556. Members: membership::{Module, Call, Storage, Event<T>, Config<T>},
  557. Forum: forum::{Module, Call, Storage, Event<T>, Config<T>},
  558. Stake: stake::{Module, Call, Storage},
  559. Minting: minting::{Module, Call, Storage},
  560. RecurringRewards: recurring_rewards::{Module, Call, Storage},
  561. Hiring: hiring::{Module, Call, Storage},
  562. Content: content::{Module, Call, Storage, Event<T>, Config<T>},
  563. // --- Storage
  564. DataObjectTypeRegistry: data_object_type_registry::{Module, Call, Storage, Event<T>, Config<T>},
  565. DataDirectory: data_directory::{Module, Call, Storage, Event<T>, Config<T>},
  566. DataObjectStorageRegistry: data_object_storage_registry::{Module, Call, Storage, Event<T>, Config<T>},
  567. // --- Proposals
  568. ProposalsEngine: proposals_engine::{Module, Call, Storage, Event<T>},
  569. ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event<T>},
  570. ProposalsCodex: proposals_codex::{Module, Call, Storage, Config<T>},
  571. // --- Working groups
  572. // reserved for the future use: ForumWorkingGroup: working_group::<Instance1>::{Module, Call, Storage, Event<T>},
  573. StorageWorkingGroup: working_group::<Instance2>::{Module, Call, Storage, Config<T>, Event<T>},
  574. ContentDirectoryWorkingGroup: working_group::<Instance3>::{Module, Call, Storage, Config<T>, Event<T>},
  575. BuilderWorkingGroup: working_group::<Instance4>::{Module, Call, Storage, Config<T>, Event<T>},
  576. GatewayWorkingGroup: working_group::<Instance5>::{Module, Call, Storage, Config<T>, Event<T>},
  577. }
  578. );