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:
joe petrowski
2023-12-22 21:28:09 +01:00
committed by GitHub
parent 4c0e0e0713
commit ecbbb5a736
111 changed files with 12730 additions and 258 deletions
+65 -3
View File
@@ -18,12 +18,16 @@
use frame_support::traits::{
fungibles::{self, Balanced, Credit},
Contains, ContainsPair, Currency, Get, Imbalance, OnUnbalanced,
Contains, ContainsPair, Currency, Get, Imbalance, OnUnbalanced, OriginTrait,
};
use pallet_asset_tx_payment::HandleCredit;
use sp_runtime::traits::Zero;
use sp_std::marker::PhantomData;
use xcm::latest::{AssetId, Fungibility::Fungible, MultiAsset, MultiLocation};
use sp_std::{marker::PhantomData, prelude::*};
use xcm::latest::{
AssetId, Fungibility, Fungibility::Fungible, Junction, Junctions::Here, MultiAsset,
MultiLocation, Parent, WeightLimit,
};
use xcm_executor::traits::ConvertLocation;
/// Type alias to conveniently refer to the `Currency::NegativeImbalance` associated type.
pub type NegativeImbalance<T> = <pallet_balances::Pallet<T> as Currency<
@@ -118,6 +122,64 @@ impl<T: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation> for AssetsFr
}
}
/// Type alias to conveniently refer to the `Currency::Balance` associated type.
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, AccountIdConverter, T>(
PhantomData<(TreasuryAccount, AccountIdConverter, T)>,
);
impl<TreasuryAccount, AccountIdConverter, T> OnUnbalanced<NegativeImbalance<T>>
for ToParentTreasury<TreasuryAccount, AccountIdConverter, 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>>,
AccountIdConverter: ConvertLocation<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 root_location: MultiLocation = Here.into();
let root_account: AccountIdOf<T> =
match AccountIdConverter::convert_location(&root_location) {
Some(a) => a,
None => {
log::warn!("Failed to convert root origin into account id");
return
},
};
let treasury_account: AccountIdOf<T> = TreasuryAccount::get();
<pallet_balances::Pallet<T>>::resolve_creating(&root_account, amount);
let result = <pallet_xcm::Pallet<T>>::limited_teleport_assets(
<<T as frame_system::Config>::RuntimeOrigin>::root(),
Box::new(Parent.into()),
Box::new(
Junction::AccountId32 { network: None, id: treasury_account.into() }
.into_location()
.into(),
),
Box::new((Parent, imbalance).into()),
0,
WeightLimit::Unlimited,
);
if let Err(err) = result {
log::warn!("Failed to teleport slashed assets: {:?}", err);
}
}
}
#[cfg(test)]
mod tests {
use super::*;
+6 -6
View File
@@ -20,17 +20,17 @@ pub mod account {
/// 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.
/// Used as a temporary place to deposit a slashed imbalance before teleporting to the Treasury.
pub const ALLIANCE_PALLET_ID: PalletId = PalletId(*b"py/allia");
/// Referenda pallet ID.
/// It is used as a temporarily place to deposit a slashed imbalance
/// before the teleport to the Treasury.
/// Used as a temporary place to deposit a slashed imbalance before teleporting to the Treasury.
pub const REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/refer");
/// Ambassador Referenda pallet ID.
/// It is used as a temporarily place to deposit a slashed imbalance
/// before the teleport to the Treasury.
/// Used as a temporary place to deposit a slashed imbalance before teleporting to the Treasury.
pub const AMBASSADOR_REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/amref");
/// Identity pallet ID.
/// Used as a temporary place to deposit a slashed imbalance before teleporting to the Treasury.
pub const IDENTITY_PALLET_ID: PalletId = PalletId(*b"py/ident");
/// Fellowship treasury pallet ID
pub const FELLOWSHIP_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/feltr");
}