difftreelog
Merge remote-tracking branch 'origin/feat/set-sub-identities' into develop
in: master
6 files changed
Makefilediffbeforeafterboth146 make _bench PALLET=app-promotion PALLET_DIR=app-promotion146 make _bench PALLET=app-promotion PALLET_DIR=app-promotion147 147 148.PHONY: bench148.PHONY: bench149# Disabled: bench-scheduler, bench-collator-selection, bench-rmrk-core, bench-rmrk-equip149# Disabled: bench-scheduler, bench-collator-selection, bench-identity, bench-rmrk-core, bench-rmrk-equip150bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-configuration bench-foreign-assets bench-identity150bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-configuration bench-foreign-assets151151pallets/identity/src/benchmarking.rsdiffbeforeafterboth417 let n in 0..600;417 let n in 0..600;418 use frame_benchmarking::account;418 use frame_benchmarking::account;419 let identities = (0..n).map(|i| (419 let identities = (0..n).map(|i| (420 account("caller", i, 0),420 account("caller", i, SEED),421 Registration::<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields> {421 Registration::<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields> {422 judgements: Default::default(),422 judgements: Default::default(),423 deposit: Default::default(),423 deposit: Default::default(),433 use frame_benchmarking::account;433 use frame_benchmarking::account;434 let origin = T::ForceOrigin::successful_origin();434 let origin = T::ForceOrigin::successful_origin();435 let identities = (0..n).map(|i| (435 let identities = (0..n).map(|i| (436 account("caller", i, 0),436 account("caller", i, SEED),437 Registration::<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields> {437 Registration::<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields> {438 judgements: Default::default(),438 judgements: Default::default(),439 deposit: Default::default(),439 deposit: Default::default(),444 Identity::<T>::force_insert_identities(origin.clone(), identities.clone()),444 Identity::<T>::force_insert_identities(origin.clone(), identities.clone()),445 );445 );446 let identities = identities.into_iter().map(|(acc, _)| acc).collect::<Vec<_>>();446 let identities = identities.into_iter().map(|(acc, _)| acc).collect::<Vec<_>>();447 }: _<T::RuntimeOrigin>(origin, identities)447 }: _<T::RuntimeOrigin>(origin, identities)448449 force_set_subs {450 let s in 0 .. T::MaxSubAccounts::get();451 let n in 0..600;452 use frame_benchmarking::account;453 let identities = (0..n).map(|i| (454 account("caller", i, SEED),455 (456 BalanceOf::<T>::max_value(),457 create_sub_accounts::<T>(&caller, s)?.try_into().unwrap(),458 ),459 )).collect::<Vec<_>>();460 let origin = T::ForceOrigin::successful_origin();461 }: _<T::RuntimeOrigin>(origin, identities)448462449 add_sub {463 add_sub {450 let s in 0 .. T::MaxSubAccounts::get() - 1;464 let s in 0 .. T::MaxSubAccounts::get() - 1;pallets/identity/src/lib.rsdiffbeforeafterboth314 main: T::AccountId,314 main: T::AccountId,315 deposit: BalanceOf<T>,315 deposit: BalanceOf<T>,316 },316 },317 /// A number of identities were forcibly updated with new sub-identities.318 SubIdentitiesInserted { amount: u32 },317 }319 }318320319 #[pallet::call]321 #[pallet::call]1137 ) -> DispatchResult {1139 ) -> DispatchResult {1138 T::ForceOrigin::ensure_origin(origin)?;1140 T::ForceOrigin::ensure_origin(origin)?;1139 for identity in identities.clone() {1141 for identity in identities.clone() {1142 let (_, sub_ids) = <SubsOf<T>>::take(&identity);1140 IdentityOf::<T>::set(identity, None);1143 <IdentityOf<T>>::remove(&identity);1144 for sub in sub_ids.iter() {1145 <SuperOf<T>>::remove(sub);1146 }1141 }1147 }1142 Self::deposit_event(Event::IdentitiesRemoved {1148 Self::deposit_event(Event::IdentitiesRemoved {1143 amount: identities.len() as u32,1149 amount: identities.len() as u32,1144 });1150 });1145 Ok(())1151 Ok(())1146 }1152 }11531154 /// Set sub-identities to be associated with the provided accounts as force origin.1155 ///1156 /// This is not meant to operate in tandem with the identity pallet as is,1157 /// and be instead used to keep identities made and verified externally,1158 /// forbidden from interacting with an ordinary user, since it ignores any safety mechanism.1159 #[pallet::call_index(17)]1160 #[pallet::weight(T::WeightInfo::force_set_subs(1161 T::MaxSubAccounts::get(), // S1162 subs.len() as u32, // N1163 ))]1164 pub fn force_set_subs(1165 origin: OriginFor<T>,1166 subs: Vec<(1167 T::AccountId,1168 (1169 BalanceOf<T>,1170 BoundedVec<(T::AccountId, Data), T::MaxSubAccounts>,1171 ),1172 )>,1173 ) -> DispatchResult {1174 T::ForceOrigin::ensure_origin(origin)?;1175 for identity in subs.clone() {1176 let account = identity.0;1177 let (_, old_subs) = <SubsOf<T>>::get(&account);1178 for old_sub in old_subs {1179 <SuperOf<T>>::remove(old_sub);1180 }11811182 let mut ids = BoundedVec::<T::AccountId, T::MaxSubAccounts>::default();1183 for (id, name) in identity.1 .1 {1184 <SuperOf<T>>::insert(&id, (account.clone(), name));1185 ids.try_push(id)1186 .expect("subs length is less than T::MaxSubAccounts; qed");1187 }11881189 if ids.is_empty() {1190 <SubsOf<T>>::remove(&account);1191 } else {1192 <SubsOf<T>>::insert(account, (identity.1 .0, ids));1193 }1194 }1195 Self::deposit_event(Event::SubIdentitiesInserted {1196 amount: subs.len() as u32,1197 });1198 Ok(())1199 }1147 }1200 }1148}1201}11491202pallets/identity/src/weights.rsdiffbeforeafterboth78 fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight;78 fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight;79 fn force_insert_identities(x: u32, n: u32, ) -> Weight;79 fn force_insert_identities(x: u32, n: u32, ) -> Weight;80 fn force_remove_identities(x: u32, n: u32, ) -> Weight;80 fn force_remove_identities(x: u32, n: u32, ) -> Weight;81 fn force_set_subs(s: u32, n: u32, ) -> Weight;81 fn add_sub(s: u32, ) -> Weight;82 fn add_sub(s: u32, ) -> Weight;82 fn rename_sub(s: u32, ) -> Weight;83 fn rename_sub(s: u32, ) -> Weight;83 fn remove_sub(s: u32, ) -> Weight;84 fn remove_sub(s: u32, ) -> Weight;273 .saturating_add(T::DbWeight::get().reads(1 as u64))274 .saturating_add(T::DbWeight::get().reads(1 as u64))274 .saturating_add(T::DbWeight::get().writes(1 as u64).saturating_mul(n as u64))275 .saturating_add(T::DbWeight::get().writes(1 as u64).saturating_mul(n as u64))275 }276 }277 // Storage: Identity IdentityOf (r:1 w:1)278 // todo:collator279 /// The range of component `s` is `[0, 100]`.280 /// The range of component `n` is `[0, 600]`.281 fn force_set_subs(s: u32, n: u32) -> Weight {282 // Minimum execution time: 41_872 nanoseconds.283 Weight::from_ref_time(40_230_216 as u64)284 // Standard Error: 2_342285 .saturating_add(Weight::from_ref_time(145_168 as u64))286 // Standard Error: 457287 .saturating_add(Weight::from_ref_time(291_732 as u64).saturating_mul(s as u64))288 .saturating_add(T::DbWeight::get().reads(1 as u64))289 .saturating_add(T::DbWeight::get().writes(1 as u64).saturating_mul(n as u64))290 }276 // Storage: Identity IdentityOf (r:1 w:0)291 // Storage: Identity IdentityOf (r:1 w:0)277 // Storage: Identity SuperOf (r:1 w:1)292 // Storage: Identity SuperOf (r:1 w:1)278 // Storage: Identity SubsOf (r:1 w:1)293 // Storage: Identity SubsOf (r:1 w:1)509 .saturating_add(RocksDbWeight::get().reads(1 as u64))524 .saturating_add(RocksDbWeight::get().reads(1 as u64))510 .saturating_add(RocksDbWeight::get().writes(1 as u64).saturating_mul(n as u64))525 .saturating_add(RocksDbWeight::get().writes(1 as u64).saturating_mul(n as u64))511 }526 }527 // Storage: Identity IdentityOf (r:1 w:1)528 // todo:collator529 /// The range of component `xs is `[0, 100]`.530 /// The range of component `n` is `[0, 600]`.531 fn force_set_subs(s: u32, n: u32) -> Weight {532 // Minimum execution time: 41_872 nanoseconds.533 Weight::from_ref_time(40_230_216 as u64)534 // Standard Error: 2_342535 .saturating_add(Weight::from_ref_time(145_168 as u64))536 // Standard Error: 457537 .saturating_add(Weight::from_ref_time(291_732 as u64).saturating_mul(s as u64))538 .saturating_add(RocksDbWeight::get().reads(1 as u64))539 .saturating_add(RocksDbWeight::get().writes(1 as u64).saturating_mul(n as u64))540 }512 // Storage: Identity IdentityOf (r:1 w:0)541 // Storage: Identity IdentityOf (r:1 w:0)513 // Storage: Identity SuperOf (r:1 w:1)542 // Storage: Identity SuperOf (r:1 w:1)514 // Storage: Identity SubsOf (r:1 w:1)543 // Storage: Identity SubsOf (r:1 w:1)tests/src/collator-selection/identity.seqtest.tsdiffbeforeafterboth29 return (await getIdentities(helper)).flatMap(([key, _value]) => key);29 return (await getIdentities(helper)).flatMap(([key, _value]) => key);30}30}3132async function getSubIdentityAccounts(helper: UniqueHelper, address: string) {33 return ((await helper.getApi().query.identity.subsOf(address)).toHuman() as any)[1];34}3536async function getSubIdentityName(helper: UniqueHelper, address: string) {37 return ((await helper.getApi().query.identity.superOf(address)).toHuman() as any);38}313932describe('Integration Test: Identities Manipulation', () => {40describe('Integration Test: Identities Manipulation', () => {33 let superuser: IKeyringPair;41 let superuser: IKeyringPair;47 .to.be.rejectedWith(/Transaction call is not expected/);55 .to.be.rejectedWith(/Transaction call is not expected/);48 });56 });495758 describe('Identities', () => {50 itSub('Sets identities', async ({helper}) => {59 itSub('Sets identities', async ({helper}) => {51 const oldIdentitiesCount = (await getIdentityAccounts(helper)).length;60 const oldIdentitiesCount = (await getIdentityAccounts(helper)).length;526191 const newIdentities = await getIdentityAccounts(helper);100 const newIdentities = await getIdentityAccounts(helper);92 expect(newIdentities.concat(scapegoats)).to.be.have.members(oldIdentities);101 expect(newIdentities.concat(scapegoats)).to.be.have.members(oldIdentities);93 });102 });103 });104105 describe('Sub-identities', () => {106 itSub('Sets subs', async ({helper}) => {107 const crowdSize = 18;108 const crowd = await helper.arrange.createCrowd(crowdSize, 0n, superuser);109 const supers = [crowd.pop()!, crowd.pop()!, crowd.pop()!];110111 const subsPerSup = crowd.length / supers.length;112 let subCount = 0;113 const subs = [114 crowd.slice(subCount, subCount += subsPerSup + 1),115 crowd.slice(subCount, subCount += subsPerSup),116 crowd.slice(subCount, subCount += subsPerSup - 1),117 ];118119 const subsInfo = supers.map((acc, i) => [120 acc.address, [121 1000000n + BigInt(i + 1),122 subs[i].map((sub, j) => [123 sub.address, {Raw: `accounter #${j}`},124 ]),125 ],126 ]);127 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceSetSubs', [subsInfo]);128129 for (let i = 0; i < supers.length; i++) {130 // check deposit131 expect(((await helper.getApi().query.identity.subsOf(supers[i].address)).toJSON() as any)[0]).to.be.equal(1000001 + i);132133 const subsAccounts = await getSubIdentityAccounts(helper, supers[i].address);134 // check sub-identities as account ids135 expect(subsAccounts).to.include.members(subs[i].map(x => x.address));136137 for (let j = 0; j < subsAccounts.length; j++) {138 // check sub-identities' names139 expect((await getSubIdentityName(helper, subsAccounts[j]))[1]).to.be.deep.equal({Raw: `accounter #${j}`});140 }141 }142 });143144 itSub('Setting sub-identities does not delete other existing but does overwrite own', async ({helper}) => {145 const crowdSize = 18;146 const crowd = await helper.arrange.createCrowd(crowdSize, 0n, superuser);147 const supers = [crowd.pop()!, crowd.pop()!, crowd.pop()!];148149 const subsPerSup = crowd.length / supers.length;150 let subCount = 0;151 const subs = [152 crowd.slice(subCount, subCount += subsPerSup + 1),153 crowd.slice(subCount, subCount += subsPerSup),154 crowd.slice(subCount, subCount += subsPerSup - 1),155 ];156157 const subsInfo1 = supers.map((acc, i) => [158 acc.address, [159 1000000n + BigInt(i + 1),160 subs[i].map((sub, j) => [161 sub.address, {Raw: `accounter #${j}`},162 ]),163 ],164 ]);165 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceSetSubs', [subsInfo1]);166167 // change some sub-identities...168 subs[2].pop(); subs[2].pop(); subs[2].push(...await helper.arrange.createAccounts([0n], superuser));169170 // ...and set them171 const subsInfo2 = [[172 supers[2].address, [173 999999n,174 subs[2].map((sub, j) => [175 sub.address, {Raw: `discounter #${j}`},176 ]),177 ],178 ]];179 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceSetSubs', [subsInfo2]);180181 // make sure everything else is the same182 for (let i = 0; i < supers.length - 1; i++) {183 // check deposit184 expect(((await helper.getApi().query.identity.subsOf(supers[i].address)).toJSON() as any)[0]).to.be.equal(1000001 + i);185186 const subsAccounts = await getSubIdentityAccounts(helper, supers[i].address);187 // check sub-identities as account ids188 expect(subsAccounts).to.include.members(subs[i].map(x => x.address));189190 for (let j = 0; j < subsAccounts; j++) {191 // check sub-identities' names192 expect((await getSubIdentityName(helper, subsAccounts[j]))[1]).to.be.deep.equal({Raw: `accounter #${j}`});193 }194 }195196 // check deposit197 expect(((await helper.getApi().query.identity.subsOf(supers[2].address)).toJSON() as any)[0]).to.be.equal(999999);198199 const subsAccounts = await getSubIdentityAccounts(helper, supers[2].address);200 // check sub-identities as account ids201 expect(subsAccounts).to.include.members(subs[2].map(x => x.address));202203 for (let j = 0; j < subsAccounts.length; j++) {204 // check sub-identities' names205 expect((await getSubIdentityName(helper, subsAccounts[j]))[1]).to.be.deep.equal({Raw: `discounter #${j}`});206 }207 });208209 itSub('Removes sub-identities', async ({helper}) => {210 const crowdSize = 3;211 const crowd = await helper.arrange.createCrowd(crowdSize, 0n, superuser);212 const sup = crowd.pop()!;213214 const subsInfo1 = [[215 sup.address, [216 1000000n,217 crowd.map((sub, j) => [218 sub.address, {Raw: `accounter #${j}`},219 ]),220 ],221 ]];222 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceSetSubs', [subsInfo1]);223224 // empty sub-identities should delete the records225 const subsInfo2 = [[226 sup.address, [227 1000000n,228 [],229 ],230 ]];231 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceSetSubs', [subsInfo2]);232233 // check deposit234 expect((await helper.getApi().query.identity.subsOf(sup.address)).toHuman()).to.be.deep.equal(['0', []]);235236 for (let j = 0; j < crowd.length; j++) {237 // check sub-identities' names238 expect((await getSubIdentityName(helper, crowd[j].address))).to.be.null;239 }240 });241242 itSub('Removing identities deletes associated sub-identities', async ({helper}) => {243 const crowd = await helper.arrange.createCrowd(3, 0n, superuser);244 const sup = crowd.pop()!;245246 // insert identity247 const identities = [[sup.address, {info: {display: {Raw: 'mental'}}}]];248 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceInsertIdentities', [identities]);249250 // and its sub-identities251 const subsInfo = [[252 sup.address, [253 1000000n,254 crowd.map((sub, j) => [255 sub.address, {Raw: `accounter #${j}`},256 ]),257 ],258 ]];259 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceSetSubs', [subsInfo]);260261 // delete top identity262 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceRemoveIdentities', [[sup.address]]);263264 // check that sub-identities are deleted265 expect((await helper.getApi().query.identity.subsOf(sup.address)).toHuman()).to.be.deep.equal(['0', []]);266267 for (let j = 0; j < crowd.length; j++) {268 // check sub-identities' names269 expect((await getSubIdentityName(helper, crowd[j].address))).to.be.null;270 }271 });272 });9427395 after(async function() {274 after(async function() {96 if (!process.env.RUN_COLLATOR_TESTS) return;275 if (!process.env.RUN_COLLATOR_TESTS) return;tests/src/util/identitySetter.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.02// SPDX-License-Identifier: Apache-2.03//4// Usage: `yarn setIdentities [relay WS URL] [parachain WS URL] [sudo key]`5// Example: `yarn setIdentities wss://polkadot-rpc.dwellir.com ws://localhost:9944 escape pattern miracle train sudden cart adapt embark wedding alien lamp mesh`364import {encodeAddress} from '@polkadot/keyring';7import {encodeAddress} from '@polkadot/keyring';5import {usingPlaygrounds, Pallets} from './index';8import {usingPlaygrounds, Pallets} from './index';9const paraUrl = process.argv[3] ?? 'ws://localhost:9944';12const paraUrl = process.argv[3] ?? 'ws://localhost:9944';10const key = process.argv.length > 4 ? process.argv.slice(4).join(' ') : '//Alice';13const key = process.argv.length > 4 ? process.argv.slice(4).join(' ') : '//Alice';1415function extractAccountId(key: any): string {16 return (key as any).toHuman()[0];17}111812function extractIdentity(key: any, value: any): [string, any] {19function extractIdentity(key: any, value: any): [string, any] {13 return [(key as any).toHuman()[0], (value as any).unwrap()];20 return [extractAccountId(key), (value as any).unwrap()];14}21}152216async function getIdentities(helper: ChainHelperBase) {23async function getIdentities(helper: ChainHelperBase, noneCasePredicate?: (key: any, value: any) => void) {17 const identities: [string, any][] = [];24 const identities: [string, any][] = [];18 for(const [key, value] of await helper.getApi().query.identity.identityOf.entries())25 for(const [key, v] of await helper.getApi().query.identity.identityOf.entries()) {26 const value = v as any;27 if (value.isNone) {28 if (noneCasePredicate) noneCasePredicate(key, value);29 continue;30 }19 identities.push(extractIdentity(key, value));31 identities.push(extractIdentity(key, value));32 }20 return identities;33 return identities;21}34}223523// This is a utility for pulling36function constructSubInfo(identityAccount: string, subQuery: any, supers: any[], ss58?: number): [string, any] {37 const deposit = subQuery.toJSON()[0];38 const subIdentities = subQuery.toHuman()[1];39 subIdentities.map((sub: string) => supers.find((sup: any) => sup[0] === sub));40 // supers.find((x: any) => x[0] === subIdentities[0])![1].toHuman();41 return [42 encodeAddress(identityAccount, ss58), [43 deposit,44 subIdentities.map((sub: string) => [45 encodeAddress(sub, ss58),46 supers.find((sup: any) => sup[0] === sub)![1].toJSON()[1],47 ]),48 ],49 ];50}5152async function getSubs(helper: ChainHelperBase) {53 return (await helper.getApi().query.identity.subsOf.entries()).map(([key, value]) => [extractAccountId(key), value as any]);54}5556async function getSupers(helper: ChainHelperBase) {57 return (await helper.getApi().query.identity.superOf.entries()).map(([key, value]) => [extractAccountId(key), value as any]);58}5960// The utility for pulling identity and sub-identity data24const forceInsertIdentities = async (): Promise<void> => {61const forceInsertIdentities = async (): Promise<void> => {25 const identitiesOnRelay: any[] = [];62 const identitiesOnRelay: any[] = [];63 const subsOnRelay: any[] = [];26 const identitiesToRemove: string[] = [];64 const identitiesToRemove: string[] = [];27 await usingPlaygrounds(async helper => {65 await usingPlaygrounds(async helper => {28 try {66 try {29 // iterate over every identity67 // iterate over every identity30 for(const [key, v] of await helper.getApi().query.identity.identityOf.entries()) {68 for(const [key, value] of await getIdentities(helper, (key, _value) => identitiesToRemove.push((key as any).toHuman()[0]))) {31 const value = v as any;32 if (value.isNone) {33 // in the nigh-impossible case that storage map would actually give None for a value, might as well delete it34 identitiesToRemove.push((key as any).toHuman()[0]);35 continue;36 }3738 // if any of the judgements resulted in a good confirmed outcome, keep this identity69 // if any of the judgements resulted in a good confirmed outcome, keep this identity39 if (value.unwrap().toHuman().judgements.filter((x: any) => x[1] == 'Reasonable' || x[1] == 'KnownGood').length == 0) continue;70 if (value.toHuman().judgements.filter((x: any) => x[1] == 'Reasonable' || x[1] == 'KnownGood').length == 0) continue;40 identitiesOnRelay.push(extractIdentity(key, value));71 identitiesOnRelay.push([key, value]);41 }72 }7374 const sublessIdentities = [...identitiesOnRelay];75 const supersOfSubs = await getSupers(helper);7677 // iterate over every sub-identity78 for(const [key, value] of await getSubs(helper)) {79 // only get subs of the identities interesting to us80 const identityIndex = sublessIdentities.findIndex((x: any) => x[0] == key);81 if (identityIndex == -1) continue;82 sublessIdentities.splice(identityIndex, 1);83 subsOnRelay.push(constructSubInfo(key, value, supersOfSubs));84 }8586 // mark the rest of sub-identities for deletion with empty arrays87 /*for(const [account, _identity] of sublessIdentities) {88 subsOnRelay.push([account, ['0', []]]);89 }*/42 } catch (error) {90 } catch (error) {43 console.error(error);91 console.error(error);44 throw Error('Error during fetching identities');92 throw Error('Error during fetching identities');60 const identity = paraIdentities.find(i => i[0] === encodedKey);108 const identity = paraIdentities.find(i => i[0] === encodedKey);61 if (identity) {109 if (identity) {62 // only update if the identity info does not exist or is changed110 // only update if the identity info does not exist or is changed63 if (value.toString() === identity[1].toString()) {111 if (JSON.stringify(value) === JSON.stringify(identity[1])) {64 continue;112 continue;65 }113 }66 }114 }71 // identitiesToRemove.push((key as any).toHuman()[0]);119 // identitiesToRemove.push((key as any).toHuman()[0]);72 }120 }7312174 // await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceRemoveIdentities', [identitiesToRemove]);122 const paraSubs = await getSubs(helper);123 const supersOfSubs = await getSupers(helper);124 const subsToUpdate: any[] = [];125126 if (identitiesToRemove.length != 0)127 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceRemoveIdentities', [identitiesToRemove]);128 if (identitiesToAdd.length != 0)75 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceInsertIdentities', [identitiesToAdd]);129 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceInsertIdentities', [identitiesToAdd]);13076 console.log(`Tried to upload ${identitiesToAdd.length} identities `131 console.log(`Tried to upload ${identitiesToAdd.length} identities`77 + `and found ${identitiesToRemove.length} identities for potential removal. `132 + ` and found ${identitiesToRemove.length} identities for potential removal.`78 + `Now there are ${(await helper.getApi().query.identity.identityOf.keys()).length}.`);133 + ` Now there are ${(await helper.getApi().query.identity.identityOf.keys()).length}.`);134135 for (const [key, value] of subsOnRelay) {136 const encodedKey = encodeAddress(key, ss58Format);137 const sub = paraSubs.find(i => i[0] === encodedKey);138 if (sub) {139 // only update if the sub-identity info does not exist or is changed140 if (JSON.stringify(value) === JSON.stringify(constructSubInfo(sub[0], sub[1], supersOfSubs)[1])) {141 continue;142 }143 }144 subsToUpdate.push([key, value]);145 }146147 if (subsToUpdate.length != 0)148 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.forceSetSubs', [subsToUpdate]);149150 console.log(`Also tried to update ${subsToUpdate.length} identities with their sub-identities.`151 + ` Now there are ${(await helper.getApi().query.identity.subsOf.keys()).length} identities with subs.`);79 } catch (error) {152 } catch (error) {80 console.error(error);153 console.error(error);81 throw Error('Error during setting identities');154 throw Error('Error during setting identities');