mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Rococo & Westend People Chain (#2281)
Rococo and Westend runtimes for the "People Chain". This chain contains the Identity pallet with plans to migrate all related data from the Relay Chain. Changes `IdentityInfo` to: - Remove `additional_fields`. - Add `github` and `discord` as first class fields. From scraping chain data, these were the only two additional fields used (for the Fellowship and Ambassador Program, respectively). - Rename `riot` to `matrix`. Note: This will use the script in https://github.com/paritytech/polkadot-sdk/pull/2025 to generate the genesis state. TODO: - [x] https://github.com/paritytech/polkadot-sdk/pull/1814 and integration of the Identity Migrator pallet for migration. - [x] Tests: https://github.com/paritytech/polkadot-sdk/pull/2373 --------- Co-authored-by: Muharem <ismailov.m.h@gmail.com> Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Dónal Murray <donal.murray@parity.io> Co-authored-by: Richard Melkonian <35300528+0xmovses@users.noreply.github.com> Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
This commit is contained in:
@@ -32,13 +32,12 @@ pub mod origins;
|
||||
mod tracks;
|
||||
|
||||
use super::*;
|
||||
use crate::xcm_config::{FellowshipAdminBodyId, WndAssetHub};
|
||||
use crate::xcm_config::{FellowshipAdminBodyId, LocationToAccountId, 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::*;
|
||||
@@ -114,9 +113,6 @@ 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;
|
||||
@@ -136,7 +132,7 @@ impl pallet_referenda::Config<AmbassadorReferendaInstance> for Runtime {
|
||||
>;
|
||||
type CancelOrigin = EitherOf<EnsureRoot<AccountId>, EnsureHeadAmbassadorsVoice>;
|
||||
type KillOrigin = EitherOf<EnsureRoot<AccountId>, EnsureHeadAmbassadorsVoice>;
|
||||
type Slash = ToParentTreasury<WestendTreasuryAccount, AmbassadorPalletAccount, Runtime>;
|
||||
type Slash = ToParentTreasury<WestendTreasuryAccount, LocationToAccountId, Runtime>;
|
||||
type Votes = pallet_ranked_collective::Votes;
|
||||
type Tally = pallet_ranked_collective::TallyOf<Runtime, AmbassadorCollectiveInstance>;
|
||||
type SubmissionDeposit = SubmissionDeposit;
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
mod origins;
|
||||
mod tracks;
|
||||
use crate::{
|
||||
impls::ToParentTreasury,
|
||||
weights,
|
||||
xcm_config::{FellowshipAdminBodyId, TreasurerBodyId, UsdtAssetHub},
|
||||
xcm_config::{FellowshipAdminBodyId, LocationToAccountId, TreasurerBodyId, UsdtAssetHub},
|
||||
AccountId, AssetRate, Balance, Balances, FellowshipReferenda, GovernanceLocation, Preimage,
|
||||
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Scheduler, WestendTreasuryAccount, DAYS,
|
||||
};
|
||||
@@ -39,15 +38,16 @@ pub use origins::{
|
||||
};
|
||||
use pallet_ranked_collective::EnsureOfRank;
|
||||
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
|
||||
use parachains_common::westend::{account, currency::GRAND};
|
||||
use parachains_common::{
|
||||
impls::ToParentTreasury,
|
||||
westend::{account, currency::GRAND},
|
||||
};
|
||||
use polkadot_runtime_common::impls::{
|
||||
LocatableAssetConverter, VersionedLocatableAsset, VersionedMultiLocationConverter,
|
||||
};
|
||||
use sp_arithmetic::Permill;
|
||||
use sp_core::{ConstU128, ConstU32};
|
||||
use sp_runtime::traits::{
|
||||
AccountIdConversion, ConstU16, ConvertToValue, IdentityLookup, Replace, TakeFirst,
|
||||
};
|
||||
use sp_runtime::traits::{ConstU16, ConvertToValue, IdentityLookup, Replace, TakeFirst};
|
||||
use westend_runtime_constants::time::HOURS;
|
||||
use xcm::prelude::*;
|
||||
use xcm_builder::{AliasesIntoAccountId32, PayOverXcm};
|
||||
@@ -72,11 +72,6 @@ pub mod ranks {
|
||||
pub const DAN_9: Rank = 9;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// Referenda pallet account, used to temporarily deposit slashed imbalance before teleporting.
|
||||
pub ReferendaPalletAccount: AccountId = account::REFERENDA_PALLET_ID.into_account_truncating();
|
||||
}
|
||||
|
||||
impl pallet_fellowship_origins::Config for Runtime {}
|
||||
|
||||
pub type FellowshipReferendaInstance = pallet_referenda::Instance1;
|
||||
@@ -103,7 +98,7 @@ impl pallet_referenda::Config<FellowshipReferendaInstance> for Runtime {
|
||||
>;
|
||||
type CancelOrigin = Architects;
|
||||
type KillOrigin = Masters;
|
||||
type Slash = ToParentTreasury<WestendTreasuryAccount, ReferendaPalletAccount, Runtime>;
|
||||
type Slash = ToParentTreasury<WestendTreasuryAccount, LocationToAccountId, Runtime>;
|
||||
type Votes = pallet_ranked_collective::Votes;
|
||||
type Tally = pallet_ranked_collective::TallyOf<Runtime, FellowshipCollectiveInstance>;
|
||||
type SubmissionDeposit = ConstU128<0>;
|
||||
|
||||
@@ -16,15 +16,12 @@
|
||||
use crate::OriginCaller;
|
||||
use frame_support::{
|
||||
dispatch::DispatchResultWithPostInfo,
|
||||
traits::{Currency, Get, Imbalance, OnUnbalanced, OriginTrait, PrivilegeCmp},
|
||||
traits::{Currency, PrivilegeCmp},
|
||||
weights::Weight,
|
||||
};
|
||||
use log;
|
||||
use pallet_alliance::{ProposalIndex, ProposalProvider};
|
||||
use parachains_common::impls::NegativeImbalance;
|
||||
use sp_runtime::DispatchError;
|
||||
use sp_std::{cmp::Ordering, marker::PhantomData, prelude::*};
|
||||
use xcm::latest::{Fungibility, Junction, Parent};
|
||||
|
||||
type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
|
||||
|
||||
@@ -36,51 +33,6 @@ type HashOf<T> = <T as frame_system::Config>::Hash;
|
||||
pub type BalanceOf<T> =
|
||||
<pallet_balances::Pallet<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||
|
||||
/// Implements `OnUnbalanced::on_unbalanced` to teleport slashed assets to relay chain treasury
|
||||
/// account.
|
||||
pub struct ToParentTreasury<TreasuryAccount, PalletAccount, T>(
|
||||
PhantomData<(TreasuryAccount, PalletAccount, T)>,
|
||||
);
|
||||
|
||||
impl<TreasuryAccount, PalletAccount, T> OnUnbalanced<NegativeImbalance<T>>
|
||||
for ToParentTreasury<TreasuryAccount, PalletAccount, T>
|
||||
where
|
||||
T: pallet_balances::Config + pallet_xcm::Config + frame_system::Config,
|
||||
<<T as frame_system::Config>::RuntimeOrigin as OriginTrait>::AccountId: From<AccountIdOf<T>>,
|
||||
[u8; 32]: From<<T as frame_system::Config>::AccountId>,
|
||||
TreasuryAccount: Get<AccountIdOf<T>>,
|
||||
PalletAccount: Get<AccountIdOf<T>>,
|
||||
BalanceOf<T>: Into<Fungibility>,
|
||||
{
|
||||
fn on_unbalanced(amount: NegativeImbalance<T>) {
|
||||
let amount = match amount.drop_zero() {
|
||||
Ok(..) => return,
|
||||
Err(amount) => amount,
|
||||
};
|
||||
let imbalance = amount.peek();
|
||||
let pallet_acc: AccountIdOf<T> = PalletAccount::get();
|
||||
let treasury_acc: AccountIdOf<T> = TreasuryAccount::get();
|
||||
|
||||
<pallet_balances::Pallet<T>>::resolve_creating(&pallet_acc, amount);
|
||||
|
||||
let result = <pallet_xcm::Pallet<T>>::teleport_assets(
|
||||
<<T as frame_system::Config>::RuntimeOrigin>::signed(pallet_acc.into()),
|
||||
Box::new(Parent.into()),
|
||||
Box::new(
|
||||
Junction::AccountId32 { network: None, id: treasury_acc.into() }
|
||||
.into_location()
|
||||
.into(),
|
||||
),
|
||||
Box::new((Parent, imbalance).into()),
|
||||
0,
|
||||
);
|
||||
|
||||
if let Err(err) = result {
|
||||
log::warn!("Failed to teleport slashed assets: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Proposal provider for alliance pallet.
|
||||
/// Adapter from collective pallet to alliance proposal provider trait.
|
||||
pub struct AllianceProposalProvider<T, I = ()>(PhantomData<(T, I)>);
|
||||
@@ -157,6 +109,7 @@ pub mod benchmarks {
|
||||
use frame_support::traits::{
|
||||
fungible,
|
||||
tokens::{Pay, PaymentStatus},
|
||||
Get,
|
||||
};
|
||||
use pallet_ranked_collective::Rank;
|
||||
use parachains_common::{AccountId, Balance};
|
||||
|
||||
@@ -46,7 +46,7 @@ pub use ambassador::pallet_ambassador_origins;
|
||||
|
||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
||||
use fellowship::{pallet_fellowship_origins, Fellows};
|
||||
use impls::{AllianceProposalProvider, EqualOrGreatestRootCmp, ToParentTreasury};
|
||||
use impls::{AllianceProposalProvider, EqualOrGreatestRootCmp};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||
use sp_runtime::{
|
||||
@@ -81,7 +81,7 @@ use frame_system::{
|
||||
};
|
||||
pub use parachains_common as common;
|
||||
use parachains_common::{
|
||||
impls::DealWithFees,
|
||||
impls::{DealWithFees, ToParentTreasury},
|
||||
message_queue::*,
|
||||
westend::{account::*, consensus::*, currency::*, fee::WeightToFee},
|
||||
AccountId, AuraId, Balance, BlockNumber, Hash, Header, Nonce, Signature,
|
||||
@@ -89,7 +89,9 @@ use parachains_common::{
|
||||
SLOT_DURATION,
|
||||
};
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use xcm_config::{GovernanceLocation, TreasurerBodyId, XcmOriginToTransactDispatchOrigin};
|
||||
use xcm_config::{
|
||||
GovernanceLocation, LocationToAccountId, TreasurerBodyId, XcmOriginToTransactDispatchOrigin,
|
||||
};
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
@@ -537,9 +539,6 @@ pub const MAX_ALLIES: u32 = 100;
|
||||
|
||||
parameter_types! {
|
||||
pub const AllyDeposit: Balance = 1_000 * UNITS; // 1,000 WND bond to join as an Ally
|
||||
// The Alliance pallet account, used as a temporary place to deposit a slashed imbalance
|
||||
// before the teleport to the Treasury.
|
||||
pub AlliancePalletAccount: AccountId = ALLIANCE_PALLET_ID.into_account_truncating();
|
||||
pub WestendTreasuryAccount: AccountId = WESTEND_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.
|
||||
@@ -553,7 +552,7 @@ impl pallet_alliance::Config for Runtime {
|
||||
type MembershipManager = RootOrAllianceTwoThirdsMajority;
|
||||
type AnnouncementOrigin = RootOrAllianceTwoThirdsMajority;
|
||||
type Currency = Balances;
|
||||
type Slashed = ToParentTreasury<WestendTreasuryAccount, AlliancePalletAccount, Runtime>;
|
||||
type Slashed = ToParentTreasury<WestendTreasuryAccount, LocationToAccountId, Runtime>;
|
||||
type InitializeMembers = AllianceMotion;
|
||||
type MembershipChanged = AllianceMotion;
|
||||
type RetirementPeriod = AllianceRetirementPeriod;
|
||||
|
||||
Reference in New Issue
Block a user