mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 08:57:56 +00:00
Identity pallet improvements (#2048)
This PR is a follow up to #1661 - [x] rename the `simple` module to `legacy` - [x] fix benchmarks to disregard the number of additional fields - [x] change the storage deposits to charge per encoded byte of the identity information instance, removing the need for `fn additional(&self) -> usize` in `IdentityInformationProvider` - [x] ~add an extrinsic to rejig deposits to account for the change above~ - [ ] ~ensure through proper configuration that the new byte-based deposit is always lower than whatever is reserved now~ - [x] remove `IdentityFields` from the `set_fields` extrinsic signature, as per [this discussion](https://github.com/paritytech/polkadot-sdk/pull/1661#discussion_r1371703403) > ensure through proper configuration that the new byte-based deposit is always lower than whatever is reserved now Not sure this is needed anymore. If the new deposits are higher than what is currently on chain and users don't have enough funds to reserve what is needed, the extrinisc fails and they're basically grandfathered and frozen until they add more funds and/or make a change to their identity. This behavior seems fine to me. Original idea [here](https://github.com/paritytech/polkadot-sdk/pull/1661#issuecomment-1779606319). > add an extrinsic to rejig deposits to account for the change above This was initially implemented but now removed from this PR in favor of the implementation detailed [here](https://github.com/paritytech/polkadot-sdk/pull/2088). --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io> Co-authored-by: joepetrowski <joe@parity.io>
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
use super::*;
|
||||
|
||||
use crate::Pallet as Identity;
|
||||
use enumflags2::BitFlag;
|
||||
use frame_benchmarking::{
|
||||
account, impl_benchmark_test_suite, v2::*, whitelisted_caller, BenchmarkError,
|
||||
};
|
||||
@@ -49,9 +48,7 @@ fn add_registrars<T: Config>(r: u32) -> Result<(), &'static str> {
|
||||
.expect("RegistrarOrigin has no successful origin required for the benchmark");
|
||||
Identity::<T>::add_registrar(registrar_origin, registrar_lookup)?;
|
||||
Identity::<T>::set_fee(RawOrigin::Signed(registrar.clone()).into(), i, 10u32.into())?;
|
||||
let fields = IdentityFields(
|
||||
<T::IdentityInformation as IdentityInformationProvider>::IdentityField::all(),
|
||||
);
|
||||
let fields = T::IdentityInformation::all_fields();
|
||||
Identity::<T>::set_fields(RawOrigin::Signed(registrar.clone()).into(), i, fields)?;
|
||||
}
|
||||
|
||||
@@ -77,7 +74,7 @@ fn create_sub_accounts<T: Config>(
|
||||
// Set identity so `set_subs` does not fail.
|
||||
if IdentityOf::<T>::get(who).is_none() {
|
||||
let _ = T::Currency::make_free_balance_be(who, BalanceOf::<T>::max_value() / 2u32.into());
|
||||
let info = T::IdentityInformation::create_identity_info(1);
|
||||
let info = T::IdentityInformation::create_identity_info();
|
||||
Identity::<T>::set_identity(who_origin.into(), Box::new(info))?;
|
||||
}
|
||||
|
||||
@@ -118,10 +115,7 @@ mod benchmarks {
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn set_identity(
|
||||
r: Linear<1, { T::MaxRegistrars::get() }>,
|
||||
x: Linear<0, { T::MaxAdditionalFields::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
fn set_identity(r: Linear<1, { T::MaxRegistrars::get() }>) -> Result<(), BenchmarkError> {
|
||||
add_registrars::<T>(r)?;
|
||||
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
@@ -131,7 +125,7 @@ mod benchmarks {
|
||||
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
|
||||
// Add an initial identity
|
||||
let initial_info = T::IdentityInformation::create_identity_info(1);
|
||||
let initial_info = T::IdentityInformation::create_identity_info();
|
||||
Identity::<T>::set_identity(caller_origin.clone(), Box::new(initial_info.clone()))?;
|
||||
|
||||
// User requests judgement from all the registrars, and they approve
|
||||
@@ -154,7 +148,7 @@ mod benchmarks {
|
||||
#[extrinsic_call]
|
||||
_(
|
||||
RawOrigin::Signed(caller.clone()),
|
||||
Box::new(T::IdentityInformation::create_identity_info(x)),
|
||||
Box::new(T::IdentityInformation::create_identity_info()),
|
||||
);
|
||||
|
||||
assert_last_event::<T>(Event::<T>::IdentitySet { who: caller }.into());
|
||||
@@ -201,7 +195,6 @@ mod benchmarks {
|
||||
fn clear_identity(
|
||||
r: Linear<1, { T::MaxRegistrars::get() }>,
|
||||
s: Linear<0, { T::MaxSubAccounts::get() }>,
|
||||
x: Linear<0, { T::MaxAdditionalFields::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let caller_origin =
|
||||
@@ -216,7 +209,7 @@ mod benchmarks {
|
||||
let _ = add_sub_accounts::<T>(&caller, s)?;
|
||||
|
||||
// Create their main identity with x additional fields
|
||||
let info = T::IdentityInformation::create_identity_info(x);
|
||||
let info = T::IdentityInformation::create_identity_info();
|
||||
Identity::<T>::set_identity(caller_origin.clone(), Box::new(info.clone()))?;
|
||||
|
||||
// User requests judgement from all the registrars, and they approve
|
||||
@@ -245,10 +238,7 @@ mod benchmarks {
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn request_judgement(
|
||||
r: Linear<1, { T::MaxRegistrars::get() }>,
|
||||
x: Linear<0, { T::MaxAdditionalFields::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
fn request_judgement(r: Linear<1, { T::MaxRegistrars::get() }>) -> Result<(), BenchmarkError> {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
|
||||
@@ -256,7 +246,7 @@ mod benchmarks {
|
||||
add_registrars::<T>(r)?;
|
||||
|
||||
// Create their main identity with x additional fields
|
||||
let info = T::IdentityInformation::create_identity_info(x);
|
||||
let info = T::IdentityInformation::create_identity_info();
|
||||
let caller_origin =
|
||||
<T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));
|
||||
Identity::<T>::set_identity(caller_origin.clone(), Box::new(info))?;
|
||||
@@ -272,10 +262,7 @@ mod benchmarks {
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn cancel_request(
|
||||
r: Linear<1, { T::MaxRegistrars::get() }>,
|
||||
x: Linear<0, { T::MaxAdditionalFields::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
fn cancel_request(r: Linear<1, { T::MaxRegistrars::get() }>) -> Result<(), BenchmarkError> {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
|
||||
@@ -283,7 +270,7 @@ mod benchmarks {
|
||||
add_registrars::<T>(r)?;
|
||||
|
||||
// Create their main identity with x additional fields
|
||||
let info = T::IdentityInformation::create_identity_info(x);
|
||||
let info = T::IdentityInformation::create_identity_info();
|
||||
let caller_origin =
|
||||
<T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));
|
||||
Identity::<T>::set_identity(caller_origin.clone(), Box::new(info))?;
|
||||
@@ -367,15 +354,12 @@ mod benchmarks {
|
||||
.expect("RegistrarOrigin has no successful origin required for the benchmark");
|
||||
Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;
|
||||
|
||||
let fields = IdentityFields(
|
||||
<T::IdentityInformation as IdentityInformationProvider>::IdentityField::all(),
|
||||
);
|
||||
|
||||
let registrars = Registrars::<T>::get();
|
||||
ensure!(
|
||||
registrars[r as usize].as_ref().unwrap().fields == Default::default(),
|
||||
"fields already set."
|
||||
);
|
||||
let fields = T::IdentityInformation::all_fields();
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Signed(caller), r, fields);
|
||||
@@ -392,7 +376,6 @@ mod benchmarks {
|
||||
#[benchmark]
|
||||
fn provide_judgement(
|
||||
r: Linear<1, { T::MaxRegistrars::get() - 1 }>,
|
||||
x: Linear<0, { T::MaxAdditionalFields::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
// The user
|
||||
let user: T::AccountId = account("user", r, SEED);
|
||||
@@ -407,7 +390,7 @@ mod benchmarks {
|
||||
|
||||
add_registrars::<T>(r)?;
|
||||
|
||||
let info = T::IdentityInformation::create_identity_info(x);
|
||||
let info = T::IdentityInformation::create_identity_info();
|
||||
let info_hash = T::Hashing::hash_of(&info);
|
||||
Identity::<T>::set_identity(user_origin.clone(), Box::new(info))?;
|
||||
|
||||
@@ -430,7 +413,6 @@ mod benchmarks {
|
||||
fn kill_identity(
|
||||
r: Linear<1, { T::MaxRegistrars::get() }>,
|
||||
s: Linear<0, { T::MaxSubAccounts::get() }>,
|
||||
x: Linear<0, { T::MaxAdditionalFields::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
add_registrars::<T>(r)?;
|
||||
|
||||
@@ -440,7 +422,7 @@ mod benchmarks {
|
||||
let target_lookup = T::Lookup::unlookup(target.clone());
|
||||
let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());
|
||||
|
||||
let info = T::IdentityInformation::create_identity_info(x);
|
||||
let info = T::IdentityInformation::create_identity_info();
|
||||
Identity::<T>::set_identity(target_origin.clone(), Box::new(info.clone()))?;
|
||||
let _ = add_sub_accounts::<T>(&target, s)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user