mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
Identity Deposits Relay to Parachain Migration (#1814)
The goal of this PR is to migrate Identity deposits from the Relay Chain to a system parachain. The problem I want to solve is that `IdentityOf` and `SubsOf` both store an amount that's held in reserve as a storage deposit. When migrating to a parachain, we can take a snapshot of the actual `IdentityInfo` and sub-account mappings, but should migrate (off chain) the `deposit`s to zero, since the chain (and by extension, accounts) won't have any funds at genesis. The good news is that we expect parachain deposits to be significantly lower (possibly 100x) on the parachain. That is, a deposit of 21 DOT on the Relay Chain would need 0.21 DOT on a parachain. This PR proposes to migrate the deposits in the following way: 1. Introduces a new pallet with two extrinsics: - `reap_identity`: Has a configurable `ReapOrigin`, which would be set to `EnsureSigned` on the Relay Chain (i.e. callable by anyone) and `EnsureRoot` on the parachain (we don't want identities reaped from there). - `poke_deposit`: Checks what deposit the pallet holds (at genesis, zero) and attempts to update the amount based on the calculated deposit for storage data. 2. `reap_identity` clears all storage data for a `target` account and unreserves their deposit. 3. A `ReapIdentityHandler` teleports the necessary DOT to the parachain and calls `poke_deposit`. Since the parachain deposit is much lower, and was just unreserved, we know we have enough. One awkwardness I ran into was that the XCMv3 instruction set does not provide a way for the system to teleport assets without a fee being deducted on reception. Users shouldn't have to pay a fee for the system to migrate their info to a more efficient location. So I wrote my own program and did the `InitiateTeleport` accounting on my own to send a program with `UnpaidExecution`. Have discussed an `InitiateUnpaidTeleport` instruction with @franciscoaguirre . Obviously any chain executing this would have to pass a `Barrier` for free execution. TODO: - [x] Confirm People Chain ParaId - [x] Confirm People Chain deposit rates (determined in https://github.com/paritytech/polkadot-sdk/pull/2281) - [x] Add pallet to Westend --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -31,7 +31,7 @@ use primitives::{
|
||||
ValidatorIndex, PARACHAIN_KEY_TYPE_ID,
|
||||
};
|
||||
use runtime_common::{
|
||||
assigned_slots, auctions, claims, crowdloan, impl_runtime_weights,
|
||||
assigned_slots, auctions, claims, crowdloan, identity_migrator, impl_runtime_weights,
|
||||
impls::{
|
||||
LocatableAssetConverter, ToAuthor, VersionedLocatableAsset, VersionedMultiLocationConverter,
|
||||
},
|
||||
@@ -68,9 +68,9 @@ use frame_support::{
|
||||
genesis_builder_helper::{build_config, create_default_config},
|
||||
parameter_types,
|
||||
traits::{
|
||||
fungible::HoldConsideration, EitherOf, EitherOfDiverse, Everything, InstanceFilter,
|
||||
KeyOwnerProofSystem, LinearStoragePrice, PrivilegeCmp, ProcessMessage, ProcessMessageError,
|
||||
StorageMapShim, WithdrawReasons,
|
||||
fungible::HoldConsideration, Contains, EitherOf, EitherOfDiverse, EverythingBut,
|
||||
InstanceFilter, KeyOwnerProofSystem, LinearStoragePrice, PrivilegeCmp, ProcessMessage,
|
||||
ProcessMessageError, StorageMapShim, WithdrawReasons,
|
||||
},
|
||||
weights::{ConstantMultiplier, WeightMeter},
|
||||
PalletId,
|
||||
@@ -114,6 +114,10 @@ mod weights;
|
||||
// XCM configurations.
|
||||
pub mod xcm_config;
|
||||
|
||||
// Implemented types.
|
||||
mod impls;
|
||||
use impls::ToParachainIdentityReaper;
|
||||
|
||||
// Governance and configurations.
|
||||
pub mod governance;
|
||||
use governance::{
|
||||
@@ -166,13 +170,24 @@ pub fn native_version() -> NativeVersion {
|
||||
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
||||
}
|
||||
|
||||
/// A type to identify calls to the Identity pallet. These will be filtered to prevent invocation,
|
||||
/// locking the state of the pallet and preventing further updates to identities and sub-identities.
|
||||
/// The locked state will be the genesis state of a new system chain and then removed from the Relay
|
||||
/// Chain.
|
||||
pub struct IsIdentityCall;
|
||||
impl Contains<RuntimeCall> for IsIdentityCall {
|
||||
fn contains(c: &RuntimeCall) -> bool {
|
||||
matches!(c, RuntimeCall::Identity(_))
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
pub const SS58Prefix: u8 = 42;
|
||||
}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = Everything;
|
||||
type BaseCallFilter = EverythingBut<IsIdentityCall>;
|
||||
type BlockWeights = BlockWeights;
|
||||
type BlockLength = BlockLength;
|
||||
type DbWeight = RocksDbWeight;
|
||||
@@ -1079,6 +1094,14 @@ impl auctions::Config for Runtime {
|
||||
type WeightInfo = weights::runtime_common_auctions::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
impl identity_migrator::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
// To be changed to `EnsureSigned` once there is a People Chain to migrate to.
|
||||
type Reaper = EnsureRoot<AccountId>;
|
||||
type ReapIdentityHandler = ToParachainIdentityReaper<Runtime, Self::AccountId>;
|
||||
type WeightInfo = weights::runtime_common_identity_migrator::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
type NisCounterpartInstance = pallet_balances::Instance2;
|
||||
impl pallet_balances::Config<NisCounterpartInstance> for Runtime {
|
||||
type Balance = Balance;
|
||||
@@ -1340,7 +1363,7 @@ construct_runtime! {
|
||||
|
||||
// NIS pallet.
|
||||
Nis: pallet_nis::{Pallet, Call, Storage, Event<T>, HoldReason} = 38,
|
||||
// pub type NisCounterpartInstance = pallet_balances::Instance2;
|
||||
// pub type NisCounterpartInstance = pallet_balances::Instance2;
|
||||
NisCounterpartBalances: pallet_balances::<Instance2> = 45,
|
||||
|
||||
// Parachains pallets. Start indices at 50 to leave room.
|
||||
@@ -1371,6 +1394,9 @@ construct_runtime! {
|
||||
// Pallet for sending XCM.
|
||||
XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config<T>} = 99,
|
||||
|
||||
// Pallet for migrating Identity to a parachain. To be removed post-migration.
|
||||
IdentityMigrator: identity_migrator::{Pallet, Call, Event<T>} = 248,
|
||||
|
||||
ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call} = 250,
|
||||
AssignedSlots: assigned_slots::{Pallet, Call, Storage, Event<T>, Config<T>} = 251,
|
||||
|
||||
@@ -1551,6 +1577,7 @@ mod benches {
|
||||
[runtime_common::auctions, Auctions]
|
||||
[runtime_common::crowdloan, Crowdloan]
|
||||
[runtime_common::claims, Claims]
|
||||
[runtime_common::identity_migrator, IdentityMigrator]
|
||||
[runtime_common::slots, Slots]
|
||||
[runtime_common::paras_registrar, Registrar]
|
||||
[runtime_parachains::configuration, Configuration]
|
||||
|
||||
Reference in New Issue
Block a user