mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
Rococo Identity Migration Part 2 + Bug Fix (#2946)
Order: - [x] Start People Chain - [RPC node](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-people-rpc.polkadot.io#/explorer) - [x] Upgrade Rococo Relay (`EnsureRoot` -> `EnsureSigned`) (v1,006,002) - Done [here](https://rococo.subscan.io/extrinsic/0xef07e0f9dbb2b9e829305f132e6ce45d291239286e409177e20895e6687daa6c) - [x] Migrate all identities - Done, see extrinsics from [this account](https://rococo.subscan.io/account/5FyNYrBwndvBttTkGUqGGCRAXtBH4Mh8xELDaxaFywTsjDKb) - [x] Upgrade Rococo People (remove call filter) (v1,006,002) - Authorized [here](https://rococo.subscan.io/extrinsic/0xedf6a80229bd411b7ed8d3a489a767b0f773bed5c49239987a294c293a35b98b) With added: - [x] Upgrade Rococo People to fix `poke_deposit` bug (v1,006,001) - Authorized [here](https://rococo.subscan.io/extrinsic/0xd1dc3cd6e8274bd0196f8d9f13ed09f6e9c76e6a40f9786a1629f4cb22cf948d) Note: It's also possible to remove the Identity Migrator pallet from both the Relay Chain and the parachain at this time. I will leave them in for now to preserve the test cases until we run them on Kusama/Polkadot. We will also want a follow up to remove all Identity-related state from the Relay Chain.
This commit is contained in:
@@ -1395,16 +1395,21 @@ impl<T: Config> Pallet<T> {
|
||||
},
|
||||
)?;
|
||||
|
||||
// Subs Deposit
|
||||
let new_subs_deposit = SubsOf::<T>::try_mutate(
|
||||
&target,
|
||||
|(current_subs_deposit, subs_of)| -> Result<BalanceOf<T>, DispatchError> {
|
||||
let new_subs_deposit = Self::subs_deposit(subs_of.len() as u32);
|
||||
Self::rejig_deposit(&target, *current_subs_deposit, new_subs_deposit)?;
|
||||
*current_subs_deposit = new_subs_deposit;
|
||||
Ok(new_subs_deposit)
|
||||
},
|
||||
)?;
|
||||
let new_subs_deposit = if SubsOf::<T>::contains_key(&target) {
|
||||
SubsOf::<T>::try_mutate(
|
||||
&target,
|
||||
|(current_subs_deposit, subs_of)| -> Result<BalanceOf<T>, DispatchError> {
|
||||
let new_subs_deposit = Self::subs_deposit(subs_of.len() as u32);
|
||||
Self::rejig_deposit(&target, *current_subs_deposit, new_subs_deposit)?;
|
||||
*current_subs_deposit = new_subs_deposit;
|
||||
Ok(new_subs_deposit)
|
||||
},
|
||||
)?
|
||||
} else {
|
||||
// If the item doesn't exist, there is no "old" deposit, and the new one is zero, so no
|
||||
// need to call rejig, it'd just be zero -> zero.
|
||||
Zero::zero()
|
||||
};
|
||||
Ok((new_id_deposit, new_subs_deposit))
|
||||
}
|
||||
|
||||
|
||||
@@ -952,6 +952,57 @@ fn poke_deposit_works() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn poke_deposit_does_not_insert_new_subs_storage() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let [_, _, _, _, ten, _, _, _] = accounts();
|
||||
let ten_info = infoof_ten();
|
||||
// Set a custom registration with 0 deposit
|
||||
IdentityOf::<Test>::insert::<
|
||||
_,
|
||||
(
|
||||
Registration<u64, MaxRegistrars, IdentityInfo<MaxAdditionalFields>>,
|
||||
Option<Username<Test>>,
|
||||
),
|
||||
>(
|
||||
&ten,
|
||||
(
|
||||
Registration {
|
||||
judgements: Default::default(),
|
||||
deposit: Zero::zero(),
|
||||
info: ten_info.clone(),
|
||||
},
|
||||
None::<Username<Test>>,
|
||||
),
|
||||
);
|
||||
assert!(Identity::identity(ten.clone()).is_some());
|
||||
|
||||
// Balance is free
|
||||
assert_eq!(Balances::free_balance(ten.clone()), 1000);
|
||||
|
||||
// poke
|
||||
assert_ok!(Identity::poke_deposit(&ten));
|
||||
|
||||
// free balance reduced correctly
|
||||
let id_deposit = id_deposit(&ten_info);
|
||||
assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit);
|
||||
// new registration deposit is 10
|
||||
assert_eq!(
|
||||
Identity::identity(&ten),
|
||||
Some((
|
||||
Registration {
|
||||
judgements: Default::default(),
|
||||
deposit: id_deposit,
|
||||
info: infoof_ten()
|
||||
},
|
||||
None
|
||||
))
|
||||
);
|
||||
// No new subs storage item.
|
||||
assert!(!SubsOf::<Test>::contains_key(&ten));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn adding_and_removing_authorities_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
|
||||
Reference in New Issue
Block a user