Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Runtime: Polkadot Fellowship promotion/demotion periods, members activity and salaries #2607

Merged
merged 32 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
13bb75e
core fellowship
muharem May 19, 2023
de643ea
core fellowship weights
muharem May 19, 2023
16b0815
salary
muharem May 20, 2023
102fdcf
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
muharem May 20, 2023
c4a7425
weights
muharem May 20, 2023
ffbb342
fellowship pot
muharem May 20, 2023
ad45934
registration period 15 days
muharem May 22, 2023
bc05ae6
use treasury account for salary pay, promotion origin
muharem May 25, 2023
e3d744a
decision period for tracks 30 days
muharem May 25, 2023
2c556af
docs
muharem May 25, 2023
fa1d47f
comment
muharem May 25, 2023
9787bc1
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
gavofyork May 29, 2023
5092d3c
Couple of fixes and some refactoring
gavofyork Jun 1, 2023
c7f3292
Alter curves to be a bit more conservative
gavofyork Jun 1, 2023
7c245b3
Use `PayOverXcm` for fellowship salary payments
gavofyork Jun 1, 2023
320b12c
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
gavofyork Jun 1, 2023
842bc9d
Docs and remove unneeded code
gavofyork Jun 1, 2023
f3ede4c
Fixes
gavofyork Jun 1, 2023
be0a235
Move Fellowship stuff in line with whitepaper
gavofyork Jun 2, 2023
3b58f19
fix: induction by a single Fellow (not proficient)
muharem Jun 2, 2023
2a882f9
doc fix
muharem Jun 2, 2023
9cc708b
renames, pallet index, allow unpaid for salary pallet
muharem Jun 4, 2023
b37bbe4
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
gavofyork Jun 5, 2023
44ffd21
Fix budget units
gavofyork Jun 5, 2023
f53b4a4
Fixes
gavofyork Jun 5, 2023
d83fd85
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
gavofyork Jun 5, 2023
459977b
Test sovereign account for Fellowship salaries
gavofyork Jun 5, 2023
1c9b566
Nice address test
gavofyork Jun 5, 2023
7b9cf0f
Fixes
gavofyork Jun 5, 2023
caaa989
test for PayOverXcm setup
muharem Jun 5, 2023
af2d1f2
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
muharem Jun 5, 2023
cf929c3
Update parachains/runtimes/collectives/collectives-polkadot/src/fello…
gavofyork Jun 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
420 changes: 229 additions & 191 deletions Cargo.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/parityt
pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-referenda = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-ranked-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-core-fellowship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-salary = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down Expand Up @@ -103,6 +105,8 @@ runtime-benchmarks = [
"pallet-preimage/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-ranked-collective/runtime-benchmarks",
"pallet-core-fellowship/runtime-benchmarks",
"pallet-salary/runtime-benchmarks",
]
try-runtime = [
"cumulus-pallet-aura-ext/try-runtime",
Expand Down Expand Up @@ -131,6 +135,8 @@ try-runtime = [
"pallet-preimage/try-runtime",
"pallet-referenda/try-runtime",
"pallet-ranked-collective/try-runtime",
"pallet-core-fellowship/try-runtime",
"pallet-salary/try-runtime",
]
std = [
"codec/std",
Expand Down Expand Up @@ -187,4 +193,6 @@ std = [
"pallet-referenda/std",
"pallet-ranked-collective/std",
"substrate-wasm-builder",
"pallet-core-fellowship/std",
"pallet-salary/std",
]
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
pub mod account {
use frame_support::PalletId;

/// Relay Chain treasury pallet id, used to convert into AccountId
pub const RELAY_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
/// Polkadot treasury pallet id, used to convert into AccountId
pub const POLKADOT_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
/// Alliance pallet ID.
/// It is used as a temporarily place to deposit a slashed imbalance
/// before the teleport to the Treasury.
Expand All @@ -26,6 +26,9 @@ pub mod account {
/// It is used as a temporarily place to deposit a slashed imbalance
/// before the teleport to the Treasury.
pub const REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/refer");
/// The Polkadot Fellowship pallet ID
/// The identifier determines an account address of the collective.
pub const FELLOWSHIP_PALLET_ID: PalletId = PalletId(*b"py/fella");
muharem marked this conversation as resolved.
Show resolved Hide resolved
}

pub mod currency {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@
pub(crate) mod migration;
mod origins;
mod tracks;
use frame_system::EnsureNever;
pub use origins::{
pallet_origins as pallet_fellowship_origins, Fellows, FellowshipCandidates, FellowshipExperts,
FellowshipMasters,
};

use crate::{
constants, impls::ToParentTreasury, weights, AccountId, Balance, Balances, BlockNumber,
FellowshipReferenda, GovernanceLocation, Preimage, RelayTreasuryAccount, Runtime, RuntimeCall,
RuntimeEvent, Scheduler, DAYS,
FellowshipReferenda, GovernanceLocation, PolkadotTreasuryAccount, Preimage, Runtime,
RuntimeCall, RuntimeEvent, Scheduler, DAYS,
};
use frame_support::{
parameter_types,
traits::{EitherOf, MapSuccess, TryMapSuccess},
traits::{tokens::PayFromAccount, EitherOf, MapSuccess, TryMapSuccess},
};
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use polkadot_runtime_constants::xcm::body::FELLOWSHIP_ADMIN_INDEX;
use polkadot_runtime_constants::{currency::UNITS, xcm::body::FELLOWSHIP_ADMIN_INDEX};
use sp_arithmetic::traits::CheckedSub;
use sp_core::ConstU32;
use sp_runtime::{
Expand Down Expand Up @@ -84,7 +85,7 @@ impl pallet_referenda::Config<FellowshipReferendaInstance> for Runtime {
pallet_ranked_collective::EnsureMember<Runtime, FellowshipCollectiveInstance, 1>;
type CancelOrigin = FellowshipExperts;
type KillOrigin = FellowshipMasters;
type Slash = ToParentTreasury<RelayTreasuryAccount, ReferendaPalletAccount, Runtime>;
type Slash = ToParentTreasury<PolkadotTreasuryAccount, ReferendaPalletAccount, Runtime>;
type Votes = pallet_ranked_collective::Votes;
type Tally = pallet_ranked_collective::TallyOf<Runtime, FellowshipCollectiveInstance>;
type SubmissionDeposit = SubmissionDeposit;
Expand All @@ -108,35 +109,93 @@ morph_types! {
impl pallet_ranked_collective::Config<FellowshipCollectiveInstance> for Runtime {
type WeightInfo = weights::pallet_ranked_collective::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
// Promotion is by any of:
// - Root can promote arbitrarily.
// Promotions and the induction of new members are serviced by `FellowshipCore` pallet instance.
type PromoteOrigin = EnsureNever<pallet_ranked_collective::Rank>;
// Demotion is by any of:
// - Root can demote arbitrarily.
// - the FellowshipAdmin origin (i.e. token holder referendum);
// - a vote by the rank *above* the new rank.
type PromoteOrigin = EitherOf<
// - a vote by the rank two above the current rank.
muharem marked this conversation as resolved.
Show resolved Hide resolved
type DemoteOrigin = EitherOf<
frame_system::EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
EitherOf<
MapSuccess<
EnsureXcm<IsVoiceOfBody<GovernanceLocation, FellowshipAdminBodyId>>,
Replace<ConstU16<9>>,
>,
TryMapSuccess<EnsureFellowship, CheckedReduceBy<ConstU16<1>>>,
TryMapSuccess<EnsureFellowship, CheckedReduceBy<ConstU16<2>>>,
>,
>;
// Demotion is by any of:
// - Root can demote arbitrarily.
type Polls = FellowshipReferenda;
type MinRankOfClass = sp_runtime::traits::Identity;
type VoteWeight = pallet_ranked_collective::Geometric;
}

pub type FellowshipCoreInstance = pallet_core_fellowship::Instance1;
ggwpez marked this conversation as resolved.
Show resolved Hide resolved

impl pallet_core_fellowship::Config<FellowshipCoreInstance> for Runtime {
type WeightInfo = weights::pallet_core_fellowship::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type Members = pallet_ranked_collective::Pallet<Runtime, FellowshipCollectiveInstance>;
type Balance = Balance;
// Parameters are set by any of:
// - Root;
// - a vote of the rank 3 or above.
type ParamsOrigin = Fellows;
// Induction is by any of:
// - Root;
// - a member of the rank 1 or above.
type InductOrigin = EnsureFellowship;
// Approval of a member's current rank is by any of:
// - Root;
// - the FellowshipAdmin origin (i.e. token holder referendum);
// - a vote by the rank two above the current rank.
type DemoteOrigin = EitherOf<
// - a vote by the rank above or equal to the current rank.
type ApproveOrigin = EitherOf<
MapSuccess<
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
EnsureXcm<IsVoiceOfBody<GovernanceLocation, FellowshipAdminBodyId>>,
Replace<ConstU16<9>>,
>,
EnsureFellowship,
>;
// Promotion is by any of:
// - Root can promote arbitrarily.
// - the FellowshipAdmin origin (i.e. token holder referendum);
// - a vote by the rank *above* the new rank.
type PromoteOrigin = EitherOf<
frame_system::EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
EitherOf<
MapSuccess<
EnsureXcm<IsVoiceOfBody<GovernanceLocation, FellowshipAdminBodyId>>,
Replace<ConstU16<9>>,
>,
TryMapSuccess<EnsureFellowship, CheckedReduceBy<ConstU16<2>>>,
TryMapSuccess<EnsureFellowship, CheckedReduceBy<ConstU16<1>>>,
>,
>;
type Polls = FellowshipReferenda;
type MinRankOfClass = sp_runtime::traits::Identity;
type VoteWeight = pallet_ranked_collective::Geometric;
type EvidenceSize = ConstU32<1024>;
}

parameter_types! {
pub FellowshipAccount: AccountId = constants::account::FELLOWSHIP_PALLET_ID.into_account_truncating();
pub const RegistrationPeriod: BlockNumber = 75 * DAYS;
pub const PayoutPeriod: BlockNumber = 15 * DAYS;
/// A total budget of a single payout cycle.
/// The cycle duration is a sum of `RegistrationPeriod` and `PayoutPeriod`.
pub const Budget: Balance = 100000 * UNITS;
muharem marked this conversation as resolved.
Show resolved Hide resolved
}

gavofyork marked this conversation as resolved.
Show resolved Hide resolved
pub type FellowshipSalaryInstance = pallet_salary::Instance1;

impl pallet_salary::Config<FellowshipSalaryInstance> for Runtime {
type WeightInfo = weights::pallet_salary::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type Paymaster = PayFromAccount<Balances, FellowshipAccount>;
type Members = pallet_ranked_collective::Pallet<Runtime, FellowshipCollectiveInstance>;
#[cfg(not(feature = "runtime-benchmarks"))]
type Salary = pallet_core_fellowship::Pallet<Runtime, FellowshipCoreInstance>;
#[cfg(feature = "runtime-benchmarks")]
type Salary = frame_support::traits::tokens::ConvertRank<
crate::impls::benchmarks::RankToSalary<Balances>,
>;
type RegistrationPeriod = RegistrationPeriod;
type PayoutPeriod = PayoutPeriod;
type Budget = Budget;
}
20 changes: 20 additions & 0 deletions parachains/runtimes/collectives/collectives-polkadot/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,23 @@ impl PrivilegeCmp<OriginCaller> for EqualOrGreatestRootCmp {
}
}
}

#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarks {
use super::*;
use frame_support::traits::fungible;
use pallet_ranked_collective::Rank;
use parachains_common::{AccountId, Balance};
use sp_runtime::traits::Convert;

/// Rank to salary conversion helper type.`
pub struct RankToSalary<Fungible>(PhantomData<Fungible>);
impl<Fungible> Convert<Rank, Balance> for RankToSalary<Fungible>
where
Fungible: fungible::Inspect<AccountId, Balance = Balance>,
{
fn convert(r: Rank) -> Balance {
Balance::from(r).saturating_mul(Fungible::minimum_balance())
}
}
}
10 changes: 8 additions & 2 deletions parachains/runtimes/collectives/collectives-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ parameter_types! {
// The Alliance pallet account, used as a temporary place to deposit a slashed imbalance
// before the teleport to the Treasury.
pub AlliancePalletAccount: AccountId = constants::account::ALLIANCE_PALLET_ID.into_account_truncating();
pub RelayTreasuryAccount: AccountId = constants::account::RELAY_TREASURY_PALLET_ID.into_account_truncating();
pub PolkadotTreasuryAccount: AccountId = constants::account::POLKADOT_TREASURY_PALLET_ID.into_account_truncating();
// The number of blocks a member must wait between giving a retirement notice and retiring.
// Supposed to be greater than time required to `kick_member` with alliance motion.
pub const AllianceRetirementPeriod: BlockNumber = (90 * DAYS) + ALLIANCE_MOTION_DURATION;
Expand All @@ -490,7 +490,7 @@ impl pallet_alliance::Config for Runtime {
type MembershipManager = RootOrAllianceTwoThirdsMajority;
type AnnouncementOrigin = RootOrAllianceTwoThirdsMajority;
type Currency = Balances;
type Slashed = ToParentTreasury<RelayTreasuryAccount, AlliancePalletAccount, Runtime>;
type Slashed = ToParentTreasury<PolkadotTreasuryAccount, AlliancePalletAccount, Runtime>;
type InitializeMembers = AllianceMotion;
type MembershipChanged = AllianceMotion;
type RetirementPeriod = AllianceRetirementPeriod;
Expand Down Expand Up @@ -599,6 +599,10 @@ construct_runtime!(
// pub type FellowshipReferendaInstance = pallet_referenda::Instance1;
FellowshipReferenda: pallet_referenda::<Instance1>::{Pallet, Call, Storage, Event<T>} = 61,
FellowshipOrigins: pallet_fellowship_origins::{Origin} = 62,
// pub type FellowshipCoreInstance = pallet_core_fellowship::Instance1;
FellowshipCore: pallet_core_fellowship::<Instance1>::{Pallet, Call, Storage, Event<T>} = 63,
// pub type FellowshipSalaryInstance = pallet_salary::Instance1;
FellowshipSalary: pallet_salary::<Instance1>::{Pallet, Call, Storage, Event<T>} = 64,
}
);

Expand Down Expand Up @@ -662,6 +666,8 @@ mod benches {
[pallet_scheduler, Scheduler]
[pallet_referenda, FellowshipReferenda]
[pallet_ranked_collective, FellowshipCollective]
[pallet_core_fellowship, FellowshipCore]
[pallet_salary, FellowshipSalary]
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ pub mod pallet_alliance;
pub mod pallet_balances;
pub mod pallet_collator_selection;
pub mod pallet_collective;
pub mod pallet_core_fellowship;
pub mod pallet_multisig;
pub mod pallet_preimage;
pub mod pallet_proxy;
pub mod pallet_ranked_collective;
pub mod pallet_referenda;
pub mod pallet_salary;
pub mod pallet_scheduler;
pub mod pallet_session;
pub mod pallet_timestamp;
Expand Down
Loading