lib.rs 25 KB

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