lib.rs 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  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. #![allow(non_fmt_panic)]
  9. #![allow(clippy::from_over_into)]
  10. // Make the WASM binary available.
  11. // This is required only by the node build.
  12. // A dummy wasm_binary.rs will be built for the IDE.
  13. #[cfg(feature = "std")]
  14. include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
  15. #[cfg(feature = "std")]
  16. /// Wasm binary unwrapped. If built with `BUILD_DUMMY_WASM_BINARY`, the function panics.
  17. pub fn wasm_binary_unwrap() -> &'static [u8] {
  18. WASM_BINARY.expect(
  19. "Development wasm binary is not available. This means the client is \
  20. built with `BUILD_DUMMY_WASM_BINARY` flag and it is only usable for \
  21. production chains. Please rebuild with the flag disabled.",
  22. )
  23. }
  24. mod constants;
  25. mod integration;
  26. pub mod primitives;
  27. mod proposals_configuration;
  28. mod runtime_api;
  29. #[cfg(test)]
  30. mod tests;
  31. /// Weights for pallets used in the runtime.
  32. mod weights; // Runtime integration tests
  33. #[macro_use]
  34. extern crate lazy_static; // for proposals_configuration module
  35. use frame_support::dispatch::DispatchResult;
  36. use frame_support::traits::{
  37. Currency, Imbalance, KeyOwnerProofSystem, LockIdentifier, OnUnbalanced,
  38. };
  39. use frame_support::weights::{
  40. constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
  41. Weight,
  42. };
  43. use frame_support::{construct_runtime, parameter_types};
  44. use frame_system::{EnsureOneOf, EnsureRoot, EnsureSigned};
  45. use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
  46. use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
  47. use pallet_session::historical as pallet_session_historical;
  48. use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
  49. use sp_core::crypto::KeyTypeId;
  50. use sp_core::Hasher;
  51. use sp_runtime::curve::PiecewiseLinear;
  52. use sp_runtime::traits::{BlakeTwo256, Block as BlockT, IdentityLookup, OpaqueKeys, Saturating};
  53. use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, ModuleId, Perbill};
  54. use sp_std::boxed::Box;
  55. use sp_std::vec::Vec;
  56. #[cfg(feature = "std")]
  57. use sp_version::NativeVersion;
  58. use sp_version::RuntimeVersion;
  59. pub use constants::*;
  60. pub use primitives::*;
  61. pub use proposals_configuration::*;
  62. pub use runtime_api::*;
  63. use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder};
  64. use common::working_group::{WorkingGroup, WorkingGroupAuthenticator, WorkingGroupBudgetHandler};
  65. use council::ReferendumConnection;
  66. use referendum::{CastVote, OptionResult};
  67. use staking_handler::{LockComparator, StakingManager};
  68. // Node dependencies
  69. pub use common;
  70. pub use council;
  71. pub use forum;
  72. pub use membership;
  73. #[cfg(any(feature = "std", test))]
  74. pub use pallet_balances::Call as BalancesCall;
  75. pub use pallet_staking::StakerStatus;
  76. pub use proposals_engine::ProposalParameters;
  77. pub use referendum;
  78. pub use working_group;
  79. pub use content;
  80. pub use content::MaxNumber;
  81. /// This runtime version.
  82. pub const VERSION: RuntimeVersion = RuntimeVersion {
  83. spec_name: create_runtime_str!("joystream-node"),
  84. impl_name: create_runtime_str!("joystream-node"),
  85. authoring_version: 10,
  86. spec_version: 0,
  87. impl_version: 0,
  88. apis: crate::runtime_api::EXPORTED_RUNTIME_API_VERSIONS,
  89. transaction_version: 1,
  90. };
  91. /// The version information used to identify this runtime when compiled natively.
  92. #[cfg(feature = "std")]
  93. pub fn native_version() -> NativeVersion {
  94. NativeVersion {
  95. runtime_version: VERSION,
  96. can_author_with: Default::default(),
  97. }
  98. }
  99. parameter_types! {
  100. pub const BlockHashCount: BlockNumber = 250;
  101. /// We allow for 2 seconds of compute with a 6 second average block time.
  102. pub const MaximumBlockWeight: Weight = 2 * frame_support::weights::constants::WEIGHT_PER_SECOND;
  103. pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
  104. pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
  105. pub const Version: RuntimeVersion = VERSION;
  106. /// Assume 10% of weight for average on_initialize calls.
  107. pub MaximumExtrinsicWeight: Weight =
  108. AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT)
  109. * MaximumBlockWeight::get();
  110. }
  111. const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10);
  112. // TODO: We need to adjust weight of this pallet
  113. // once we move to a newer version of substrate where parameters
  114. // are not discarded. See the comment in 'scripts/generate-weights.sh'
  115. impl frame_system::Trait for Runtime {
  116. type BaseCallFilter = ();
  117. type Origin = Origin;
  118. type Call = Call;
  119. type Index = Index;
  120. type BlockNumber = BlockNumber;
  121. type Hash = Hash;
  122. type Hashing = BlakeTwo256;
  123. type AccountId = AccountId;
  124. type Lookup = IdentityLookup<AccountId>;
  125. type Header = generic::Header<BlockNumber, BlakeTwo256>;
  126. type Event = Event;
  127. type BlockHashCount = BlockHashCount;
  128. type MaximumBlockWeight = MaximumBlockWeight;
  129. type DbWeight = RocksDbWeight;
  130. type BlockExecutionWeight = BlockExecutionWeight;
  131. type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
  132. type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
  133. type MaximumBlockLength = MaximumBlockLength;
  134. type AvailableBlockRatio = AvailableBlockRatio;
  135. type Version = Version;
  136. type PalletInfo = PalletInfo;
  137. type AccountData = pallet_balances::AccountData<Balance>;
  138. type OnNewAccount = ();
  139. type OnKilledAccount = ();
  140. type SystemWeightInfo = weights::frame_system::WeightInfo;
  141. }
  142. impl substrate_utility::Trait for Runtime {
  143. type Event = Event;
  144. type Call = Call;
  145. type WeightInfo = weights::substrate_utility::WeightInfo;
  146. }
  147. parameter_types! {
  148. pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64;
  149. pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
  150. }
  151. impl pallet_babe::Trait for Runtime {
  152. type EpochDuration = EpochDuration;
  153. type ExpectedBlockTime = ExpectedBlockTime;
  154. type EpochChangeTrigger = pallet_babe::ExternalTrigger;
  155. type KeyOwnerProofSystem = Historical;
  156. type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
  157. KeyTypeId,
  158. pallet_babe::AuthorityId,
  159. )>>::Proof;
  160. type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
  161. KeyTypeId,
  162. pallet_babe::AuthorityId,
  163. )>>::IdentificationTuple;
  164. type HandleEquivocation =
  165. pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
  166. type WeightInfo = ();
  167. }
  168. impl pallet_grandpa::Trait for Runtime {
  169. type Event = Event;
  170. type Call = Call;
  171. type KeyOwnerProof =
  172. <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
  173. type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
  174. KeyTypeId,
  175. GrandpaId,
  176. )>>::IdentificationTuple;
  177. type KeyOwnerProofSystem = Historical;
  178. type HandleEquivocation =
  179. pallet_grandpa::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
  180. type WeightInfo = ();
  181. }
  182. impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
  183. where
  184. Call: From<LocalCall>,
  185. {
  186. fn create_transaction<C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>>(
  187. call: Call,
  188. public: <Signature as sp_runtime::traits::Verify>::Signer,
  189. account: AccountId,
  190. nonce: Index,
  191. ) -> Option<(
  192. Call,
  193. <UncheckedExtrinsic as sp_runtime::traits::Extrinsic>::SignaturePayload,
  194. )> {
  195. integration::transactions::create_transaction::<C>(call, public, account, nonce)
  196. }
  197. }
  198. impl frame_system::offchain::SigningTypes for Runtime {
  199. type Public = <Signature as sp_runtime::traits::Verify>::Signer;
  200. type Signature = Signature;
  201. }
  202. impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
  203. where
  204. Call: From<C>,
  205. {
  206. type Extrinsic = UncheckedExtrinsic;
  207. type OverarchingCall = Call;
  208. }
  209. parameter_types! {
  210. pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
  211. }
  212. impl pallet_timestamp::Trait for Runtime {
  213. type Moment = Moment;
  214. type OnTimestampSet = Babe;
  215. type MinimumPeriod = MinimumPeriod;
  216. type WeightInfo = weights::pallet_timestamp::WeightInfo;
  217. }
  218. parameter_types! {
  219. pub const MaxLocks: u32 = 50;
  220. }
  221. impl pallet_balances::Trait for Runtime {
  222. type Balance = Balance;
  223. type DustRemoval = ();
  224. type Event = Event;
  225. type ExistentialDeposit = ExistentialDeposit;
  226. type AccountStore = System;
  227. type WeightInfo = weights::pallet_balances::WeightInfo;
  228. type MaxLocks = MaxLocks;
  229. }
  230. parameter_types! {
  231. pub const TransactionByteFee: Balance = 1;
  232. }
  233. type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
  234. pub struct Author;
  235. impl OnUnbalanced<NegativeImbalance> for Author {
  236. fn on_nonzero_unbalanced(amount: NegativeImbalance) {
  237. Balances::resolve_creating(&Authorship::author(), amount);
  238. }
  239. }
  240. pub struct DealWithFees;
  241. impl OnUnbalanced<NegativeImbalance> for DealWithFees {
  242. fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
  243. if let Some(fees) = fees_then_tips.next() {
  244. // for fees, 20% to author, for now we don't have treasury so the 80% is ignored
  245. let mut split = fees.ration(80, 20);
  246. if let Some(tips) = fees_then_tips.next() {
  247. // For tips %100 are for the author
  248. tips.ration_merge_into(0, 100, &mut split);
  249. }
  250. Author::on_unbalanced(split.1);
  251. }
  252. }
  253. }
  254. impl pallet_transaction_payment::Trait for Runtime {
  255. type Currency = Balances;
  256. type OnTransactionPayment = DealWithFees;
  257. type TransactionByteFee = TransactionByteFee;
  258. type WeightToFee = constants::fees::WeightToFee;
  259. type FeeMultiplierUpdate = constants::fees::SlowAdjustingFeeUpdate<Self>;
  260. }
  261. impl pallet_sudo::Trait for Runtime {
  262. type Event = Event;
  263. type Call = Call;
  264. }
  265. parameter_types! {
  266. pub const UncleGenerations: BlockNumber = 0;
  267. }
  268. impl pallet_authorship::Trait for Runtime {
  269. type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
  270. type UncleGenerations = UncleGenerations;
  271. type FilterUncle = ();
  272. type EventHandler = (Staking, ImOnline);
  273. }
  274. impl_opaque_keys! {
  275. pub struct SessionKeys {
  276. pub grandpa: Grandpa,
  277. pub babe: Babe,
  278. pub im_online: ImOnline,
  279. pub authority_discovery: AuthorityDiscovery,
  280. }
  281. }
  282. // NOTE: `SessionHandler` and `SessionKeys` are co-dependent: One key will be used for each handler.
  283. // The number and order of items in `SessionHandler` *MUST* be the same number and order of keys in
  284. // `SessionKeys`.
  285. // TODO: Introduce some structure to tie these together to make it a bit less of a footgun. This
  286. // should be easy, since OneSessionHandler trait provides the `Key` as an associated type. #2858
  287. parameter_types! {
  288. pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
  289. }
  290. impl pallet_session::Trait for Runtime {
  291. type Event = Event;
  292. type ValidatorId = AccountId;
  293. type ValidatorIdOf = pallet_staking::StashOf<Self>;
  294. type ShouldEndSession = Babe;
  295. type NextSessionRotation = Babe;
  296. type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
  297. type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
  298. type Keys = SessionKeys;
  299. type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
  300. type WeightInfo = weights::pallet_session::WeightInfo;
  301. }
  302. impl pallet_session::historical::Trait for Runtime {
  303. type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
  304. type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
  305. }
  306. pallet_staking_reward_curve::build! {
  307. const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
  308. min_inflation: 0_050_000,
  309. max_inflation: 0_750_000,
  310. ideal_stake: 0_300_000,
  311. falloff: 0_050_000,
  312. max_piece_count: 100,
  313. test_precision: 0_005_000,
  314. );
  315. }
  316. parameter_types! {
  317. pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_SLOTS as _;
  318. pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
  319. /// We prioritize im-online heartbeats over election solution submission.
  320. pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2;
  321. }
  322. parameter_types! {
  323. pub const SessionsPerEra: sp_staking::SessionIndex = 6;
  324. pub const BondingDuration: pallet_staking::EraIndex = BONDING_DURATION;
  325. pub const SlashDeferDuration: pallet_staking::EraIndex = BONDING_DURATION - 1; // 'slightly less' than the bonding duration.
  326. pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
  327. pub const MaxNominatorRewardedPerValidator: u32 = 64;
  328. pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4;
  329. pub const MaxIterations: u32 = 10;
  330. // 0.05%. The higher the value, the more strict solution acceptance becomes.
  331. pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000);
  332. }
  333. impl pallet_staking::Trait for Runtime {
  334. type Currency = Balances;
  335. type UnixTime = Timestamp;
  336. type CurrencyToVote = CurrencyToVoteHandler;
  337. type RewardRemainder = (); // Could be Treasury.
  338. type Event = Event;
  339. type Slash = (); // Where to send the slashed funds. Could be Treasury.
  340. type Reward = (); // Rewards are minted from the void.
  341. type SessionsPerEra = SessionsPerEra;
  342. type BondingDuration = BondingDuration;
  343. type SlashDeferDuration = SlashDeferDuration;
  344. type SlashCancelOrigin = EnsureRoot<AccountId>; // Requires sudo. Parity recommends: a super-majority of the council can cancel the slash.
  345. type SessionInterface = Self;
  346. type RewardCurve = RewardCurve;
  347. type NextNewSession = Session;
  348. type ElectionLookahead = ElectionLookahead;
  349. type Call = Call;
  350. type MaxIterations = MaxIterations;
  351. type MinSolutionScoreBump = MinSolutionScoreBump;
  352. type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
  353. type UnsignedPriority = StakingUnsignedPriority;
  354. type WeightInfo = weights::pallet_staking::WeightInfo;
  355. }
  356. impl pallet_im_online::Trait for Runtime {
  357. type AuthorityId = ImOnlineId;
  358. type Event = Event;
  359. type SessionDuration = SessionDuration;
  360. type ReportUnresponsiveness = Offences;
  361. // Using the default weights until we check if we can run the benchmarks for this pallet in
  362. // the reference machine in an acceptable time.
  363. type WeightInfo = ();
  364. type UnsignedPriority = ImOnlineUnsignedPriority;
  365. }
  366. parameter_types! {
  367. pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
  368. }
  369. impl pallet_offences::Trait for Runtime {
  370. type Event = Event;
  371. type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
  372. type OnOffenceHandler = Staking;
  373. type WeightSoftLimit = OffencesWeightSoftLimit;
  374. }
  375. impl pallet_authority_discovery::Trait for Runtime {}
  376. parameter_types! {
  377. pub const WindowSize: BlockNumber = 101;
  378. pub const ReportLatency: BlockNumber = 1000;
  379. }
  380. impl pallet_finality_tracker::Trait for Runtime {
  381. type OnFinalizationStalled = ();
  382. type WindowSize = WindowSize;
  383. type ReportLatency = ReportLatency;
  384. }
  385. impl common::currency::GovernanceCurrency for Runtime {
  386. type Currency = pallet_balances::Module<Self>;
  387. }
  388. parameter_types! {
  389. pub const MaxNumberOfCuratorsPerGroup: MaxNumber = 50;
  390. pub const MaxModerators: u64 = 5; // TODO: update
  391. pub const CleanupMargin: u32 = 3; // TODO: update
  392. pub const CleanupCost: u32 = 1; // TODO: update
  393. pub const PricePerByte: u32 = 2; // TODO: update
  394. pub const ContentModuleId: ModuleId = ModuleId(*b"mContent"); // module content
  395. pub const BloatBondCap: u32 = 1000; // TODO: update
  396. pub const VideosMigrationsEachBlock: u64 = 100;
  397. pub const ChannelsMigrationsEachBlock: u64 = 25;
  398. }
  399. impl content::Trait for Runtime {
  400. type Event = Event;
  401. type ChannelCategoryId = ChannelCategoryId;
  402. type VideoId = VideoId;
  403. type VideoCategoryId = VideoCategoryId;
  404. type MaxNumberOfCuratorsPerGroup = MaxNumberOfCuratorsPerGroup;
  405. type DataObjectStorage = Storage;
  406. type VideoPostId = VideoPostId;
  407. type ReactionId = ReactionId;
  408. type MaxModerators = MaxModerators;
  409. type PricePerByte = PricePerByte;
  410. type BloatBondCap = BloatBondCap;
  411. type CleanupMargin = CleanupMargin;
  412. type CleanupCost = CleanupCost;
  413. type ModuleId = ContentModuleId;
  414. type VideosMigrationsEachBlock = VideosMigrationsEachBlock;
  415. type ChannelsMigrationsEachBlock = ChannelsMigrationsEachBlock;
  416. }
  417. // The referendum instance alias.
  418. pub type ReferendumInstance = referendum::Instance1;
  419. pub type ReferendumModule = referendum::Module<Runtime, ReferendumInstance>;
  420. pub type CouncilModule = council::Module<Runtime>;
  421. parameter_types! {
  422. // referendum parameters
  423. pub const MaxSaltLength: u64 = 32;
  424. pub const VoteStageDuration: BlockNumber = 5;
  425. pub const RevealStageDuration: BlockNumber = 7;
  426. pub const MinimumVotingStake: u64 = 10000;
  427. // council parameteres
  428. pub const MinNumberOfExtraCandidates: u64 = 1;
  429. pub const AnnouncingPeriodDuration: BlockNumber = 15;
  430. pub const IdlePeriodDuration: BlockNumber = 27;
  431. pub const CouncilSize: u64 = 3;
  432. pub const MinCandidateStake: u64 = 11000;
  433. pub const ElectedMemberRewardPeriod: BlockNumber = 10;
  434. pub const DefaultBudgetIncrement: u64 = 1000;
  435. pub const BudgetRefillPeriod: BlockNumber = 1000;
  436. pub const MaxWinnerTargetCount: u64 = 10;
  437. }
  438. impl referendum::Trait<ReferendumInstance> for Runtime {
  439. type Event = Event;
  440. type MaxSaltLength = MaxSaltLength;
  441. type StakingHandler = staking_handler::StakingManager<Self, VotingLockId>;
  442. type ManagerOrigin =
  443. EnsureOneOf<Self::AccountId, EnsureSigned<Self::AccountId>, EnsureRoot<Self::AccountId>>;
  444. type VotePower = Balance;
  445. type VoteStageDuration = VoteStageDuration;
  446. type RevealStageDuration = RevealStageDuration;
  447. type MinimumStake = MinimumVotingStake;
  448. type WeightInfo = weights::referendum::WeightInfo;
  449. type MaxWinnerTargetCount = MaxWinnerTargetCount;
  450. fn calculate_vote_power(
  451. _account_id: &<Self as frame_system::Trait>::AccountId,
  452. stake: &Balance,
  453. ) -> Self::VotePower {
  454. *stake
  455. }
  456. fn can_unlock_vote_stake(vote: &CastVote<Self::Hash, Balance, Self::MemberId>) -> bool {
  457. <CouncilModule as ReferendumConnection<Runtime>>::can_unlock_vote_stake(vote).is_ok()
  458. }
  459. fn process_results(winners: &[OptionResult<Self::MemberId, Self::VotePower>]) {
  460. let tmp_winners: Vec<OptionResult<Self::MemberId, Self::VotePower>> = winners
  461. .iter()
  462. .map(|item| OptionResult {
  463. option_id: item.option_id,
  464. vote_power: item.vote_power,
  465. })
  466. .collect();
  467. <CouncilModule as ReferendumConnection<Runtime>>::recieve_referendum_results(
  468. tmp_winners.as_slice(),
  469. );
  470. }
  471. fn is_valid_option_id(option_index: &u64) -> bool {
  472. <CouncilModule as ReferendumConnection<Runtime>>::is_valid_candidate_id(option_index)
  473. }
  474. fn get_option_power(option_id: &u64) -> Self::VotePower {
  475. <CouncilModule as ReferendumConnection<Runtime>>::get_option_power(option_id)
  476. }
  477. fn increase_option_power(option_id: &u64, amount: &Self::VotePower) {
  478. <CouncilModule as ReferendumConnection<Runtime>>::increase_option_power(option_id, amount);
  479. }
  480. }
  481. impl council::Trait for Runtime {
  482. type Event = Event;
  483. type Referendum = ReferendumModule;
  484. type MinNumberOfExtraCandidates = MinNumberOfExtraCandidates;
  485. type CouncilSize = CouncilSize;
  486. type AnnouncingPeriodDuration = AnnouncingPeriodDuration;
  487. type IdlePeriodDuration = IdlePeriodDuration;
  488. type MinCandidateStake = MinCandidateStake;
  489. type CandidacyLock = StakingManager<Self, CandidacyLockId>;
  490. type CouncilorLock = StakingManager<Self, CouncilorLockId>;
  491. type StakingAccountValidator = Members;
  492. type ElectedMemberRewardPeriod = ElectedMemberRewardPeriod;
  493. type BudgetRefillPeriod = BudgetRefillPeriod;
  494. type MemberOriginValidator = Members;
  495. type WeightInfo = weights::council::WeightInfo;
  496. fn new_council_elected(_elected_members: &[council::CouncilMemberOf<Self>]) {
  497. <proposals_engine::Module<Runtime>>::reject_active_proposals();
  498. <proposals_engine::Module<Runtime>>::reactivate_pending_constitutionality_proposals();
  499. }
  500. }
  501. impl common::StorageOwnership for Runtime {
  502. type ChannelId = ChannelId;
  503. type ContentId = ContentId;
  504. type DataObjectTypeId = DataObjectTypeId;
  505. }
  506. impl memo::Trait for Runtime {
  507. type Event = Event;
  508. }
  509. parameter_types! {
  510. pub const MaxDistributionBucketFamilyNumber: u64 = 200;
  511. pub const DataObjectDeletionPrize: Balance = 0; //TODO: Change during Olympia release
  512. pub const BlacklistSizeLimit: u64 = 10000; //TODO: adjust value
  513. pub const MaxRandomIterationNumber: u64 = 10; //TODO: adjust value
  514. pub const MaxNumberOfPendingInvitationsPerDistributionBucket: u64 = 20; //TODO: adjust value
  515. pub const StorageModuleId: ModuleId = ModuleId(*b"mstorage"); // module storage
  516. pub const StorageBucketsPerBagValueConstraint: storage::StorageBucketsPerBagValueConstraint =
  517. storage::StorageBucketsPerBagValueConstraint {min: 5, max_min_diff: 15}; //TODO: adjust value
  518. pub const DefaultMemberDynamicBagNumberOfStorageBuckets: u64 = 5; //TODO: adjust value
  519. pub const DefaultChannelDynamicBagNumberOfStorageBuckets: u64 = 5; //TODO: adjust value
  520. pub const DistributionBucketsPerBagValueConstraint: storage::DistributionBucketsPerBagValueConstraint =
  521. storage::DistributionBucketsPerBagValueConstraint {min: 1, max_min_diff: 100}; //TODO: adjust value
  522. pub const MaxDataObjectSize: u64 = 10 * 1024 * 1024 * 1024; // 10 GB
  523. }
  524. impl storage::Trait for Runtime {
  525. type Event = Event;
  526. type DataObjectId = DataObjectId;
  527. type StorageBucketId = StorageBucketId;
  528. type DistributionBucketIndex = DistributionBucketIndex;
  529. type DistributionBucketFamilyId = DistributionBucketFamilyId;
  530. type ChannelId = ChannelId;
  531. type DataObjectDeletionPrize = DataObjectDeletionPrize;
  532. type BlacklistSizeLimit = BlacklistSizeLimit;
  533. type ModuleId = StorageModuleId;
  534. type StorageBucketsPerBagValueConstraint = StorageBucketsPerBagValueConstraint;
  535. type DefaultMemberDynamicBagNumberOfStorageBuckets =
  536. DefaultMemberDynamicBagNumberOfStorageBuckets;
  537. type DefaultChannelDynamicBagNumberOfStorageBuckets =
  538. DefaultChannelDynamicBagNumberOfStorageBuckets;
  539. type Randomness = RandomnessCollectiveFlip;
  540. type MaxRandomIterationNumber = MaxRandomIterationNumber;
  541. type MaxDistributionBucketFamilyNumber = MaxDistributionBucketFamilyNumber;
  542. type DistributionBucketsPerBagValueConstraint = DistributionBucketsPerBagValueConstraint;
  543. type DistributionBucketOperatorId = DistributionBucketOperatorId;
  544. type MaxNumberOfPendingInvitationsPerDistributionBucket =
  545. MaxNumberOfPendingInvitationsPerDistributionBucket;
  546. type MaxDataObjectSize = MaxDataObjectSize;
  547. type ContentId = ContentId;
  548. fn ensure_storage_working_group_leader_origin(origin: Self::Origin) -> DispatchResult {
  549. StorageWorkingGroup::ensure_leader_origin(origin)
  550. }
  551. fn ensure_storage_worker_origin(origin: Self::Origin, worker_id: ActorId) -> DispatchResult {
  552. StorageWorkingGroup::ensure_worker_origin(origin, &worker_id)
  553. }
  554. fn ensure_storage_worker_exists(worker_id: &ActorId) -> DispatchResult {
  555. StorageWorkingGroup::ensure_worker_exists(&worker_id)
  556. }
  557. fn ensure_distribution_working_group_leader_origin(origin: Self::Origin) -> DispatchResult {
  558. DistributionWorkingGroup::ensure_leader_origin(origin)
  559. }
  560. fn ensure_distribution_worker_origin(
  561. origin: Self::Origin,
  562. worker_id: ActorId,
  563. ) -> DispatchResult {
  564. DistributionWorkingGroup::ensure_worker_origin(origin, &worker_id)
  565. }
  566. fn ensure_distribution_worker_exists(worker_id: &ActorId) -> DispatchResult {
  567. DistributionWorkingGroup::ensure_worker_exists(&worker_id)
  568. }
  569. }
  570. impl common::membership::MembershipTypes for Runtime {
  571. type MemberId = MemberId;
  572. type ActorId = ActorId;
  573. }
  574. parameter_types! {
  575. pub const DefaultMembershipPrice: Balance = 100;
  576. pub const ReferralCutMaximumPercent: u8 = 50;
  577. pub const DefaultInitialInvitationBalance: Balance = 100;
  578. // The candidate stake should be more than the transaction fee which currently is 53
  579. pub const CandidateStake: Balance = 200;
  580. }
  581. impl membership::Trait for Runtime {
  582. type Event = Event;
  583. type DefaultMembershipPrice = DefaultMembershipPrice;
  584. type DefaultInitialInvitationBalance = DefaultInitialInvitationBalance;
  585. type InvitedMemberStakingHandler = InvitedMemberStakingManager;
  586. type StakingCandidateStakingHandler = StakingCandidateStakingHandler;
  587. type WorkingGroup = MembershipWorkingGroup;
  588. type WeightInfo = weights::membership::WeightInfo;
  589. type ReferralCutMaximumPercent = ReferralCutMaximumPercent;
  590. type CandidateStake = CandidateStake;
  591. }
  592. parameter_types! {
  593. pub const MaxCategoryDepth: u64 = 6;
  594. pub const MaxSubcategories: u64 = 20;
  595. pub const MaxThreadsInCategory: u64 = 20;
  596. pub const MaxPostsInThread: u64 = 20;
  597. pub const MaxModeratorsForCategory: u64 = 20;
  598. pub const MaxCategories: u64 = 20;
  599. pub const MaxPollAlternativesNumber: u64 = 20;
  600. pub const ThreadDeposit: u64 = 30;
  601. pub const PostDeposit: u64 = 10;
  602. pub const ForumModuleId: ModuleId = ModuleId(*b"mo:forum"); // module : forum
  603. pub const PostLifeTime: BlockNumber = 3600;
  604. }
  605. pub struct MapLimits;
  606. impl forum::StorageLimits for MapLimits {
  607. type MaxSubcategories = MaxSubcategories;
  608. type MaxModeratorsForCategory = MaxModeratorsForCategory;
  609. type MaxCategories = MaxCategories;
  610. type MaxPollAlternativesNumber = MaxPollAlternativesNumber;
  611. }
  612. impl forum::Trait for Runtime {
  613. type Event = Event;
  614. type ThreadId = ThreadId;
  615. type PostId = PostId;
  616. type CategoryId = u64;
  617. type PostReactionId = u64;
  618. type MaxCategoryDepth = MaxCategoryDepth;
  619. type ThreadDeposit = ThreadDeposit;
  620. type PostDeposit = PostDeposit;
  621. type ModuleId = ForumModuleId;
  622. type MapLimits = MapLimits;
  623. type WeightInfo = weights::forum::WeightInfo;
  624. type WorkingGroup = ForumWorkingGroup;
  625. type MemberOriginValidator = Members;
  626. type PostLifeTime = PostLifeTime;
  627. fn calculate_hash(text: &[u8]) -> Self::Hash {
  628. Self::Hashing::hash(text)
  629. }
  630. }
  631. impl LockComparator<<Runtime as pallet_balances::Trait>::Balance> for Runtime {
  632. fn are_locks_conflicting(new_lock: &LockIdentifier, existing_locks: &[LockIdentifier]) -> bool {
  633. existing_locks
  634. .iter()
  635. .any(|lock| !ALLOWED_LOCK_COMBINATIONS.contains(&(*new_lock, *lock)))
  636. }
  637. }
  638. parameter_types! {
  639. pub const MaxWorkerNumberLimit: u32 = 100;
  640. pub const MinUnstakingPeriodLimit: u32 = 43200;
  641. pub const ForumWorkingGroupRewardPeriod: u32 = 14400 + 10;
  642. pub const StorageWorkingGroupRewardPeriod: u32 = 14400 + 20;
  643. pub const ContentWorkingGroupRewardPeriod: u32 = 14400 + 30;
  644. pub const MembershipRewardPeriod: u32 = 14400 + 40;
  645. pub const GatewayRewardPeriod: u32 = 14400 + 50;
  646. pub const DistributionRewardPeriod: u32 = 14400 + 50;
  647. pub const OperationsAlphaRewardPeriod: u32 = 14400 + 60;
  648. pub const OperationsBetaRewardPeriod: u32 = 14400 + 70;
  649. pub const OperationsGammaRewardPeriod: u32 = 14400 + 80;
  650. // This should be more costly than `apply_on_opening` fee with the current configuration
  651. // the base cost of `apply_on_opening` in tokens is 193. And has a very slight slope
  652. // with the lenght with the length of rationale, with 2000 stake we are probably safe.
  653. pub const MinimumApplicationStake: Balance = 2000;
  654. // This should be more costly than `add_opening` fee with the current configuration
  655. // the base cost of `add_opening` in tokens is 81. And has a very slight slope
  656. // with the lenght with the length of rationale, with 2000 stake we are probably safe.
  657. pub const LeaderOpeningStake: Balance = 2000;
  658. }
  659. // Staking managers type aliases.
  660. pub type ForumWorkingGroupStakingManager =
  661. staking_handler::StakingManager<Runtime, ForumGroupLockId>;
  662. pub type ContentWorkingGroupStakingManager =
  663. staking_handler::StakingManager<Runtime, ContentWorkingGroupLockId>;
  664. pub type StorageWorkingGroupStakingManager =
  665. staking_handler::StakingManager<Runtime, StorageWorkingGroupLockId>;
  666. pub type MembershipWorkingGroupStakingManager =
  667. staking_handler::StakingManager<Runtime, MembershipWorkingGroupLockId>;
  668. pub type InvitedMemberStakingManager =
  669. staking_handler::StakingManager<Runtime, InvitedMemberLockId>;
  670. pub type StakingCandidateStakingHandler =
  671. staking_handler::StakingManager<Runtime, StakingCandidateLockId>;
  672. pub type GatewayWorkingGroupStakingManager =
  673. staking_handler::StakingManager<Runtime, GatewayWorkingGroupLockId>;
  674. pub type OperationsWorkingGroupAlphaStakingManager =
  675. staking_handler::StakingManager<Runtime, OperationsWorkingGroupAlphaLockId>;
  676. pub type OperationsWorkingGroupBetaStakingManager =
  677. staking_handler::StakingManager<Runtime, OperationsWorkingGroupBetaLockId>;
  678. pub type OperationsWorkingGroupGammaStakingManager =
  679. staking_handler::StakingManager<Runtime, OperationsWorkingGroupGammaLockId>;
  680. pub type DistributionWorkingGroupStakingManager =
  681. staking_handler::StakingManager<Runtime, DistributionWorkingGroupLockId>;
  682. // The forum working group instance alias.
  683. pub type ForumWorkingGroupInstance = working_group::Instance1;
  684. // The storage working group instance alias.
  685. pub type StorageWorkingGroupInstance = working_group::Instance2;
  686. // The content directory working group instance alias.
  687. pub type ContentWorkingGroupInstance = working_group::Instance3;
  688. // The builder working group instance alias.
  689. pub type OperationsWorkingGroupInstanceAlpha = working_group::Instance4;
  690. // The gateway working group instance alias.
  691. pub type GatewayWorkingGroupInstance = working_group::Instance5;
  692. // The membership working group instance alias.
  693. pub type MembershipWorkingGroupInstance = working_group::Instance6;
  694. // The builder working group instance alias.
  695. pub type OperationsWorkingGroupInstanceBeta = working_group::Instance7;
  696. // The builder working group instance alias.
  697. pub type OperationsWorkingGroupInstanceGamma = working_group::Instance8;
  698. // The distribution working group instance alias.
  699. pub type DistributionWorkingGroupInstance = working_group::Instance9;
  700. impl working_group::Trait<ForumWorkingGroupInstance> for Runtime {
  701. type Event = Event;
  702. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  703. type StakingHandler = ForumWorkingGroupStakingManager;
  704. type StakingAccountValidator = Members;
  705. type MemberOriginValidator = Members;
  706. type MinUnstakingPeriodLimit = MinUnstakingPeriodLimit;
  707. type RewardPeriod = ForumWorkingGroupRewardPeriod;
  708. type WeightInfo = weights::working_group::WeightInfo;
  709. type MinimumApplicationStake = MinimumApplicationStake;
  710. type LeaderOpeningStake = LeaderOpeningStake;
  711. }
  712. impl working_group::Trait<StorageWorkingGroupInstance> for Runtime {
  713. type Event = Event;
  714. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  715. type StakingHandler = StorageWorkingGroupStakingManager;
  716. type StakingAccountValidator = Members;
  717. type MemberOriginValidator = Members;
  718. type MinUnstakingPeriodLimit = MinUnstakingPeriodLimit;
  719. type RewardPeriod = StorageWorkingGroupRewardPeriod;
  720. type WeightInfo = weights::working_group::WeightInfo;
  721. type MinimumApplicationStake = MinimumApplicationStake;
  722. type LeaderOpeningStake = LeaderOpeningStake;
  723. }
  724. impl working_group::Trait<ContentWorkingGroupInstance> for Runtime {
  725. type Event = Event;
  726. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  727. type StakingHandler = ContentWorkingGroupStakingManager;
  728. type StakingAccountValidator = Members;
  729. type MemberOriginValidator = Members;
  730. type MinUnstakingPeriodLimit = MinUnstakingPeriodLimit;
  731. type RewardPeriod = ContentWorkingGroupRewardPeriod;
  732. type WeightInfo = weights::working_group::WeightInfo;
  733. type MinimumApplicationStake = MinimumApplicationStake;
  734. type LeaderOpeningStake = LeaderOpeningStake;
  735. }
  736. impl working_group::Trait<MembershipWorkingGroupInstance> for Runtime {
  737. type Event = Event;
  738. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  739. type StakingHandler = MembershipWorkingGroupStakingManager;
  740. type StakingAccountValidator = Members;
  741. type MemberOriginValidator = Members;
  742. type MinUnstakingPeriodLimit = MinUnstakingPeriodLimit;
  743. type RewardPeriod = MembershipRewardPeriod;
  744. type WeightInfo = weights::working_group::WeightInfo;
  745. type MinimumApplicationStake = MinimumApplicationStake;
  746. type LeaderOpeningStake = LeaderOpeningStake;
  747. }
  748. impl working_group::Trait<OperationsWorkingGroupInstanceAlpha> for Runtime {
  749. type Event = Event;
  750. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  751. type StakingHandler = OperationsWorkingGroupAlphaStakingManager;
  752. type StakingAccountValidator = Members;
  753. type MemberOriginValidator = Members;
  754. type MinUnstakingPeriodLimit = MinUnstakingPeriodLimit;
  755. type RewardPeriod = OperationsAlphaRewardPeriod;
  756. type WeightInfo = weights::working_group::WeightInfo;
  757. type MinimumApplicationStake = MinimumApplicationStake;
  758. type LeaderOpeningStake = LeaderOpeningStake;
  759. }
  760. impl working_group::Trait<GatewayWorkingGroupInstance> for Runtime {
  761. type Event = Event;
  762. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  763. type StakingHandler = GatewayWorkingGroupStakingManager;
  764. type StakingAccountValidator = Members;
  765. type MemberOriginValidator = Members;
  766. type MinUnstakingPeriodLimit = MinUnstakingPeriodLimit;
  767. type RewardPeriod = GatewayRewardPeriod;
  768. type WeightInfo = weights::working_group::WeightInfo;
  769. type MinimumApplicationStake = MinimumApplicationStake;
  770. type LeaderOpeningStake = LeaderOpeningStake;
  771. }
  772. impl working_group::Trait<OperationsWorkingGroupInstanceBeta> for Runtime {
  773. type Event = Event;
  774. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  775. type StakingHandler = OperationsWorkingGroupBetaStakingManager;
  776. type StakingAccountValidator = Members;
  777. type MemberOriginValidator = Members;
  778. type MinUnstakingPeriodLimit = MinUnstakingPeriodLimit;
  779. type RewardPeriod = OperationsBetaRewardPeriod;
  780. type WeightInfo = weights::working_group::WeightInfo;
  781. type MinimumApplicationStake = MinimumApplicationStake;
  782. type LeaderOpeningStake = LeaderOpeningStake;
  783. }
  784. impl working_group::Trait<OperationsWorkingGroupInstanceGamma> for Runtime {
  785. type Event = Event;
  786. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  787. type StakingHandler = OperationsWorkingGroupGammaStakingManager;
  788. type StakingAccountValidator = Members;
  789. type MemberOriginValidator = Members;
  790. type MinUnstakingPeriodLimit = MinUnstakingPeriodLimit;
  791. type RewardPeriod = OperationsGammaRewardPeriod;
  792. type WeightInfo = weights::working_group::WeightInfo;
  793. type MinimumApplicationStake = MinimumApplicationStake;
  794. type LeaderOpeningStake = LeaderOpeningStake;
  795. }
  796. impl working_group::Trait<DistributionWorkingGroupInstance> for Runtime {
  797. type Event = Event;
  798. type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
  799. type StakingHandler = DistributionWorkingGroupStakingManager;
  800. type StakingAccountValidator = Members;
  801. type MemberOriginValidator = Members;
  802. type MinUnstakingPeriodLimit = MinUnstakingPeriodLimit;
  803. type RewardPeriod = DistributionRewardPeriod;
  804. type WeightInfo = weights::working_group::WeightInfo;
  805. type MinimumApplicationStake = MinimumApplicationStake;
  806. type LeaderOpeningStake = LeaderOpeningStake;
  807. }
  808. parameter_types! {
  809. pub const ProposalCancellationFee: u64 = 10000;
  810. pub const ProposalRejectionFee: u64 = 5000;
  811. pub const ProposalTitleMaxLength: u32 = 40;
  812. pub const ProposalDescriptionMaxLength: u32 = 3000;
  813. pub const ProposalMaxActiveProposalLimit: u32 = 20;
  814. }
  815. impl proposals_engine::Trait for Runtime {
  816. type Event = Event;
  817. type ProposerOriginValidator = Members;
  818. type CouncilOriginValidator = Council;
  819. type TotalVotersCounter = CouncilManager<Self>;
  820. type ProposalId = u32;
  821. type StakingHandler = staking_handler::StakingManager<Self, ProposalsLockId>;
  822. type CancellationFee = ProposalCancellationFee;
  823. type RejectionFee = ProposalRejectionFee;
  824. type TitleMaxLength = ProposalTitleMaxLength;
  825. type DescriptionMaxLength = ProposalDescriptionMaxLength;
  826. type MaxActiveProposalLimit = ProposalMaxActiveProposalLimit;
  827. type DispatchableCallCode = Call;
  828. type ProposalObserver = ProposalsCodex;
  829. type WeightInfo = weights::proposals_engine::WeightInfo;
  830. type StakingAccountValidator = Members;
  831. }
  832. impl Default for Call {
  833. fn default() -> Self {
  834. panic!("shouldn't call default for Call");
  835. }
  836. }
  837. parameter_types! {
  838. pub const MaxWhiteListSize: u32 = 20;
  839. pub const ProposalsPostDeposit: Balance = 2000;
  840. // module : proposals_discussion
  841. pub const ProposalsDiscussionModuleId: ModuleId = ModuleId(*b"mo:prdis");
  842. pub const ForumPostLifeTime: BlockNumber = 3600;
  843. }
  844. macro_rules! call_wg {
  845. ($working_group:ident, $function:ident $(,$x:expr)*) => {{
  846. match $working_group {
  847. WorkingGroup::Content => <ContentWorkingGroup as WorkingGroupBudgetHandler<Runtime>>::$function($($x,)*),
  848. WorkingGroup::Storage => <StorageWorkingGroup as WorkingGroupBudgetHandler<Runtime>>::$function($($x,)*),
  849. WorkingGroup::Forum => <ForumWorkingGroup as WorkingGroupBudgetHandler<Runtime>>::$function($($x,)*),
  850. WorkingGroup::Membership => <MembershipWorkingGroup as WorkingGroupBudgetHandler<Runtime>>::$function($($x,)*),
  851. WorkingGroup::Gateway => <GatewayWorkingGroup as WorkingGroupBudgetHandler<Runtime>>::$function($($x,)*),
  852. WorkingGroup::Distribution => <DistributionWorkingGroup as WorkingGroupBudgetHandler<Runtime>>::$function($($x,)*),
  853. WorkingGroup::OperationsAlpha => <OperationsWorkingGroupAlpha as WorkingGroupBudgetHandler<Runtime>>::$function($($x,)*),
  854. WorkingGroup::OperationsBeta => <OperationsWorkingGroupBeta as WorkingGroupBudgetHandler<Runtime>>::$function($($x,)*),
  855. WorkingGroup::OperationsGamma => <OperationsWorkingGroupGamma as WorkingGroupBudgetHandler<Runtime>>::$function($($x,)*),
  856. }
  857. }};
  858. }
  859. impl proposals_discussion::Trait for Runtime {
  860. type Event = Event;
  861. type AuthorOriginValidator = Members;
  862. type CouncilOriginValidator = Council;
  863. type ThreadId = ThreadId;
  864. type PostId = PostId;
  865. type MaxWhiteListSize = MaxWhiteListSize;
  866. type WeightInfo = weights::proposals_discussion::WeightInfo;
  867. type PostDeposit = ProposalsPostDeposit;
  868. type ModuleId = ProposalsDiscussionModuleId;
  869. type PostLifeTime = ForumPostLifeTime;
  870. }
  871. impl joystream_utility::Trait for Runtime {
  872. type Event = Event;
  873. type WeightInfo = weights::joystream_utility::WeightInfo;
  874. fn get_working_group_budget(working_group: WorkingGroup) -> Balance {
  875. call_wg!(working_group, get_budget)
  876. }
  877. fn set_working_group_budget(working_group: WorkingGroup, budget: Balance) {
  878. call_wg!(working_group, set_budget, budget)
  879. }
  880. }
  881. parameter_types! {
  882. pub const RuntimeUpgradeWasmProposalMaxLength: u32 = 3_000_000;
  883. }
  884. impl proposals_codex::Trait for Runtime {
  885. type Event = Event;
  886. type MembershipOriginValidator = Members;
  887. type ProposalEncoder = ExtrinsicProposalEncoder;
  888. type SetMaxValidatorCountProposalParameters = SetMaxValidatorCountProposalParameters;
  889. type RuntimeUpgradeProposalParameters = RuntimeUpgradeProposalParameters;
  890. type SignalProposalParameters = SignalProposalParameters;
  891. type FundingRequestProposalParameters = FundingRequestProposalParameters;
  892. type CreateWorkingGroupLeadOpeningProposalParameters =
  893. CreateWorkingGroupLeadOpeningProposalParameters;
  894. type FillWorkingGroupLeadOpeningProposalParameters =
  895. FillWorkingGroupLeadOpeningProposalParameters;
  896. type UpdateWorkingGroupBudgetProposalParameters = UpdateWorkingGroupBudgetProposalParameters;
  897. type DecreaseWorkingGroupLeadStakeProposalParameters =
  898. DecreaseWorkingGroupLeadStakeProposalParameters;
  899. type SlashWorkingGroupLeadProposalParameters = SlashWorkingGroupLeadProposalParameters;
  900. type SetWorkingGroupLeadRewardProposalParameters = SetWorkingGroupLeadRewardProposalParameters;
  901. type TerminateWorkingGroupLeadProposalParameters = TerminateWorkingGroupLeadProposalParameters;
  902. type AmendConstitutionProposalParameters = AmendConstitutionProposalParameters;
  903. type CancelWorkingGroupLeadOpeningProposalParameters =
  904. CancelWorkingGroupLeadOpeningProposalParameters;
  905. type SetMembershipPriceProposalParameters = SetMembershipPriceProposalParameters;
  906. type SetCouncilBudgetIncrementProposalParameters = SetCouncilBudgetIncrementProposalParameters;
  907. type SetCouncilorRewardProposalParameters = SetCouncilorRewardProposalParameters;
  908. type SetInitialInvitationBalanceProposalParameters =
  909. SetInitialInvitationBalanceProposalParameters;
  910. type SetInvitationCountProposalParameters = SetInvitationCountProposalParameters;
  911. type SetMembershipLeadInvitationQuotaProposalParameters =
  912. SetMembershipLeadInvitationQuotaProposalParameters;
  913. type SetReferralCutProposalParameters = SetReferralCutProposalParameters;
  914. type CreateBlogPostProposalParameters = CreateBlogPostProposalParameters;
  915. type EditBlogPostProoposalParamters = EditBlogPostProoposalParamters;
  916. type LockBlogPostProposalParameters = LockBlogPostProposalParameters;
  917. type UnlockBlogPostProposalParameters = UnlockBlogPostProposalParameters;
  918. type VetoProposalProposalParameters = VetoProposalProposalParameters;
  919. type WeightInfo = weights::proposals_codex::WeightInfo;
  920. }
  921. impl pallet_constitution::Trait for Runtime {
  922. type Event = Event;
  923. type WeightInfo = weights::pallet_constitution::WeightInfo;
  924. }
  925. parameter_types! {
  926. pub const BountyModuleId: ModuleId = ModuleId(*b"m:bounty"); // module : bounty
  927. pub const ClosedContractSizeLimit: u32 = 50;
  928. pub const MinCherryLimit: Balance = 10;
  929. pub const MinFundingLimit: Balance = 10;
  930. pub const MinWorkEntrantStake: Balance = 100;
  931. }
  932. impl bounty::Trait for Runtime {
  933. type Event = Event;
  934. type ModuleId = BountyModuleId;
  935. type BountyId = u64;
  936. type Membership = Members;
  937. type WeightInfo = weights::bounty::WeightInfo;
  938. type CouncilBudgetManager = Council;
  939. type StakingHandler = staking_handler::StakingManager<Self, BountyLockId>;
  940. type EntryId = u64;
  941. type ClosedContractSizeLimit = ClosedContractSizeLimit;
  942. type MinCherryLimit = MinCherryLimit;
  943. type MinFundingLimit = MinFundingLimit;
  944. type MinWorkEntrantStake = MinWorkEntrantStake;
  945. }
  946. parameter_types! {
  947. pub const PostsMaxNumber: u64 = 20;
  948. pub const RepliesMaxNumber: u64 = 100;
  949. pub const ReplyDeposit: Balance = 2000;
  950. pub const BlogModuleId: ModuleId = ModuleId(*b"mod:blog"); // module : forum
  951. pub const ReplyLifetime: BlockNumber = 43_200;
  952. }
  953. pub type BlogInstance = blog::Instance1;
  954. impl blog::Trait<BlogInstance> for Runtime {
  955. type Event = Event;
  956. type PostsMaxNumber = PostsMaxNumber;
  957. type ParticipantEnsureOrigin = Members;
  958. type WeightInfo = weights::blog::WeightInfo;
  959. type ReplyId = u64;
  960. type ReplyDeposit = ReplyDeposit;
  961. type ModuleId = BlogModuleId;
  962. type ReplyLifetime = ReplyLifetime;
  963. }
  964. /// Forum identifier for category
  965. pub type CategoryId = u64;
  966. /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
  967. /// the specifics of the runtime. They can then be made to be agnostic over specific formats
  968. /// of data like extrinsics, allowing for them to continue syncing the network through upgrades
  969. /// to even the core datastructures.
  970. pub mod opaque {
  971. use super::*;
  972. pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
  973. /// Opaque block header type.
  974. pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
  975. /// Opaque block type.
  976. pub type Block = generic::Block<Header, UncheckedExtrinsic>;
  977. /// Opaque block identifier type.
  978. pub type BlockId = generic::BlockId<Block>;
  979. }
  980. construct_runtime!(
  981. pub enum Runtime where
  982. Block = Block,
  983. NodeBlock = opaque::Block,
  984. UncheckedExtrinsic = UncheckedExtrinsic
  985. {
  986. // Substrate
  987. System: frame_system::{Module, Call, Storage, Config, Event<T>},
  988. Utility: substrate_utility::{Module, Call, Event},
  989. Babe: pallet_babe::{Module, Call, Storage, Config, Inherent, ValidateUnsigned},
  990. Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
  991. Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
  992. Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
  993. TransactionPayment: pallet_transaction_payment::{Module, Storage},
  994. Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
  995. Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
  996. Historical: pallet_session_historical::{Module},
  997. FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent},
  998. Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
  999. ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
  1000. AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
  1001. Offences: pallet_offences::{Module, Call, Storage, Event},
  1002. RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
  1003. Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
  1004. // Joystream
  1005. Council: council::{Module, Call, Storage, Event<T>, Config<T>},
  1006. Referendum: referendum::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
  1007. Memo: memo::{Module, Call, Storage, Event<T>},
  1008. Members: membership::{Module, Call, Storage, Event<T>, Config<T>},
  1009. Forum: forum::{Module, Call, Storage, Event<T>, Config<T>},
  1010. Constitution: pallet_constitution::{Module, Call, Storage, Event},
  1011. Bounty: bounty::{Module, Call, Storage, Event<T>},
  1012. Blog: blog::<Instance1>::{Module, Call, Storage, Event<T>},
  1013. JoystreamUtility: joystream_utility::{Module, Call, Event<T>},
  1014. Content: content::{Module, Call, Storage, Event<T>, Config<T>},
  1015. Storage: storage::{Module, Call, Storage, Event<T>},
  1016. // --- Proposals
  1017. ProposalsEngine: proposals_engine::{Module, Call, Storage, Event<T>},
  1018. ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event<T>},
  1019. ProposalsCodex: proposals_codex::{Module, Call, Storage, Event<T>},
  1020. // --- Working groups
  1021. ForumWorkingGroup: working_group::<Instance1>::{Module, Call, Storage, Event<T>},
  1022. StorageWorkingGroup: working_group::<Instance2>::{Module, Call, Storage, Event<T>},
  1023. ContentWorkingGroup: working_group::<Instance3>::{Module, Call, Storage, Event<T>},
  1024. OperationsWorkingGroupAlpha: working_group::<Instance4>::{Module, Call, Storage, Event<T>},
  1025. GatewayWorkingGroup: working_group::<Instance5>::{Module, Call, Storage, Event<T>},
  1026. MembershipWorkingGroup: working_group::<Instance6>::{Module, Call, Storage, Event<T>},
  1027. OperationsWorkingGroupBeta: working_group::<Instance7>::{Module, Call, Storage, Event<T>},
  1028. OperationsWorkingGroupGamma: working_group::<Instance8>::{Module, Call, Storage, Event<T>},
  1029. DistributionWorkingGroup: working_group::<Instance9>::{Module, Call, Storage, Event<T>},
  1030. }
  1031. );