Browse Source

Move proposals voting_period and grace_period to the config

Shamil Gadelshin 4 years ago
parent
commit
055cfd66f3

+ 16 - 0
node/src/chain_spec.rs

@@ -300,6 +300,22 @@ pub fn testnet_genesis(
         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,
         })
     }
 }

+ 61 - 1
runtime-modules/proposals/codex/src/lib.rs

@@ -255,9 +255,69 @@ decl_storage! {
         pub SetValidatorCountProposalVotingPeriod get(set_validator_count_proposal_voting_period)
             config(): T::BlockNumber;
 
-        /// Grate period for the 'set validator count' proposal
+        /// 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;
     }
 }
 

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

@@ -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,8 @@ 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 +73,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 +87,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 +101,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 +115,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,