Skip to content

Commit

Permalink
restor pallet_democracy
Browse files Browse the repository at this point in the history
  • Loading branch information
vgantchev committed Sep 18, 2024
1 parent f1bfc7c commit 9e4320e
Show file tree
Hide file tree
Showing 5 changed files with 595 additions and 12 deletions.
2 changes: 2 additions & 0 deletions runtime/basilisk/src/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ use sp_runtime::{traits::IdentityLookup, DispatchError};

pub mod origins;
mod tracks;
// Old governance pallet, remove once storage is safe to wipe (6mo voting lockup).
pub mod old;

pub type TechCommitteeMajority = EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 2>;

Expand Down
79 changes: 79 additions & 0 deletions runtime/basilisk/src/governance/old.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// This file is part of Basilisk-node.

// Copyright (C) 2020-2023 Intergalactic, Limited (GIB).
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::governance::TechnicalCollective;
use crate::*;

use primitives::constants::{
currency::DOLLARS,
time::{DAYS, HOURS},
};

use frame_support::parameter_types;
use frame_system::{EnsureRoot, EnsureSigned};

parameter_types! {
pub const LaunchPeriod: BlockNumber = 3 * DAYS;
pub const VotingPeriod: BlockNumber = 3 * DAYS;
pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS;
pub const MinimumDeposit: Balance = 1000 * DOLLARS;
pub const EnactmentPeriod: BlockNumber = 12 * HOURS;
// Make sure VoteLockingPeriod > EnactmentPeriod
pub const VoteLockingPeriod: BlockNumber = 6 * DAYS;
pub const CooloffPeriod: BlockNumber = 7 * DAYS;
pub const InstantAllowed: bool = true;
pub const MaxVotes: u32 = 100;
pub const MaxProposals: u32 = 100;
}

impl pallet_democracy::Config for Runtime {
type WeightInfo = weights::pallet_democracy::BasiliskWeight<Runtime>;
type RuntimeEvent = RuntimeEvent;
type Scheduler = Scheduler;
type Preimages = Preimage;
type Currency = Balances;
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type VoteLockingPeriod = VoteLockingPeriod;
type MinimumDeposit = MinimumDeposit;
type InstantAllowed = InstantAllowed;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
type CooloffPeriod = CooloffPeriod;
type MaxVotes = MaxVotes;
type MaxProposals = MaxProposals;
type MaxDeposits = ConstU32<100>;
type MaxBlacklisted = ConstU32<100>;
type ExternalOrigin = EnsureRoot<AccountId>;
type ExternalMajorityOrigin = EnsureRoot<AccountId>;
type ExternalDefaultOrigin = EnsureRoot<AccountId>;
/// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote
/// be tabled immediately and with a shorter voting/enactment period.
type FastTrackOrigin = EnsureRoot<AccountId>;
type InstantOrigin = EnsureRoot<AccountId>;
type CancellationOrigin = EnsureRoot<AccountId>;
type BlacklistOrigin = EnsureRoot<AccountId>;
// To cancel a proposal before it has been passed, the technical committee must be unanimous or
// Root must agree.
type CancelProposalOrigin = EnsureRoot<AccountId>;
// Any single technical committee member may veto a coming council proposal, however they can
// only do it once and it lasts only for the cooloff period.
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
type PalletsOrigin = OriginCaller;
type Slash = Treasury;
type SubmitOrigin = EnsureSigned<AccountId>;
}
14 changes: 2 additions & 12 deletions runtime/basilisk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ construct_runtime!(
Treasury: pallet_treasury = 4,
Utility: pallet_utility = 5,
//NOTE: 6 - is used by Scheduler which must be after cumulus_pallet_parachain_system
Democracy: pallet_democracy exclude_parts { Config } = 7,
TechnicalCommittee: pallet_collective::<Instance2> = 10,
Vesting: orml_vesting = 11,
Proxy: pallet_proxy = 12,
Expand Down Expand Up @@ -273,7 +274,6 @@ pub mod migrations {
use frame_system::pallet_prelude::BlockNumberFor;

parameter_types! {
pub const DemocracyPalletName: &'static str = "Democracy";
pub const CouncilPalletName: &'static str = "Council";
// pub const TechnicalCommitteePalletName: &'static str = "TechnicalCommittee";
pub const PhragmenElectionPalletName: &'static str = "PhragmenElection";
Expand All @@ -287,15 +287,6 @@ pub mod migrations {
// Special Config for Gov V1 pallets, allowing us to run migrations for them without
// implementing their configs on [`Runtime`].
pub struct UnlockConfig;
impl pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockConfig for UnlockConfig {
type Currency = Balances;
type MaxVotes = ConstU32<100>;
type MaxDeposits = ConstU32<100>;
type AccountId = AccountId;
type BlockNumber = BlockNumberFor<Runtime>;
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
type PalletName = DemocracyPalletName;
}
impl pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockConfig
for UnlockConfig
{
Expand Down Expand Up @@ -323,11 +314,9 @@ pub mod migrations {
// Unlock/unreserve balances from Gov v1 pallets that hold them
// https://github.com/paritytech/polkadot/issues/6749
pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<UnlockConfig, ()>,

// Delete storage key/values from all Gov v1 pallets
frame_support::migrations::RemovePallet<DemocracyPalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<CouncilPalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<PhragmenElectionPalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<TipsPalletName, <Runtime as frame_system::Config>::DbWeight>,
Expand All @@ -349,6 +338,7 @@ mod benches {
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_timestamp, Timestamp]
[pallet_democracy, Democracy]
[pallet_treasury, Treasury]
[pallet_scheduler, Scheduler]
[pallet_utility, Utility]
Expand Down
1 change: 1 addition & 0 deletions runtime/basilisk/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod pallet_collator_selection;
pub mod pallet_collective;
pub mod pallet_conviction_voting;
pub mod pallet_currencies;
pub mod pallet_democracy;
pub mod pallet_duster;
pub mod pallet_ema_oracle;
pub mod pallet_identity;
Expand Down
Loading

0 comments on commit 9e4320e

Please sign in to comment.