ソースを参照

runtime: council: update name

conectado 4 年 前
コミット
3ed8f90a42

+ 4 - 4
node/src/chain_spec/council_config.rs

@@ -1,9 +1,9 @@
-use node_runtime::pallet_council::{CouncilStageUpdate, Trait as CouncilTrait};
+use node_runtime::council::{CouncilStageUpdate, Trait as CouncilTrait};
 use node_runtime::referendum::ReferendumStage;
-use node_runtime::{NewCouncilConfig, ReferendumConfig, Runtime};
+use node_runtime::{CouncilConfig, ReferendumConfig, Runtime};
 
-pub fn create_council_config() -> NewCouncilConfig {
-    NewCouncilConfig {
+pub fn create_council_config() -> CouncilConfig {
+    CouncilConfig {
         stage: CouncilStageUpdate::default(),
         council_members: vec![],
         candidates: vec![],

+ 1 - 1
node/src/chain_spec/mod.rs

@@ -265,7 +265,7 @@ pub fn testnet_genesis(
                 .collect::<Vec<_>>(),
         }),
         referendum_Instance1: Some(council_config::create_referendum_config()),
-        pallet_council: Some(council_config::create_council_config()),
+        council: Some(council_config::create_council_config()),
         membership: Some(MembersConfig { members }),
         forum: Some(forum_config),
         data_object_type_registry: Some(DataObjectTypeRegistryConfig {

+ 2 - 4
runtime/Cargo.toml

@@ -66,9 +66,8 @@ 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'}
-#governance = { package = 'pallet-governance', default-features = false, path = '../runtime-modules/governance'}
 referendum = { package = 'pallet-referendum', default-features = false, path = '../runtime-modules/referendum'}
-pallet_council = { package = 'pallet-council', default-features = false, path = '../runtime-modules/council'}
+council = { package = 'pallet-council', default-features = false, path = '../runtime-modules/council'}
 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'}
 working-group = { package = 'pallet-working-group', default-features = false, path = '../runtime-modules/working-group'}
@@ -142,8 +141,7 @@ std = [
     'memo/std',
     'forum/std',
     'membership/std',
-    #'governance/std',
-    'pallet_council/std',
+    'council/std',
     'referendum/std',
     'minting/std',
     'recurring-rewards/std',

+ 4 - 4
runtime/src/integration/proposals/council_origin_validator.rs

@@ -15,7 +15,7 @@ pub struct CouncilManager<T> {
     marker: PhantomData<T>,
 }
 
-impl<T: pallet_council::Trait + membership::Trait>
+impl<T: council::Trait + membership::Trait>
     ActorOriginValidator<
         <T as frame_system::Trait>::Origin,
         MemberId<T>,
@@ -30,7 +30,7 @@ impl<T: pallet_council::Trait + membership::Trait>
     ) -> Result<<T as frame_system::Trait>::AccountId, &'static str> {
         let account_id = <MembershipOriginValidator<T>>::ensure_actor_origin(origin, actor_id)?;
 
-        if pallet_council::Module::<T>::council_members()
+        if council::Module::<T>::council_members()
             .iter()
             .any(|council_member| council_member.member_id() == &actor_id)
         {
@@ -41,10 +41,10 @@ impl<T: pallet_council::Trait + membership::Trait>
     }
 }
 
-impl<T: pallet_council::Trait> VotersParameters for CouncilManager<T> {
+impl<T: council::Trait> VotersParameters for CouncilManager<T> {
     /// Implement total_voters_count() as council size
     fn total_voters_count() -> u32 {
-        pallet_council::Module::<T>::council_members()
+        council::Module::<T>::council_members()
             .len()
             .saturated_into()
     }

+ 2 - 2
runtime/src/integration/proposals/proposal_encoder.rs

@@ -36,10 +36,10 @@ impl ProposalEncoder<Runtime> for ExtrinsicProposalEncoder {
             ProposalDetails::Text(text) => {
                 Call::ProposalsCodex(proposals_codex::Call::execute_text_proposal(text))
             }
-            ProposalDetails::Spending(_balance, _destination) => Call::NewCouncil(
+            ProposalDetails::Spending(_balance, _destination) => Call::Council(
                 // TODO: This is an stub since this has been modified in
                 // the proposal branch
-                pallet_council::Call::set_budget(0),
+                council::Call::set_budget(0),
             ),
             ProposalDetails::SetValidatorCount(new_validator_count) => Call::Staking(
                 pallet_staking::Call::set_validator_count(new_validator_count),

+ 6 - 20
runtime/src/lib.rs

@@ -54,7 +54,7 @@ pub use runtime_api::*;
 
 use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator};
 
-use pallet_council::ReferendumConnection;
+use council::ReferendumConnection;
 use referendum::{Balance as BalanceReferendum, CastVote, OptionResult};
 use staking_handler::{LockComparator, StakingManager};
 use storage::data_object_storage_registry;
@@ -65,11 +65,11 @@ pub use content_directory;
 pub use content_directory::{
     HashedTextMaxLength, InputValidationLengthConstraint, MaxNumber, TextMaxLength, VecMaxLength,
 };
+pub use council;
 pub use forum;
 pub use membership;
 #[cfg(any(feature = "std", test))]
 pub use pallet_balances::Call as BalancesCall;
-pub use pallet_council;
 pub use pallet_staking::StakerStatus;
 pub use proposals_engine::ProposalParameters;
 pub use referendum;
@@ -470,7 +470,7 @@ impl common::currency::GovernanceCurrency for Runtime {
 // The referendum instance alias.
 pub type ReferendumInstance = referendum::Instance1;
 pub type ReferendumModule = referendum::Module<Runtime, ReferendumInstance>;
-pub type CouncilModule = pallet_council::Module<Runtime>;
+pub type CouncilModule = council::Module<Runtime>;
 
 parameter_types! {
     // referendum parameters
@@ -548,7 +548,7 @@ impl referendum::Trait<ReferendumInstance> for Runtime {
     }
 }
 
-impl pallet_council::Trait for Runtime {
+impl council::Trait for Runtime {
     type Event = Event;
 
     type Referendum = ReferendumModule;
@@ -576,24 +576,12 @@ impl pallet_council::Trait for Runtime {
         true
     }
 
-    fn new_council_elected(_elected_members: &[pallet_council::CouncilMemberOf<Self>]) {
+    fn new_council_elected(_elected_members: &[council::CouncilMemberOf<Self>]) {
         <proposals_engine::Module<Runtime>>::reject_active_proposals();
         <proposals_engine::Module<Runtime>>::reactivate_pending_constitutionality_proposals();
     }
 }
 
-/*
-impl governance::election::Trait for Runtime {
-    type Event = Event;
-    type CouncilElected = (Council, integration::proposals::CouncilElectedHandler);
-}
-
-impl governance::council::Trait for Runtime {
-    type Event = Event;
-    type CouncilTermEnded = (CouncilElection,);
-}
-*/
-
 impl memo::Trait for Runtime {
     type Event = Event;
 }
@@ -925,9 +913,7 @@ construct_runtime!(
         RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
         Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
         // Joystream
-        //CouncilElection: election::{Module, Call, Storage, Event<T>, Config<T>},
-        //Council: council::{Module, Call, Storage, Event<T>, Config<T>},
-        NewCouncil: pallet_council::{Module, Call, Storage, Event<T>, Config<T>},
+        Council: council::{Module, Call, Storage, Event<T>, Config<T>},
         Referendum: referendum::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
         Memo: memo::{Module, Call, Storage, Event<T>},
         Members: membership::{Module, Call, Storage, Event<T>, Config<T>},

+ 7 - 10
runtime/src/tests/mod.rs

@@ -16,7 +16,7 @@ use sp_std::convert::TryInto;
 type Membership = membership::Module<Runtime>;
 type System = frame_system::Module<Runtime>;
 type ProposalsEngine = proposals_engine::Module<Runtime>;
-type Council = pallet_council::Module<Runtime>;
+type Council = council::Module<Runtime>;
 type Referendum = referendum::Module<Runtime, ReferendumInstance>;
 
 pub(crate) fn initial_test_ext() -> sp_io::TestExternalities {
@@ -25,7 +25,7 @@ pub(crate) fn initial_test_ext() -> sp_io::TestExternalities {
         .unwrap();
 
     // build the council config to initialize the mint
-    let council_config = pallet_council::GenesisConfig::<crate::Runtime>::default()
+    let council_config = council::GenesisConfig::<crate::Runtime>::default()
         .build_storage()
         .unwrap();
 
@@ -37,7 +37,7 @@ pub(crate) fn initial_test_ext() -> sp_io::TestExternalities {
 pub(crate) fn elect_council(council: Vec<AccountId32>, cycle_id: u64) {
     let mut voters = Vec::<AccountId32>::new();
 
-    let councilor_stake: u128 = <Runtime as pallet_council::Trait>::MinCandidateStake::get().into();
+    let councilor_stake: u128 = <Runtime as council::Trait>::MinCandidateStake::get().into();
 
     for (i, councilor) in council.iter().enumerate() {
         increase_total_balance_issuance_using_account_id(
@@ -55,8 +55,7 @@ pub(crate) fn elect_council(council: Vec<AccountId32>, cycle_id: u64) {
         voters.push([10u8.saturating_add(i.try_into().unwrap()); 32].into()); // TODO: change me
     }
 
-    let extra_candidates =
-        <Runtime as pallet_council::Trait>::MinNumberOfExtraCandidates::get() + 1;
+    let extra_candidates = <Runtime as council::Trait>::MinNumberOfExtraCandidates::get() + 1;
     for i in council.len()..(council.len() + extra_candidates as usize) {
         let extra_councilor: AccountId32 = [i as u8; 32].into();
 
@@ -64,7 +63,7 @@ pub(crate) fn elect_council(council: Vec<AccountId32>, cycle_id: u64) {
             RawOrigin::Signed(extra_councilor.clone()).into(),
             i.try_into().unwrap(),
         )
-        .unwrap_or_else(|err| assert_eq!(err, pallet_council::Error::NoStake));
+        .unwrap_or_else(|err| assert_eq!(err, council::Error::NoStake));
         increase_total_balance_issuance_using_account_id(
             extra_councilor.clone().into(),
             councilor_stake + 1,
@@ -81,9 +80,7 @@ pub(crate) fn elect_council(council: Vec<AccountId32>, cycle_id: u64) {
     }
 
     let current_block = System::block_number();
-    run_to_block(
-        current_block + <Runtime as pallet_council::Trait>::AnnouncingPeriodDuration::get(),
-    );
+    run_to_block(current_block + <Runtime as council::Trait>::AnnouncingPeriodDuration::get());
 
     let voter_stake: u128 =
         <Runtime as referendum::Trait<ReferendumInstance>>::MinimumStake::get().into();
@@ -124,7 +121,7 @@ pub(crate) fn elect_council(council: Vec<AccountId32>, cycle_id: u64) {
             + <Runtime as referendum::Trait<ReferendumInstance>>::RevealStageDuration::get(),
     );
 
-    let council_members = pallet_council::Module::<Runtime>::council_members();
+    let council_members = council::Module::<Runtime>::council_members();
     assert_eq!(
         council_members
             .iter()

+ 1 - 1
runtime/src/tests/proposals_integration/mod.rs

@@ -374,7 +374,7 @@ fn proposal_reset_succeeds() {
 // Preconditions: currently in idle period, idle period started in currnet block
 fn end_idle_period() {
     let current_block = System::block_number();
-    let idle_period_duration = <Runtime as pallet_council::Trait>::IdlePeriodDuration::get();
+    let idle_period_duration = <Runtime as council::Trait>::IdlePeriodDuration::get();
     run_to_block(current_block + idle_period_duration);
 }