lib.rs 24 KB

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