From 66f1557375609f65bb23577e4d9d0aae7db94c15 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 09:54:39 -0400 Subject: [PATCH 01/29] To turbo --- substrate/frame/identity/src/legacy.rs | 2 +- substrate/frame/identity/src/lib.rs | 68 +++++++++++++------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/substrate/frame/identity/src/legacy.rs b/substrate/frame/identity/src/legacy.rs index 60e812c2238b..00882d02566a 100644 --- a/substrate/frame/identity/src/legacy.rs +++ b/substrate/frame/identity/src/legacy.rs @@ -172,7 +172,7 @@ impl> Default for IdentityInfo { impl> IdentityInfo { pub(crate) fn fields(&self) -> BitFlags { - let mut res = >::empty(); + let mut res = BitFlags::::empty(); if !self.display.is_none() { res.insert(IdentityField::Display); } diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 5a36101cc2f7..7a4a9c6becfc 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -413,7 +413,7 @@ pub mod pallet { T::RegistrarOrigin::ensure_origin(origin)?; let account = T::Lookup::lookup(account)?; - let (i, registrar_count) = >::try_mutate( + let (i, registrar_count) = Registrars::::try_mutate( |registrars| -> Result<(RegistrarIndex, usize), DispatchError> { registrars .try_push(Some(RegistrarInfo { @@ -449,7 +449,7 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - let (mut id, username) = match >::get(&sender) { + let (mut id, username) = match IdentityOf::::get(&sender) { Some((mut id, maybe_username)) => ( { // Only keep non-positive judgements. @@ -475,7 +475,7 @@ pub mod pallet { id.deposit = new_deposit; let judgements = id.judgements.len(); - >::insert(&sender, (id, username)); + IdentityOf::::insert(&sender, (id, username)); Self::deposit_event(Event::IdentitySet { who: sender }); Ok(Some(T::WeightInfo::set_identity(judgements as u32)).into()) @@ -505,13 +505,13 @@ pub mod pallet { subs: Vec<(T::AccountId, Data)>, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - ensure!(>::contains_key(&sender), Error::::NotFound); + ensure!(IdentityOf::::contains_key(&sender), Error::::NotFound); ensure!( subs.len() <= T::MaxSubAccounts::get() as usize, Error::::TooManySubAccounts ); - let (old_deposit, old_ids) = >::get(&sender); + let (old_deposit, old_ids) = SubsOf::::get(&sender); let new_deposit = Self::subs_deposit(subs.len() as u32); let not_other_sub = @@ -527,19 +527,19 @@ pub mod pallet { // do nothing if they're equal. for s in old_ids.iter() { - >::remove(s); + SuperOf::::remove(s); } let mut ids = BoundedVec::::default(); for (id, name) in subs { - >::insert(&id, (sender.clone(), name)); + SuperOf::::insert(&id, (sender.clone(), name)); ids.try_push(id).expect("subs length is less than T::MaxSubAccounts; qed"); } let new_subs = ids.len(); if ids.is_empty() { - >::remove(&sender); + SubsOf::::remove(&sender); } else { - >::insert(&sender, (new_deposit, ids)); + SubsOf::::insert(&sender, (new_deposit, ids)); } Ok(Some( @@ -566,12 +566,12 @@ pub mod pallet { pub fn clear_identity(origin: OriginFor) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - let (subs_deposit, sub_ids) = >::take(&sender); + let (subs_deposit, sub_ids) = SubsOf::::take(&sender); let (id, maybe_username) = - >::take(&sender).ok_or(Error::::NoIdentity)?; + IdentityOf::::take(&sender).ok_or(Error::::NoIdentity)?; let deposit = id.total_deposit().saturating_add(subs_deposit); for sub in sub_ids.iter() { - >::remove(sub); + SuperOf::::remove(sub); } if let Some(username) = maybe_username { AccountOfUsername::::remove(username); @@ -614,13 +614,13 @@ pub mod pallet { #[pallet::compact] max_fee: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - let registrars = >::get(); + let registrars = Registrars::::get(); let registrar = registrars .get(reg_index as usize) .and_then(Option::as_ref) .ok_or(Error::::EmptyIndex)?; ensure!(max_fee >= registrar.fee, Error::::FeeChanged); - let (mut id, username) = >::get(&sender).ok_or(Error::::NoIdentity)?; + let (mut id, username) = IdentityOf::::get(&sender).ok_or(Error::::NoIdentity)?; let item = (reg_index, Judgement::FeePaid(registrar.fee)); match id.judgements.binary_search_by_key(®_index, |x| x.0) { @@ -637,7 +637,7 @@ pub mod pallet { T::Currency::reserve(&sender, registrar.fee)?; let judgements = id.judgements.len(); - >::insert(&sender, (id, username)); + IdentityOf::::insert(&sender, (id, username)); Self::deposit_event(Event::JudgementRequested { who: sender, @@ -664,7 +664,7 @@ pub mod pallet { reg_index: RegistrarIndex, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - let (mut id, username) = >::get(&sender).ok_or(Error::::NoIdentity)?; + let (mut id, username) = IdentityOf::::get(&sender).ok_or(Error::::NoIdentity)?; let pos = id .judgements @@ -679,7 +679,7 @@ pub mod pallet { let err_amount = T::Currency::unreserve(&sender, fee); debug_assert!(err_amount.is_zero()); let judgements = id.judgements.len(); - >::insert(&sender, (id, username)); + IdentityOf::::insert(&sender, (id, username)); Self::deposit_event(Event::JudgementUnrequested { who: sender, @@ -705,7 +705,7 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; - let registrars = >::mutate(|rs| -> Result { + let registrars = Registrars::::mutate(|rs| -> Result { rs.get_mut(index as usize) .and_then(|x| x.as_mut()) .and_then(|r| { @@ -739,7 +739,7 @@ pub mod pallet { let who = ensure_signed(origin)?; let new = T::Lookup::lookup(new)?; - let registrars = >::mutate(|rs| -> Result { + let registrars = Registrars::::mutate(|rs| -> Result { rs.get_mut(index as usize) .and_then(|x| x.as_mut()) .and_then(|r| { @@ -773,7 +773,7 @@ pub mod pallet { let who = ensure_signed(origin)?; let registrars = - >::mutate(|registrars| -> Result { + Registrars::::mutate(|registrars| -> Result { let registrar = registrars .get_mut(index as usize) .and_then(|r| r.as_mut()) @@ -813,13 +813,13 @@ pub mod pallet { let sender = ensure_signed(origin)?; let target = T::Lookup::lookup(target)?; ensure!(!judgement.has_deposit(), Error::::InvalidJudgement); - >::get() + Registrars::::get() .get(reg_index as usize) .and_then(Option::as_ref) .filter(|r| r.account == sender) .ok_or(Error::::InvalidIndex)?; let (mut id, username) = - >::get(&target).ok_or(Error::::InvalidTarget)?; + IdentityOf::::get(&target).ok_or(Error::::InvalidTarget)?; if T::Hashing::hash_of(&id.info) != identity { return Err(Error::::JudgementForDifferentIdentity.into()) @@ -846,7 +846,7 @@ pub mod pallet { } let judgements = id.judgements.len(); - >::insert(&target, (id, username)); + IdentityOf::::insert(&target, (id, username)); Self::deposit_event(Event::JudgementGiven { target, registrar_index: reg_index }); Ok(Some(T::WeightInfo::provide_judgement(judgements as u32)).into()) @@ -878,12 +878,12 @@ pub mod pallet { // Figure out who we're meant to be clearing. let target = T::Lookup::lookup(target)?; // Grab their deposit (and check that they have one). - let (subs_deposit, sub_ids) = >::take(&target); + let (subs_deposit, sub_ids) = SubsOf::::take(&target); let (id, maybe_username) = - >::take(&target).ok_or(Error::::NoIdentity)?; + IdentityOf::::take(&target).ok_or(Error::::NoIdentity)?; let deposit = id.total_deposit().saturating_add(subs_deposit); for sub in sub_ids.iter() { - >::remove(sub); + SuperOf::::remove(sub); } if let Some(username) = maybe_username { AccountOfUsername::::remove(username); @@ -1209,7 +1209,7 @@ impl Pallet { /// Calculate the deposit required for a number of `sub` accounts. fn subs_deposit(subs: u32) -> BalanceOf { - T::SubAccountDeposit::get().saturating_mul(>::from(subs)) + T::SubAccountDeposit::get().saturating_mul(BalanceOf::::from(subs)) } /// Take the `current` deposit that `who` is holding, and update it to a `new` one. @@ -1239,7 +1239,7 @@ impl Pallet { /// Calculate the deposit required for an identity. fn calculate_identity_deposit(info: &T::IdentityInformation) -> BalanceOf { let bytes = info.encoded_size() as u32; - let byte_deposit = T::ByteDeposit::get().saturating_mul(>::from(bytes)); + let byte_deposit = T::ByteDeposit::get().saturating_mul(BalanceOf::::from(bytes)); T::BasicDeposit::get().saturating_add(byte_deposit) } @@ -1293,7 +1293,7 @@ impl Pallet { pub fn insert_username(who: &T::AccountId, username: Username) { // Check if they already have a primary. If so, leave it. If not, set it. // Likewise, check if they have an identity. If not, give them a minimal one. - let (reg, primary_username, new_is_primary) = match >::get(&who) { + let (reg, primary_username, new_is_primary) = match IdentityOf::::get(&who) { // User has an existing Identity and a primary username. Leave it. Some((reg, Some(primary))) => (reg, primary, false), // User has an Identity but no primary. Set the new one as primary. @@ -1348,15 +1348,15 @@ impl Pallet { pub fn reap_identity(who: &T::AccountId) -> Result<(u32, u32, u32), DispatchError> { // `take` any storage items keyed by `target` // identity - let (id, _maybe_username) = >::take(&who).ok_or(Error::::NoIdentity)?; + let (id, _maybe_username) = IdentityOf::::take(&who).ok_or(Error::::NoIdentity)?; let registrars = id.judgements.len() as u32; let encoded_byte_size = id.info.encoded_size() as u32; // subs - let (subs_deposit, sub_ids) = >::take(&who); + let (subs_deposit, sub_ids) = SubsOf::::take(&who); let actual_subs = sub_ids.len() as u32; for sub in sub_ids.iter() { - >::remove(sub); + SuperOf::::remove(sub); } // unreserve any deposits @@ -1386,7 +1386,7 @@ impl Pallet { // Calculate what deposit should be let encoded_byte_size = reg.info.encoded_size() as u32; let byte_deposit = - T::ByteDeposit::get().saturating_mul(>::from(encoded_byte_size)); + T::ByteDeposit::get().saturating_mul(BalanceOf::::from(encoded_byte_size)); let new_id_deposit = T::BasicDeposit::get().saturating_add(byte_deposit); // Update account @@ -1445,7 +1445,7 @@ impl Pallet { ) -> DispatchResult { let mut sub_accounts = BoundedVec::::default(); for (sub, name) in subs { - >::insert(&sub, (who.clone(), name)); + SuperOf::::insert(&sub, (who.clone(), name)); sub_accounts .try_push(sub) .expect("benchmark should not pass more than T::MaxSubAccounts"); From a3d5668c2a9d516ad27529eae8c9cf61bc3fba01 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 09:57:35 -0400 Subject: [PATCH 02/29] Remove identity getter --- substrate/frame/identity/src/lib.rs | 1 - substrate/frame/identity/src/tests.rs | 36 +++++++++++++-------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 7a4a9c6becfc..41c80a0c4bff 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -213,7 +213,6 @@ pub mod pallet { /// /// TWOX-NOTE: OK ― `AccountId` is a secure hash. #[pallet::storage] - #[pallet::getter(fn identity)] pub(super) type IdentityOf = StorageMap< _, Twox64Concat, diff --git a/substrate/frame/identity/src/tests.rs b/substrate/frame/identity/src/tests.rs index 60579a23b91b..43e3ca5b3146 100644 --- a/substrate/frame/identity/src/tests.rs +++ b/substrate/frame/identity/src/tests.rs @@ -412,7 +412,7 @@ fn registration_should_work() { RuntimeOrigin::signed(ten.clone()), Box::new(ten_info.clone()) )); - assert_eq!(Identity::identity(ten.clone()).unwrap().0.info, ten_info); + assert_eq!(IdentityOf::::get(ten.clone()).unwrap().0.info, ten_info); assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit); assert_ok!(Identity::clear_identity(RuntimeOrigin::signed(ten.clone()))); assert_eq!(Balances::free_balance(ten.clone()), 1000); @@ -495,7 +495,7 @@ fn uninvited_judgement_should_work() { Judgement::Reasonable, identity_hash )); - assert_eq!(Identity::identity(ten).unwrap().0.judgements, vec![(0, Judgement::Reasonable)]); + assert_eq!(IdentityOf::::get(ten).unwrap().0.judgements, vec![(0, Judgement::Reasonable)]); }); } @@ -516,7 +516,7 @@ fn clearing_judgement_should_work() { BlakeTwo256::hash_of(&infoof_ten()) )); assert_ok!(Identity::clear_identity(RuntimeOrigin::signed(ten.clone()))); - assert_eq!(Identity::identity(ten), None); + assert_eq!(IdentityOf::::get(ten), None); }); } @@ -529,7 +529,7 @@ fn killing_slashing_should_work() { assert_ok!(Identity::set_identity(RuntimeOrigin::signed(ten.clone()), Box::new(ten_info))); assert_noop!(Identity::kill_identity(RuntimeOrigin::signed(one), ten.clone()), BadOrigin); assert_ok!(Identity::kill_identity(RuntimeOrigin::root(), ten.clone())); - assert_eq!(Identity::identity(ten.clone()), None); + assert_eq!(IdentityOf::::get(ten.clone()), None); assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit); assert_noop!( Identity::kill_identity(RuntimeOrigin::root(), ten), @@ -868,7 +868,7 @@ fn reap_identity_works() { // reap assert_ok!(Identity::reap_identity(&ten)); // no identity or subs - assert!(Identity::identity(ten.clone()).is_none()); + assert!(IdentityOf::::get(ten.clone()).is_none()); assert!(Identity::super_of(twenty).is_none()); // balance is unreserved assert_eq!(Balances::free_balance(ten), 1000); @@ -898,7 +898,7 @@ fn poke_deposit_works() { None::>, ), ); - assert!(Identity::identity(ten.clone()).is_some()); + assert!(IdentityOf::::get(ten.clone()).is_some()); // Set a sub with zero deposit SubsOf::::insert::<_, (u64, BoundedVec, ConstU32<2>>)>( &ten, @@ -917,7 +917,7 @@ fn poke_deposit_works() { assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit - subs_deposit); // new registration deposit is 10 assert_eq!( - Identity::identity(&ten), + IdentityOf::::get(&ten), Some(( Registration { judgements: Default::default(), @@ -955,7 +955,7 @@ fn poke_deposit_does_not_insert_new_subs_storage() { None::>, ), ); - assert!(Identity::identity(ten.clone()).is_some()); + assert!(IdentityOf::::get(ten.clone()).is_some()); // Balance is free assert_eq!(Balances::free_balance(ten.clone()), 1000); @@ -968,7 +968,7 @@ fn poke_deposit_does_not_insert_new_subs_storage() { assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit); // new registration deposit is 10 assert_eq!( - Identity::identity(&ten), + IdentityOf::::get(&ten), Some(( Registration { judgements: Default::default(), @@ -1059,7 +1059,7 @@ fn set_username_with_signature_without_existing_identity_should_work() { // Even though user has no balance and no identity, they get a default one for free. assert_eq!( - Identity::identity(&who_account), + IdentityOf::::get(&who_account), Some(( Registration { judgements: Default::default(), @@ -1116,7 +1116,7 @@ fn set_username_with_signature_with_existing_identity_should_work() { )); assert_eq!( - Identity::identity(&who_account), + IdentityOf::::get(&who_account), Some(( Registration { judgements: Default::default(), @@ -1199,7 +1199,7 @@ fn set_username_with_bytes_signature_should_work() { // The username in storage should not include ``. As in, it's the original // `username_to_sign`. assert_eq!( - Identity::identity(&who_account), + IdentityOf::::get(&who_account), Some(( Registration { judgements: Default::default(), @@ -1259,7 +1259,7 @@ fn set_username_with_acceptance_should_work() { assert!(PendingUsernames::::get::<&Username>(&full_username).is_none()); // Check Identity storage assert_eq!( - Identity::identity(&who), + IdentityOf::::get(&who), Some(( Registration { judgements: Default::default(), @@ -1414,7 +1414,7 @@ fn setting_primary_should_work() { // First username set as primary. assert_eq!( - Identity::identity(&who_account), + IdentityOf::::get(&who_account), Some(( Registration { judgements: Default::default(), @@ -1440,7 +1440,7 @@ fn setting_primary_should_work() { // The primary is still the first username. assert_eq!( - Identity::identity(&who_account), + IdentityOf::::get(&who_account), Some(( Registration { judgements: Default::default(), @@ -1468,7 +1468,7 @@ fn setting_primary_should_work() { // The primary is now the second username. assert_eq!( - Identity::identity(&who_account), + IdentityOf::::get(&who_account), Some(( Registration { judgements: Default::default(), @@ -1673,7 +1673,7 @@ fn removing_dangling_usernames_should_work() { // The primary should still be the first one. assert_eq!( - Identity::identity(&who_account), + IdentityOf::::get(&who_account), Some(( Registration { judgements: Default::default(), @@ -1707,7 +1707,7 @@ fn removing_dangling_usernames_should_work() { assert_ok!(Identity::clear_identity(RuntimeOrigin::signed(who_account.clone()),)); // Identity is gone - assert!(Identity::identity(who_account.clone()).is_none()); + assert!(IdentityOf::::get(who_account.clone()).is_none()); // The reverse lookup of the primary is gone. assert!(AccountOfUsername::::get::<&Username>(&username_to_sign).is_none()); From 5813a55c88d24a3c8677eef68e6829c430ddeaaa Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 09:58:56 -0400 Subject: [PATCH 03/29] Remove super of getter --- substrate/frame/identity/src/lib.rs | 1 - substrate/frame/identity/src/tests.rs | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 41c80a0c4bff..872b0d86ab2f 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -224,7 +224,6 @@ pub mod pallet { /// The super-identity of an alternative "sub" identity together with its name, within that /// context. If the account is not some other account's sub-identity, then just `None`. #[pallet::storage] - #[pallet::getter(fn super_of)] pub(super) type SuperOf = StorageMap<_, Blake2_128Concat, T::AccountId, (T::AccountId, Data), OptionQuery>; diff --git a/substrate/frame/identity/src/tests.rs b/substrate/frame/identity/src/tests.rs index 43e3ca5b3146..0ec0e2325051 100644 --- a/substrate/frame/identity/src/tests.rs +++ b/substrate/frame/identity/src/tests.rs @@ -560,7 +560,7 @@ fn setting_subaccounts_should_work() { (sub_deposit, vec![twenty.clone()].try_into().unwrap()) ); assert_eq!( - Identity::super_of(twenty.clone()), + SuperOf::::get(twenty.clone()), Some((ten.clone(), Data::Raw(vec![40; 1].try_into().unwrap()))) ); @@ -573,11 +573,11 @@ fn setting_subaccounts_should_work() { (2 * sub_deposit, vec![twenty.clone(), thirty.clone()].try_into().unwrap()) ); assert_eq!( - Identity::super_of(twenty.clone()), + SuperOf::::get(twenty.clone()), Some((ten.clone(), Data::Raw(vec![40; 1].try_into().unwrap()))) ); assert_eq!( - Identity::super_of(thirty.clone()), + SuperOf::::get(thirty.clone()), Some((ten.clone(), Data::Raw(vec![50; 1].try_into().unwrap()))) ); @@ -590,13 +590,13 @@ fn setting_subaccounts_should_work() { Identity::subs_of(ten.clone()), (2 * sub_deposit, vec![forty.clone(), thirty.clone()].try_into().unwrap()) ); - assert_eq!(Identity::super_of(twenty.clone()), None); + assert_eq!(SuperOf::::get(twenty.clone()), None); assert_eq!( - Identity::super_of(thirty.clone()), + SuperOf::::get(thirty.clone()), Some((ten.clone(), Data::Raw(vec![50; 1].try_into().unwrap()))) ); assert_eq!( - Identity::super_of(forty.clone()), + SuperOf::::get(forty.clone()), Some((ten.clone(), Data::Raw(vec![60; 1].try_into().unwrap()))) ); @@ -604,8 +604,8 @@ fn setting_subaccounts_should_work() { assert_ok!(Identity::set_subs(RuntimeOrigin::signed(ten.clone()), vec![])); assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit); assert_eq!(Identity::subs_of(ten.clone()), (0, BoundedVec::default())); - assert_eq!(Identity::super_of(thirty.clone()), None); - assert_eq!(Identity::super_of(forty), None); + assert_eq!(SuperOf::::get(thirty.clone()), None); + assert_eq!(SuperOf::::get(forty), None); subs.push((twenty, Data::Raw(vec![40; 1].try_into().unwrap()))); assert_noop!( @@ -631,7 +631,7 @@ fn clearing_account_should_remove_subaccounts_and_refund() { )); assert_ok!(Identity::clear_identity(RuntimeOrigin::signed(ten.clone()))); assert_eq!(Balances::free_balance(ten), 1000); - assert!(Identity::super_of(twenty).is_none()); + assert!(SuperOf::::get(twenty).is_none()); }); } @@ -651,7 +651,7 @@ fn killing_account_should_remove_subaccounts_and_not_refund() { assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit - sub_deposit); assert_ok!(Identity::kill_identity(RuntimeOrigin::root(), ten.clone())); assert_eq!(Balances::free_balance(ten), 1000 - id_deposit - sub_deposit); - assert!(Identity::super_of(twenty).is_none()); + assert!(SuperOf::::get(twenty).is_none()); }); } @@ -869,7 +869,7 @@ fn reap_identity_works() { assert_ok!(Identity::reap_identity(&ten)); // no identity or subs assert!(IdentityOf::::get(ten.clone()).is_none()); - assert!(Identity::super_of(twenty).is_none()); + assert!(SuperOf::::get(twenty).is_none()); // balance is unreserved assert_eq!(Balances::free_balance(ten), 1000); }); From e33498617dc3fe718b7f89401eb148a30d690a69 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 10:00:31 -0400 Subject: [PATCH 04/29] Remove subs of getter --- substrate/frame/identity/src/lib.rs | 1 - substrate/frame/identity/src/tests.rs | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 872b0d86ab2f..d729205bb5b2 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -233,7 +233,6 @@ pub mod pallet { /// /// TWOX-NOTE: OK ― `AccountId` is a secure hash. #[pallet::storage] - #[pallet::getter(fn subs_of)] pub(super) type SubsOf = StorageMap< _, Twox64Concat, diff --git a/substrate/frame/identity/src/tests.rs b/substrate/frame/identity/src/tests.rs index 0ec0e2325051..ef6e49581399 100644 --- a/substrate/frame/identity/src/tests.rs +++ b/substrate/frame/identity/src/tests.rs @@ -556,7 +556,7 @@ fn setting_subaccounts_should_work() { assert_ok!(Identity::set_subs(RuntimeOrigin::signed(ten.clone()), subs.clone())); assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit - sub_deposit); assert_eq!( - Identity::subs_of(ten.clone()), + SubsOf::::get(ten.clone()), (sub_deposit, vec![twenty.clone()].try_into().unwrap()) ); assert_eq!( @@ -569,7 +569,7 @@ fn setting_subaccounts_should_work() { assert_ok!(Identity::set_subs(RuntimeOrigin::signed(ten.clone()), subs.clone())); assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit - 2 * sub_deposit); assert_eq!( - Identity::subs_of(ten.clone()), + SubsOf::::get(ten.clone()), (2 * sub_deposit, vec![twenty.clone(), thirty.clone()].try_into().unwrap()) ); assert_eq!( @@ -587,7 +587,7 @@ fn setting_subaccounts_should_work() { // no change in the balance assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit - 2 * sub_deposit); assert_eq!( - Identity::subs_of(ten.clone()), + SubsOf::::get(ten.clone()), (2 * sub_deposit, vec![forty.clone(), thirty.clone()].try_into().unwrap()) ); assert_eq!(SuperOf::::get(twenty.clone()), None); @@ -603,7 +603,7 @@ fn setting_subaccounts_should_work() { // clear assert_ok!(Identity::set_subs(RuntimeOrigin::signed(ten.clone()), vec![])); assert_eq!(Balances::free_balance(ten.clone()), 1000 - id_deposit); - assert_eq!(Identity::subs_of(ten.clone()), (0, BoundedVec::default())); + assert_eq!(SubsOf::::get(ten.clone()), (0, BoundedVec::default())); assert_eq!(SuperOf::::get(thirty.clone()), None); assert_eq!(SuperOf::::get(forty), None); @@ -928,7 +928,7 @@ fn poke_deposit_works() { )) ); // new subs deposit is 10 vvvvvvvvvvvv - assert_eq!(Identity::subs_of(ten), (subs_deposit, vec![twenty].try_into().unwrap())); + assert_eq!(SubsOf::::get(ten), (subs_deposit, vec![twenty].try_into().unwrap())); }); } From d94cbaf46c29c72eb24751786c0b50a737d04c4b Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 10:24:36 -0400 Subject: [PATCH 05/29] Remove registrars getter --- substrate/frame/identity/src/lib.rs | 3 +-- substrate/frame/identity/src/tests.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index d729205bb5b2..2a94a9bf3c80 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -246,7 +246,6 @@ pub mod pallet { /// /// The index into this can be cast to `RegistrarIndex` to get a valid value. #[pallet::storage] - #[pallet::getter(fn registrars)] pub(super) type Registrars = StorageValue< _, BoundedVec< @@ -599,7 +598,7 @@ pub mod pallet { /// - `max_fee`: The maximum fee that may be paid. This should just be auto-populated as: /// /// ```nocompile - /// Self::registrars().get(reg_index).unwrap().fee + /// Registrars::::get().get(reg_index).unwrap().fee /// ``` /// /// Emits `JudgementRequested` if successful. diff --git a/substrate/frame/identity/src/tests.rs b/substrate/frame/identity/src/tests.rs index ef6e49581399..fd4229091c8d 100644 --- a/substrate/frame/identity/src/tests.rs +++ b/substrate/frame/identity/src/tests.rs @@ -376,7 +376,7 @@ fn adding_registrar_should_work() { let fields = IdentityField::Display | IdentityField::Legal; assert_ok!(Identity::set_fields(RuntimeOrigin::signed(three.clone()), 0, fields.bits())); assert_eq!( - Identity::registrars(), + Registrars:: Date: Sat, 25 May 2024 10:26:17 -0400 Subject: [PATCH 06/29] Remove authority getter --- substrate/frame/identity/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 2a94a9bf3c80..d98c41f113f3 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -263,7 +263,6 @@ pub mod pallet { /// A map of the accounts who are authorized to grant usernames. #[pallet::storage] - #[pallet::getter(fn authority)] pub(super) type UsernameAuthorities = StorageMap<_, Twox64Concat, T::AccountId, AuthorityPropertiesOf, OptionQuery>; From 4e614bfb0c44540991243818f752a8e8b9b101a5 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 10:27:37 -0400 Subject: [PATCH 07/29] Remove username getter --- substrate/frame/identity/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index d98c41f113f3..21e932a7f292 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -272,7 +272,6 @@ pub mod pallet { /// Multiple usernames may map to the same `AccountId`, but `IdentityOf` will only map to one /// primary username. #[pallet::storage] - #[pallet::getter(fn username)] pub(super) type AccountOfUsername = StorageMap<_, Blake2_128Concat, Username, T::AccountId, OptionQuery>; From c05163f3f42acb1170e1e739542e5f8c7014b62b Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 10:28:35 -0400 Subject: [PATCH 08/29] Remove preapproved_usernames getter --- substrate/frame/identity/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 21e932a7f292..3e5962e985f3 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -282,7 +282,6 @@ pub mod pallet { /// /// First tuple item is the account and second is the acceptance deadline. #[pallet::storage] - #[pallet::getter(fn preapproved_usernames)] pub type PendingUsernames = StorageMap< _, Blake2_128Concat, From 8e90b029956dc037661cdf4f188ba5623418da1a Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 10:38:46 -0400 Subject: [PATCH 09/29] Fix missing > --- substrate/frame/identity/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/identity/src/tests.rs b/substrate/frame/identity/src/tests.rs index fd4229091c8d..6304b76c5f83 100644 --- a/substrate/frame/identity/src/tests.rs +++ b/substrate/frame/identity/src/tests.rs @@ -376,7 +376,7 @@ fn adding_registrar_should_work() { let fields = IdentityField::Display | IdentityField::Legal; assert_ok!(Identity::set_fields(RuntimeOrigin::signed(three.clone()), 0, fields.bits())); assert_eq!( - Registrars::::get(), vec![Some(RegistrarInfo { account: three, fee: 10, fields: fields.bits() })] ); }); From 510d0a500de3e85809122b5bdd6e7e01247ebb02 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 11:04:50 -0400 Subject: [PATCH 10/29] Make storage public --- substrate/frame/identity/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 3e5962e985f3..4c5ceed85f7d 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -213,7 +213,7 @@ pub mod pallet { /// /// TWOX-NOTE: OK ― `AccountId` is a secure hash. #[pallet::storage] - pub(super) type IdentityOf = StorageMap< + pub type IdentityOf = StorageMap< _, Twox64Concat, T::AccountId, @@ -224,7 +224,7 @@ pub mod pallet { /// The super-identity of an alternative "sub" identity together with its name, within that /// context. If the account is not some other account's sub-identity, then just `None`. #[pallet::storage] - pub(super) type SuperOf = + pub type SuperOf = StorageMap<_, Blake2_128Concat, T::AccountId, (T::AccountId, Data), OptionQuery>; /// Alternative "sub" identities of this account. @@ -233,7 +233,7 @@ pub mod pallet { /// /// TWOX-NOTE: OK ― `AccountId` is a secure hash. #[pallet::storage] - pub(super) type SubsOf = StorageMap< + pub type SubsOf = StorageMap< _, Twox64Concat, T::AccountId, @@ -246,7 +246,7 @@ pub mod pallet { /// /// The index into this can be cast to `RegistrarIndex` to get a valid value. #[pallet::storage] - pub(super) type Registrars = StorageValue< + pub type Registrars = StorageValue< _, BoundedVec< Option< @@ -263,7 +263,7 @@ pub mod pallet { /// A map of the accounts who are authorized to grant usernames. #[pallet::storage] - pub(super) type UsernameAuthorities = + pub type UsernameAuthorities = StorageMap<_, Twox64Concat, T::AccountId, AuthorityPropertiesOf, OptionQuery>; /// Reverse lookup from `username` to the `AccountId` that has registered it. The value should @@ -272,7 +272,7 @@ pub mod pallet { /// Multiple usernames may map to the same `AccountId`, but `IdentityOf` will only map to one /// primary username. #[pallet::storage] - pub(super) type AccountOfUsername = + pub type AccountOfUsername = StorageMap<_, Blake2_128Concat, Username, T::AccountId, OptionQuery>; /// Usernames that an authority has granted, but that the account controller has not confirmed From 53b7abc1d45ac0f818761c227e35bce580d28baf Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 11:07:45 -0400 Subject: [PATCH 11/29] remove getter usage from kitchen sink --- substrate/bin/node/runtime/src/impls.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/bin/node/runtime/src/impls.rs b/substrate/bin/node/runtime/src/impls.rs index dbe562857c99..dc57deaf1eef 100644 --- a/substrate/bin/node/runtime/src/impls.rs +++ b/substrate/bin/node/runtime/src/impls.rs @@ -64,8 +64,8 @@ impl IdentityVerifier for AllianceIdentityVerifier { } fn has_good_judgement(who: &AccountId) -> bool { - use pallet_identity::Judgement; - crate::Identity::identity(who) + use pallet_identity::{Judgement, IdentityOf}; + IdentityOf::::get(who) .map(|(registration, _)| registration.judgements) .map_or(false, |judgements| { judgements From 715554831076a97bfc9160b8e1e452372b01c678 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 11:30:10 -0400 Subject: [PATCH 12/29] Update identity usage in kitchen sink --- substrate/bin/node/runtime/src/impls.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/substrate/bin/node/runtime/src/impls.rs b/substrate/bin/node/runtime/src/impls.rs index dc57deaf1eef..87e0754d270d 100644 --- a/substrate/bin/node/runtime/src/impls.rs +++ b/substrate/bin/node/runtime/src/impls.rs @@ -64,7 +64,7 @@ impl IdentityVerifier for AllianceIdentityVerifier { } fn has_good_judgement(who: &AccountId) -> bool { - use pallet_identity::{Judgement, IdentityOf}; + use pallet_identity::{IdentityOf, Judgement}; IdentityOf::::get(who) .map(|(registration, _)| registration.judgements) .map_or(false, |judgements| { @@ -75,7 +75,8 @@ impl IdentityVerifier for AllianceIdentityVerifier { } fn super_account_id(who: &AccountId) -> Option { - crate::Identity::super_of(who).map(|parent| parent.0) + use pallet_identity::SuperOf; + SuperOf::::get(who).map(|parent| parent.0) } } From cf404ec632923bc6ca29db4fa8f2b7c89616b1a0 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 11:30:16 -0400 Subject: [PATCH 13/29] fmt --- substrate/frame/identity/src/tests.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/substrate/frame/identity/src/tests.rs b/substrate/frame/identity/src/tests.rs index 6304b76c5f83..911fe8907c5d 100644 --- a/substrate/frame/identity/src/tests.rs +++ b/substrate/frame/identity/src/tests.rs @@ -495,7 +495,10 @@ fn uninvited_judgement_should_work() { Judgement::Reasonable, identity_hash )); - assert_eq!(IdentityOf::::get(ten).unwrap().0.judgements, vec![(0, Judgement::Reasonable)]); + assert_eq!( + IdentityOf::::get(ten).unwrap().0.judgements, + vec![(0, Judgement::Reasonable)] + ); }); } From 6361ae323eef002ae7d4114302b89ca8ac2c45ab Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 11:35:20 -0400 Subject: [PATCH 14/29] Create pr_9999.prdoc --- prdoc/pr_9999.prdoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 prdoc/pr_9999.prdoc diff --git a/prdoc/pr_9999.prdoc b/prdoc/pr_9999.prdoc new file mode 100644 index 000000000000..7e3cff2e052a --- /dev/null +++ b/prdoc/pr_9999.prdoc @@ -0,0 +1,16 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Removed `pallet::getter` usage from pallet-identity + +doc: + - audience: Runtime Dev + description: | + This PR removed the `pallet::getter`s from `pallet-identity`. + The syntax `StorageItem::::get()` should be used instead. + +crates: + - name: pallet-identity + bump: major + - name: kitchensink-runtime + bump: minor From 86df6c6a9459b953feecda68a654758d16cf07d8 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 25 May 2024 11:41:44 -0400 Subject: [PATCH 15/29] Update prdoc number --- prdoc/{pr_9999.prdoc => pr_4586.prdoc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename prdoc/{pr_9999.prdoc => pr_4586.prdoc} (100%) diff --git a/prdoc/pr_9999.prdoc b/prdoc/pr_4586.prdoc similarity index 100% rename from prdoc/pr_9999.prdoc rename to prdoc/pr_4586.prdoc From 0fa9bb62f9c06147532427c3906b02bfd1379e32 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Mon, 27 May 2024 16:25:41 -0400 Subject: [PATCH 16/29] Update prdoc/pr_4586.prdoc reduce kitchensink bump to patch Co-authored-by: Oliver Tale-Yazdi --- prdoc/pr_4586.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_4586.prdoc b/prdoc/pr_4586.prdoc index 7e3cff2e052a..6a1b427a0434 100644 --- a/prdoc/pr_4586.prdoc +++ b/prdoc/pr_4586.prdoc @@ -13,4 +13,4 @@ crates: - name: pallet-identity bump: major - name: kitchensink-runtime - bump: minor + bump: patch From cec64b1df7041148060d0795889d58e7256c3b3d Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Tue, 28 May 2024 07:35:45 -0400 Subject: [PATCH 17/29] Fix system chain integration tests --- .../people-rococo/src/tests/reap_identity.rs | 21 +++++++++++-------- .../people-westend/src/tests/reap_identity.rs | 21 +++++++++++-------- prdoc/pr_4586.prdoc | 4 ++++ 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs index 3f1f8638d6fa..7528e0447853 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs @@ -41,14 +41,17 @@ use crate::imports::*; use frame_support::BoundedVec; use pallet_balances::Event as BalancesEvent; -use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent}; -use people_rococo_runtime::people::{ - BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain, - IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain, +use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent, IdentityOf, SubsOf}; +use people_rococo_runtime::{ + people::{ + BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain, + IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain, + }, + Runtime as PeopleRuntime, }; use rococo_runtime::{ BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as RococoOrigin, - SubAccountDeposit, + SubAccountDeposit, Runtime as RococoRuntime, }; use rococo_runtime_constants::currency::*; use rococo_system_emulated_network::{ @@ -270,9 +273,9 @@ fn assert_set_id_parachain(id: &Identity) { // No amount should be reserved as deposit amounts are set to 0. let reserved_balance = PeopleRococoBalances::reserved_balance(PeopleRococoSender::get()); assert_eq!(reserved_balance, 0); - assert!(PeopleRococoIdentity::identity(PeopleRococoSender::get()).is_some()); + assert!(IdentityOf::::get(PeopleRococoSender::get()).is_some()); - let (_, sub_accounts) = PeopleRococoIdentity::subs_of(PeopleRococoSender::get()); + let (_, sub_accounts) = SubsOf::::get(PeopleRococoSender::get()); match id.subs { Subs::Zero => assert_eq!(sub_accounts.len(), 0), @@ -318,10 +321,10 @@ fn assert_reap_id_relay(total_deposit: Balance, id: &Identity) { ] ); // Identity should be gone. - assert!(PeopleRococoIdentity::identity(RococoRelaySender::get()).is_none()); + assert!(IdentityOf::::get(RococoRelaySender::get()).is_none()); // Subs should be gone. - let (_, sub_accounts) = RococoIdentity::subs_of(RococoRelaySender::get()); + let (_, sub_accounts) = SubsOf::::get(RococoRelaySender::get()); assert_eq!(sub_accounts.len(), 0); let reserved_balance = RococoBalances::reserved_balance(RococoRelaySender::get()); diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs index 3ed8592918d6..d0bf4b562673 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs @@ -41,14 +41,17 @@ use crate::imports::*; use frame_support::BoundedVec; use pallet_balances::Event as BalancesEvent; -use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent}; -use people_westend_runtime::people::{ - BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain, - IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain, +use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent, IdentityOf, SubsOf}; +use people_westend_runtime::{ + people::{ + BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain, + IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain, + }, + Runtime as PeopleRuntime, }; use westend_runtime::{ BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as WestendOrigin, - SubAccountDeposit, + SubAccountDeposit, Runtime as WestendRuntime, }; use westend_runtime_constants::currency::*; use westend_system_emulated_network::{ @@ -270,9 +273,9 @@ fn assert_set_id_parachain(id: &Identity) { // No amount should be reserved as deposit amounts are set to 0. let reserved_balance = PeopleWestendBalances::reserved_balance(PeopleWestendSender::get()); assert_eq!(reserved_balance, 0); - assert!(PeopleWestendIdentity::identity(PeopleWestendSender::get()).is_some()); + assert!(IdentityOf::::get(PeopleWestendSender::get()).is_some()); - let (_, sub_accounts) = PeopleWestendIdentity::subs_of(PeopleWestendSender::get()); + let (_, sub_accounts) = SubsOf::::get(PeopleWestendSender::get()); match id.subs { Subs::Zero => assert_eq!(sub_accounts.len(), 0), @@ -318,10 +321,10 @@ fn assert_reap_id_relay(total_deposit: Balance, id: &Identity) { ] ); // Identity should be gone. - assert!(PeopleWestendIdentity::identity(WestendRelaySender::get()).is_none()); + assert!(IdentityOf::::get(WestendRelaySender::get()).is_none()); // Subs should be gone. - let (_, sub_accounts) = WestendIdentity::subs_of(WestendRelaySender::get()); + let (_, sub_accounts) = SubsOf::::get(WestendRelaySender::get()); assert_eq!(sub_accounts.len(), 0); let reserved_balance = WestendBalances::reserved_balance(WestendRelaySender::get()); diff --git a/prdoc/pr_4586.prdoc b/prdoc/pr_4586.prdoc index 6a1b427a0434..0f40b6ca8a6d 100644 --- a/prdoc/pr_4586.prdoc +++ b/prdoc/pr_4586.prdoc @@ -14,3 +14,7 @@ crates: bump: major - name: kitchensink-runtime bump: patch + - name: people-rococo-integration-tests + bump: patch + - name: people-westend-integration-tests + bump: patch From ff47fddb409e5fabd10cf486760a8d0b4c6a999d Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Tue, 28 May 2024 07:44:03 -0400 Subject: [PATCH 18/29] Fix pallet alliance issues --- prdoc/pr_4586.prdoc | 2 ++ substrate/frame/alliance/src/mock.rs | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/prdoc/pr_4586.prdoc b/prdoc/pr_4586.prdoc index 0f40b6ca8a6d..01489fdcba5c 100644 --- a/prdoc/pr_4586.prdoc +++ b/prdoc/pr_4586.prdoc @@ -12,6 +12,8 @@ doc: crates: - name: pallet-identity bump: major + - name: pallet-alliance + bump: patch - name: kitchensink-runtime bump: patch - name: people-rococo-integration-tests diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index a9cfd6d0fde0..b89c0df59c4d 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -31,7 +31,7 @@ pub use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy}; use pallet_identity::{ legacy::{IdentityField, IdentityInfo}, - Data, Judgement, + Data, Judgement, IdentityOf, SuperOf, }; pub use crate as pallet_alliance; @@ -161,7 +161,7 @@ impl IdentityVerifier for AllianceIdentityVerifier { fn has_good_judgement(who: &AccountId) -> bool { if let Some(judgements) = - Identity::identity(who).map(|(registration, _)| registration.judgements) + IdentityOf::::get(who).map(|(registration, _)| registration.judgements) { judgements .iter() @@ -172,7 +172,7 @@ impl IdentityVerifier for AllianceIdentityVerifier { } fn super_account_id(who: &AccountId) -> Option { - Identity::super_of(who).map(|parent| parent.0) + SuperOf::::get(who).map(|parent| parent.0) } } From 858bd86918b4008c4f00343e912074db0d114960 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Tue, 28 May 2024 08:00:14 -0400 Subject: [PATCH 19/29] fmt --- .../tests/people/people-rococo/src/tests/reap_identity.rs | 4 ++-- .../tests/people/people-westend/src/tests/reap_identity.rs | 4 ++-- substrate/frame/alliance/src/mock.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs index 7528e0447853..f80df7ec5519 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs @@ -50,8 +50,8 @@ use people_rococo_runtime::{ Runtime as PeopleRuntime, }; use rococo_runtime::{ - BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as RococoOrigin, - SubAccountDeposit, Runtime as RococoRuntime, + BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, Runtime as RococoRuntime, + RuntimeOrigin as RococoOrigin, SubAccountDeposit, }; use rococo_runtime_constants::currency::*; use rococo_system_emulated_network::{ diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs index d0bf4b562673..42bdc0965633 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs @@ -50,8 +50,8 @@ use people_westend_runtime::{ Runtime as PeopleRuntime, }; use westend_runtime::{ - BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as WestendOrigin, - SubAccountDeposit, Runtime as WestendRuntime, + BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, Runtime as WestendRuntime, + RuntimeOrigin as WestendOrigin, SubAccountDeposit, }; use westend_runtime_constants::currency::*; use westend_system_emulated_network::{ diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index b89c0df59c4d..6f3027e9bc85 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -31,7 +31,7 @@ pub use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy}; use pallet_identity::{ legacy::{IdentityField, IdentityInfo}, - Data, Judgement, IdentityOf, SuperOf, + Data, IdentityOf, Judgement, SuperOf, }; pub use crate as pallet_alliance; From 063a83dab88038f951b24af4654bd3f30cba662f Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Mon, 24 Jun 2024 15:05:17 -0400 Subject: [PATCH 20/29] Remove unnecessary semver bumps --- prdoc/pr_4586.prdoc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/prdoc/pr_4586.prdoc b/prdoc/pr_4586.prdoc index 01489fdcba5c..c8b7b4c115e4 100644 --- a/prdoc/pr_4586.prdoc +++ b/prdoc/pr_4586.prdoc @@ -12,11 +12,3 @@ doc: crates: - name: pallet-identity bump: major - - name: pallet-alliance - bump: patch - - name: kitchensink-runtime - bump: patch - - name: people-rococo-integration-tests - bump: patch - - name: people-westend-integration-tests - bump: patch From 9b724efe8d076143986c1770ffbb7f6e2dcded19 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 6 Jul 2024 13:43:02 -0400 Subject: [PATCH 21/29] Replace macro getters with explicit ones --- substrate/frame/identity/src/lib.rs | 57 ++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 577f4efb18ab..d07e7a6754e2 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -118,6 +118,7 @@ pub use types::{ Data, IdentityInformationProvider, Judgement, RegistrarIndex, RegistrarInfo, Registration, }; pub use weights::WeightInfo; +use frame_system::pallet_prelude::*; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -130,7 +131,6 @@ type AccountIdLookupOf = <::Lookup as StaticLookup pub mod pallet { use super::*; use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; #[pallet::config] pub trait Config: frame_system::Config { @@ -1190,6 +1190,61 @@ pub mod pallet { } impl Pallet { + /// Information that is pertinent to identify the entity behind an account. First item is the + /// registration, second is the account's primary username. + /// + /// TWOX-NOTE: OK ― `AccountId` is a secure hash. + pub fn identity(who: T::AccountId) -> Option<(Registration, T::MaxRegistrars, T::IdentityInformation>, Option>)> { + IdentityOf::::get(who) + } + + /// The super-identity of an alternative "sub" identity together with its name, within that + /// context. If the account is not some other account's sub-identity, then just `None`. + pub fn super_of(who: T::AccountId) -> Option<(T::AccountId, Data)> { + SuperOf::::get(who) + } + + /// Alternative "sub" identities of this account. + /// + /// The first item is the deposit, the second is a vector of the accounts. + /// + /// TWOX-NOTE: OK ― `AccountId` is a secure hash. + pub fn subs_of(who: T::AccountId) -> (BalanceOf, BoundedVec) { + SubsOf::::get(who) + } + + /// The set of registrars. Not expected to get very big as can only be added through a + /// special origin (likely a council motion). + /// + /// The index into this can be cast to `RegistrarIndex` to get a valid value. + pub fn registrars() -> BoundedVec< Option< RegistrarInfo< BalanceOf, T::AccountId, ::FieldsIdentifier, >, >, T::MaxRegistrars, > { + Registrars::::get() + } + + /// A map of the accounts who are authorized to grant usernames. + pub fn authority(who: T::AccountId) -> Option> { + UsernameAuthorities::::get(who) + } + + /// Reverse lookup from `username` to the `AccountId` that has registered it. The value should + /// be a key in the `IdentityOf` map, but it may not if the user has cleared their identity. + /// + /// Multiple usernames may map to the same `AccountId`, but `IdentityOf` will only map to one + /// primary username. + pub fn username(username: Username) -> Option { + AccountOfUsername::::get(username) + } + + /// Usernames that an authority has granted, but that the account controller has not confirmed + /// that they want it. Used primarily in cases where the `AccountId` cannot provide a signature + /// because they are a pure proxy, multisig, etc. In order to confirm it, they should call + /// [`Call::accept_username`]. + /// + /// First tuple item is the account and second is the acceptance deadline. + pub fn preapproved_usernames(username: Username) -> Option<(T::AccountId, BlockNumberFor)> { + PendingUsernames::::get(username) + } + /// Get the subs of an account. pub fn subs(who: &T::AccountId) -> Vec<(T::AccountId, Data)> { SubsOf::::get(who) From 6b1f932911745c6e6029567221abf4d011e29da9 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 6 Jul 2024 13:45:10 -0400 Subject: [PATCH 22/29] fmt --- substrate/frame/identity/src/lib.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index d07e7a6754e2..526b7c94df82 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -109,6 +109,7 @@ use frame_support::{ traits::{BalanceStatus, Currency, Get, OnUnbalanced, ReservableCurrency, StorageVersion}, BoundedVec, }; +use frame_system::pallet_prelude::*; pub use pallet::*; use sp_runtime::traits::{ AppendZerosInput, Hash, IdentifyAccount, Saturating, StaticLookup, Verify, Zero, @@ -118,7 +119,6 @@ pub use types::{ Data, IdentityInformationProvider, Judgement, RegistrarIndex, RegistrarInfo, Registration, }; pub use weights::WeightInfo; -use frame_system::pallet_prelude::*; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -1194,7 +1194,12 @@ impl Pallet { /// registration, second is the account's primary username. /// /// TWOX-NOTE: OK ― `AccountId` is a secure hash. - pub fn identity(who: T::AccountId) -> Option<(Registration, T::MaxRegistrars, T::IdentityInformation>, Option>)> { + pub fn identity( + who: T::AccountId, + ) -> Option<( + Registration, T::MaxRegistrars, T::IdentityInformation>, + Option>, + )> { IdentityOf::::get(who) } @@ -1209,7 +1214,9 @@ impl Pallet { /// The first item is the deposit, the second is a vector of the accounts. /// /// TWOX-NOTE: OK ― `AccountId` is a secure hash. - pub fn subs_of(who: T::AccountId) -> (BalanceOf, BoundedVec) { + pub fn subs_of( + who: T::AccountId, + ) -> (BalanceOf, BoundedVec) { SubsOf::::get(who) } @@ -1217,7 +1224,16 @@ impl Pallet { /// special origin (likely a council motion). /// /// The index into this can be cast to `RegistrarIndex` to get a valid value. - pub fn registrars() -> BoundedVec< Option< RegistrarInfo< BalanceOf, T::AccountId, ::FieldsIdentifier, >, >, T::MaxRegistrars, > { + pub fn registrars() -> BoundedVec< + Option< + RegistrarInfo< + BalanceOf, + T::AccountId, + ::FieldsIdentifier, + >, + >, + T::MaxRegistrars, + > { Registrars::::get() } @@ -1241,7 +1257,9 @@ impl Pallet { /// [`Call::accept_username`]. /// /// First tuple item is the account and second is the acceptance deadline. - pub fn preapproved_usernames(username: Username) -> Option<(T::AccountId, BlockNumberFor)> { + pub fn preapproved_usernames( + username: Username, + ) -> Option<(T::AccountId, BlockNumberFor)> { PendingUsernames::::get(username) } From 0302e61d845fd519dc06ede247b25e418026a32e Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Sat, 6 Jul 2024 13:45:57 -0400 Subject: [PATCH 23/29] Update semver bump to minor --- prdoc/pr_4586.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_4586.prdoc b/prdoc/pr_4586.prdoc index c8b7b4c115e4..01ff9f2bcf3f 100644 --- a/prdoc/pr_4586.prdoc +++ b/prdoc/pr_4586.prdoc @@ -11,4 +11,4 @@ doc: crates: - name: pallet-identity - bump: major + bump: minor From 03d34eac338f76ea8b788d156b45ffc67a4c130f Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Mon, 8 Jul 2024 16:55:02 -0400 Subject: [PATCH 24/29] Export people runtime dependency --- .../emulated/tests/people/people-westend/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs index ce1ed9751a2e..a1b921bc576b 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs @@ -38,7 +38,7 @@ mod imports { self, people_westend_emulated_chain::{ genesis::ED as PEOPLE_WESTEND_ED, - people_westend_runtime::{people, xcm_config::XcmConfig as PeopleWestendXcmConfig}, + people_westend_runtime::{people, xcm_config::XcmConfig as PeopleWestendXcmConfig, Runtime as PeopleRuntime}, PeopleWestendParaPallet as PeopleWestendPallet, }, westend_emulated_chain::{ From 65842812f14ea0e200faff14065ef4de2d618789 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Mon, 8 Jul 2024 18:07:43 -0400 Subject: [PATCH 25/29] re-export rococo dependencies --- .../emulated/tests/people/people-rococo/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs index 6c23c2f1f292..e728fbe88ea1 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs @@ -38,7 +38,7 @@ mod imports { pub use rococo_system_emulated_network::{ people_rococo_emulated_chain::{ genesis::ED as PEOPLE_ROCOCO_ED, - people_rococo_runtime::{people, xcm_config::XcmConfig as PeopleRococoXcmConfig}, + people_rococo_runtime::{people, xcm_config::XcmConfig as PeopleRococoXcmConfig, Runtime as PeopleRuntime}, PeopleRococoParaPallet as PeopleRococoPallet, }, rococo_emulated_chain::{ @@ -46,7 +46,7 @@ mod imports { rococo_runtime::{ xcm_config::XcmConfig as RococoXcmConfig, BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as RococoOrigin, - SubAccountDeposit, + SubAccountDeposit, Runtime as RococoRuntime, }, RococoRelayPallet as RococoPallet, }, From f3e943a60d4067a8cd8aee7fd8593653b15fa290 Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Mon, 8 Jul 2024 18:23:59 -0400 Subject: [PATCH 26/29] re-export westend runtime --- .../emulated/tests/people/people-westend/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs index a1b921bc576b..d3c8925a9afb 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs @@ -46,7 +46,7 @@ mod imports { westend_runtime::{ xcm_config::XcmConfig as WestendXcmConfig, BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as WestendOrigin, - SubAccountDeposit, + SubAccountDeposit, Runtime as WestendRuntime, }, WestendRelayPallet as WestendPallet, }, From bc8c275eecbef04d4660a331afbebcdc9aacafaa Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Mon, 8 Jul 2024 21:36:18 -0400 Subject: [PATCH 27/29] fmt --- .../emulated/tests/people/people-rococo/src/lib.rs | 8 +++++--- .../emulated/tests/people/people-westend/src/lib.rs | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs index e728fbe88ea1..c854cbb3ae61 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs @@ -38,15 +38,17 @@ mod imports { pub use rococo_system_emulated_network::{ people_rococo_emulated_chain::{ genesis::ED as PEOPLE_ROCOCO_ED, - people_rococo_runtime::{people, xcm_config::XcmConfig as PeopleRococoXcmConfig, Runtime as PeopleRuntime}, + people_rococo_runtime::{ + people, xcm_config::XcmConfig as PeopleRococoXcmConfig, Runtime as PeopleRuntime, + }, PeopleRococoParaPallet as PeopleRococoPallet, }, rococo_emulated_chain::{ genesis::ED as ROCOCO_ED, rococo_runtime::{ xcm_config::XcmConfig as RococoXcmConfig, BasicDeposit, ByteDeposit, - MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as RococoOrigin, - SubAccountDeposit, Runtime as RococoRuntime, + MaxAdditionalFields, MaxSubAccounts, Runtime as RococoRuntime, + RuntimeOrigin as RococoOrigin, SubAccountDeposit, }, RococoRelayPallet as RococoPallet, }, diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs index d3c8925a9afb..e96a27d77b95 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs @@ -38,15 +38,17 @@ mod imports { self, people_westend_emulated_chain::{ genesis::ED as PEOPLE_WESTEND_ED, - people_westend_runtime::{people, xcm_config::XcmConfig as PeopleWestendXcmConfig, Runtime as PeopleRuntime}, + people_westend_runtime::{ + people, xcm_config::XcmConfig as PeopleWestendXcmConfig, Runtime as PeopleRuntime, + }, PeopleWestendParaPallet as PeopleWestendPallet, }, westend_emulated_chain::{ genesis::ED as WESTEND_ED, westend_runtime::{ xcm_config::XcmConfig as WestendXcmConfig, BasicDeposit, ByteDeposit, - MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as WestendOrigin, - SubAccountDeposit, Runtime as WestendRuntime, + MaxAdditionalFields, MaxSubAccounts, Runtime as WestendRuntime, + RuntimeOrigin as WestendOrigin, SubAccountDeposit, }, WestendRelayPallet as WestendPallet, }, From 7615790b773af4bdbc399c32416cec1637ac1fcd Mon Sep 17 00:00:00 2001 From: "polka.dom" Date: Tue, 9 Jul 2024 12:33:07 -0400 Subject: [PATCH 28/29] Set semver bumps to none --- prdoc/pr_4586.prdoc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/prdoc/pr_4586.prdoc b/prdoc/pr_4586.prdoc index 01ff9f2bcf3f..46d166d0f977 100644 --- a/prdoc/pr_4586.prdoc +++ b/prdoc/pr_4586.prdoc @@ -12,3 +12,11 @@ doc: crates: - name: pallet-identity bump: minor + - name: pallet-alliance + bump: none + - name: kitchensink-runtime + bump: none + - name: people-rococo-integration-tests + bump: none + - name: people-westend-integration-tests + bump: none From b455a802a3c30c243518dac0611cca1855f5a974 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 23 Jul 2024 16:53:25 +0000 Subject: [PATCH 29/29] ".git/.scripts/commands/fmt/fmt.sh" --- .../emulated/tests/people/people-rococo/src/lib.rs | 4 ++-- .../emulated/tests/people/people-westend/src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs index 1bde8f8f352b..3c0533f775e2 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs @@ -39,8 +39,8 @@ mod imports { people_rococo_emulated_chain::{ genesis::ED as PEOPLE_ROCOCO_ED, people_rococo_runtime::{ - people, xcm_config::XcmConfig as PeopleRococoXcmConfig, Runtime as PeopleRuntime, - ExistentialDeposit as PeopleRococoExistentialDeposit, + people, xcm_config::XcmConfig as PeopleRococoXcmConfig, + ExistentialDeposit as PeopleRococoExistentialDeposit, Runtime as PeopleRuntime, }, PeopleRococoParaPallet as PeopleRococoPallet, }, diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs index 309d4884edc3..689409fe5040 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs @@ -39,8 +39,8 @@ mod imports { people_westend_emulated_chain::{ genesis::ED as PEOPLE_WESTEND_ED, people_westend_runtime::{ - people, xcm_config::XcmConfig as PeopleWestendXcmConfig, Runtime as PeopleRuntime, - ExistentialDeposit as PeopleWestendExistentialDeposit, + people, xcm_config::XcmConfig as PeopleWestendXcmConfig, + ExistentialDeposit as PeopleWestendExistentialDeposit, Runtime as PeopleRuntime, }, PeopleWestendParaPallet as PeopleWestendPallet, },