Browse Source

Merge pull request #969 from mnaamani/dev-proposal-settings

Dev proposal settings
shamil-gadelshin 4 years ago
parent
commit
4602f1d14a

+ 3 - 3
Cargo.lock

@@ -390,7 +390,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
 
 [[package]]
 name = "chain-spec-builder"
-version = "2.0.0-alpha.3"
+version = "2.1.0"
 dependencies = [
  "ansi_term 0.12.1",
  "joystream-node",
@@ -1569,7 +1569,7 @@ dependencies = [
 
 [[package]]
 name = "joystream-node"
-version = "2.6.0"
+version = "2.7.0"
 dependencies = [
  "ctrlc",
  "derive_more 0.14.1",
@@ -1614,7 +1614,7 @@ dependencies = [
 
 [[package]]
 name = "joystream-node-runtime"
-version = "6.20.0"
+version = "6.21.0"
 dependencies = [
  "parity-scale-codec",
  "safe-mix",

+ 1 - 1
node/Cargo.toml

@@ -3,7 +3,7 @@ authors = ['Joystream']
 build = 'build.rs'
 edition = '2018'
 name = 'joystream-node'
-version = '2.6.0'
+version = '2.7.0'
 default-run = "joystream-node"
 
 [[bin]]

+ 3 - 2
node/src/chain_spec.rs

@@ -108,6 +108,7 @@ impl Alternative {
                             get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
                             get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
                         ],
+                        crate::proposals_config::development(),
                     )
                 },
                 vec![],
@@ -140,6 +141,7 @@ impl Alternative {
                             get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
                             get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
                         ],
+                        crate::proposals_config::development(),
                     )
                 },
                 vec![],
@@ -181,14 +183,13 @@ pub fn testnet_genesis(
     initial_authorities: Vec<(AccountId, AccountId, GrandpaId, BabeId, ImOnlineId)>,
     root_key: AccountId,
     endowed_accounts: Vec<AccountId>,
+    cpcp: node_runtime::ProposalsConfigParameters,
 ) -> GenesisConfig {
     const CENTS: Balance = 1;
     const DOLLARS: Balance = 100 * CENTS;
     const STASH: Balance = 20 * DOLLARS;
     const ENDOWMENT: Balance = 100_000 * DOLLARS;
 
-    // default codex proposals config parameters
-    let cpcp = node_runtime::ProposalsConfigParameters::default();
     let default_text_constraint = node_runtime::working_group::default_text_constraint();
 
     GenesisConfig {

+ 1 - 0
node/src/lib.rs

@@ -2,4 +2,5 @@ pub mod chain_spec;
 pub mod cli;
 pub mod forum_config;
 pub mod members_config;
+pub mod proposals_config;
 pub mod service;

+ 17 - 0
node/src/proposals_config.rs

@@ -0,0 +1,17 @@
+use node_runtime::ProposalsConfigParameters;
+
+/// Development chain config. 0 grace period for all proposals, ie.
+/// proposals executed immediatly. Short voting period.
+pub fn development() -> ProposalsConfigParameters {
+    ProposalsConfigParameters::with_grace_and_voting_periods(0, 200)
+}
+
+/// Staging chain config. Shorter grace periods and voting periods than default.
+pub fn staging() -> ProposalsConfigParameters {
+    ProposalsConfigParameters::with_grace_and_voting_periods(200, 600)
+}
+
+/// The default configuration as defined in the runtime module
+pub fn default() -> ProposalsConfigParameters {
+    ProposalsConfigParameters::default()
+}

+ 2 - 4
runtime-modules/proposals/codex/src/lib.rs

@@ -1053,11 +1053,9 @@ impl<T: Trait> Module<T> {
         Ok(())
     }
 
-    /// Sets default config values for the proposals.
+    /// Sets config values for the proposals.
     /// Should be called on the migration to the new runtime version.
-    pub fn set_default_config_values() {
-        let p = ProposalsConfigParameters::default();
-
+    pub fn set_config_values(p: ProposalsConfigParameters) {
         <SetValidatorCountProposalVotingPeriod<T>>::put(T::BlockNumber::from(
             p.set_validator_count_proposal_voting_period,
         ));

+ 41 - 0
runtime-modules/proposals/codex/src/proposal_types/mod.rs

@@ -220,6 +220,7 @@ pub struct RoleParameters<Balance, BlockNumber> {
 }
 
 /// Contains proposal config parameters. Default values are used by migration and genesis config.
+#[derive(Copy, Clone)]
 pub struct ProposalsConfigParameters {
     /// 'Set validator count' proposal voting period
     pub set_validator_count_proposal_voting_period: u32,
@@ -348,3 +349,43 @@ impl Default for ProposalsConfigParameters {
         }
     }
 }
+
+impl ProposalsConfigParameters {
+    /// Set same voting_period for all proposals. For proposals
+    /// that by default have 0 grace period remain with 0 grace period.
+    /// All remaining proposals get assigned grace_period.
+    pub fn with_grace_and_voting_periods(grace_period: u32, voting_period: u32) -> Self {
+        ProposalsConfigParameters {
+            set_validator_count_proposal_voting_period: voting_period,
+            set_validator_count_proposal_grace_period: 0,
+            runtime_upgrade_proposal_voting_period: voting_period,
+            runtime_upgrade_proposal_grace_period: grace_period,
+            text_proposal_voting_period: voting_period,
+            text_proposal_grace_period: 0,
+            set_election_parameters_proposal_voting_period: voting_period,
+            set_election_parameters_proposal_grace_period: grace_period,
+            set_content_working_group_mint_capacity_proposal_voting_period: voting_period,
+            set_content_working_group_mint_capacity_proposal_grace_period: 0,
+            set_lead_proposal_voting_period: voting_period,
+            set_lead_proposal_grace_period: 0,
+            spending_proposal_voting_period: voting_period,
+            spending_proposal_grace_period: grace_period,
+            add_working_group_opening_proposal_voting_period: voting_period,
+            add_working_group_opening_proposal_grace_period: 0,
+            begin_review_working_group_leader_applications_proposal_voting_period: voting_period,
+            begin_review_working_group_leader_applications_proposal_grace_period: grace_period,
+            fill_working_group_leader_opening_proposal_voting_period: voting_period,
+            fill_working_group_leader_opening_proposal_grace_period: 0,
+            set_working_group_mint_capacity_proposal_voting_period: voting_period,
+            set_working_group_mint_capacity_proposal_grace_period: 0,
+            decrease_working_group_leader_stake_proposal_voting_period: voting_period,
+            decrease_working_group_leader_stake_proposal_grace_period: 0,
+            slash_working_group_leader_stake_proposal_voting_period: voting_period,
+            slash_working_group_leader_stake_proposal_grace_period: 0,
+            set_working_group_leader_reward_proposal_voting_period: voting_period,
+            set_working_group_leader_reward_proposal_grace_period: 0,
+            terminate_working_group_leader_role_proposal_voting_period: voting_period,
+            terminate_working_group_leader_role_proposal_grace_period: 0,
+        }
+    }
+}

+ 1 - 1
runtime-modules/proposals/codex/src/tests/mod.rs

@@ -802,7 +802,7 @@ fn set_default_proposal_parameters_succeeded() {
         // nothing is set
         assert_eq!(<SetValidatorCountProposalVotingPeriod<Test>>::get(), 0);
 
-        ProposalCodex::set_default_config_values();
+        ProposalCodex::set_config_values(p);
 
         assert_eq!(
             <SetValidatorCountProposalVotingPeriod<Test>>::get(),

+ 1 - 1
runtime/Cargo.toml

@@ -4,7 +4,7 @@ edition = '2018'
 name = 'joystream-node-runtime'
 # Follow convention: https://github.com/Joystream/substrate-runtime-joystream/issues/1
 # {Authoring}.{Spec}.{Impl} of the RuntimeVersion
-version = '6.20.0'
+version = '6.21.0'
 
 [features]
 default = ['std']

+ 1 - 1
runtime/src/lib.rs

@@ -161,7 +161,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
     spec_name: create_runtime_str!("joystream-node"),
     impl_name: create_runtime_str!("joystream-node"),
     authoring_version: 6,
-    spec_version: 20,
+    spec_version: 21,
     impl_version: 0,
     apis: RUNTIME_API_VERSIONS,
 };

+ 2 - 1
runtime/src/migration.rs

@@ -2,6 +2,7 @@
 #![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
 
 use crate::VERSION;
+use proposals_codex::ProposalsConfigParameters;
 use rstd::prelude::*;
 use sr_primitives::{
     print,
@@ -26,7 +27,7 @@ impl<T: Trait> Module<T> {
         Self::initialize_storage_working_group_text_constraints();
         Self::clear_storage_data();
 
-        proposals_codex::Module::<T>::set_default_config_values();
+        proposals_codex::Module::<T>::set_config_values(ProposalsConfigParameters::default());
     }
 }
 

+ 2 - 2
utils/chain-spec-builder/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "chain-spec-builder"
-version = "2.0.0-alpha.3"
+version = "2.1.0"
 authors = ["Parity Technologies <admin@parity.io>"]
 edition = "2018"
 build = "build.rs"
@@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/"
 ansi_term = "0.12.1"
 rand = "0.7.2"
 structopt = "0.3.5"
-joystream-node = { version = "2.1.2", path = "../../node" }
+joystream-node = { path = "../../node" }
 
 [dependencies.sr-keystore]
 git = 'https://github.com/paritytech/substrate.git'

+ 5 - 4
utils/chain-spec-builder/src/main.rs

@@ -23,7 +23,10 @@ use ansi_term::Style;
 use rand::{distributions::Alphanumeric, rngs::OsRng, Rng};
 use structopt::StructOpt;
 
-use joystream_node::chain_spec::{self, chain_spec_properties, AccountId};
+use joystream_node::{
+    chain_spec::{self, chain_spec_properties, AccountId},
+    proposals_config,
+};
 use sr_keystore::Store as Keystore;
 use sr_primitives::{
     crypto::{Public, Ss58Codec},
@@ -102,13 +105,11 @@ fn genesis_constructor(
         .map(chain_spec::get_authority_keys_from_seed)
         .collect::<Vec<_>>();
 
-    // let enable_println = true;
-
     chain_spec::testnet_genesis(
         authorities,
         sudo_account.clone(),
         endowed_accounts.to_vec(),
-        // enable_println,
+        proposals_config::default(),
     )
 }