Browse Source

revert related changes

iorveth 4 years ago
parent
commit
627fd27aa1

+ 46 - 23
Cargo.lock

@@ -1554,7 +1554,7 @@ dependencies = [
 
 [[package]]
 name = "joystream-node"
-version = "2.1.6"
+version = "2.1.3"
 dependencies = [
  "ctrlc",
  "derive_more 0.14.1",
@@ -1599,7 +1599,7 @@ dependencies = [
 
 [[package]]
 name = "joystream-node-runtime"
-version = "6.12.0"
+version = "6.8.1"
 dependencies = [
  "parity-scale-codec",
  "safe-mix",
@@ -1633,7 +1633,6 @@ dependencies = [
  "substrate-client",
  "substrate-common-module",
  "substrate-consensus-babe-primitives",
- "substrate-content-directory-module",
  "substrate-content-working-group-module",
  "substrate-forum-module",
  "substrate-governance-module",
@@ -1649,6 +1648,8 @@ dependencies = [
  "substrate-stake-module",
  "substrate-storage-module",
  "substrate-token-mint-module",
+ "substrate-versioned-store",
+ "substrate-versioned-store-permissions-module",
  "substrate-wasm-builder-runner",
 ]
 
@@ -4647,24 +4648,6 @@ dependencies = [
  "substrate-primitives",
 ]
 
-[[package]]
-name = "substrate-content-directory-module"
-version = "1.0.1"
-dependencies = [
- "hex-literal 0.1.4",
- "parity-scale-codec",
- "quote 0.6.13",
- "serde",
- "sr-io",
- "sr-primitives",
- "sr-std",
- "srml-support",
- "srml-support-procedural",
- "srml-system",
- "srml-timestamp",
- "substrate-primitives",
-]
-
 [[package]]
 name = "substrate-content-working-group-module"
 version = "1.0.0"
@@ -4679,7 +4662,6 @@ dependencies = [
  "srml-system",
  "srml-timestamp",
  "substrate-common-module",
- "substrate-content-directory-module",
  "substrate-forum-module",
  "substrate-hiring-module",
  "substrate-membership-module",
@@ -4687,6 +4669,8 @@ dependencies = [
  "substrate-recurring-reward-module",
  "substrate-stake-module",
  "substrate-token-mint-module",
+ "substrate-versioned-store",
+ "substrate-versioned-store-permissions-module",
 ]
 
 [[package]]
@@ -4812,7 +4796,6 @@ dependencies = [
  "substrate-common-module",
  "substrate-membership-module",
  "substrate-primitives",
- "substrate-token-mint-module",
 ]
 
 [[package]]
@@ -5415,6 +5398,46 @@ dependencies = [
  "trie-root",
 ]
 
+[[package]]
+name = "substrate-versioned-store"
+version = "1.0.1"
+dependencies = [
+ "hex-literal 0.1.4",
+ "parity-scale-codec",
+ "quote 0.6.13",
+ "serde",
+ "serde_derive",
+ "sr-io",
+ "sr-primitives",
+ "sr-std",
+ "srml-balances",
+ "srml-support",
+ "srml-support-procedural",
+ "srml-system",
+ "srml-timestamp",
+ "substrate-primitives",
+]
+
+[[package]]
+name = "substrate-versioned-store-permissions-module"
+version = "1.0.1"
+dependencies = [
+ "hex-literal 0.1.4",
+ "parity-scale-codec",
+ "quote 0.6.13",
+ "serde",
+ "serde_derive",
+ "sr-io",
+ "sr-primitives",
+ "sr-std",
+ "srml-support",
+ "srml-support-procedural",
+ "srml-system",
+ "srml-timestamp",
+ "substrate-primitives",
+ "substrate-versioned-store",
+]
+
 [[package]]
 name = "substrate-wasm-builder-runner"
 version = "1.0.5"

+ 2 - 1
Cargo.toml

@@ -14,7 +14,8 @@ members = [
 	"runtime-modules/stake",
 	"runtime-modules/storage",
 	"runtime-modules/token-minting",
-	"runtime-modules/content-directory",
+	"runtime-modules/versioned-store",
+	"runtime-modules/versioned-store-permissions",
 	"node",
 	"utils/chain-spec-builder/"
 ]

+ 8 - 2
README.md

@@ -1,12 +1,18 @@
-# Joystream
+# Joystream [![Build Status](https://travis-ci.org/Joystream/substrate-runtime-joystream.svg?branch=master)](https://travis-ci.org/Joystream/substrate-runtime-joystream)
 
 This is the main code reposity for all joystream software. It will  house the substrate chain project, the full node and runtime and all reusable substrate runtime modules that make up the joystream runtime. In addition to all front-end apps and infrastructure servers necessary for operating the network.
 
 The repository is currently just a cargo workspace, but eventually will also contain yarn workspaces, and possibly other project type workspaces.
 
+## Build Status
+
+Development [![Development Branch Build Status](https://travis-ci.org/Joystream/substrate-runtime-joystream.svg?branch=development)](https://travis-ci.org/Joystream/substrate-runtime-joystream)
+
+More detailed build history on [Travis CI](https://travis-ci.org/github/Joystream/substrate-runtime-joystream/builds)
+
 ## Overview
 
-The joystream network builds on a pre-release version of [substrate v2.0](https://substrate.dev/) and adds additional
+The Joystream network builds on a pre-release version of [substrate v2.0](https://substrate.dev/) and adds additional
 functionality to support the [various roles](https://www.joystream.org/roles) that can be entered into on the platform.
 
 

+ 1 - 1
node/Cargo.toml

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

+ 22 - 24
node/src/chain_spec.rs

@@ -15,12 +15,12 @@
 // along with Joystream node.  If not, see <http://www.gnu.org/licenses/>.
 
 use node_runtime::{
-    content_directory::InputValidationLengthConstraint as VsInputValidation, ActorsConfig,
+    versioned_store::InputValidationLengthConstraint as VsInputValidation, ActorsConfig,
     AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig,
     CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig,
-    DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, IndicesConfig,
-    MembersConfig, Perbill, ProposalsConfig, SessionConfig, SessionKeys, Signature, StakerStatus,
-    StakingConfig, SudoConfig, SystemConfig, VersionedStorePermissionsConfig, DAYS, WASM_BINARY,
+    DataObjectTypeRegistryConfig, GrandpaConfig, ImOnlineConfig, IndicesConfig, MembersConfig,
+    Perbill, ProposalsConfig, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig,
+    SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY,
 };
 pub use node_runtime::{AccountId, GenesisConfig};
 use primitives::{sr25519, Pair, Public};
@@ -235,16 +235,14 @@ pub fn testnet_genesis(
         }),
         election: Some(CouncilElectionConfig {
             auto_start: true,
-            election_parameters: ElectionParameters {
-                announcing_period: 3 * DAYS,
-                voting_period: 1 * DAYS,
-                revealing_period: 1 * DAYS,
-                council_size: 12,
-                candidacy_limit: 25,
-                min_council_stake: 10 * DOLLARS,
-                new_term_duration: 14 * DAYS,
-                min_voting_stake: 1 * DOLLARS,
-            },
+            announcing_period: 3 * DAYS,
+            voting_period: 1 * DAYS,
+            revealing_period: 1 * DAYS,
+            council_size: 12,
+            candidacy_limit: 25,
+            min_council_stake: 10 * DOLLARS,
+            new_term_duration: 14 * DAYS,
+            min_voting_stake: 1 * DOLLARS,
         }),
         proposals: Some(ProposalsConfig {
             approval_quorum: 66,
@@ -273,16 +271,16 @@ pub fn testnet_genesis(
             enable_storage_role: true,
             request_life_time: 300,
         }),
-        // content_directory: Some(VersionedStorePermissionsConfig {
-        //     class_by_id: vec![],
-        //     entity_by_id: vec![],
-        //     next_class_id: 1,
-        //     next_entity_id: 1,
-        //     property_name_constraint: new_vs_validation(1, 99),
-        //     property_description_constraint: new_vs_validation(1, 999),
-        //     class_name_constraint: new_vs_validation(1, 99),
-        //     class_description_constraint: new_vs_validation(1, 999),
-        // }),
+        versioned_store: Some(VersionedStoreConfig {
+            class_by_id: vec![],
+            entity_by_id: vec![],
+            next_class_id: 1,
+            next_entity_id: 1,
+            property_name_constraint: new_vs_validation(1, 99),
+            property_description_constraint: new_vs_validation(1, 999),
+            class_name_constraint: new_vs_validation(1, 99),
+            class_description_constraint: new_vs_validation(1, 999),
+        }),
         content_wg: Some(ContentWorkingGroupConfig {
             mint_capacity: 100000,
             curator_opening_by_id: vec![],

+ 10 - 4
runtime-modules/content-working-group/Cargo.toml

@@ -19,7 +19,8 @@ std = [
     'hiring/std',
     'stake/std',
     'minting/std',
-    'content_directory/std',
+    'versioned_store/std',
+    'versioned_store_permissions/std',
     'recurringrewards/std',
 ]
 
@@ -90,10 +91,15 @@ default_features = false
 package = 'substrate-hiring-module'
 path = '../hiring'
 
-[dependencies.content_directory]
+[dependencies.versioned_store]
 default_features = false
-package = 'substrate-content-directory-module'
-path = '../content-directory'
+package ='substrate-versioned-store'
+path = '../versioned-store'
+
+[dependencies.versioned_store_permissions]
+default_features = false
+package = 'substrate-versioned-store-permissions-module'
+path = '../versioned-store-permissions'
 
 [dependencies.membership]
 default_features = false

+ 3 - 3
runtime-modules/content-working-group/src/genesis.rs

@@ -43,11 +43,11 @@ pub struct GenesisConfigBuilder<T: Trait> {
 }
 
 impl<T: Trait> GenesisConfigBuilder<T> {
-    pub fn with_mint_capacity(mut self, capacity: minting::BalanceOf<T>) -> Self {
-        self.mint_capacity = capacity;
+    /*
+    pub fn set_mint(mut self, mint: <T as minting::Trait>::MintId) -> Self {
+        self.mint = mint;
         self
     }
-    /*
     pub fn set_channel_handle_constraint(mut self, constraint: InputValidationLengthConstraint) -> Self {
         self.channel_description_constraint = constraint;
         self

+ 98 - 142
runtime-modules/content-working-group/src/lib.rs

@@ -41,7 +41,7 @@ pub trait Trait:
     + recurringrewards::Trait
     + stake::Trait
     + hiring::Trait
-    + content_directory::Trait
+    + versioned_store_permissions::Trait
     + members::Trait
 {
     // + Sized
@@ -88,7 +88,7 @@ pub type RewardRelationshipId<T> = <T as recurringrewards::Trait>::RewardRelatio
 pub type StakeId<T> = <T as stake::Trait>::StakeId;
 
 /// Type of permissions module prinicipal identifiers
-pub type PrincipalId<T> = <T as content_directory::Trait>::Credential;
+pub type PrincipalId<T> = <T as versioned_store_permissions::Trait>::Credential;
 
 pub type CuratorApplicationIdToCuratorIdMap<T> = BTreeMap<CuratorApplicationId<T>, CuratorId<T>>;
 
@@ -1080,9 +1080,7 @@ decl_event! {
         CuratorApplicationId = CuratorApplicationId<T>,
         CuratorId = CuratorId<T>,
         CuratorApplicationIdToCuratorIdMap = CuratorApplicationIdToCuratorIdMap<T>,
-        MintBalanceOf = minting::BalanceOf<T>,
         <T as system::Trait>::AccountId,
-        <T as minting::Trait>::MintId,
     {
         ChannelCreated(ChannelId),
         ChannelOwnershipTransferred(ChannelId),
@@ -1102,8 +1100,6 @@ decl_event! {
         CuratorRewardAccountUpdated(CuratorId, AccountId),
         ChannelUpdatedByCurationActor(ChannelId),
         ChannelCreationEnabledUpdated(bool),
-        MintCapacityIncreased(MintId, MintBalanceOf, MintBalanceOf),
-        MintCapacityDecreased(MintId, MintBalanceOf, MintBalanceOf),
     }
 }
 
@@ -1910,23 +1906,103 @@ decl_module! {
             );
         }
 
-        /// Replace the current lead. First unsets the active lead if there is one.
-        /// If a value is provided for new_lead it will then set that new lead.
-        /// It is responsibility of the caller to ensure the new lead can be set
-        /// to avoid the lead role being vacant at the end of the call.
-        pub fn replace_lead(origin, new_lead: Option<(T::MemberId, T::AccountId)>) {
+        /*
+         * Root origin routines for managing lead.
+         */
+
+
+        /// Introduce a lead when one is not currently set.
+        pub fn set_lead(origin, member: T::MemberId, role_account: T::AccountId) {
+
             // Ensure root is origin
             ensure_root(origin)?;
 
-            // Unset current lead first
-            if Self::ensure_lead_is_set().is_ok() {
-                Self::unset_lead()?;
-            }
+            // Ensure there is no current lead
+            ensure!(
+                <CurrentLeadId<T>>::get().is_none(),
+                MSG_CURRENT_LEAD_ALREADY_SET
+            );
 
-            // Try to set new lead
-            if let Some((member_id, role_account)) = new_lead {
-                Self::set_lead(member_id, role_account)?;
-            }
+            // Ensure that member can actually become lead
+            let new_lead_id = <NextLeadId<T>>::get();
+
+            let new_lead_role =
+                role_types::ActorInRole::new(role_types::Role::CuratorLead, new_lead_id);
+
+            let _profile = <members::Module<T>>::can_register_role_on_member(
+                &member,
+                &role_types::ActorInRole::new(role_types::Role::CuratorLead, new_lead_id),
+            )?;
+
+            //
+            // == MUTATION SAFE ==
+            //
+
+            // Construct lead
+            let new_lead = Lead {
+                role_account: role_account.clone(),
+                reward_relationship: None,
+                inducted: <system::Module<T>>::block_number(),
+                stage: LeadRoleState::Active,
+            };
+
+            // Store lead
+            <LeadById<T>>::insert(new_lead_id, new_lead);
+
+            // Update current lead
+            <CurrentLeadId<T>>::put(new_lead_id); // Some(new_lead_id)
+
+            // Update next lead counter
+            <NextLeadId<T>>::mutate(|id| *id += <LeadId<T> as One>::one());
+
+            // Register in role
+            let registered_role =
+                <members::Module<T>>::register_role_on_member(member, &new_lead_role).is_ok();
+
+            assert!(registered_role);
+
+            // Trigger event
+            Self::deposit_event(RawEvent::LeadSet(new_lead_id));
+        }
+
+        /// Evict the currently unset lead
+        pub fn unset_lead(origin) {
+
+            // Ensure root is origin
+            ensure_root(origin)?;
+
+            // Ensure there is a lead set
+            let (lead_id,lead) = Self::ensure_lead_is_set()?;
+
+            //
+            // == MUTATION SAFE ==
+            //
+
+            // Unregister from role in membership model
+            let current_lead_role = role_types::ActorInRole{
+                role: role_types::Role::CuratorLead,
+                actor_id: lead_id
+            };
+
+            let unregistered_role = <members::Module<T>>::unregister_role(current_lead_role).is_ok();
+
+            assert!(unregistered_role);
+
+            // Update lead stage as exited
+            let current_block = <system::Module<T>>::block_number();
+
+            let new_lead = Lead{
+                stage: LeadRoleState::Exited(ExitedLeadRole { initiated_at_block_number: current_block}),
+                ..lead
+            };
+
+            <LeadById<T>>::insert(lead_id, new_lead);
+
+            // Update current lead
+            <CurrentLeadId<T>>::take(); // None
+
+            // Trigger event
+            Self::deposit_event(RawEvent::LeadUnset(lead_id));
         }
 
         /// Add an opening for a curator role.
@@ -1946,11 +2022,7 @@ decl_module! {
             Self::deposit_event(RawEvent::ChannelCreationEnabledUpdated(enabled));
         }
 
-        /// Add to capacity of current acive mint.
-        /// This may be deprecated in the future, since set_mint_capacity is sufficient to
-        /// both increase and decrease capacity. Although when considering that it may be executed
-        /// by a proposal, given the temporal delay in approving a proposal, it might be more suitable
-        /// than set_mint_capacity?
+        /// Add to capacity of current acive mint
         pub fn increase_mint_capacity(
             origin,
             additional_capacity: minting::BalanceOf<T>
@@ -1960,47 +2032,12 @@ decl_module! {
             let mint_id = Self::mint();
             let mint = <minting::Module<T>>::mints(mint_id); // must exist
             let new_capacity = mint.capacity() + additional_capacity;
-            <minting::Module<T>>::set_mint_capacity(mint_id, new_capacity)?;
-
-            Self::deposit_event(RawEvent::MintCapacityIncreased(
-                mint_id, additional_capacity, new_capacity
-            ));
-        }
-
-        /// Sets the capacity of the current active mint
-        pub fn set_mint_capacity(
-            origin,
-            new_capacity: minting::BalanceOf<T>
-        ) {
-            ensure_root(origin)?;
-
-            let mint_id = Self::mint();
-
-            // Mint must exist - it is set at genesis
-            let mint = <minting::Module<T>>::mints(mint_id);
-
-            let current_capacity = mint.capacity();
-
-            if new_capacity != current_capacity {
-                // Cannot fail if mint exists
-                <minting::Module<T>>::set_mint_capacity(mint_id, new_capacity)?;
-
-                if new_capacity > current_capacity {
-                    Self::deposit_event(RawEvent::MintCapacityIncreased(
-                        mint_id, new_capacity - current_capacity, new_capacity
-                    ));
-                } else {
-                    Self::deposit_event(RawEvent::MintCapacityDecreased(
-                        mint_id, current_capacity - new_capacity, new_capacity
-                    ));
-                }
-            }
-
+            let _ = <minting::Module<T>>::set_mint_capacity(mint_id, new_capacity);
         }
     }
 }
 
-impl<T: Trait> content_directory::CredentialChecker<T> for Module<T> {
+impl<T: Trait> versioned_store_permissions::CredentialChecker<T> for Module<T> {
     fn account_has_credential(account: &T::AccountId, id: PrincipalId<T>) -> bool {
         // Check that principal exists
         if !PrincipalById::<T>::exists(&id) {
@@ -2042,87 +2079,6 @@ impl<T: Trait> content_directory::CredentialChecker<T> for Module<T> {
 }
 
 impl<T: Trait> Module<T> {
-    /// Introduce a lead when one is not currently set.
-    fn set_lead(member: T::MemberId, role_account: T::AccountId) -> dispatch::Result {
-        // Ensure there is no current lead
-        ensure!(
-            <CurrentLeadId<T>>::get().is_none(),
-            MSG_CURRENT_LEAD_ALREADY_SET
-        );
-
-        let new_lead_id = <NextLeadId<T>>::get();
-
-        let new_lead_role =
-            role_types::ActorInRole::new(role_types::Role::CuratorLead, new_lead_id);
-
-        //
-        // == MUTATION SAFE ==
-        //
-
-        // Register in role - will fail if member cannot become lead
-        members::Module::<T>::register_role_on_member(member, &new_lead_role)?;
-
-        // Construct lead
-        let new_lead = Lead {
-            role_account: role_account.clone(),
-            reward_relationship: None,
-            inducted: <system::Module<T>>::block_number(),
-            stage: LeadRoleState::Active,
-        };
-
-        // Store lead
-        <LeadById<T>>::insert(new_lead_id, new_lead);
-
-        // Update current lead
-        <CurrentLeadId<T>>::put(new_lead_id); // Some(new_lead_id)
-
-        // Update next lead counter
-        <NextLeadId<T>>::mutate(|id| *id += <LeadId<T> as One>::one());
-
-        // Trigger event
-        Self::deposit_event(RawEvent::LeadSet(new_lead_id));
-
-        Ok(())
-    }
-
-    /// Evict the currently set lead
-    fn unset_lead() -> dispatch::Result {
-        // Ensure there is a lead set
-        let (lead_id, lead) = Self::ensure_lead_is_set()?;
-
-        //
-        // == MUTATION SAFE ==
-        //
-
-        // Unregister from role in membership model
-        let current_lead_role = role_types::ActorInRole {
-            role: role_types::Role::CuratorLead,
-            actor_id: lead_id,
-        };
-
-        <members::Module<T>>::unregister_role(current_lead_role)?;
-
-        // Update lead stage as exited
-        let current_block = <system::Module<T>>::block_number();
-
-        let new_lead = Lead {
-            stage: LeadRoleState::Exited(ExitedLeadRole {
-                initiated_at_block_number: current_block,
-            }),
-            ..lead
-        };
-
-        <LeadById<T>>::insert(lead_id, new_lead);
-
-        // Update current lead
-        <CurrentLeadId<T>>::take(); // None
-
-        // Trigger event
-        Self::deposit_event(RawEvent::LeadUnset(lead_id));
-
-        Ok(())
-    }
-
     fn ensure_member_has_no_active_application_on_opening(
         curator_applications: CuratorApplicationIdSet<T>,
         member_id: T::MemberId,

+ 10 - 9
runtime-modules/content-working-group/src/mock.rs

@@ -20,7 +20,8 @@ pub use membership::members;
 pub use minting;
 pub use recurringrewards;
 pub use stake;
-pub use content_directory;
+pub use versioned_store;
+pub use versioned_store_permissions;
 
 use crate::genesis;
 
@@ -53,6 +54,7 @@ mod lib {
 
 impl_outer_event! {
     pub enum TestEvent for Test {
+        versioned_store<T>,
         members<T>,
         balances<T>,
         lib<T>,
@@ -66,9 +68,7 @@ pub type RawLibTestEvent = RawEvent<
     CuratorApplicationId<Test>,
     CuratorId<Test>,
     CuratorApplicationIdToCuratorIdMap<Test>,
-    minting::BalanceOf<Test>,
     <Test as system::Trait>::AccountId,
-    <Test as minting::Trait>::MintId,
 >;
 
 pub fn get_last_event_or_panic() -> RawLibTestEvent {
@@ -169,8 +169,12 @@ impl hiring::Trait for Test {
     type StakeHandlerProvider = hiring::Module<Self>;
 }
 
+impl versioned_store::Trait for Test {
+    type Event = TestEvent;
+}
+
 type TestPrincipalId = u64;
-impl content_directory::Trait for Test {
+impl versioned_store_permissions::Trait for Test {
     type Credential = TestPrincipalId;
     type CredentialChecker = ();
     type CreateClassPermissionsChecker = ();
@@ -216,13 +220,11 @@ impl<T: Trait> TestExternalitiesBuilder<T> {
         self.membership_config = Some(membership_config);
         self
     }
-    */
-
-    pub fn with_content_wg_config(mut self, conteng_wg_config: GenesisConfig<T>) -> Self {
+    pub fn set_content_wg_config(mut self, conteng_wg_config: GenesisConfig<T>) -> Self {
         self.content_wg_config = Some(conteng_wg_config);
         self
     }
-
+    */
     pub fn build(self) -> runtime_io::TestExternalities {
         // Add system
         let mut t = self
@@ -258,4 +260,3 @@ impl<T: Trait> TestExternalitiesBuilder<T> {
 pub type System = system::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type ContentWorkingGroup = Module<Test>;
-pub type Minting = minting::Module<Test>;

+ 6 - 92
runtime-modules/content-working-group/src/tests.rs

@@ -1,6 +1,6 @@
 #![cfg(test)]
 
-use super::genesis;
+//use super::genesis;
 use super::mock::{self, *};
 //use crate::membership;
 use hiring;
@@ -1160,10 +1160,7 @@ struct SetLeadFixture {
 
 impl SetLeadFixture {
     fn call(&self) -> Result<(), &'static str> {
-        ContentWorkingGroup::replace_lead(
-            self.origin.clone(),
-            Some((self.member_id, self.new_role_account)),
-        )
+        ContentWorkingGroup::set_lead(self.origin.clone(), self.member_id, self.new_role_account)
     }
 
     pub fn call_and_assert_success(&self) {
@@ -1224,7 +1221,7 @@ struct UnsetLeadFixture {
 
 impl UnsetLeadFixture {
     fn call(&self) -> Result<(), &'static str> {
-        ContentWorkingGroup::replace_lead(self.origin.clone(), None)
+        ContentWorkingGroup::unset_lead(self.origin.clone())
     }
 
     pub fn call_and_assert_success(&self) {
@@ -2124,9 +2121,10 @@ pub fn set_lead(
 
     // Set lead
     assert_eq!(
-        ContentWorkingGroup::replace_lead(
+        ContentWorkingGroup::set_lead(
             mock::Origin::system(system::RawOrigin::Root),
-            Some((member_id, new_role_account))
+            member_id,
+            new_role_account
         )
         .unwrap(),
         ()
@@ -2186,87 +2184,3 @@ pub fn generate_too_short_length_buffer(constraint: &InputValidationLengthConstr
 pub fn generate_too_long_length_buffer(constraint: &InputValidationLengthConstraint) -> Vec<u8> {
     generate_text((constraint.max() + 1) as usize)
 }
-
-#[test]
-fn increasing_mint_capacity() {
-    const MINT_CAPACITY: u64 = 50000;
-
-    TestExternalitiesBuilder::<Test>::default()
-        .with_content_wg_config(
-            genesis::GenesisConfigBuilder::<Test>::default()
-                .with_mint_capacity(MINT_CAPACITY)
-                .build(),
-        )
-        .build()
-        .execute_with(|| {
-            let mint_id = ContentWorkingGroup::mint();
-            let mint = Minting::mints(mint_id);
-            assert_eq!(mint.capacity(), MINT_CAPACITY);
-
-            let increase = 25000;
-            // Increasing mint capacity
-            let expected_new_capacity = MINT_CAPACITY + increase;
-            assert_ok!(ContentWorkingGroup::increase_mint_capacity(
-                Origin::ROOT,
-                increase
-            ));
-            // Excpected event after increasing
-            assert_eq!(
-                get_last_event_or_panic(),
-                crate::RawEvent::MintCapacityIncreased(mint_id, increase, expected_new_capacity)
-            );
-            // Excpected value of capacity after increasing
-            let mint = Minting::mints(mint_id);
-            assert_eq!(mint.capacity(), expected_new_capacity);
-        });
-}
-
-#[test]
-fn setting_mint_capacity() {
-    const MINT_CAPACITY: u64 = 50000;
-
-    TestExternalitiesBuilder::<Test>::default()
-        .with_content_wg_config(
-            genesis::GenesisConfigBuilder::<Test>::default()
-                .with_mint_capacity(MINT_CAPACITY)
-                .build(),
-        )
-        .build()
-        .execute_with(|| {
-            let mint_id = ContentWorkingGroup::mint();
-            let mint = Minting::mints(mint_id);
-            assert_eq!(mint.capacity(), MINT_CAPACITY);
-
-            // Decreasing mint capacity
-            let new_lower_capacity = 10000;
-            let decrease = MINT_CAPACITY - new_lower_capacity;
-            assert_ok!(ContentWorkingGroup::set_mint_capacity(
-                Origin::ROOT,
-                new_lower_capacity
-            ));
-            // Correct event after decreasing
-            assert_eq!(
-                get_last_event_or_panic(),
-                crate::RawEvent::MintCapacityDecreased(mint_id, decrease, new_lower_capacity)
-            );
-            // Correct value of capacity after decreasing
-            let mint = Minting::mints(mint_id);
-            assert_eq!(mint.capacity(), new_lower_capacity);
-
-            // Increasing mint capacity
-            let new_higher_capacity = 25000;
-            let increase = new_higher_capacity - mint.capacity();
-            assert_ok!(ContentWorkingGroup::set_mint_capacity(
-                Origin::ROOT,
-                new_higher_capacity
-            ));
-            // Excpected event after increasing
-            assert_eq!(
-                get_last_event_or_panic(),
-                crate::RawEvent::MintCapacityIncreased(mint_id, increase, new_higher_capacity)
-            );
-            // Excpected value of capacity after increasing
-            let mint = Minting::mints(mint_id);
-            assert_eq!(mint.capacity(), new_higher_capacity);
-        });
-}

+ 1 - 7
runtime-modules/governance/Cargo.toml

@@ -17,7 +17,6 @@ std = [
 	'rstd/std',
 	'common/std',
 	'membership/std',
-	'minting/std',
 ]
 
 [dependencies.sr-primitives]
@@ -87,9 +86,4 @@ rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-balances'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.minting]
-default_features = false
-package = 'substrate-token-mint-module'
-path = '../token-minting'
+rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'

+ 3 - 41
runtime-modules/governance/src/council.rs

@@ -21,7 +21,7 @@ impl<X: CouncilTermEnded> CouncilTermEnded for (X,) {
     }
 }
 
-pub trait Trait: system::Trait + minting::Trait + GovernanceCurrency {
+pub trait Trait: system::Trait + GovernanceCurrency {
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
 
     type CouncilTermEnded: CouncilTermEnded;
@@ -29,14 +29,8 @@ pub trait Trait: system::Trait + minting::Trait + GovernanceCurrency {
 
 decl_storage! {
     trait Store for Module<T: Trait> as Council {
-        pub ActiveCouncil get(active_council) config(): Seats<T::AccountId, BalanceOf<T>>;
-
-        pub TermEndsAt get(term_ends_at) config() : T::BlockNumber = T::BlockNumber::from(1);
-
-        /// The mint that funds council member rewards and spending proposals budget. It is an Option
-        /// because it was introduced in a runtime upgrade. It will be automatically created when
-        /// a successful call to set_council_mint_capacity() is made.
-        pub CouncilMint get(council_mint) : Option<<T as minting::Trait>::MintId>;
+        ActiveCouncil get(active_council) config(): Seats<T::AccountId, BalanceOf<T>>;
+        TermEndsAt get(term_ends_at) config() : T::BlockNumber = T::BlockNumber::from(1);
     }
 }
 
@@ -66,15 +60,6 @@ impl<T: Trait> Module<T> {
     pub fn is_councilor(sender: &T::AccountId) -> bool {
         Self::active_council().iter().any(|c| c.member == *sender)
     }
-
-    /// Initializes a new mint, discarding previous mint if it existed.
-    pub fn create_new_council_mint(
-        capacity: minting::BalanceOf<T>,
-    ) -> Result<T::MintId, &'static str> {
-        let mint_id = <minting::Module<T>>::add_mint(capacity, None)?;
-        CouncilMint::<T>::put(mint_id);
-        Ok(mint_id)
-    }
 }
 
 decl_module! {
@@ -133,29 +118,6 @@ decl_module! {
             ensure!(ends_at > <system::Module<T>>::block_number(), "must set future block number");
             <TermEndsAt<T>>::put(ends_at);
         }
-
-        /// Sets the capacity of the the council mint, if it doesn't exist, attempts to
-        /// create a new one.
-        fn set_council_mint_capacity(origin, capacity: minting::BalanceOf<T>) {
-            ensure_root(origin)?;
-
-            if let Some(mint_id) = Self::council_mint() {
-                minting::Module::<T>::set_mint_capacity(mint_id, capacity)?;
-            } else {
-                Self::create_new_council_mint(capacity)?;
-            }
-        }
-
-        /// Attempts to mint and transfer amount to destination account
-        fn spend_from_council_mint(origin, amount: minting::BalanceOf<T>, destination: T::AccountId) {
-            ensure_root(origin)?;
-
-            if let Some(mint_id) = Self::council_mint() {
-                minting::Module::<T>::transfer_tokens(mint_id, amount, &destination)?;
-            } else {
-                return Err("CouncilHashNoMint")
-            }
-        }
     }
 }
 

+ 64 - 126
runtime-modules/governance/src/election.rs

@@ -1,26 +1,3 @@
-//! Council Elections Manager
-//!
-//! # Election Parameters:
-//! We don't currently handle zero periods, zero council term, zero council size and candidacy
-//! limit in any special way. The behaviour in such cases:
-//!
-//! - Setting any period to 0 will mean the election getting stuck in that stage, until force changing
-//! the state.
-//!
-//! - Council Size of 0 - no limit to size of council, all applicants that move beyond
-//! announcing stage would become council members, so effectively the candidacy limit will
-//! be the size of the council, voting and revealing have no impact on final results.
-//!
-//! - If candidacy limit is zero and council size > 0, council_size number of applicants will reach the voting stage.
-//! and become council members, voting will have no impact on final results.
-//!
-//! - If both candidacy limit and council size are zero then all applicant become council members
-//! since no filtering occurs at end of announcing stage.
-//!
-//! We only guard against these edge cases in the [`set_election_parameters`] call.
-//!
-//! [`set_election_parameters`]: struct.Module.html#method.set_election_parameters
-
 use rstd::prelude::*;
 use srml_support::traits::{Currency, ReservableCurrency};
 use srml_support::{decl_event, decl_module, decl_storage, dispatch::Result, ensure};
@@ -37,7 +14,6 @@ use super::sealed_vote::SealedVote;
 use super::stake::Stake;
 
 use super::council;
-use crate::election_params::ElectionParameters;
 pub use common::currency::{BalanceOf, GovernanceCurrency};
 
 pub trait Trait:
@@ -48,8 +24,6 @@ pub trait Trait:
     type CouncilElected: CouncilElected<Seats<Self::AccountId, BalanceOf<Self>>, Self::BlockNumber>;
 }
 
-pub static MSG_CANNOT_CHANGE_PARAMS_DURING_ELECTION: &str = "CannotChangeParamsDuringElection";
-
 #[derive(Clone, Copy, Encode, Decode)]
 pub enum ElectionStage<BlockNumber> {
     Announcing(BlockNumber),
@@ -132,25 +106,16 @@ decl_storage! {
         // TODO value type of this map looks scary, is there any way to simplify the notation?
         Votes get(votes): map T::Hash => SealedVote<T::AccountId, ElectionStake<T>, T::Hash, T::AccountId>;
 
-        // Current Election Parameters.
-        // Should we replace all the individual values with a single ElectionParameters type?
-        // Having them individually makes it more flexible to add and remove new parameters in future
-        // without dealing with migration issues.
-        AnnouncingPeriod get(announcing_period): T::BlockNumber;
-        VotingPeriod get(voting_period): T::BlockNumber;
-        RevealingPeriod get(revealing_period): T::BlockNumber;
-        CouncilSize get(council_size): u32;
-        CandidacyLimit get (candidacy_limit): u32;
-        MinCouncilStake get(min_council_stake): BalanceOf<T>;
-        NewTermDuration get(new_term_duration): T::BlockNumber;
-        MinVotingStake get(min_voting_stake): BalanceOf<T>;
-    }
-    add_extra_genesis {
-        config(election_parameters): ElectionParameters<BalanceOf<T>, T::BlockNumber>;
-        build(|config: &GenesisConfig<T>| {
-            config.election_parameters.ensure_valid().expect("Invalid Election Parameters");
-            Module::<T>::set_verified_election_parameters(config.election_parameters);
-        });
+        // Current Election Parameters - default "zero" values are not meaningful. Running an election without
+        // settings reasonable values is a bad idea. Parameters can be set in the TriggerElection hook.
+        AnnouncingPeriod get(announcing_period) config(): T::BlockNumber = T::BlockNumber::from(100);
+        VotingPeriod get(voting_period) config(): T::BlockNumber = T::BlockNumber::from(100);
+        RevealingPeriod get(revealing_period) config(): T::BlockNumber = T::BlockNumber::from(100);
+        CouncilSize get(council_size) config(): u32 = 10;
+        CandidacyLimit get (candidacy_limit) config(): u32 = 20;
+        MinCouncilStake get(min_council_stake) config(): BalanceOf<T> = BalanceOf::<T>::from(100);
+        NewTermDuration get(new_term_duration) config(): T::BlockNumber = T::BlockNumber::from(1000);
+        MinVotingStake get(min_voting_stake) config(): BalanceOf<T> = BalanceOf::<T>::from(10);
     }
 }
 
@@ -191,7 +156,7 @@ impl<T: Trait> Module<T> {
     }
 
     fn can_participate(sender: &T::AccountId) -> bool {
-        !<T as GovernanceCurrency>::Currency::free_balance(sender).is_zero()
+        !T::Currency::free_balance(sender).is_zero()
             && <membership::members::Module<T>>::is_member_account(sender)
     }
 
@@ -230,7 +195,7 @@ impl<T: Trait> Module<T> {
 
         // Take snapshot of seat and backing stakes of an existing council
         // Its important to note that the election system takes ownership of these stakes, and is responsible
-        // to return any unused stake to original owners at the end of the election.
+        // to return any unused stake to original owners and the end of the election.
         Self::initialize_transferable_stakes(current_council);
 
         Self::deposit_event(RawEvent::ElectionStarted());
@@ -391,10 +356,7 @@ impl<T: Trait> Module<T> {
         for stakeholder in Self::existing_stake_holders().iter() {
             let stake = Self::transferable_stakes(stakeholder);
             if !stake.seat.is_zero() || !stake.backing.is_zero() {
-                <T as GovernanceCurrency>::Currency::unreserve(
-                    stakeholder,
-                    stake.seat + stake.backing,
-                );
+                T::Currency::unreserve(stakeholder, stake.seat + stake.backing);
             }
         }
     }
@@ -419,7 +381,7 @@ impl<T: Trait> Module<T> {
 
         // return new stake to account's free balance
         if !stake.new.is_zero() {
-            <T as GovernanceCurrency>::Currency::unreserve(applicant, stake.new);
+            T::Currency::unreserve(applicant, stake.new);
         }
 
         // return unused transferable stake
@@ -473,7 +435,7 @@ impl<T: Trait> Module<T> {
                 // return new stake to account's free balance
                 let SealedVote { voter, stake, .. } = sealed_vote;
                 if !stake.new.is_zero() {
-                    <T as GovernanceCurrency>::Currency::unreserve(voter, stake.new);
+                    T::Currency::unreserve(voter, stake.new);
                 }
 
                 // return unused transferable stake
@@ -664,12 +626,12 @@ impl<T: Trait> Module<T> {
         let new_stake = Self::new_stake_reusing_transferable(&mut transferable_stake.seat, stake);
 
         ensure!(
-            <T as GovernanceCurrency>::Currency::can_reserve(&applicant, new_stake.new),
+            T::Currency::can_reserve(&applicant, new_stake.new),
             "not enough free balance to reserve"
         );
 
         ensure!(
-            <T as GovernanceCurrency>::Currency::reserve(&applicant, new_stake.new).is_ok(),
+            T::Currency::reserve(&applicant, new_stake.new).is_ok(),
             "failed to reserve applicant stake!"
         );
 
@@ -700,12 +662,12 @@ impl<T: Trait> Module<T> {
             Self::new_stake_reusing_transferable(&mut transferable_stake.backing, stake);
 
         ensure!(
-            <T as GovernanceCurrency>::Currency::can_reserve(&voter, vote_stake.new),
+            T::Currency::can_reserve(&voter, vote_stake.new),
             "not enough free balance to reserve"
         );
 
         ensure!(
-            <T as GovernanceCurrency>::Currency::reserve(&voter, vote_stake.new).is_ok(),
+            T::Currency::reserve(&voter, vote_stake.new).is_ok(),
             "failed to reserve voting stake!"
         );
 
@@ -751,17 +713,6 @@ impl<T: Trait> Module<T> {
 
         Ok(())
     }
-
-    fn set_verified_election_parameters(params: ElectionParameters<BalanceOf<T>, T::BlockNumber>) {
-        <AnnouncingPeriod<T>>::put(params.announcing_period);
-        <VotingPeriod<T>>::put(params.voting_period);
-        <RevealingPeriod<T>>::put(params.revealing_period);
-        <MinCouncilStake<T>>::put(params.min_council_stake);
-        <NewTermDuration<T>>::put(params.new_term_duration);
-        CouncilSize::put(params.council_size);
-        CandidacyLimit::put(params.candidacy_limit);
-        <MinVotingStake<T>>::put(params.min_voting_stake);
-    }
 }
 
 decl_module! {
@@ -852,16 +803,52 @@ decl_module! {
             <Stage<T>>::put(ElectionStage::Voting(ends_at));
         }
 
-        /// Sets new election parameters. Some combination of parameters that are not desirable, so
-        /// the parameters are checked for validity.
-        /// The call will fail if an election is in progress. If a council is not being elected for some
-        /// reaon after multiple rounds, force_stop_election() can be called to stop elections and followed by
-        /// set_election_parameters().
-        pub fn set_election_parameters(origin, params: ElectionParameters<BalanceOf<T>, T::BlockNumber>) {
+        fn set_param_announcing_period(origin, period: T::BlockNumber) {
+            ensure_root(origin)?;
+            ensure!(!Self::is_election_running(), "cannot change params during election");
+            ensure!(!period.is_zero(), "period cannot be zero");
+            <AnnouncingPeriod<T>>::put(period);
+        }
+        fn set_param_voting_period(origin,  period: T::BlockNumber) {
+            ensure_root(origin)?;
+            ensure!(!Self::is_election_running(), "cannot change params during election");
+            ensure!(!period.is_zero(), "period cannot be zero");
+            <VotingPeriod<T>>::put(period);
+        }
+        fn set_param_revealing_period(origin, period: T::BlockNumber) {
+            ensure_root(origin)?;
+            ensure!(!Self::is_election_running(), "cannot change params during election");
+            ensure!(!period.is_zero(), "period cannot be zero");
+            <RevealingPeriod<T>>::put(period);
+        }
+        fn set_param_min_council_stake(origin, amount: BalanceOf<T>) {
+            ensure_root(origin)?;
+            ensure!(!Self::is_election_running(), "cannot change params during election");
+            <MinCouncilStake<T>>::put(amount);
+        }
+        fn set_param_new_term_duration(origin, duration: T::BlockNumber) {
+            ensure_root(origin)?;
+            ensure!(!Self::is_election_running(), "cannot change params during election");
+            ensure!(!duration.is_zero(), "new term duration cannot be zero");
+            <NewTermDuration<T>>::put(duration);
+        }
+        fn set_param_council_size(origin, council_size: u32) {
+            ensure_root(origin)?;
+            ensure!(!Self::is_election_running(), "cannot change params during election");
+            ensure!(council_size > 0, "council size cannot be zero");
+            ensure!(council_size <= Self::candidacy_limit(), "council size cannot greater than candidacy limit");
+            CouncilSize::put(council_size);
+        }
+        fn set_param_candidacy_limit(origin, limit: u32) {
+            ensure_root(origin)?;
+            ensure!(!Self::is_election_running(), "cannot change params during election");
+            ensure!(limit >= Self::council_size(), "candidacy limit cannot be less than council size");
+            CandidacyLimit::put(limit);
+        }
+        fn set_param_min_voting_stake(origin, amount: BalanceOf<T>) {
             ensure_root(origin)?;
-            ensure!(!Self::is_election_running(), MSG_CANNOT_CHANGE_PARAMS_DURING_ELECTION);
-            params.ensure_valid()?;
-            Self::set_verified_election_parameters(params);
+            ensure!(!Self::is_election_running(), "cannot change params during election");
+            <MinVotingStake<T>>::put(amount);
         }
 
         fn force_stop_election(origin) {
@@ -2055,53 +2042,4 @@ mod tests {
             assert_ok!(Election::start_election(vec![]));
         });
     }
-
-    #[test]
-    fn setting_election_parameters() {
-        initial_test_ext().execute_with(|| {
-            let default_parameters: ElectionParameters<u64, u64> = ElectionParameters::default();
-            // default all zeros is invalid
-            assert!(default_parameters.ensure_valid().is_err());
-
-            let new_parameters = ElectionParameters {
-                announcing_period: 1,
-                voting_period: 2,
-                revealing_period: 3,
-                council_size: 4,
-                candidacy_limit: 5,
-                min_voting_stake: 6,
-                min_council_stake: 7,
-                new_term_duration: 8,
-            };
-
-            assert_ok!(Election::set_election_parameters(
-                Origin::ROOT,
-                new_parameters
-            ));
-
-            assert_eq!(
-                <AnnouncingPeriod<Test>>::get(),
-                new_parameters.announcing_period
-            );
-            assert_eq!(<VotingPeriod<Test>>::get(), new_parameters.voting_period);
-            assert_eq!(
-                <RevealingPeriod<Test>>::get(),
-                new_parameters.revealing_period
-            );
-            assert_eq!(
-                <MinCouncilStake<Test>>::get(),
-                new_parameters.min_council_stake
-            );
-            assert_eq!(
-                <NewTermDuration<Test>>::get(),
-                new_parameters.new_term_duration
-            );
-            assert_eq!(CouncilSize::get(), new_parameters.council_size);
-            assert_eq!(CandidacyLimit::get(), new_parameters.candidacy_limit);
-            assert_eq!(
-                <MinVotingStake<Test>>::get(),
-                new_parameters.min_voting_stake
-            );
-        });
-    }
 }

+ 0 - 1
runtime-modules/governance/src/lib.rs

@@ -3,7 +3,6 @@
 
 pub mod council;
 pub mod election;
-pub mod election_params;
 pub mod proposals;
 
 mod sealed_vote;

+ 1 - 4
runtime-modules/governance/src/mock.rs

@@ -70,10 +70,7 @@ impl membership::members::Trait for Test {
     type ActorId = u32;
     type InitialMembersBalance = InitialMembersBalance;
 }
-impl minting::Trait for Test {
-    type Currency = Balances;
-    type MintId = u64;
-}
+
 parameter_types! {
     pub const ExistentialDeposit: u32 = 0;
     pub const TransferFee: u32 = 0;

+ 9 - 15
runtime-modules/governance/src/proposals.rs

@@ -244,7 +244,7 @@ decl_module! {
             ensure!(wasm_code.len() as u32 <= Self::wasm_code_max_len(), MSG_TOO_LONG_WASM_CODE);
 
             // Lock proposer's stake:
-            <T as GovernanceCurrency>::Currency::reserve(&proposer, stake)
+            T::Currency::reserve(&proposer, stake)
                 .map_err(|_| MSG_STAKE_IS_GREATER_THAN_BALANCE)?;
 
             let proposal_id = Self::proposal_count() + 1;
@@ -312,11 +312,11 @@ decl_module! {
 
             // Spend some minimum fee on proposer's balance for canceling a proposal
             let fee = Self::cancellation_fee();
-            let _ = <T as GovernanceCurrency>::Currency::slash_reserved(&proposer, fee);
+            let _ = T::Currency::slash_reserved(&proposer, fee);
 
             // Return unspent part of remaining staked deposit (after taking some fee)
             let left_stake = proposal.stake - fee;
-            let _ = <T as GovernanceCurrency>::Currency::unreserve(&proposer, left_stake);
+            let _ = T::Currency::unreserve(&proposer, left_stake);
 
             Self::_update_proposal_status(proposal_id, Cancelled)?;
             Self::deposit_event(RawEvent::ProposalCanceled(proposer, proposal_id));
@@ -336,7 +336,7 @@ decl_module! {
             let proposal = Self::proposals(proposal_id);
             ensure!(proposal.status == Active, MSG_PROPOSAL_FINALIZED);
 
-            let _ = <T as GovernanceCurrency>::Currency::unreserve(&proposal.proposer, proposal.stake);
+            let _ = T::Currency::unreserve(&proposal.proposer, proposal.stake);
 
             Self::_update_proposal_status(proposal_id, Cancelled)?;
 
@@ -357,7 +357,7 @@ impl<T: Trait> Module<T> {
     }
 
     fn can_participate(sender: &T::AccountId) -> bool {
-        !<T as GovernanceCurrency>::Currency::free_balance(sender).is_zero()
+        !T::Currency::free_balance(sender).is_zero()
             && <membership::members::Module<T>>::is_member_account(sender)
     }
 
@@ -513,8 +513,7 @@ impl<T: Trait> Module<T> {
         let proposal = Self::proposals(proposal_id);
 
         // Slash proposer's stake:
-        let _ =
-            <T as GovernanceCurrency>::Currency::slash_reserved(&proposal.proposer, proposal.stake);
+        let _ = T::Currency::slash_reserved(&proposal.proposer, proposal.stake);
 
         Ok(())
     }
@@ -526,11 +525,11 @@ impl<T: Trait> Module<T> {
 
         // Spend some minimum fee on proposer's balance to prevent spamming attacks:
         let fee = Self::rejection_fee();
-        let _ = <T as GovernanceCurrency>::Currency::slash_reserved(&proposer, fee);
+        let _ = T::Currency::slash_reserved(&proposer, fee);
 
         // Return unspent part of remaining staked deposit (after taking some fee):
         let left_stake = proposal.stake - fee;
-        let _ = <T as GovernanceCurrency>::Currency::unreserve(&proposer, left_stake);
+        let _ = T::Currency::unreserve(&proposer, left_stake);
 
         Ok(())
     }
@@ -541,7 +540,7 @@ impl<T: Trait> Module<T> {
         let wasm_code = Self::wasm_code_by_hash(proposal.wasm_hash);
 
         // Return staked deposit to proposer:
-        let _ = <T as GovernanceCurrency>::Currency::unreserve(&proposal.proposer, proposal.stake);
+        let _ = T::Currency::unreserve(&proposal.proposer, proposal.stake);
 
         // Update wasm code of node's runtime:
         <system::Module<T>>::set_code(system::RawOrigin::Root.into(), wasm_code)?;
@@ -650,11 +649,6 @@ mod tests {
         type InitialMembersBalance = InitialMembersBalance;
     }
 
-    impl minting::Trait for Test {
-        type Currency = balances::Module<Self>;
-        type MintId = u64;
-    }
-
     impl Trait for Test {
         type Event = ();
     }

+ 0 - 18
runtime-modules/token-minting/src/lib.rs

@@ -73,24 +73,6 @@ impl From<MintingError> for TransferError {
     }
 }
 
-impl From<GeneralError> for &'static str {
-    fn from(err: GeneralError) -> &'static str {
-        match err {
-            GeneralError::MintNotFound => "MintNotFound",
-            GeneralError::NextAdjustmentInPast => "NextAdjustmentInPast",
-        }
-    }
-}
-
-impl From<TransferError> for &'static str {
-    fn from(err: TransferError) -> &'static str {
-        match err {
-            TransferError::MintNotFound => "MintNotFound",
-            TransferError::NotEnoughCapacity => "NotEnoughCapacity",
-        }
-    }
-}
-
 #[derive(Encode, Decode, Copy, Clone, Debug, Eq, PartialEq)]
 pub enum Adjustment<Balance: Zero, BlockNumber> {
     // First adjustment will be after AdjustOnInterval.block_interval

+ 11 - 5
runtime/Cargo.toml

@@ -5,7 +5,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.12.0'
+version = '6.8.1'
 
 [features]
 default = ['std']
@@ -49,7 +49,8 @@ std = [
     'recurringrewards/std',
     'stake/std',
     'hiring/std',
-    'content_directory/std',
+    'versioned_store/std',
+    'versioned_store_permissions/std',
     'common/std',
     'content_working_group/std',
     'governance/std',
@@ -295,10 +296,15 @@ default_features = false
 package = 'substrate-hiring-module'
 path = '../runtime-modules/hiring'
 
-[dependencies.content_directory]
+[dependencies.versioned_store]
 default_features = false
-package = 'substrate-content-directory-module'
-path = '../runtime-modules/content-directory'
+package ='substrate-versioned-store'
+path = '../runtime-modules/versioned-store'
+
+[dependencies.versioned_store_permissions]
+default_features = false
+package = 'substrate-versioned-store-permissions-module'
+path = '../runtime-modules/versioned-store-permissions'
 
 [dependencies.common]
 default_features = false

+ 21 - 16
runtime/src/lib.rs

@@ -115,7 +115,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: 12,
+    spec_version: 8,
     impl_version: 0,
     apis: RUNTIME_API_VERSIONS,
 };
@@ -396,11 +396,11 @@ impl finality_tracker::Trait for Runtime {
 }
 
 pub use forum;
-pub use governance::election_params::ElectionParameters;
 use governance::{council, election, proposals};
 use membership::members;
 use storage::{data_directory, data_object_storage_registry, data_object_type_registry};
-pub use content_directory;
+pub use versioned_store;
+use versioned_store_permissions;
 
 pub use content_working_group as content_wg;
 mod migration;
@@ -414,7 +414,11 @@ use stake;
 /// Alias for ContentId, used in various places.
 pub type ContentId = primitives::H256;
 
-impl content_directory::Trait for Runtime {
+impl versioned_store::Trait for Runtime {
+    type Event = Event;
+}
+
+impl versioned_store_permissions::Trait for Runtime {
     type Credential = Credential;
     type CredentialChecker = (ContentWorkingGroupCredentials, SudoKeyHasAllCredentials);
     type CreateClassPermissionsChecker = ContentLeadOrSudoKeyCanCreateClasses;
@@ -422,10 +426,10 @@ impl content_directory::Trait for Runtime {
 
 // Credential Checker that gives the sudo key holder all credentials
 pub struct SudoKeyHasAllCredentials {}
-impl content_directory::CredentialChecker<Runtime> for SudoKeyHasAllCredentials {
+impl versioned_store_permissions::CredentialChecker<Runtime> for SudoKeyHasAllCredentials {
     fn account_has_credential(
         account: &AccountId,
-        _credential: <Runtime as content_directory::Trait>::Credential,
+        _credential: <Runtime as versioned_store_permissions::Trait>::Credential,
     ) -> bool {
         <sudo::Module<Runtime>>::key() == *account
     }
@@ -439,10 +443,10 @@ parameter_types! {
 }
 
 pub struct ContentWorkingGroupCredentials {}
-impl content_directory::CredentialChecker<Runtime> for ContentWorkingGroupCredentials {
+impl versioned_store_permissions::CredentialChecker<Runtime> for ContentWorkingGroupCredentials {
     fn account_has_credential(
         account: &AccountId,
-        credential: <Runtime as content_directory::Trait>::Credential,
+        credential: <Runtime as versioned_store_permissions::Trait>::Credential,
     ) -> bool {
         match credential {
             // Credentials from 0..999 represents groups or more complex requirements
@@ -499,7 +503,7 @@ impl content_directory::CredentialChecker<Runtime> for ContentWorkingGroupCreden
 
 // Allow sudo key holder permission to create classes
 pub struct SudoKeyCanCreateClasses {}
-impl content_directory::CreateClassPermissionsChecker<Runtime>
+impl versioned_store_permissions::CreateClassPermissionsChecker<Runtime>
     for SudoKeyCanCreateClasses
 {
     fn account_can_create_class_permissions(account: &AccountId) -> bool {
@@ -510,10 +514,10 @@ impl content_directory::CreateClassPermissionsChecker<Runtime>
 // Impl this in the permissions module - can't be done here because
 // neither CreateClassPermissionsChecker or (X, Y) are local types?
 // impl<
-//         T: content_directory::Trait,
-//         X: content_directory::CreateClassPermissionsChecker<T>,
-//         Y: content_directory::CreateClassPermissionsChecker<T>,
-//     > content_directory::CreateClassPermissionsChecker<T> for (X, Y)
+//         T: versioned_store_permissions::Trait,
+//         X: versioned_store_permissions::CreateClassPermissionsChecker<T>,
+//         Y: versioned_store_permissions::CreateClassPermissionsChecker<T>,
+//     > versioned_store_permissions::CreateClassPermissionsChecker<T> for (X, Y)
 // {
 //     fn account_can_create_class_permissions(account: &T::AccountId) -> bool {
 //         X::account_can_create_class_permissions(account)
@@ -522,7 +526,7 @@ impl content_directory::CreateClassPermissionsChecker<Runtime>
 // }
 
 pub struct ContentLeadOrSudoKeyCanCreateClasses {}
-impl content_directory::CreateClassPermissionsChecker<Runtime>
+impl versioned_store_permissions::CreateClassPermissionsChecker<Runtime>
     for ContentLeadOrSudoKeyCanCreateClasses
 {
     fn account_can_create_class_permissions(account: &AccountId) -> bool {
@@ -533,7 +537,7 @@ impl content_directory::CreateClassPermissionsChecker<Runtime>
 
 // Allow content working group lead to create classes in content directory
 pub struct ContentLeadCanCreateClasses {}
-impl content_directory::CreateClassPermissionsChecker<Runtime>
+impl versioned_store_permissions::CreateClassPermissionsChecker<Runtime>
     for ContentLeadCanCreateClasses
 {
     fn account_can_create_class_permissions(account: &AccountId) -> bool {
@@ -833,7 +837,8 @@ construct_runtime!(
         DataDirectory: data_directory::{Module, Call, Storage, Event<T>},
         DataObjectStorageRegistry: data_object_storage_registry::{Module, Call, Storage, Event<T>, Config<T>},
         Discovery: discovery::{Module, Call, Storage, Event<T>},
-        ContentDirectory: content_directory::{Module, Call, Storage, Config<T>},
+        VersionedStore: versioned_store::{Module, Call, Storage, Event<T>, Config},
+        VersionedStorePermissions: versioned_store_permissions::{Module, Call, Storage},
         Stake: stake::{Module, Call, Storage},
         Minting: minting::{Module, Call, Storage},
         RecurringRewards: recurringrewards::{Module, Call, Storage},

+ 16 - 13
runtime/src/migration.rs

@@ -1,24 +1,28 @@
 use crate::VERSION;
-use sr_primitives::{print, traits::Zero};
+use sr_primitives::print;
 use srml_support::{decl_event, decl_module, decl_storage};
 use sudo;
 use system;
 
+// When preparing a new major runtime release version bump this value to match it and update
+// the initialization code in runtime_initialization(). Because of the way substrate runs runtime code
+// the runtime doesn't need to maintain any logic for old migrations. All knowledge about state of the chain and runtime
+// prior to the new runtime taking over is implicit in the migration code implementation. If assumptions are incorrect
+// behaviour is undefined.
+const MIGRATION_FOR_SPEC_VERSION: u32 = 0;
+
 impl<T: Trait> Module<T> {
-    fn runtime_upgraded() {
-        print("running runtime initializers...");
+    fn runtime_initialization() {
+        if VERSION.spec_version != MIGRATION_FOR_SPEC_VERSION {
+            return;
+        }
+
+        print("running runtime initializers");
 
         // ...
-        // add initialization of modules introduced in new runtime release. This
-        // would be any new storage values that need an initial value which would not
-        // have been initialized with config() or build() mechanism.
+        // add initialization of other modules introduced in this runtime
         // ...
 
-        // Create the Council mint. If it fails, we can't do anything about it here.
-        let _ = governance::council::Module::<T>::create_new_council_mint(
-            minting::BalanceOf::<T>::zero(),
-        );
-
         Self::deposit_event(RawEvent::Migrated(
             <system::Module<T>>::block_number(),
             VERSION.spec_version,
@@ -32,7 +36,6 @@ pub trait Trait:
     + storage::data_object_storage_registry::Trait
     + forum::Trait
     + sudo::Trait
-    + governance::council::Trait
 {
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
 }
@@ -61,7 +64,7 @@ decl_module! {
                 SpecVersion::put(VERSION.spec_version);
 
                 // run migrations and store initializers
-                Self::runtime_upgraded();
+                Self::runtime_initialization();
             }
         }
     }