-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip(kreivo-runtime): implement ranked collective for kreivo * change(kreivo-runtime): configure the kreivo collective and root governance
- Loading branch information
Showing
7 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use super::*; | ||
|
||
use pallet_communities::origin::AsSignedByCommunity; | ||
use parachains_common::kusama::currency::QUID; | ||
use sp_core::ConstU128; | ||
|
||
pub type KreivoTracksInstance = pallet_referenda_tracks::Instance1; | ||
pub type KreivoReferendaInstance = pallet_referenda::Instance1; | ||
|
||
parameter_types! { | ||
pub const AlarmInterval: BlockNumber = 1; | ||
pub const SubmissionDeposit: Balance = QUID; | ||
pub const UndecidingTimeout: BlockNumber = 14 * DAYS; | ||
} | ||
|
||
impl pallet_referenda::Config<KreivoReferendaInstance> for Runtime { | ||
type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>; | ||
type RuntimeCall = RuntimeCall; | ||
type RuntimeEvent = RuntimeEvent; | ||
type Scheduler = Scheduler; | ||
type Currency = Balances; | ||
// Communities can submit proposals. | ||
type SubmitOrigin = AsEnsureOriginWithArg<AsSignedByCommunity<Self>>; | ||
type CancelOrigin = EnsureRoot<AccountId>; | ||
type KillOrigin = EnsureRoot<AccountId>; | ||
type Slash = (); | ||
type Votes = pallet_ranked_collective::Votes; | ||
type Tally = pallet_ranked_collective::TallyOf<Runtime, KreivoCollectiveInstance>; | ||
type SubmissionDeposit = ConstU128<0>; | ||
type MaxQueued = ConstU32<10>; | ||
type UndecidingTimeout = ConstU32<{ 2 * DAYS }>; | ||
type AlarmInterval = ConstU32<1>; | ||
type Tracks = tracks::TracksInfo; | ||
type Preimages = Preimage; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use super::*; | ||
|
||
use frame_system::EnsureRootWithSuccess; | ||
use sp_core::ConstU16; | ||
|
||
pub mod governance; | ||
pub mod tracks; | ||
|
||
pub type KreivoCollectiveInstance = pallet_ranked_collective::Instance1; | ||
impl pallet_ranked_collective::Config<KreivoCollectiveInstance> for Runtime { | ||
type WeightInfo = pallet_ranked_collective::weights::SubstrateWeight<Self>; | ||
type RuntimeEvent = RuntimeEvent; | ||
|
||
// Initially, members of kreivo collective are promoted via governance action | ||
// In the future, it's expected to have an auxilliary pallet to observe the | ||
// criteria for ranking | ||
type PromoteOrigin = EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>; | ||
|
||
// Initially, members of kreivo collective are demoted via governance action | ||
// In the future, it's expected to have an auxilliary pallet to observe the | ||
// criteria for ranking | ||
type DemoteOrigin = EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>; | ||
|
||
type Polls = KreivoReferenda; | ||
type MinRankOfClass = (); | ||
type VoteWeight = pallet_ranked_collective::Linear; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use super::*; | ||
|
||
use pallet_referenda::{impl_tracksinfo_get, Track}; | ||
use sp_runtime::str_array as s; | ||
use sp_std::borrow::Cow; | ||
|
||
pub type TrackId = u16; | ||
|
||
pub struct TracksInfo; | ||
impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo { | ||
type Id = TrackId; | ||
type RuntimeOrigin = <RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin; | ||
type TracksIter = pallet_referenda::StaticTracksIter<Self::Id, Balance, BlockNumber>; | ||
|
||
fn tracks() -> Self::TracksIter { | ||
const DATA: [pallet_referenda::Track<TrackId, Balance, BlockNumber>; 1] = [Track { | ||
id: 0, | ||
info: pallet_referenda::TrackInfo { | ||
name: s("Root"), | ||
max_deciding: 1, | ||
decision_deposit: 0, | ||
prepare_period: 15 * MINUTES, | ||
decision_period: 4 * DAYS, | ||
confirm_period: 15 * MINUTES, | ||
min_enactment_period: 1, | ||
min_approval: pallet_referenda::Curve::LinearDecreasing { | ||
length: Perbill::from_percent(100), | ||
floor: Perbill::from_percent(90), | ||
ceil: Perbill::from_percent(100), | ||
}, | ||
min_support: pallet_referenda::Curve::LinearDecreasing { | ||
length: Perbill::from_percent(100), | ||
floor: Perbill::from_percent(0), | ||
ceil: Perbill::from_percent(100), | ||
}, | ||
}, | ||
}]; | ||
DATA.iter().map(Cow::Borrowed) | ||
} | ||
|
||
fn track_for(id: &Self::RuntimeOrigin) -> Result<Self::Id, ()> { | ||
if let Ok(system_origin) = frame_system::RawOrigin::try_from(id.clone()) { | ||
match system_origin { | ||
frame_system::RawOrigin::Root => Ok(0), | ||
_ => Err(()), | ||
} | ||
} else { | ||
Err(()) | ||
} | ||
} | ||
} | ||
impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters