Browse Source

Move proposal parameters to the config

Move ‘Set validator count’ proposal parameters (grace_period and voting_period) to the config
Shamil Gadelshin 4 years ago
parent
commit
5ba0383147

+ 5 - 1
node/src/chain_spec.rs

@@ -20,7 +20,7 @@ use node_runtime::{
     CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig,
     DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, IndicesConfig,
     MembersConfig, Perbill, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig,
-    SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY,
+    SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY, ProposalsCodexConfig
 };
 pub use node_runtime::{AccountId, GenesisConfig};
 use primitives::{sr25519, Pair, Public};
@@ -297,5 +297,9 @@ 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,
+        })
     }
 }

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

@@ -250,6 +250,14 @@ 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;
+
+        /// Grate period for the 'set validator count' proposal
+        pub SetValidatorCountProposalGracePeriod get(set_validator_count_proposal_grace_period)
+            config(): T::BlockNumber;
     }
 }
 

+ 3 - 3
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, ProposalParameters, Module};
 
 // 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,

+ 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>},
         // ---
 	}
 );