Add collectives-westend and glutton-westend runtimes (#2024)

Add collectives and glutton parachain westend runtimes to prepare for
#1737.

The removal of system parachain native runtimes #1737 is blocked until
chainspecs and runtime APIs can be dealt with cleanly (merge of #1256
and follow up PRs).

In the meantime, these additions are ready to be merged to `master`, so
I have separated them out into this PR.

Also marked `bridge-hub-westend` as unimplemented in line with [this
issue](https://github.com/paritytech/parity-bridges-common/issues/2602).

TODO
- [x] add to `command-bot` benchmarks
- [x] add to `command-bot-scripts` benchmarks
- [x] generate weights

---------

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: Muharem <ismailov.m.h@gmail.com>
Co-authored-by: command-bot <>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Branislav Kontur <bkontur@gmail.com>
This commit is contained in:
Dónal Murray
2023-11-15 15:01:55 +00:00
committed by GitHub
parent c79b234b3b
commit 0226b55f9f
68 changed files with 11792 additions and 7 deletions
@@ -0,0 +1,262 @@
// Copyright (C) 2022 Parity Technologies (UK) Ltd.
// 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.
//! The Ambassador Program.
//!
//! The module defines the following on-chain functionality of the Ambassador Program:
//!
//! - Managed set of program members, where every member has a [rank](ranks)
//! (via [AmbassadorCollective](pallet_ranked_collective)).
//! - Referendum functionality for the program members to propose, vote on, and execute
//! proposals on behalf of the members of a certain [rank](Origin)
//! (via [AmbassadorReferenda](pallet_referenda)).
//! - Managed content (charter, announcements) (via [pallet_collective_content]).
//! - Promotion and demotion periods, register of members' activity, and rank based salaries
//! (via [AmbassadorCore](pallet_core_fellowship)).
//! - Members' salaries (via [AmbassadorSalary](pallet_salary), requiring a member to be
//! imported or inducted into [AmbassadorCore](pallet_core_fellowship)).
pub mod origins;
mod tracks;
use super::*;
use crate::xcm_config::{FellowshipAdminBodyId, WndAssetHub};
use frame_support::traits::{EitherOf, MapSuccess, TryMapSuccess};
pub use origins::pallet_origins as pallet_ambassador_origins;
use origins::pallet_origins::{
EnsureAmbassadorsVoice, EnsureAmbassadorsVoiceFrom, EnsureHeadAmbassadorsVoice, Origin,
};
use parachains_common::polkadot::account;
use sp_core::ConstU128;
use sp_runtime::traits::{CheckedReduceBy, ConstU16, ConvertToValue, Replace};
use xcm::prelude::*;
use xcm_builder::{AliasesIntoAccountId32, PayOverXcm};
/// The Ambassador Program's member ranks.
pub mod ranks {
use pallet_ranked_collective::Rank;
#[allow(dead_code)]
pub const CANDIDATE: Rank = 0;
pub const AMBASSADOR_TIER_1: Rank = 1;
pub const AMBASSADOR_TIER_2: Rank = 2;
pub const SENIOR_AMBASSADOR_TIER_3: Rank = 3;
pub const SENIOR_AMBASSADOR_TIER_4: Rank = 4;
pub const HEAD_AMBASSADOR_TIER_5: Rank = 5;
pub const HEAD_AMBASSADOR_TIER_6: Rank = 6;
pub const HEAD_AMBASSADOR_TIER_7: Rank = 7;
pub const MASTER_AMBASSADOR_TIER_8: Rank = 8;
pub const MASTER_AMBASSADOR_TIER_9: Rank = 9;
}
impl pallet_ambassador_origins::Config for Runtime {}
pub type AmbassadorCollectiveInstance = pallet_ranked_collective::Instance2;
/// Demotion is by any of:
/// - Root can demote arbitrarily.
/// - the FellowshipAdmin origin (i.e. token holder referendum);
/// - a senior members vote by the rank two above the current rank.
pub type DemoteOrigin = EitherOf<
frame_system::EnsureRootWithSuccess<AccountId, ConstU16<65535>>,
EitherOf<
MapSuccess<
EnsureXcm<IsVoiceOfBody<GovernanceLocation, FellowshipAdminBodyId>>,
Replace<ConstU16<{ ranks::MASTER_AMBASSADOR_TIER_9 }>>,
>,
TryMapSuccess<
EnsureAmbassadorsVoiceFrom<ConstU16<{ ranks::SENIOR_AMBASSADOR_TIER_3 }>>,
CheckedReduceBy<ConstU16<2>>,
>,
>,
>;
/// Promotion and approval (rank-retention) is by any of:
/// - Root can promote arbitrarily.
/// - the FellowshipAdmin origin (i.e. token holder referendum);
/// - a senior members vote by the rank two above the new/current rank.
/// - a member of rank `5` or above can add a candidate (rank `0`).
pub type PromoteOrigin = EitherOf<
DemoteOrigin,
TryMapSuccess<
pallet_ranked_collective::EnsureMember<
Runtime,
AmbassadorCollectiveInstance,
{ ranks::HEAD_AMBASSADOR_TIER_5 },
>,
Replace<ConstU16<0>>,
>,
>;
impl pallet_ranked_collective::Config<AmbassadorCollectiveInstance> for Runtime {
type WeightInfo = weights::pallet_ranked_collective_ambassador_collective::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type PromoteOrigin = PromoteOrigin;
type DemoteOrigin = DemoteOrigin;
type Polls = AmbassadorReferenda;
type MinRankOfClass = sp_runtime::traits::Identity;
type VoteWeight = pallet_ranked_collective::Linear;
}
parameter_types! {
pub const AlarmInterval: BlockNumber = 1;
pub const SubmissionDeposit: Balance = 0;
pub const UndecidingTimeout: BlockNumber = 7 * DAYS;
// The Ambassador Referenda pallet account, used as a temporary place to deposit a slashed
// imbalance before teleport to the treasury.
pub AmbassadorPalletAccount: AccountId = account::AMBASSADOR_REFERENDA_PALLET_ID.into_account_truncating();
}
pub type AmbassadorReferendaInstance = pallet_referenda::Instance2;
impl pallet_referenda::Config<AmbassadorReferendaInstance> for Runtime {
type WeightInfo = weights::pallet_referenda_ambassador_referenda::WeightInfo<Runtime>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type Scheduler = Scheduler;
type Currency = Balances;
// A proposal can be submitted by a member of the Ambassador Program of
// [ranks::SENIOR_AMBASSADOR_TIER_3] rank or higher.
type SubmitOrigin = pallet_ranked_collective::EnsureMember<
Runtime,
AmbassadorCollectiveInstance,
{ ranks::SENIOR_AMBASSADOR_TIER_3 },
>;
type CancelOrigin = EitherOf<EnsureRoot<AccountId>, EnsureHeadAmbassadorsVoice>;
type KillOrigin = EitherOf<EnsureRoot<AccountId>, EnsureHeadAmbassadorsVoice>;
type Slash = ToParentTreasury<WestendTreasuryAccount, AmbassadorPalletAccount, Runtime>;
type Votes = pallet_ranked_collective::Votes;
type Tally = pallet_ranked_collective::TallyOf<Runtime, AmbassadorCollectiveInstance>;
type SubmissionDeposit = SubmissionDeposit;
type MaxQueued = ConstU32<20>;
type UndecidingTimeout = UndecidingTimeout;
type AlarmInterval = AlarmInterval;
type Tracks = tracks::TracksInfo;
type Preimages = Preimage;
}
parameter_types! {
pub const AnnouncementLifetime: BlockNumber = 180 * DAYS;
pub const MaxAnnouncements: u32 = 50;
}
pub type AmbassadorContentInstance = pallet_collective_content::Instance1;
impl pallet_collective_content::Config<AmbassadorContentInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type CharterOrigin = EitherOf<EnsureRoot<AccountId>, EnsureHeadAmbassadorsVoice>;
type AnnouncementLifetime = AnnouncementLifetime;
// An announcement can be submitted by a Senior Ambassador member or an ambassador plurality
// voice taken via referendum.
type AnnouncementOrigin = EitherOfDiverse<
pallet_ranked_collective::EnsureMember<
Runtime,
AmbassadorCollectiveInstance,
{ ranks::SENIOR_AMBASSADOR_TIER_3 },
>,
EnsureAmbassadorsVoice,
>;
type MaxAnnouncements = MaxAnnouncements;
type WeightInfo = weights::pallet_collective_content::WeightInfo<Runtime>;
}
pub type AmbassadorCoreInstance = pallet_core_fellowship::Instance2;
impl pallet_core_fellowship::Config<AmbassadorCoreInstance> for Runtime {
type WeightInfo = weights::pallet_core_fellowship_ambassador_core::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type Members = pallet_ranked_collective::Pallet<Runtime, AmbassadorCollectiveInstance>;
type Balance = Balance;
// Parameters are set by any of:
// - Root;
// - the FellowshipAdmin origin (i.e. token holder referendum);
// - a vote among all Head Ambassadors.
type ParamsOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EitherOfDiverse<
EnsureXcm<IsVoiceOfBody<GovernanceLocation, FellowshipAdminBodyId>>,
EnsureHeadAmbassadorsVoice,
>,
>;
// Induction (creating a candidate) is by any of:
// - Root;
// - the FellowshipAdmin origin (i.e. token holder referendum);
// - a single Head Ambassador;
// - a vote among all senior members.
type InductOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EitherOfDiverse<
EnsureXcm<IsVoiceOfBody<GovernanceLocation, FellowshipAdminBodyId>>,
EitherOfDiverse<
pallet_ranked_collective::EnsureMember<
Runtime,
AmbassadorCollectiveInstance,
{ ranks::HEAD_AMBASSADOR_TIER_5 },
>,
EnsureAmbassadorsVoiceFrom<ConstU16<{ ranks::SENIOR_AMBASSADOR_TIER_3 }>>,
>,
>,
>;
type ApproveOrigin = PromoteOrigin;
type PromoteOrigin = PromoteOrigin;
type EvidenceSize = ConstU32<65536>;
}
pub type AmbassadorSalaryInstance = pallet_salary::Instance2;
parameter_types! {
// The interior location on AssetHub for the paying account. This is the Ambassador Salary
// pallet instance (which sits at index 74). This sovereign account will need funding.
pub AmbassadorSalaryLocation: InteriorMultiLocation = PalletInstance(74).into();
}
/// [`PayOverXcm`] setup to pay the Ambassador salary on the AssetHub in WND.
pub type AmbassadorSalaryPaymaster = PayOverXcm<
AmbassadorSalaryLocation,
crate::xcm_config::XcmRouter,
crate::PolkadotXcm,
ConstU32<{ 6 * HOURS }>,
AccountId,
(),
ConvertToValue<WndAssetHub>,
AliasesIntoAccountId32<(), AccountId>,
>;
impl pallet_salary::Config<AmbassadorSalaryInstance> for Runtime {
type WeightInfo = weights::pallet_salary_ambassador_salary::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
#[cfg(not(feature = "runtime-benchmarks"))]
type Paymaster = AmbassadorSalaryPaymaster;
#[cfg(feature = "runtime-benchmarks")]
type Paymaster = crate::impls::benchmarks::PayWithEnsure<
AmbassadorSalaryPaymaster,
crate::impls::benchmarks::OpenHrmpChannel<ConstU32<1000>>,
>;
type Members = pallet_ranked_collective::Pallet<Runtime, AmbassadorCollectiveInstance>;
#[cfg(not(feature = "runtime-benchmarks"))]
type Salary = pallet_core_fellowship::Pallet<Runtime, AmbassadorCoreInstance>;
#[cfg(feature = "runtime-benchmarks")]
type Salary = frame_support::traits::tokens::ConvertRank<
crate::impls::benchmarks::RankToSalary<Balances>,
>;
// 15 days to register for a salary payment.
type RegistrationPeriod = ConstU32<{ 15 * DAYS }>;
// 15 days to claim the salary payment.
type PayoutPeriod = ConstU32<{ 15 * DAYS }>;
// Total monthly salary budget.
type Budget = ConstU128<{ 10_000 * DOLLARS }>;
}
@@ -0,0 +1,135 @@
// Copyright (C) 2022 Parity Technologies (UK) Ltd.
// 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.
//! The Ambassador Program's origins.
#[frame_support::pallet]
pub mod pallet_origins {
use crate::ambassador::ranks;
use frame_support::pallet_prelude::*;
use pallet_ranked_collective::Rank;
#[pallet::pallet]
pub struct Pallet<T>(PhantomData<T>);
/// The pallet configuration trait.
#[pallet::config]
pub trait Config: frame_system::Config {}
#[derive(PartialEq, Eq, Clone, MaxEncodedLen, Encode, Decode, TypeInfo, RuntimeDebug)]
#[pallet::origin]
pub enum Origin {
/// Plurality voice of the [ranks::AMBASSADOR_TIER_1] members or above given via
/// referendum.
Ambassadors,
/// Plurality voice of the [ranks::AMBASSADOR_TIER_2] members or above given via
/// referendum.
AmbassadorsTier2,
/// Plurality voice of the [ranks::SENIOR_AMBASSADOR_TIER_3] members or above given via
/// referendum.
SeniorAmbassadors,
/// Plurality voice of the [ranks::SENIOR_AMBASSADOR_TIER_4] members or above given via
/// referendum.
SeniorAmbassadorsTier4,
/// Plurality voice of the [ranks::HEAD_AMBASSADOR_TIER_5] members or above given via
/// referendum.
HeadAmbassadors,
/// Plurality voice of the [ranks::HEAD_AMBASSADOR_TIER_6] members or above given via
/// referendum.
HeadAmbassadorsTier6,
/// Plurality voice of the [ranks::HEAD_AMBASSADOR_TIER_7] members or above given via
/// referendum.
HeadAmbassadorsTier7,
/// Plurality voice of the [ranks::MASTER_AMBASSADOR_TIER_8] members or above given via
/// referendum.
MasterAmbassadors,
/// Plurality voice of the [ranks::MASTER_AMBASSADOR_TIER_9] members or above given via
/// referendum.
MasterAmbassadorsTier9,
}
impl Origin {
/// Returns the rank that the origin `self` speaks for, or `None` if it doesn't speak for
/// any.
pub fn as_voice(&self) -> Option<Rank> {
Some(match &self {
Origin::Ambassadors => ranks::AMBASSADOR_TIER_1,
Origin::AmbassadorsTier2 => ranks::AMBASSADOR_TIER_2,
Origin::SeniorAmbassadors => ranks::SENIOR_AMBASSADOR_TIER_3,
Origin::SeniorAmbassadorsTier4 => ranks::SENIOR_AMBASSADOR_TIER_4,
Origin::HeadAmbassadors => ranks::HEAD_AMBASSADOR_TIER_5,
Origin::HeadAmbassadorsTier6 => ranks::HEAD_AMBASSADOR_TIER_6,
Origin::HeadAmbassadorsTier7 => ranks::HEAD_AMBASSADOR_TIER_7,
Origin::MasterAmbassadors => ranks::MASTER_AMBASSADOR_TIER_8,
Origin::MasterAmbassadorsTier9 => ranks::MASTER_AMBASSADOR_TIER_9,
})
}
}
/// Implementation of the [EnsureOrigin] trait for the [Origin::HeadAmbassadors] origin.
pub struct EnsureHeadAmbassadorsVoice;
impl<O: Into<Result<Origin, O>> + From<Origin>> EnsureOrigin<O> for EnsureHeadAmbassadorsVoice {
type Success = ();
fn try_origin(o: O) -> Result<Self::Success, O> {
o.into().and_then(|o| match o {
Origin::HeadAmbassadors => Ok(()),
r => Err(O::from(r)),
})
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<O, ()> {
Ok(O::from(Origin::HeadAmbassadors))
}
}
/// Implementation of the [EnsureOrigin] trait for the plurality voice [Origin]s
/// from a given rank `R` with the success result of the corresponding [Rank].
pub struct EnsureAmbassadorsVoiceFrom<R>(PhantomData<R>);
impl<R: Get<Rank>, O: Into<Result<Origin, O>> + From<Origin>> EnsureOrigin<O>
for EnsureAmbassadorsVoiceFrom<R>
{
type Success = Rank;
fn try_origin(o: O) -> Result<Self::Success, O> {
o.into().and_then(|o| match Origin::as_voice(&o) {
Some(r) if r >= R::get() => Ok(r),
_ => Err(O::from(o)),
})
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<O, ()> {
ranks::MASTER_AMBASSADOR_TIER_9
.ge(&R::get())
.then(|| O::from(Origin::MasterAmbassadorsTier9))
.ok_or(())
}
}
/// Implementation of the [EnsureOrigin] trait for the plurality voice [Origin]s with the
/// success result of the corresponding [Rank].
pub struct EnsureAmbassadorsVoice;
impl<O: Into<Result<Origin, O>> + From<Origin>> EnsureOrigin<O> for EnsureAmbassadorsVoice {
type Success = Rank;
fn try_origin(o: O) -> Result<Self::Success, O> {
o.into().and_then(|o| Origin::as_voice(&o).ok_or(O::from(o)))
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<O, ()> {
Ok(O::from(Origin::MasterAmbassadorsTier9))
}
}
}
@@ -0,0 +1,282 @@
// Copyright (C) 2022 Parity Technologies (UK) Ltd.
// 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.
//! The Ambassador Program's referenda voting tracks.
use super::Origin;
use crate::{Balance, BlockNumber, RuntimeOrigin, DAYS, DOLLARS, HOURS};
use sp_runtime::Perbill;
/// Referendum `TrackId` type.
pub type TrackId = u16;
/// Referendum track IDs.
pub mod constants {
use super::TrackId;
pub const AMBASSADOR_TIER_1: TrackId = 1;
pub const AMBASSADOR_TIER_2: TrackId = 2;
pub const SENIOR_AMBASSADOR_TIER_3: TrackId = 3;
pub const SENIOR_AMBASSADOR_TIER_4: TrackId = 4;
pub const HEAD_AMBASSADOR_TIER_5: TrackId = 5;
pub const HEAD_AMBASSADOR_TIER_6: TrackId = 6;
pub const HEAD_AMBASSADOR_TIER_7: TrackId = 7;
pub const MASTER_AMBASSADOR_TIER_8: TrackId = 8;
pub const MASTER_AMBASSADOR_TIER_9: TrackId = 9;
}
/// The type implementing the [`pallet_referenda::TracksInfo`] trait for referenda pallet.
pub struct TracksInfo;
/// Information on the voting tracks.
impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
type Id = TrackId;
type RuntimeOrigin = <RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin;
/// Return the array of available tracks and their information.
fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo<Balance, BlockNumber>)] {
static DATA: [(TrackId, pallet_referenda::TrackInfo<Balance, BlockNumber>); 9] = [
(
constants::AMBASSADOR_TIER_1,
pallet_referenda::TrackInfo {
name: "ambassador tier 1",
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
decision_period: 1 * DAYS,
confirm_period: 24 * HOURS,
min_enactment_period: 1 * HOURS,
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(10),
ceil: Perbill::from_percent(50),
},
},
),
(
constants::AMBASSADOR_TIER_2,
pallet_referenda::TrackInfo {
name: "ambassador tier 2",
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
decision_period: 1 * DAYS,
confirm_period: 24 * HOURS,
min_enactment_period: 1 * HOURS,
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(10),
ceil: Perbill::from_percent(50),
},
},
),
(
constants::SENIOR_AMBASSADOR_TIER_3,
pallet_referenda::TrackInfo {
name: "senior ambassador tier 3",
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
decision_period: 1 * DAYS,
confirm_period: 24 * HOURS,
min_enactment_period: 1 * HOURS,
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(10),
ceil: Perbill::from_percent(50),
},
},
),
(
constants::SENIOR_AMBASSADOR_TIER_4,
pallet_referenda::TrackInfo {
name: "senior ambassador tier 4",
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
decision_period: 1 * DAYS,
confirm_period: 24 * HOURS,
min_enactment_period: 1 * HOURS,
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(10),
ceil: Perbill::from_percent(50),
},
},
),
(
constants::HEAD_AMBASSADOR_TIER_5,
pallet_referenda::TrackInfo {
name: "head ambassador tier 5",
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
decision_period: 1 * DAYS,
confirm_period: 24 * HOURS,
min_enactment_period: 1 * HOURS,
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(10),
ceil: Perbill::from_percent(50),
},
},
),
(
constants::HEAD_AMBASSADOR_TIER_6,
pallet_referenda::TrackInfo {
name: "head ambassador tier 6",
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
decision_period: 1 * DAYS,
confirm_period: 24 * HOURS,
min_enactment_period: 1 * HOURS,
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(10),
ceil: Perbill::from_percent(50),
},
},
),
(
constants::HEAD_AMBASSADOR_TIER_7,
pallet_referenda::TrackInfo {
name: "head ambassador tier 7",
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
decision_period: 1 * DAYS,
confirm_period: 24 * HOURS,
min_enactment_period: 1 * HOURS,
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(10),
ceil: Perbill::from_percent(50),
},
},
),
(
constants::MASTER_AMBASSADOR_TIER_8,
pallet_referenda::TrackInfo {
name: "master ambassador tier 8",
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
decision_period: 1 * DAYS,
confirm_period: 24 * HOURS,
min_enactment_period: 1 * HOURS,
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(10),
ceil: Perbill::from_percent(50),
},
},
),
(
constants::MASTER_AMBASSADOR_TIER_9,
pallet_referenda::TrackInfo {
name: "master ambassador tier 9",
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
decision_period: 1 * DAYS,
confirm_period: 24 * HOURS,
min_enactment_period: 1 * HOURS,
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(10),
ceil: Perbill::from_percent(50),
},
},
),
];
&DATA[..]
}
/// Determine the voting track for the given `origin`.
fn track_for(id: &Self::RuntimeOrigin) -> Result<Self::Id, ()> {
#[cfg(feature = "runtime-benchmarks")]
{
// For benchmarks, we enable a root origin.
// It is important that this is not available in production!
let root: Self::RuntimeOrigin = frame_system::RawOrigin::Root.into();
if &root == id {
return Ok(constants::MASTER_AMBASSADOR_TIER_9)
}
}
match Origin::try_from(id.clone()) {
Ok(Origin::Ambassadors) => Ok(constants::AMBASSADOR_TIER_1),
Ok(Origin::AmbassadorsTier2) => Ok(constants::AMBASSADOR_TIER_2),
Ok(Origin::SeniorAmbassadors) => Ok(constants::SENIOR_AMBASSADOR_TIER_3),
Ok(Origin::SeniorAmbassadorsTier4) => Ok(constants::SENIOR_AMBASSADOR_TIER_4),
Ok(Origin::HeadAmbassadors) => Ok(constants::HEAD_AMBASSADOR_TIER_5),
Ok(Origin::HeadAmbassadorsTier6) => Ok(constants::HEAD_AMBASSADOR_TIER_6),
Ok(Origin::HeadAmbassadorsTier7) => Ok(constants::HEAD_AMBASSADOR_TIER_7),
Ok(Origin::MasterAmbassadors) => Ok(constants::MASTER_AMBASSADOR_TIER_8),
Ok(Origin::MasterAmbassadorsTier9) => Ok(constants::MASTER_AMBASSADOR_TIER_9),
_ => Err(()),
}
}
}
// implements [`frame_support::traits::Get`] for [`TracksInfo`]
pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber);