Browse Source

Merge pull request #300 from shamil-gadelshin/proposal_periods_to_config

Move all proposals voting_period and grace_period to the config
Bedeho Mender 4 years ago
parent
commit
88e8a39fb8

+ 22 - 2
node/src/chain_spec.rs

@@ -19,8 +19,8 @@ use node_runtime::{
     AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig,
     CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig,
     DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, IndicesConfig,
-    MembersConfig, Perbill, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig,
-    SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY,
+    MembersConfig, Perbill, ProposalsCodexConfig, SessionConfig, SessionKeys, Signature,
+    StakerStatus, StakingConfig, SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY,
 };
 pub use node_runtime::{AccountId, GenesisConfig};
 use primitives::{sr25519, Pair, Public};
@@ -297,5 +297,25 @@ pub fn testnet_genesis(
             channel_banner_constraint: crate::forum_config::new_validation(5, 1024),
             channel_title_constraint: crate::forum_config::new_validation(5, 1024),
         }),
+        proposals_codex: Some(ProposalsCodexConfig {
+            set_validator_count_proposal_voting_period: 43200u32,
+            set_validator_count_proposal_grace_period: 0u32,
+            runtime_upgrade_proposal_voting_period: 72000u32,
+            runtime_upgrade_proposal_grace_period: 72000u32,
+            text_proposal_voting_period: 72000u32,
+            text_proposal_grace_period: 0u32,
+            set_election_parameters_proposal_voting_period: 72000u32,
+            set_election_parameters_proposal_grace_period: 201601u32,
+            set_content_working_group_mint_capacity_proposal_voting_period: 43200u32,
+            set_content_working_group_mint_capacity_proposal_grace_period: 0u32,
+            set_lead_proposal_voting_period: 43200u32,
+            set_lead_proposal_grace_period: 0u32,
+            spending_proposal_voting_period: 72000u32,
+            spending_proposal_grace_period: 14400u32,
+            evict_storage_provider_proposal_voting_period: 43200u32,
+            evict_storage_provider_proposal_grace_period: 0u32,
+            set_storage_role_parameters_proposal_voting_period: 43200u32,
+            set_storage_role_parameters_proposal_grace_period: 14400u32,
+        }),
     }
 }

+ 68 - 0
runtime-modules/proposals/codex/src/lib.rs

@@ -250,6 +250,74 @@ decl_storage! {
                 T::AccountId,
                 T::MemberId
             >;
+
+        /// Voting period for the 'set validator count' proposal
+        pub SetValidatorCountProposalVotingPeriod get(set_validator_count_proposal_voting_period)
+            config(): T::BlockNumber;
+
+        /// Grace period for the 'set validator count' proposal
+        pub SetValidatorCountProposalGracePeriod get(set_validator_count_proposal_grace_period)
+            config(): T::BlockNumber;
+
+        /// Voting period for the 'runtime upgrade' proposal
+        pub RuntimeUpgradeProposalVotingPeriod get(runtime_upgrade_proposal_voting_period)
+            config(): T::BlockNumber;
+
+        /// Grace period for the 'runtime upgrade' proposal
+        pub RuntimeUpgradeProposalGracePeriod get(runtime_upgrade_proposal_grace_period)
+            config(): T::BlockNumber;
+
+        /// Voting period for the 'set election parameters' proposal
+        pub SetElectionParametersProposalVotingPeriod get(set_election_parameters_proposal_voting_period)
+            config(): T::BlockNumber;
+
+        /// Grace period for the 'set election parameters' proposal
+        pub SetElectionParametersProposalGracePeriod get(set_election_parameters_proposal_grace_period)
+            config(): T::BlockNumber;
+
+        /// Voting period for the 'text' proposal
+        pub TextProposalVotingPeriod get(text_proposal_voting_period) config(): T::BlockNumber;
+
+        /// Grace period for the 'text' proposal
+        pub TextProposalGracePeriod get(text_proposal_grace_period) config(): T::BlockNumber;
+
+        /// Voting period for the 'set content working group mint capacity' proposal
+        pub SetContentWorkingGroupMintCapacityProposalVotingPeriod get(set_content_working_group_mint_capacity_proposal_voting_period)
+            config(): T::BlockNumber;
+
+        /// Grace period for the 'set content working group mint capacity' proposal
+        pub SetContentWorkingGroupMintCapacityProposalGracePeriod get(set_content_working_group_mint_capacity_proposal_grace_period)
+            config(): T::BlockNumber;
+
+        /// Voting period for the 'set lead' proposal
+        pub SetLeadProposalVotingPeriod get(set_lead_proposal_voting_period)
+            config(): T::BlockNumber;
+
+        /// Grace period for the 'set lead' proposal
+        pub SetLeadProposalGracePeriod get(set_lead_proposal_grace_period)
+            config(): T::BlockNumber;
+
+        /// Voting period for the 'spending' proposal
+        pub SpendingProposalVotingPeriod get(spending_proposal_voting_period) config(): T::BlockNumber;
+
+        /// Grace period for the 'spending' proposal
+        pub SpendingProposalGracePeriod get(spending_proposal_grace_period) config(): T::BlockNumber;
+
+        /// Voting period for the 'evict storage provider' proposal
+        pub EvictStorageProviderProposalVotingPeriod get(evict_storage_provider_proposal_voting_period)
+            config(): T::BlockNumber;
+
+        /// Grace period for the 'evict storage provider' proposal
+        pub EvictStorageProviderProposalGracePeriod get(evict_storage_provider_proposal_grace_period)
+            config(): T::BlockNumber;
+
+        /// Voting period for the 'set storage role parameters' proposal
+        pub SetStorageRoleParametersProposalVotingPeriod get(set_storage_role_parameters_proposal_voting_period)
+            config(): T::BlockNumber;
+
+        /// Grace period for the 'set storage role parameters' proposal
+        pub SetStorageRoleParametersProposalGracePeriod get(set_storage_role_parameters_proposal_grace_period)
+            config(): T::BlockNumber;
     }
 }
 

+ 20 - 19
runtime-modules/proposals/codex/src/proposal_types/parameters.rs

@@ -1,11 +1,11 @@
-use crate::{get_required_stake_by_fraction, BalanceOf, ProposalParameters};
+use crate::{get_required_stake_by_fraction, BalanceOf, Module, ProposalParameters};
 
 // Proposal parameters for the 'Set validator count' proposal
 pub(crate) fn set_validator_count_proposal<T: crate::Trait>(
 ) -> ProposalParameters<T::BlockNumber, BalanceOf<T>> {
     ProposalParameters {
-        voting_period: T::BlockNumber::from(43200u32),
-        grace_period: T::BlockNumber::from(0u32),
+        voting_period: <Module<T>>::set_validator_count_proposal_voting_period(),
+        grace_period: <Module<T>>::set_validator_count_proposal_grace_period(),
         approval_quorum_percentage: 66,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -18,8 +18,8 @@ pub(crate) fn set_validator_count_proposal<T: crate::Trait>(
 pub(crate) fn runtime_upgrade_proposal<T: crate::Trait>(
 ) -> ProposalParameters<T::BlockNumber, BalanceOf<T>> {
     ProposalParameters {
-        voting_period: T::BlockNumber::from(72000u32),
-        grace_period: T::BlockNumber::from(72000u32),
+        voting_period: <Module<T>>::runtime_upgrade_proposal_voting_period(),
+        grace_period: <Module<T>>::runtime_upgrade_proposal_grace_period(),
         approval_quorum_percentage: 80,
         approval_threshold_percentage: 100,
         slashing_quorum_percentage: 60,
@@ -31,8 +31,8 @@ pub(crate) fn runtime_upgrade_proposal<T: crate::Trait>(
 // Proposal parameters for the text proposal
 pub(crate) fn text_proposal<T: crate::Trait>() -> ProposalParameters<T::BlockNumber, BalanceOf<T>> {
     ProposalParameters {
-        voting_period: T::BlockNumber::from(72000u32),
-        grace_period: T::BlockNumber::from(0u32),
+        voting_period: <Module<T>>::text_proposal_voting_period(),
+        grace_period: <Module<T>>::text_proposal_grace_period(),
         approval_quorum_percentage: 66,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -45,8 +45,8 @@ pub(crate) fn text_proposal<T: crate::Trait>() -> ProposalParameters<T::BlockNum
 pub(crate) fn set_election_parameters_proposal<T: crate::Trait>(
 ) -> ProposalParameters<T::BlockNumber, BalanceOf<T>> {
     ProposalParameters {
-        voting_period: T::BlockNumber::from(72000u32),
-        grace_period: T::BlockNumber::from(201601u32),
+        voting_period: <Module<T>>::set_election_parameters_proposal_voting_period(),
+        grace_period: <Module<T>>::set_election_parameters_proposal_grace_period(),
         approval_quorum_percentage: 66,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -59,8 +59,9 @@ pub(crate) fn set_election_parameters_proposal<T: crate::Trait>(
 pub(crate) fn set_content_working_group_mint_capacity_proposal<T: crate::Trait>(
 ) -> ProposalParameters<T::BlockNumber, BalanceOf<T>> {
     ProposalParameters {
-        voting_period: T::BlockNumber::from(43200u32),
-        grace_period: T::BlockNumber::from(0u32),
+        voting_period: <Module<T>>::set_content_working_group_mint_capacity_proposal_voting_period(
+        ),
+        grace_period: <Module<T>>::set_content_working_group_mint_capacity_proposal_grace_period(),
         approval_quorum_percentage: 50,
         approval_threshold_percentage: 75,
         slashing_quorum_percentage: 60,
@@ -73,8 +74,8 @@ pub(crate) fn set_content_working_group_mint_capacity_proposal<T: crate::Trait>(
 pub(crate) fn spending_proposal<T: crate::Trait>(
 ) -> ProposalParameters<T::BlockNumber, BalanceOf<T>> {
     ProposalParameters {
-        voting_period: T::BlockNumber::from(72000u32),
-        grace_period: T::BlockNumber::from(14400u32),
+        voting_period: <Module<T>>::spending_proposal_voting_period(),
+        grace_period: <Module<T>>::spending_proposal_grace_period(),
         approval_quorum_percentage: 66,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -87,8 +88,8 @@ pub(crate) fn spending_proposal<T: crate::Trait>(
 pub(crate) fn set_lead_proposal<T: crate::Trait>(
 ) -> ProposalParameters<T::BlockNumber, BalanceOf<T>> {
     ProposalParameters {
-        voting_period: T::BlockNumber::from(43200u32),
-        grace_period: T::BlockNumber::from(0u32),
+        voting_period: <Module<T>>::set_lead_proposal_voting_period(),
+        grace_period: <Module<T>>::set_lead_proposal_grace_period(),
         approval_quorum_percentage: 66,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -101,8 +102,8 @@ pub(crate) fn set_lead_proposal<T: crate::Trait>(
 pub(crate) fn evict_storage_provider_proposal<T: crate::Trait>(
 ) -> ProposalParameters<T::BlockNumber, BalanceOf<T>> {
     ProposalParameters {
-        voting_period: T::BlockNumber::from(43200u32),
-        grace_period: T::BlockNumber::from(0u32),
+        voting_period: <Module<T>>::evict_storage_provider_proposal_voting_period(),
+        grace_period: <Module<T>>::evict_storage_provider_proposal_grace_period(),
         approval_quorum_percentage: 50,
         approval_threshold_percentage: 75,
         slashing_quorum_percentage: 60,
@@ -115,8 +116,8 @@ pub(crate) fn evict_storage_provider_proposal<T: crate::Trait>(
 pub(crate) fn set_storage_role_parameters_proposal<T: crate::Trait>(
 ) -> ProposalParameters<T::BlockNumber, BalanceOf<T>> {
     ProposalParameters {
-        voting_period: T::BlockNumber::from(43200u32),
-        grace_period: T::BlockNumber::from(14400u32),
+        voting_period: <Module<T>>::set_storage_role_parameters_proposal_voting_period(),
+        grace_period: <Module<T>>::set_storage_role_parameters_proposal_grace_period(),
         approval_quorum_percentage: 75,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,

+ 1 - 1
runtime/src/lib.rs

@@ -913,7 +913,7 @@ construct_runtime!(
         // --- Proposals
         ProposalsEngine: proposals_engine::{Module, Call, Storage, Event<T>},
         ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event<T>},
-        ProposalsCodex: proposals_codex::{Module, Call, Storage, Error},
+        ProposalsCodex: proposals_codex::{Module, Call, Storage, Error, Config<T>},
         // ---
 	}
 );