瀏覽代碼

runtime: Remove stake pallet dependencies.

Shamil Gadelshin 4 年之前
父節點
當前提交
5d78df0978

+ 0 - 1
Cargo.lock

@@ -2364,7 +2364,6 @@ dependencies = [
  "pallet-service-discovery",
  "pallet-session",
  "pallet-session-benchmarking",
- "pallet-stake",
  "pallet-staking",
  "pallet-staking-reward-curve",
  "pallet-storage",

+ 0 - 1
runtime-modules/proposals/discussion/src/tests/mock.rs

@@ -27,7 +27,6 @@ parameter_types! {
     pub const MaximumBlockLength: u32 = 2 * 1024;
     pub const AvailableBlockRatio: Perbill = Perbill::one();
     pub const MinimumPeriod: u64 = 5;
-    pub const StakePoolId: [u8; 8] = *b"joystake";
 }
 
 parameter_types! {

+ 0 - 1
runtime-modules/proposals/engine/src/tests/mock/mod.rs

@@ -171,7 +171,6 @@ parameter_types! {
     pub const MaximumBlockLength: u32 = 2 * 1024;
     pub const AvailableBlockRatio: Perbill = Perbill::one();
     pub const MinimumPeriod: u64 = 5;
-    pub const StakePoolId: [u8; 8] = *b"joystake";
 }
 
 impl frame_system::Trait for Test {

+ 0 - 1
runtime-modules/staking-handler/src/mock.rs

@@ -21,7 +21,6 @@ parameter_types! {
     pub const MaximumBlockLength: u32 = 2 * 1024;
     pub const AvailableBlockRatio: Perbill = Perbill::one();
     pub const MinimumPeriod: u64 = 5;
-    pub const StakePoolId: [u8; 8] = *b"joystake";
     pub const ExistentialDeposit: u32 = 0;
 }
 

+ 0 - 1
runtime-modules/working-group/src/tests/mock.rs

@@ -37,7 +37,6 @@ parameter_types! {
     pub const MaximumBlockLength: u32 = 2 * 1024;
     pub const AvailableBlockRatio: Perbill = Perbill::one();
     pub const MinimumPeriod: u64 = 5;
-    pub const StakePoolId: [u8; 8] = *b"joystake";
     pub const ExistentialDeposit: u32 = 0;
 }
 

+ 0 - 2
runtime/Cargo.toml

@@ -66,7 +66,6 @@ common = { package = 'pallet-common', default-features = false, path = '../runti
 memo = { package = 'pallet-memo', default-features = false, path = '../runtime-modules/memo'}
 forum = { package = 'pallet-forum', default-features = false, path = '../runtime-modules/forum'}
 membership = { package = 'pallet-membership', default-features = false, path = '../runtime-modules/membership'}
-stake = { package = 'pallet-stake', default-features = false, path = '../runtime-modules/stake'}
 governance = { package = 'pallet-governance', default-features = false, path = '../runtime-modules/governance'}
 minting = { package = 'pallet-token-mint', default-features = false, path = '../runtime-modules/token-minting'}
 recurring-rewards = { package = 'pallet-recurring-reward', default-features = false, path = '../runtime-modules/recurring-reward'}
@@ -141,7 +140,6 @@ std = [
     'memo/std',
     'forum/std',
     'membership/std',
-    'stake/std',
     'governance/std',
     'minting/std',
     'recurring-rewards/std',

+ 0 - 13
runtime/src/lib.rs

@@ -459,18 +459,6 @@ impl recurring_rewards::Trait for Runtime {
     type RewardRelationshipId = u64;
 }
 
-parameter_types! {
-    pub const StakePoolId: [u8; 8] = *b"joystake";
-}
-
-impl stake::Trait for Runtime {
-    type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
-    type StakePoolId = StakePoolId;
-    type StakingEventsHandler = ();
-    type StakeId = u64;
-    type SlashId = u64;
-}
-
 impl common::currency::GovernanceCurrency for Runtime {
     type Currency = pallet_balances::Module<Self>;
 }
@@ -799,7 +787,6 @@ construct_runtime!(
         Memo: memo::{Module, Call, Storage, Event<T>},
         Members: membership::{Module, Call, Storage, Event<T>, Config<T>},
         Forum: forum::{Module, Call, Storage, Event<T>, Config<T>},
-        Stake: stake::{Module, Call, Storage},
         Minting: minting::{Module, Call, Storage},
         RecurringRewards: recurring_rewards::{Module, Call, Storage},
         ContentDirectory: content_directory::{Module, Call, Storage, Event<T>, Config<T>},

+ 5 - 9
runtime/src/tests/proposals_integration/mod.rs

@@ -77,7 +77,7 @@ pub(crate) fn increase_total_balance_issuance_using_account_id(
     type Balances = pallet_balances::Module<Runtime>;
     let initial_balance = Balances::total_issuance();
     {
-        let _ = <Runtime as stake::Trait>::Currency::deposit_creating(&account_id, balance);
+        let _ = Balances::deposit_creating(&account_id, balance);
     }
     assert_eq!(Balances::total_issuance(), initial_balance + balance);
 }
@@ -305,17 +305,13 @@ fn proposal_cancellation_with_slashes_with_balance_checks_succeeds() {
             .with_proposer(member_id);
 
         let account_balance = 500000;
-        let _imbalance =
-            <Runtime as stake::Trait>::Currency::deposit_creating(&account_id, account_balance);
+        let _imbalance = Balances::deposit_creating(&account_id, account_balance);
 
-        assert_eq!(
-            <Runtime as stake::Trait>::Currency::usable_balance(&account_id),
-            account_balance
-        );
+        assert_eq!(Balances::usable_balance(&account_id), account_balance);
 
         let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap();
         assert_eq!(
-            <Runtime as stake::Trait>::Currency::usable_balance(&account_id),
+            Balances::usable_balance(&account_id),
             account_balance - stake_amount
         );
 
@@ -341,7 +337,7 @@ fn proposal_cancellation_with_slashes_with_balance_checks_succeeds() {
 
         let cancellation_fee = ProposalCancellationFee::get() as u128;
         assert_eq!(
-            <Runtime as stake::Trait>::Currency::usable_balance(&account_id),
+            Balances::usable_balance(&account_id),
             account_balance - cancellation_fee
         );
     });

+ 26 - 40
runtime/src/tests/proposals_integration/working_group_proposals.rs

@@ -3,10 +3,10 @@
 
 use super::*;
 
-use frame_system::RawOrigin;
-
 use common::working_group::WorkingGroup;
+use frame_system::RawOrigin;
 use proposals_codex::AddOpeningParameters;
+use strum::IntoEnumIterator;
 use working_group::{Penalty, StakeParameters};
 
 use crate::primitives::{ActorId, MemberId};
@@ -16,8 +16,6 @@ use crate::{
     ForumWorkingGroupStakingManager, StorageWorkingGroup, StorageWorkingGroupInstance,
     StorageWorkingGroupStakingManager,
 };
-use frame_support::traits;
-use strum::IntoEnumIterator;
 
 type WorkingGroupInstance<T, I> = working_group::Module<T, I>;
 
@@ -115,14 +113,6 @@ fn fill_opening(
     codex_extrinsic_test_fixture.call_extrinsic_and_assert();
 }
 
-fn get_stake_balance(stake: stake::Stake<BlockNumber, Balance, u64>) -> Balance {
-    if let stake::StakingStatus::Staked(stake) = stake.staking_status {
-        return stake.staked_amount;
-    }
-
-    panic!("Not staked.");
-}
-
 fn decrease_stake(
     member_id: u64,
     account_id: [u8; 32],
@@ -313,7 +303,7 @@ fn create_add_working_group_leader_opening_proposal_execution_succeeds() {
 }
 
 fn run_create_add_working_group_leader_opening_proposal_execution_succeeds<
-    T: working_group::Trait<I> + frame_system::Trait + stake::Trait,
+    T: working_group::Trait<I> + frame_system::Trait,
     I: frame_support::traits::Instance,
 >(
     working_group: WorkingGroup,
@@ -369,7 +359,7 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
 }
 
 fn run_create_fill_working_group_leader_opening_proposal_execution_succeeds<
-    T: working_group::Trait<I> + frame_system::Trait + stake::Trait,
+    T: working_group::Trait<I> + frame_system::Trait,
     I: frame_support::traits::Instance,
 >(
     working_group: WorkingGroup,
@@ -450,20 +440,17 @@ fn create_decrease_group_leader_stake_proposal_execution_succeeds() {
 }
 
 fn run_create_decrease_group_leader_stake_proposal_execution_succeeds<
-        T: working_group::Trait<I> + frame_system::Trait + stake::Trait + membership::Trait + pallet_balances::Trait,
-        I: frame_support::traits::Instance,
-        SM: staking_handler::StakingHandler<T>
-    >(
-        working_group: WorkingGroup,
-    ) where
-        <T as frame_system::Trait>::AccountId: From<[u8; 32]>,
-        <T as membership::Trait>::MemberId: From<u64>,
-        <T as membership::Trait>::ActorId: Into<u64>,
-        <<T as stake::Trait>::Currency as traits::Currency<
-            <T as frame_system::Trait>::AccountId,
-        >>::Balance: From<u128>,
-        <T as pallet_balances::Trait>::Balance: From<u128>,
-    {
+    T: working_group::Trait<I> + frame_system::Trait + membership::Trait + pallet_balances::Trait,
+    I: frame_support::traits::Instance,
+    SM: staking_handler::StakingHandler<T>,
+>(
+    working_group: WorkingGroup,
+) where
+    <T as frame_system::Trait>::AccountId: From<[u8; 32]>,
+    <T as membership::Trait>::MemberId: From<u64>,
+    <T as membership::Trait>::ActorId: Into<u64>,
+    <T as pallet_balances::Trait>::Balance: From<u128>,
+{
     initial_test_ext().execute_with(|| {
         let member_id: MemberId = 1;
         let account_id: [u8; 32] = [member_id as u8; 32];
@@ -571,18 +558,17 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() {
 }
 
 fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
-        T: working_group::Trait<I> + frame_system::Trait + stake::Trait,
-        I: frame_support::traits::Instance,
-        SM: staking_handler::StakingHandler<T>
-> (working_group: WorkingGroup) where
-        <T as frame_system::Trait>::AccountId: From<[u8; 32]>,
-        <T as membership::Trait>::MemberId: From<u64>,
-        <T as membership::Trait>::ActorId: Into<u64>,
-        <<T as stake::Trait>::Currency as traits::Currency<
-            <T as frame_system::Trait>::AccountId,
-        >>::Balance: From<u128>,
-        <T as pallet_balances::Trait>::Balance: From<u128>,
-    {
+    T: working_group::Trait<I> + frame_system::Trait,
+    I: frame_support::traits::Instance,
+    SM: staking_handler::StakingHandler<T>,
+>(
+    working_group: WorkingGroup,
+) where
+    <T as frame_system::Trait>::AccountId: From<[u8; 32]>,
+    <T as membership::Trait>::MemberId: From<u64>,
+    <T as membership::Trait>::ActorId: Into<u64>,
+    <T as pallet_balances::Trait>::Balance: From<u128>,
+{
     initial_test_ext().execute_with(|| {
         let member_id: MemberId = 1;
         let account_id: [u8; 32] = [member_id as u8; 32];