Skip to content

Commit f574868

Browse files
authored
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.
1 parent f80cfc2 commit f574868

File tree

7 files changed

+95
-40
lines changed

7 files changed

+95
-40
lines changed

cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ fn assert_reap_id_relay(total_deposit: Balance, id: &Identity) {
291291
assert_eq!(reserved_balance, total_deposit);
292292

293293
assert_ok!(RococoIdentityMigrator::reap_identity(
294-
RococoOrigin::root(),
294+
RococoOrigin::signed(RococoRelaySender::get()),
295295
RococoRelaySender::get()
296296
));
297297

cumulus/parachains/runtimes/people/people-rococo/src/lib.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ use frame_support::{
3030
genesis_builder_helper::{build_config, create_default_config},
3131
parameter_types,
3232
traits::{
33-
ConstBool, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse, EverythingBut,
34-
TransformOrigin,
33+
ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything, TransformOrigin,
3534
},
3635
weights::{ConstantMultiplier, Weight},
3736
PalletId,
@@ -124,7 +123,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
124123
spec_name: create_runtime_str!("people-rococo"),
125124
impl_name: create_runtime_str!("people-rococo"),
126125
authoring_version: 1,
127-
spec_version: 1_006_000,
126+
spec_version: 1_006_002,
128127
impl_version: 0,
129128
apis: RUNTIME_API_VERSIONS,
130129
transaction_version: 0,
@@ -162,16 +161,9 @@ parameter_types! {
162161
pub const SS58Prefix: u8 = 42;
163162
}
164163

165-
pub struct IdentityCalls;
166-
impl Contains<RuntimeCall> for IdentityCalls {
167-
fn contains(c: &RuntimeCall) -> bool {
168-
matches!(c, RuntimeCall::Identity(_))
169-
}
170-
}
171-
172164
#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig as frame_system::DefaultConfig)]
173165
impl frame_system::Config for Runtime {
174-
type BaseCallFilter = EverythingBut<IdentityCalls>;
166+
type BaseCallFilter = Everything;
175167
type BlockWeights = RuntimeBlockWeights;
176168
type BlockLength = RuntimeBlockLength;
177169
type AccountId = AccountId;

cumulus/parachains/runtimes/people/people-rococo/src/xcm_config.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,17 @@ impl Contains<RuntimeCall> for SafeCallFilter {
176176

177177
matches!(
178178
call,
179-
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
180-
RuntimeCall::System(
181-
frame_system::Call::set_heap_pages { .. } |
182-
frame_system::Call::set_code { .. } |
183-
frame_system::Call::set_code_without_checks { .. } |
184-
frame_system::Call::kill_prefix { .. },
185-
) | RuntimeCall::ParachainSystem(..) |
179+
RuntimeCall::PolkadotXcm(
180+
pallet_xcm::Call::force_xcm_version { .. } |
181+
pallet_xcm::Call::force_default_xcm_version { .. }
182+
) | RuntimeCall::System(
183+
frame_system::Call::set_heap_pages { .. } |
184+
frame_system::Call::set_code { .. } |
185+
frame_system::Call::set_code_without_checks { .. } |
186+
frame_system::Call::authorize_upgrade { .. } |
187+
frame_system::Call::authorize_upgrade_without_checks { .. } |
188+
frame_system::Call::kill_prefix { .. },
189+
) | RuntimeCall::ParachainSystem(..) |
186190
RuntimeCall::Timestamp(..) |
187191
RuntimeCall::Balances(..) |
188192
RuntimeCall::CollatorSelection(

cumulus/parachains/runtimes/people/people-westend/src/xcm_config.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,17 @@ impl Contains<RuntimeCall> for SafeCallFilter {
183183

184184
matches!(
185185
call,
186-
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
187-
RuntimeCall::System(
188-
frame_system::Call::set_heap_pages { .. } |
189-
frame_system::Call::set_code { .. } |
190-
frame_system::Call::set_code_without_checks { .. } |
191-
frame_system::Call::kill_prefix { .. },
192-
) | RuntimeCall::ParachainSystem(..) |
186+
RuntimeCall::PolkadotXcm(
187+
pallet_xcm::Call::force_xcm_version { .. } |
188+
pallet_xcm::Call::force_default_xcm_version { .. }
189+
) | RuntimeCall::System(
190+
frame_system::Call::set_heap_pages { .. } |
191+
frame_system::Call::set_code { .. } |
192+
frame_system::Call::set_code_without_checks { .. } |
193+
frame_system::Call::authorize_upgrade { .. } |
194+
frame_system::Call::authorize_upgrade_without_checks { .. } |
195+
frame_system::Call::kill_prefix { .. },
196+
) | RuntimeCall::ParachainSystem(..) |
193197
RuntimeCall::Timestamp(..) |
194198
RuntimeCall::Balances(..) |
195199
RuntimeCall::CollatorSelection(

polkadot/runtime/rococo/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ use frame_support::{
7979
weights::{ConstantMultiplier, WeightMeter},
8080
PalletId,
8181
};
82-
use frame_system::EnsureRoot;
82+
use frame_system::{EnsureRoot, EnsureSigned};
8383
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
8484
use pallet_identity::legacy::IdentityInfo;
8585
use pallet_session::historical as session_historical;
@@ -150,7 +150,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
150150
spec_name: create_runtime_str!("rococo"),
151151
impl_name: create_runtime_str!("parity-rococo-v2.0"),
152152
authoring_version: 0,
153-
spec_version: 1_006_001,
153+
spec_version: 1_006_002,
154154
impl_version: 0,
155155
apis: RUNTIME_API_VERSIONS,
156156
transaction_version: 24,
@@ -1142,8 +1142,7 @@ impl auctions::Config for Runtime {
11421142

11431143
impl identity_migrator::Config for Runtime {
11441144
type RuntimeEvent = RuntimeEvent;
1145-
// To be changed to `EnsureSigned` once there is a People Chain to migrate to.
1146-
type Reaper = EnsureRoot<AccountId>;
1145+
type Reaper = EnsureSigned<AccountId>;
11471146
type ReapIdentityHandler = ToParachainIdentityReaper<Runtime, Self::AccountId>;
11481147
type WeightInfo = weights::runtime_common_identity_migrator::WeightInfo<Runtime>;
11491148
}

substrate/frame/identity/src/lib.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,16 +1395,21 @@ impl<T: Config> Pallet<T> {
13951395
},
13961396
)?;
13971397

1398-
// Subs Deposit
1399-
let new_subs_deposit = SubsOf::<T>::try_mutate(
1400-
&target,
1401-
|(current_subs_deposit, subs_of)| -> Result<BalanceOf<T>, DispatchError> {
1402-
let new_subs_deposit = Self::subs_deposit(subs_of.len() as u32);
1403-
Self::rejig_deposit(&target, *current_subs_deposit, new_subs_deposit)?;
1404-
*current_subs_deposit = new_subs_deposit;
1405-
Ok(new_subs_deposit)
1406-
},
1407-
)?;
1398+
let new_subs_deposit = if SubsOf::<T>::contains_key(&target) {
1399+
SubsOf::<T>::try_mutate(
1400+
&target,
1401+
|(current_subs_deposit, subs_of)| -> Result<BalanceOf<T>, DispatchError> {
1402+
let new_subs_deposit = Self::subs_deposit(subs_of.len() as u32);
1403+
Self::rejig_deposit(&target, *current_subs_deposit, new_subs_deposit)?;
1404+
*current_subs_deposit = new_subs_deposit;
1405+
Ok(new_subs_deposit)
1406+
},
1407+
)?
1408+
} else {
1409+
// If the item doesn't exist, there is no "old" deposit, and the new one is zero, so no
1410+
// need to call rejig, it'd just be zero -> zero.
1411+
Zero::zero()
1412+
};
14081413
Ok((new_id_deposit, new_subs_deposit))
14091414
}
14101415

substrate/frame/identity/src/tests.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,57 @@ fn poke_deposit_works() {
952952
});
953953
}
954954

955+
#[test]
956+
fn poke_deposit_does_not_insert_new_subs_storage() {
957+
new_test_ext().execute_with(|| {
958+
let [_, _, _, _, ten, _, _, _] = accounts();
959+
let ten_info = infoof_ten();
960+
// Set a custom registration with 0 deposit
961+
IdentityOf::<Test>::insert::<
962+
_,
963+
(
964+
Registration<u64, MaxRegistrars, IdentityInfo<MaxAdditionalFields>>,
965+
Option<Username<Test>>,
966+
),
967+
>(
968+
&ten,
969+
(
970+
Registration {
971+
judgements: Default::default(),
972+
deposit: Zero::zero(),
973+
info: ten_info.clone(),
974+
},
975+
None::<Username<Test>>,
976+
),
977+
);
978+
assert!(Identity::identity(ten.clone()).is_some());
979+
980+
// Balance is free
981+
assert_eq!(Balances::free_balance(ten.clone()), 1000);
982+
983+
// poke
984+
assert_ok!(Identity::poke_deposit(&ten));
985+
986+
// free balance reduced correctly
987+
let id_deposit = id_deposit(&ten_info);
988+
assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit);
989+
// new registration deposit is 10
990+
assert_eq!(
991+
Identity::identity(&ten),
992+
Some((
993+
Registration {
994+
judgements: Default::default(),
995+
deposit: id_deposit,
996+
info: infoof_ten()
997+
},
998+
None
999+
))
1000+
);
1001+
// No new subs storage item.
1002+
assert!(!SubsOf::<Test>::contains_key(&ten));
1003+
});
1004+
}
1005+
9551006
#[test]
9561007
fn adding_and_removing_authorities_should_work() {
9571008
new_test_ext().execute_with(|| {

0 commit comments

Comments
 (0)