Skip to content

Commit

Permalink
Allow RawOrigin::Root to fast-track supermajority proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Sep 2, 2024
1 parent a31722d commit 23607c1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions substrate/frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl<AccountId: Encode + Decode> DepositPaybackTarget<AccountId> {
pub mod pallet {
use super::{DispatchResult, *};
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use frame_system::{pallet_prelude::*, RawOrigin};

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]

Check warning on line 421 in substrate/frame/democracy/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite

trait `Store` is never used
Expand Down Expand Up @@ -1071,6 +1071,11 @@ pub mod pallet {
voting_period: T::BlockNumber,
delay: T::BlockNumber,
) -> DispatchResult {
let (is_root, origin) = match origin.into() {
Ok(RawOrigin::Root) => (true, RawOrigin::Root.into()),
Ok(other) => (false, other.into()),
Err(origin) => (false, origin),
};
// Rather complicated bit of code to ensure that either:
// - `voting_period` is at least `FastTrackVotingPeriod` and `origin` is
// `FastTrackOrigin`; or
Expand All @@ -1093,7 +1098,7 @@ pub mod pallet {
let (e_proposal_hash, threshold) =
<NextExternal<T>>::get().ok_or(Error::<T>::ProposalMissing)?;
ensure!(
threshold != VoteThreshold::SuperMajorityApprove,
is_root || threshold != VoteThreshold::SuperMajorityApprove,
Error::<T>::NotSimpleMajority,
);
ensure!(proposal_hash == e_proposal_hash, Error::<T>::InvalidHash);
Expand Down

0 comments on commit 23607c1

Please sign in to comment.