mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 16:07:57 +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)?;
|
||||
|
||||
|
||||
@@ -16,13 +16,15 @@
|
||||
// limitations under the License.
|
||||
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
use enumflags2::BitFlag;
|
||||
use enumflags2::{bitflags, BitFlags};
|
||||
use frame_support::{traits::Get, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound};
|
||||
use scale_info::{build::Variants, Path, Type, TypeInfo};
|
||||
use sp_runtime::{BoundedVec, RuntimeDebug};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use crate::types::{Data, IdentityFields, IdentityInformationProvider, U64BitFlag};
|
||||
use crate::types::{Data, IdentityInformationProvider};
|
||||
|
||||
/// The fields that we use to identify the owner of an account with. Each corresponds to a field
|
||||
/// in the `IdentityInfo` struct.
|
||||
@@ -58,8 +60,6 @@ impl TypeInfo for IdentityField {
|
||||
}
|
||||
}
|
||||
|
||||
impl U64BitFlag for IdentityField {}
|
||||
|
||||
/// Information concerning the identity of the controller of an account.
|
||||
///
|
||||
/// NOTE: This should be stored at the end of the storage item to facilitate the addition of extra
|
||||
@@ -124,22 +124,20 @@ pub struct IdentityInfo<FieldLimit: Get<u32>> {
|
||||
}
|
||||
|
||||
impl<FieldLimit: Get<u32> + 'static> IdentityInformationProvider for IdentityInfo<FieldLimit> {
|
||||
type IdentityField = IdentityField;
|
||||
type FieldsIdentifier = u64;
|
||||
|
||||
fn has_identity(&self, fields: u64) -> bool {
|
||||
self.fields().0.bits() & fields == fields
|
||||
}
|
||||
|
||||
fn additional(&self) -> usize {
|
||||
self.additional.len()
|
||||
fn has_identity(&self, fields: Self::FieldsIdentifier) -> bool {
|
||||
self.fields().bits() & fields == fields
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn create_identity_info(num_fields: u32) -> Self {
|
||||
fn create_identity_info() -> Self {
|
||||
let data = Data::Raw(vec![0; 32].try_into().unwrap());
|
||||
|
||||
IdentityInfo {
|
||||
additional: vec![(data.clone(), data.clone()); num_fields as usize].try_into().unwrap(),
|
||||
additional: vec![(data.clone(), data.clone()); FieldLimit::get().try_into().unwrap()]
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
display: data.clone(),
|
||||
legal: data.clone(),
|
||||
web: data.clone(),
|
||||
@@ -150,11 +148,15 @@ impl<FieldLimit: Get<u32> + 'static> IdentityInformationProvider for IdentityInf
|
||||
twitter: data,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn all_fields() -> Self::FieldsIdentifier {
|
||||
IdentityField::all().bits()
|
||||
}
|
||||
}
|
||||
|
||||
impl<FieldLimit: Get<u32>> IdentityInfo<FieldLimit> {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn fields(&self) -> IdentityFields<IdentityField> {
|
||||
pub(crate) fn fields(&self) -> BitFlags<IdentityField> {
|
||||
let mut res = <BitFlags<IdentityField>>::empty();
|
||||
if !self.display.is_none() {
|
||||
res.insert(IdentityField::Display);
|
||||
@@ -180,6 +182,6 @@ impl<FieldLimit: Get<u32>> IdentityInfo<FieldLimit> {
|
||||
if !self.twitter.is_none() {
|
||||
res.insert(IdentityField::Twitter);
|
||||
}
|
||||
IdentityFields(res)
|
||||
res
|
||||
}
|
||||
}
|
||||
@@ -73,21 +73,23 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
mod benchmarking;
|
||||
pub mod simple;
|
||||
pub mod legacy;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
mod types;
|
||||
pub mod weights;
|
||||
|
||||
use frame_support::traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency};
|
||||
use frame_support::{
|
||||
pallet_prelude::DispatchResult,
|
||||
traits::{BalanceStatus, Currency, Get, OnUnbalanced, ReservableCurrency},
|
||||
};
|
||||
use sp_runtime::traits::{AppendZerosInput, Hash, Saturating, StaticLookup, Zero};
|
||||
use sp_std::prelude::*;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
pub use pallet::*;
|
||||
pub use types::{
|
||||
Data, IdentityFields, IdentityInformationProvider, Judgement, RegistrarIndex, RegistrarInfo,
|
||||
Registration,
|
||||
Data, IdentityInformationProvider, Judgement, RegistrarIndex, RegistrarInfo, Registration,
|
||||
};
|
||||
|
||||
type BalanceOf<T> =
|
||||
@@ -115,9 +117,9 @@ pub mod pallet {
|
||||
#[pallet::constant]
|
||||
type BasicDeposit: Get<BalanceOf<Self>>;
|
||||
|
||||
/// The amount held on deposit per additional field for a registered identity.
|
||||
/// The amount held on deposit per encoded byte for a registered identity.
|
||||
#[pallet::constant]
|
||||
type FieldDeposit: Get<BalanceOf<Self>>;
|
||||
type ByteDeposit: Get<BalanceOf<Self>>;
|
||||
|
||||
/// The amount held on deposit for a registered subaccount. This should account for the fact
|
||||
/// that one storage item's value will increase by the size of an account ID, and there will
|
||||
@@ -129,11 +131,6 @@ pub mod pallet {
|
||||
#[pallet::constant]
|
||||
type MaxSubAccounts: Get<u32>;
|
||||
|
||||
/// Maximum number of additional fields that may be stored in an ID. Needed to bound the I/O
|
||||
/// required to access an identity, but can be pretty high.
|
||||
#[pallet::constant]
|
||||
type MaxAdditionalFields: Get<u32>;
|
||||
|
||||
/// Structure holding information about an identity.
|
||||
type IdentityInformation: IdentityInformationProvider;
|
||||
|
||||
@@ -206,7 +203,7 @@ pub mod pallet {
|
||||
RegistrarInfo<
|
||||
BalanceOf<T>,
|
||||
T::AccountId,
|
||||
<T::IdentityInformation as IdentityInformationProvider>::IdentityField,
|
||||
<T::IdentityInformation as IdentityInformationProvider>::FieldsIdentifier,
|
||||
>,
|
||||
>,
|
||||
T::MaxRegistrars,
|
||||
@@ -238,8 +235,6 @@ pub mod pallet {
|
||||
InvalidIndex,
|
||||
/// The target is invalid.
|
||||
InvalidTarget,
|
||||
/// Too many additional fields.
|
||||
TooManyFields,
|
||||
/// Maximum amount of registrars reached. Cannot add any more.
|
||||
TooManyRegistrars,
|
||||
/// Account ID is already named.
|
||||
@@ -328,19 +323,15 @@ pub mod pallet {
|
||||
///
|
||||
/// Emits `IdentitySet` if successful.
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::set_identity(
|
||||
T::MaxRegistrars::get(),
|
||||
T::MaxAdditionalFields::get(),
|
||||
))]
|
||||
#[pallet::weight(T::WeightInfo::set_identity(T::MaxRegistrars::get()))]
|
||||
pub fn set_identity(
|
||||
origin: OriginFor<T>,
|
||||
info: Box<T::IdentityInformation>,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
let sender = ensure_signed(origin)?;
|
||||
#[allow(deprecated)]
|
||||
let extra_fields = info.additional() as u32;
|
||||
ensure!(extra_fields <= T::MaxAdditionalFields::get(), Error::<T>::TooManyFields);
|
||||
let fd = <BalanceOf<T>>::from(extra_fields) * T::FieldDeposit::get();
|
||||
let encoded_byte_size = info.encoded_size() as u32;
|
||||
let byte_deposit =
|
||||
T::ByteDeposit::get().saturating_mul(<BalanceOf<T>>::from(encoded_byte_size));
|
||||
|
||||
let mut id = match <IdentityOf<T>>::get(&sender) {
|
||||
Some(mut id) => {
|
||||
@@ -357,7 +348,7 @@ pub mod pallet {
|
||||
};
|
||||
|
||||
let old_deposit = id.deposit;
|
||||
id.deposit = T::BasicDeposit::get() + fd;
|
||||
id.deposit = T::BasicDeposit::get().saturating_add(byte_deposit);
|
||||
if id.deposit > old_deposit {
|
||||
T::Currency::reserve(&sender, id.deposit - old_deposit)?;
|
||||
}
|
||||
@@ -370,7 +361,7 @@ pub mod pallet {
|
||||
<IdentityOf<T>>::insert(&sender, id);
|
||||
Self::deposit_event(Event::IdentitySet { who: sender });
|
||||
|
||||
Ok(Some(T::WeightInfo::set_identity(judgements as u32, extra_fields)).into())
|
||||
Ok(Some(T::WeightInfo::set_identity(judgements as u32)).into())
|
||||
}
|
||||
|
||||
/// Set the sub-accounts of the sender.
|
||||
@@ -404,7 +395,8 @@ pub mod pallet {
|
||||
);
|
||||
|
||||
let (old_deposit, old_ids) = <SubsOf<T>>::get(&sender);
|
||||
let new_deposit = T::SubAccountDeposit::get() * <BalanceOf<T>>::from(subs.len() as u32);
|
||||
let new_deposit =
|
||||
T::SubAccountDeposit::get().saturating_mul(<BalanceOf<T>>::from(subs.len() as u32));
|
||||
|
||||
let not_other_sub =
|
||||
subs.iter().filter_map(|i| SuperOf::<T>::get(&i.0)).all(|i| i.0 == sender);
|
||||
@@ -454,14 +446,13 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::clear_identity(
|
||||
T::MaxRegistrars::get(),
|
||||
T::MaxSubAccounts::get(),
|
||||
T::MaxAdditionalFields::get(),
|
||||
))]
|
||||
pub fn clear_identity(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
|
||||
let sender = ensure_signed(origin)?;
|
||||
|
||||
let (subs_deposit, sub_ids) = <SubsOf<T>>::take(&sender);
|
||||
let id = <IdentityOf<T>>::take(&sender).ok_or(Error::<T>::NotNamed)?;
|
||||
let deposit = id.total_deposit() + subs_deposit;
|
||||
let deposit = id.total_deposit().saturating_add(subs_deposit);
|
||||
for sub in sub_ids.iter() {
|
||||
<SuperOf<T>>::remove(sub);
|
||||
}
|
||||
@@ -475,7 +466,6 @@ pub mod pallet {
|
||||
Ok(Some(T::WeightInfo::clear_identity(
|
||||
id.judgements.len() as u32,
|
||||
sub_ids.len() as u32,
|
||||
id.info.additional() as u32,
|
||||
))
|
||||
.into())
|
||||
}
|
||||
@@ -497,10 +487,7 @@ pub mod pallet {
|
||||
///
|
||||
/// Emits `JudgementRequested` if successful.
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight(T::WeightInfo::request_judgement(
|
||||
T::MaxRegistrars::get(),
|
||||
T::MaxAdditionalFields::get(),
|
||||
))]
|
||||
#[pallet::weight(T::WeightInfo::request_judgement(T::MaxRegistrars::get(),))]
|
||||
pub fn request_judgement(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] reg_index: RegistrarIndex,
|
||||
@@ -530,8 +517,6 @@ pub mod pallet {
|
||||
T::Currency::reserve(&sender, registrar.fee)?;
|
||||
|
||||
let judgements = id.judgements.len();
|
||||
#[allow(deprecated)]
|
||||
let extra_fields = id.info.additional();
|
||||
<IdentityOf<T>>::insert(&sender, id);
|
||||
|
||||
Self::deposit_event(Event::JudgementRequested {
|
||||
@@ -539,8 +524,7 @@ pub mod pallet {
|
||||
registrar_index: reg_index,
|
||||
});
|
||||
|
||||
Ok(Some(T::WeightInfo::request_judgement(judgements as u32, extra_fields as u32))
|
||||
.into())
|
||||
Ok(Some(T::WeightInfo::request_judgement(judgements as u32)).into())
|
||||
}
|
||||
|
||||
/// Cancel a previous request.
|
||||
@@ -554,10 +538,7 @@ pub mod pallet {
|
||||
///
|
||||
/// Emits `JudgementUnrequested` if successful.
|
||||
#[pallet::call_index(5)]
|
||||
#[pallet::weight(T::WeightInfo::cancel_request(
|
||||
T::MaxRegistrars::get(),
|
||||
T::MaxAdditionalFields::get(),
|
||||
))]
|
||||
#[pallet::weight(T::WeightInfo::cancel_request(T::MaxRegistrars::get()))]
|
||||
pub fn cancel_request(
|
||||
origin: OriginFor<T>,
|
||||
reg_index: RegistrarIndex,
|
||||
@@ -578,8 +559,6 @@ pub mod pallet {
|
||||
let err_amount = T::Currency::unreserve(&sender, fee);
|
||||
debug_assert!(err_amount.is_zero());
|
||||
let judgements = id.judgements.len();
|
||||
#[allow(deprecated)]
|
||||
let extra_fields = id.info.additional();
|
||||
<IdentityOf<T>>::insert(&sender, id);
|
||||
|
||||
Self::deposit_event(Event::JudgementUnrequested {
|
||||
@@ -587,7 +566,7 @@ pub mod pallet {
|
||||
registrar_index: reg_index,
|
||||
});
|
||||
|
||||
Ok(Some(T::WeightInfo::cancel_request(judgements as u32, extra_fields as u32)).into())
|
||||
Ok(Some(T::WeightInfo::cancel_request(judgements as u32)).into())
|
||||
}
|
||||
|
||||
/// Set the fee required for a judgement to be requested from a registrar.
|
||||
@@ -669,26 +648,21 @@ pub mod pallet {
|
||||
pub fn set_fields(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] index: RegistrarIndex,
|
||||
fields: IdentityFields<
|
||||
<T::IdentityInformation as IdentityInformationProvider>::IdentityField,
|
||||
>,
|
||||
fields: <T::IdentityInformation as IdentityInformationProvider>::FieldsIdentifier,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
let registrars = <Registrars<T>>::mutate(|rs| -> Result<usize, DispatchError> {
|
||||
rs.get_mut(index as usize)
|
||||
.and_then(|x| x.as_mut())
|
||||
.and_then(|r| {
|
||||
if r.account == who {
|
||||
r.fields = fields;
|
||||
Some(())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.ok_or_else(|| DispatchError::from(Error::<T>::InvalidIndex))?;
|
||||
Ok(rs.len())
|
||||
})?;
|
||||
let registrars =
|
||||
<Registrars<T>>::mutate(|registrars| -> Result<usize, DispatchError> {
|
||||
let registrar = registrars
|
||||
.get_mut(index as usize)
|
||||
.and_then(|r| r.as_mut())
|
||||
.filter(|r| r.account == who)
|
||||
.ok_or_else(|| DispatchError::from(Error::<T>::InvalidIndex))?;
|
||||
registrar.fields = fields;
|
||||
|
||||
Ok(registrars.len())
|
||||
})?;
|
||||
Ok(Some(T::WeightInfo::set_fields(registrars as u32)).into())
|
||||
}
|
||||
|
||||
@@ -706,10 +680,7 @@ pub mod pallet {
|
||||
///
|
||||
/// Emits `JudgementGiven` if successful.
|
||||
#[pallet::call_index(9)]
|
||||
#[pallet::weight(T::WeightInfo::provide_judgement(
|
||||
T::MaxRegistrars::get(),
|
||||
T::MaxAdditionalFields::get(),
|
||||
))]
|
||||
#[pallet::weight(T::WeightInfo::provide_judgement(T::MaxRegistrars::get()))]
|
||||
pub fn provide_judgement(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] reg_index: RegistrarIndex,
|
||||
@@ -752,13 +723,10 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
let judgements = id.judgements.len();
|
||||
#[allow(deprecated)]
|
||||
let extra_fields = id.info.additional();
|
||||
<IdentityOf<T>>::insert(&target, id);
|
||||
Self::deposit_event(Event::JudgementGiven { target, registrar_index: reg_index });
|
||||
|
||||
Ok(Some(T::WeightInfo::provide_judgement(judgements as u32, extra_fields as u32))
|
||||
.into())
|
||||
Ok(Some(T::WeightInfo::provide_judgement(judgements as u32)).into())
|
||||
}
|
||||
|
||||
/// Remove an account's identity and sub-account information and slash the deposits.
|
||||
@@ -777,7 +745,6 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::kill_identity(
|
||||
T::MaxRegistrars::get(),
|
||||
T::MaxSubAccounts::get(),
|
||||
T::MaxAdditionalFields::get(),
|
||||
))]
|
||||
pub fn kill_identity(
|
||||
origin: OriginFor<T>,
|
||||
@@ -790,7 +757,7 @@ pub mod pallet {
|
||||
// Grab their deposit (and check that they have one).
|
||||
let (subs_deposit, sub_ids) = <SubsOf<T>>::take(&target);
|
||||
let id = <IdentityOf<T>>::take(&target).ok_or(Error::<T>::NotNamed)?;
|
||||
let deposit = id.total_deposit() + subs_deposit;
|
||||
let deposit = id.total_deposit().saturating_add(subs_deposit);
|
||||
for sub in sub_ids.iter() {
|
||||
<SuperOf<T>>::remove(sub);
|
||||
}
|
||||
@@ -800,12 +767,8 @@ pub mod pallet {
|
||||
Self::deposit_event(Event::IdentityKilled { who: target, deposit });
|
||||
|
||||
#[allow(deprecated)]
|
||||
Ok(Some(T::WeightInfo::kill_identity(
|
||||
id.judgements.len() as u32,
|
||||
sub_ids.len() as u32,
|
||||
id.info.additional() as u32,
|
||||
))
|
||||
.into())
|
||||
Ok(Some(T::WeightInfo::kill_identity(id.judgements.len() as u32, sub_ids.len() as u32))
|
||||
.into())
|
||||
}
|
||||
|
||||
/// Add the given account to the sender's subs.
|
||||
@@ -936,7 +899,10 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
|
||||
/// Check if the account has corresponding identity information by the identity field.
|
||||
pub fn has_identity(who: &T::AccountId, fields: u64) -> bool {
|
||||
pub fn has_identity(
|
||||
who: &T::AccountId,
|
||||
fields: <T::IdentityInformation as IdentityInformationProvider>::FieldsIdentifier,
|
||||
) -> bool {
|
||||
IdentityOf::<T>::get(who)
|
||||
.map_or(false, |registration| (registration.info.has_identity(fields)))
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
use super::*;
|
||||
use crate::{
|
||||
self as pallet_identity,
|
||||
simple::{IdentityField as SimpleIdentityField, IdentityInfo},
|
||||
legacy::{IdentityField, IdentityInfo},
|
||||
};
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{
|
||||
assert_noop, assert_ok, ord_parameter_types, parameter_types,
|
||||
traits::{ConstU32, ConstU64, EitherOfDiverse},
|
||||
traits::{ConstU32, ConstU64, EitherOfDiverse, Get},
|
||||
BoundedVec,
|
||||
};
|
||||
use frame_system::{EnsureRoot, EnsureSignedBy};
|
||||
@@ -105,11 +105,10 @@ impl pallet_identity::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type Slashed = ();
|
||||
type BasicDeposit = ConstU64<10>;
|
||||
type FieldDeposit = ConstU64<10>;
|
||||
type SubAccountDeposit = ConstU64<10>;
|
||||
type BasicDeposit = ConstU64<100>;
|
||||
type ByteDeposit = ConstU64<10>;
|
||||
type SubAccountDeposit = ConstU64<100>;
|
||||
type MaxSubAccounts = ConstU32<2>;
|
||||
type MaxAdditionalFields = MaxAdditionalFields;
|
||||
type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
|
||||
type MaxRegistrars = MaxRegistrars;
|
||||
type RegistrarOrigin = EnsureOneOrRoot;
|
||||
@@ -120,7 +119,7 @@ impl pallet_identity::Config for Test {
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
pallet_balances::GenesisConfig::<Test> {
|
||||
balances: vec![(1, 10), (2, 10), (3, 10), (10, 100), (20, 100), (30, 100)],
|
||||
balances: vec![(1, 100), (2, 100), (3, 100), (10, 1000), (20, 1000), (30, 1000)],
|
||||
}
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
@@ -143,39 +142,43 @@ fn twenty() -> IdentityInfo<MaxAdditionalFields> {
|
||||
}
|
||||
}
|
||||
|
||||
fn id_deposit(id: &IdentityInfo<MaxAdditionalFields>) -> u64 {
|
||||
let base_deposit: u64 = <<Test as Config>::BasicDeposit as Get<u64>>::get();
|
||||
let byte_deposit: u64 = <<Test as Config>::ByteDeposit as Get<u64>>::get() *
|
||||
TryInto::<u64>::try_into(id.encoded_size()).unwrap();
|
||||
base_deposit + byte_deposit
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn identity_fields_repr_works() {
|
||||
// `SimpleIdentityField` sanity checks.
|
||||
assert_eq!(SimpleIdentityField::Display as u64, 1 << 0);
|
||||
assert_eq!(SimpleIdentityField::Legal as u64, 1 << 1);
|
||||
assert_eq!(SimpleIdentityField::Web as u64, 1 << 2);
|
||||
assert_eq!(SimpleIdentityField::Riot as u64, 1 << 3);
|
||||
assert_eq!(SimpleIdentityField::Email as u64, 1 << 4);
|
||||
assert_eq!(SimpleIdentityField::PgpFingerprint as u64, 1 << 5);
|
||||
assert_eq!(SimpleIdentityField::Image as u64, 1 << 6);
|
||||
assert_eq!(SimpleIdentityField::Twitter as u64, 1 << 7);
|
||||
// `IdentityField` sanity checks.
|
||||
assert_eq!(IdentityField::Display as u64, 1 << 0);
|
||||
assert_eq!(IdentityField::Legal as u64, 1 << 1);
|
||||
assert_eq!(IdentityField::Web as u64, 1 << 2);
|
||||
assert_eq!(IdentityField::Riot as u64, 1 << 3);
|
||||
assert_eq!(IdentityField::Email as u64, 1 << 4);
|
||||
assert_eq!(IdentityField::PgpFingerprint as u64, 1 << 5);
|
||||
assert_eq!(IdentityField::Image as u64, 1 << 6);
|
||||
assert_eq!(IdentityField::Twitter as u64, 1 << 7);
|
||||
|
||||
let fields = IdentityFields(
|
||||
SimpleIdentityField::Legal |
|
||||
SimpleIdentityField::Web |
|
||||
SimpleIdentityField::Riot |
|
||||
SimpleIdentityField::PgpFingerprint |
|
||||
SimpleIdentityField::Twitter,
|
||||
);
|
||||
let fields = IdentityField::Legal |
|
||||
IdentityField::Web |
|
||||
IdentityField::Riot |
|
||||
IdentityField::PgpFingerprint |
|
||||
IdentityField::Twitter;
|
||||
|
||||
assert!(!fields.0.contains(SimpleIdentityField::Display));
|
||||
assert!(fields.0.contains(SimpleIdentityField::Legal));
|
||||
assert!(fields.0.contains(SimpleIdentityField::Web));
|
||||
assert!(fields.0.contains(SimpleIdentityField::Riot));
|
||||
assert!(!fields.0.contains(SimpleIdentityField::Email));
|
||||
assert!(fields.0.contains(SimpleIdentityField::PgpFingerprint));
|
||||
assert!(!fields.0.contains(SimpleIdentityField::Image));
|
||||
assert!(fields.0.contains(SimpleIdentityField::Twitter));
|
||||
assert!(!fields.contains(IdentityField::Display));
|
||||
assert!(fields.contains(IdentityField::Legal));
|
||||
assert!(fields.contains(IdentityField::Web));
|
||||
assert!(fields.contains(IdentityField::Riot));
|
||||
assert!(!fields.contains(IdentityField::Email));
|
||||
assert!(fields.contains(IdentityField::PgpFingerprint));
|
||||
assert!(!fields.contains(IdentityField::Image));
|
||||
assert!(fields.contains(IdentityField::Twitter));
|
||||
|
||||
// The `IdentityFields` inner `BitFlags::bits` is used for `Encode`/`Decode`, so we ensure that
|
||||
// the `u64` representation matches what we expect during encode/decode operations.
|
||||
// Ensure that the `u64` representation matches what we expect.
|
||||
assert_eq!(
|
||||
fields.0.bits(),
|
||||
fields.bits(),
|
||||
0b00000000_00000000_00000000_00000000_00000000_00000000_00000000_10101110
|
||||
);
|
||||
}
|
||||
@@ -190,18 +193,23 @@ fn editing_subaccounts_should_work() {
|
||||
Error::<Test>::NoIdentity
|
||||
);
|
||||
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
let ten = ten();
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten.clone())));
|
||||
let id_deposit = id_deposit(&ten);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit);
|
||||
|
||||
let sub_deposit: u64 = <<Test as Config>::SubAccountDeposit as Get<u64>>::get();
|
||||
|
||||
// first sub account
|
||||
assert_ok!(Identity::add_sub(RuntimeOrigin::signed(10), 1, data(1)));
|
||||
assert_eq!(SuperOf::<Test>::get(1), Some((10, data(1))));
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - sub_deposit);
|
||||
|
||||
// second sub account
|
||||
assert_ok!(Identity::add_sub(RuntimeOrigin::signed(10), 2, data(2)));
|
||||
assert_eq!(SuperOf::<Test>::get(1), Some((10, data(1))));
|
||||
assert_eq!(SuperOf::<Test>::get(2), Some((10, data(2))));
|
||||
assert_eq!(Balances::free_balance(10), 70);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - 2 * sub_deposit);
|
||||
|
||||
// third sub account is too many
|
||||
assert_noop!(
|
||||
@@ -213,20 +221,20 @@ fn editing_subaccounts_should_work() {
|
||||
assert_ok!(Identity::rename_sub(RuntimeOrigin::signed(10), 1, data(11)));
|
||||
assert_eq!(SuperOf::<Test>::get(1), Some((10, data(11))));
|
||||
assert_eq!(SuperOf::<Test>::get(2), Some((10, data(2))));
|
||||
assert_eq!(Balances::free_balance(10), 70);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - 2 * sub_deposit);
|
||||
|
||||
// remove first sub account
|
||||
assert_ok!(Identity::remove_sub(RuntimeOrigin::signed(10), 1));
|
||||
assert_eq!(SuperOf::<Test>::get(1), None);
|
||||
assert_eq!(SuperOf::<Test>::get(2), Some((10, data(2))));
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - sub_deposit);
|
||||
|
||||
// add third sub account
|
||||
assert_ok!(Identity::add_sub(RuntimeOrigin::signed(10), 3, data(3)));
|
||||
assert_eq!(SuperOf::<Test>::get(1), None);
|
||||
assert_eq!(SuperOf::<Test>::get(2), Some((10, data(2))));
|
||||
assert_eq!(SuperOf::<Test>::get(3), Some((10, data(3))));
|
||||
assert_eq!(Balances::free_balance(10), 70);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - 2 * sub_deposit);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -234,15 +242,22 @@ fn editing_subaccounts_should_work() {
|
||||
fn resolving_subaccount_ownership_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data = |x| Data::Raw(vec![x; 1].try_into().unwrap());
|
||||
let sub_deposit: u64 = <<Test as Config>::SubAccountDeposit as Get<u64>>::get();
|
||||
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(20), Box::new(twenty())));
|
||||
let ten = ten();
|
||||
let ten_deposit = id_deposit(&ten);
|
||||
let twenty = twenty();
|
||||
let twenty_deposit = id_deposit(&twenty);
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten)));
|
||||
assert_eq!(Balances::free_balance(10), 1000 - ten_deposit);
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(20), Box::new(twenty)));
|
||||
assert_eq!(Balances::free_balance(20), 1000 - twenty_deposit);
|
||||
|
||||
// 10 claims 1 as a subaccount
|
||||
assert_ok!(Identity::add_sub(RuntimeOrigin::signed(10), 1, data(1)));
|
||||
assert_eq!(Balances::free_balance(1), 10);
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert_eq!(Balances::reserved_balance(10), 20);
|
||||
assert_eq!(Balances::free_balance(1), 100);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - ten_deposit - sub_deposit);
|
||||
assert_eq!(Balances::reserved_balance(10), ten_deposit + sub_deposit);
|
||||
// 20 cannot claim 1 now
|
||||
assert_noop!(
|
||||
Identity::add_sub(RuntimeOrigin::signed(20), 1, data(1)),
|
||||
@@ -251,9 +266,9 @@ fn resolving_subaccount_ownership_works() {
|
||||
// 1 wants to be with 20 so it quits from 10
|
||||
assert_ok!(Identity::quit_sub(RuntimeOrigin::signed(1)));
|
||||
// 1 gets the 10 that 10 paid.
|
||||
assert_eq!(Balances::free_balance(1), 20);
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert_eq!(Balances::reserved_balance(10), 10);
|
||||
assert_eq!(Balances::free_balance(1), 100 + sub_deposit);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - ten_deposit - sub_deposit);
|
||||
assert_eq!(Balances::reserved_balance(10), ten_deposit);
|
||||
// 20 can claim 1 now
|
||||
assert_ok!(Identity::add_sub(RuntimeOrigin::signed(20), 1, data(1)));
|
||||
});
|
||||
@@ -269,16 +284,29 @@ fn trailing_zeros_decodes_into_default_data() {
|
||||
assert_eq!(b, Data::None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn adding_registrar_invalid_index() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(RuntimeOrigin::signed(3), 0, 10));
|
||||
let fields = IdentityField::Display | IdentityField::Legal;
|
||||
assert_noop!(
|
||||
Identity::set_fields(RuntimeOrigin::signed(3), 100, fields.bits()),
|
||||
Error::<Test>::InvalidIndex
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn adding_registrar_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(RuntimeOrigin::signed(3), 0, 10));
|
||||
let fields = IdentityFields(SimpleIdentityField::Display | SimpleIdentityField::Legal);
|
||||
assert_ok!(Identity::set_fields(RuntimeOrigin::signed(3), 0, fields));
|
||||
let fields = IdentityField::Display | IdentityField::Legal;
|
||||
assert_ok!(Identity::set_fields(RuntimeOrigin::signed(3), 0, fields.bits()));
|
||||
assert_eq!(
|
||||
Identity::registrars(),
|
||||
vec![Some(RegistrarInfo { account: 3, fee: 10, fields })]
|
||||
vec![Some(RegistrarInfo { account: 3, fee: 10, fields: fields.bits() })]
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -306,11 +334,13 @@ fn registration_should_work() {
|
||||
three_fields.additional.try_push(Default::default()).unwrap();
|
||||
three_fields.additional.try_push(Default::default()).unwrap();
|
||||
assert!(three_fields.additional.try_push(Default::default()).is_err());
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_eq!(Identity::identity(10).unwrap().info, ten());
|
||||
assert_eq!(Balances::free_balance(10), 90);
|
||||
let ten = ten();
|
||||
let id_deposit = id_deposit(&ten);
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten.clone())));
|
||||
assert_eq!(Identity::identity(10).unwrap().info, ten);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit);
|
||||
assert_ok!(Identity::clear_identity(RuntimeOrigin::signed(10)));
|
||||
assert_eq!(Balances::free_balance(10), 100);
|
||||
assert_eq!(Balances::free_balance(10), 1000);
|
||||
assert_noop!(Identity::clear_identity(RuntimeOrigin::signed(10)), Error::<Test>::NotNamed);
|
||||
});
|
||||
}
|
||||
@@ -407,11 +437,13 @@ fn clearing_judgement_should_work() {
|
||||
#[test]
|
||||
fn killing_slashing_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
let ten = ten();
|
||||
let id_deposit = id_deposit(&ten);
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten)));
|
||||
assert_noop!(Identity::kill_identity(RuntimeOrigin::signed(1), 10), BadOrigin);
|
||||
assert_ok!(Identity::kill_identity(RuntimeOrigin::signed(2), 10));
|
||||
assert_eq!(Identity::identity(10), None);
|
||||
assert_eq!(Balances::free_balance(10), 90);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit);
|
||||
assert_noop!(
|
||||
Identity::kill_identity(RuntimeOrigin::signed(2), 10),
|
||||
Error::<Test>::NotNamed
|
||||
@@ -422,38 +454,43 @@ fn killing_slashing_should_work() {
|
||||
#[test]
|
||||
fn setting_subaccounts_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let ten = ten();
|
||||
let id_deposit = id_deposit(&ten);
|
||||
let sub_deposit: u64 = <<Test as Config>::SubAccountDeposit as Get<u64>>::get();
|
||||
let mut subs = vec![(20, Data::Raw(vec![40; 1].try_into().unwrap()))];
|
||||
assert_noop!(
|
||||
Identity::set_subs(RuntimeOrigin::signed(10), subs.clone()),
|
||||
Error::<Test>::NotFound
|
||||
);
|
||||
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten)));
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit);
|
||||
assert_ok!(Identity::set_subs(RuntimeOrigin::signed(10), subs.clone()));
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert_eq!(Identity::subs_of(10), (10, vec![20].try_into().unwrap()));
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - sub_deposit);
|
||||
assert_eq!(Identity::subs_of(10), (sub_deposit, vec![20].try_into().unwrap()));
|
||||
assert_eq!(Identity::super_of(20), Some((10, Data::Raw(vec![40; 1].try_into().unwrap()))));
|
||||
|
||||
// push another item and re-set it.
|
||||
subs.push((30, Data::Raw(vec![50; 1].try_into().unwrap())));
|
||||
assert_ok!(Identity::set_subs(RuntimeOrigin::signed(10), subs.clone()));
|
||||
assert_eq!(Balances::free_balance(10), 70);
|
||||
assert_eq!(Identity::subs_of(10), (20, vec![20, 30].try_into().unwrap()));
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - 2 * sub_deposit);
|
||||
assert_eq!(Identity::subs_of(10), (2 * sub_deposit, vec![20, 30].try_into().unwrap()));
|
||||
assert_eq!(Identity::super_of(20), Some((10, Data::Raw(vec![40; 1].try_into().unwrap()))));
|
||||
assert_eq!(Identity::super_of(30), Some((10, Data::Raw(vec![50; 1].try_into().unwrap()))));
|
||||
|
||||
// switch out one of the items and re-set.
|
||||
subs[0] = (40, Data::Raw(vec![60; 1].try_into().unwrap()));
|
||||
assert_ok!(Identity::set_subs(RuntimeOrigin::signed(10), subs.clone()));
|
||||
assert_eq!(Balances::free_balance(10), 70); // no change in the balance
|
||||
assert_eq!(Identity::subs_of(10), (20, vec![40, 30].try_into().unwrap()));
|
||||
// no change in the balance
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - 2 * sub_deposit);
|
||||
assert_eq!(Identity::subs_of(10), (2 * sub_deposit, vec![40, 30].try_into().unwrap()));
|
||||
assert_eq!(Identity::super_of(20), None);
|
||||
assert_eq!(Identity::super_of(30), Some((10, Data::Raw(vec![50; 1].try_into().unwrap()))));
|
||||
assert_eq!(Identity::super_of(40), Some((10, Data::Raw(vec![60; 1].try_into().unwrap()))));
|
||||
|
||||
// clear
|
||||
assert_ok!(Identity::set_subs(RuntimeOrigin::signed(10), vec![]));
|
||||
assert_eq!(Balances::free_balance(10), 90);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit);
|
||||
assert_eq!(Identity::subs_of(10), (0, BoundedVec::default()));
|
||||
assert_eq!(Identity::super_of(30), None);
|
||||
assert_eq!(Identity::super_of(40), None);
|
||||
@@ -469,13 +506,15 @@ fn setting_subaccounts_should_work() {
|
||||
#[test]
|
||||
fn clearing_account_should_remove_subaccounts_and_refund() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
let ten = ten();
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten.clone())));
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit(&ten));
|
||||
assert_ok!(Identity::set_subs(
|
||||
RuntimeOrigin::signed(10),
|
||||
vec![(20, Data::Raw(vec![40; 1].try_into().unwrap()))]
|
||||
));
|
||||
assert_ok!(Identity::clear_identity(RuntimeOrigin::signed(10)));
|
||||
assert_eq!(Balances::free_balance(10), 100);
|
||||
assert_eq!(Balances::free_balance(10), 1000);
|
||||
assert!(Identity::super_of(20).is_none());
|
||||
});
|
||||
}
|
||||
@@ -483,13 +522,18 @@ fn clearing_account_should_remove_subaccounts_and_refund() {
|
||||
#[test]
|
||||
fn killing_account_should_remove_subaccounts_and_not_refund() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
let ten = ten();
|
||||
let id_deposit = id_deposit(&ten);
|
||||
let sub_deposit: u64 = <<Test as Config>::SubAccountDeposit as Get<u64>>::get();
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten)));
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit);
|
||||
assert_ok!(Identity::set_subs(
|
||||
RuntimeOrigin::signed(10),
|
||||
vec![(20, Data::Raw(vec![40; 1].try_into().unwrap()))]
|
||||
));
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - sub_deposit);
|
||||
assert_ok!(Identity::kill_identity(RuntimeOrigin::signed(2), 10));
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - sub_deposit);
|
||||
assert!(Identity::super_of(20).is_none());
|
||||
});
|
||||
}
|
||||
@@ -503,10 +547,12 @@ fn cancelling_requested_judgement_should_work() {
|
||||
Identity::cancel_request(RuntimeOrigin::signed(10), 0),
|
||||
Error::<Test>::NoIdentity
|
||||
);
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
let ten = ten();
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten.clone())));
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit(&ten));
|
||||
assert_ok!(Identity::request_judgement(RuntimeOrigin::signed(10), 0, 10));
|
||||
assert_ok!(Identity::cancel_request(RuntimeOrigin::signed(10), 0));
|
||||
assert_eq!(Balances::free_balance(10), 90);
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit(&ten));
|
||||
assert_noop!(
|
||||
Identity::cancel_request(RuntimeOrigin::signed(10), 0),
|
||||
Error::<Test>::NotFound
|
||||
@@ -517,7 +563,7 @@ fn cancelling_requested_judgement_should_work() {
|
||||
0,
|
||||
10,
|
||||
Judgement::Reasonable,
|
||||
BlakeTwo256::hash_of(&ten())
|
||||
BlakeTwo256::hash_of(&ten)
|
||||
));
|
||||
assert_noop!(
|
||||
Identity::cancel_request(RuntimeOrigin::signed(10), 0),
|
||||
@@ -531,14 +577,17 @@ fn requesting_judgement_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(RuntimeOrigin::signed(3), 0, 10));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
let ten = ten();
|
||||
let id_deposit = id_deposit(&ten);
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten.clone())));
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit);
|
||||
assert_noop!(
|
||||
Identity::request_judgement(RuntimeOrigin::signed(10), 0, 9),
|
||||
Error::<Test>::FeeChanged
|
||||
);
|
||||
assert_ok!(Identity::request_judgement(RuntimeOrigin::signed(10), 0, 10));
|
||||
// 10 for the judgement request, 10 for the identity.
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
// 10 for the judgement request and the deposit for the identity.
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - 10);
|
||||
|
||||
// Re-requesting won't work as we already paid.
|
||||
assert_noop!(
|
||||
@@ -550,10 +599,11 @@ fn requesting_judgement_should_work() {
|
||||
0,
|
||||
10,
|
||||
Judgement::Erroneous,
|
||||
BlakeTwo256::hash_of(&ten())
|
||||
BlakeTwo256::hash_of(&ten)
|
||||
));
|
||||
// Registrar got their payment now.
|
||||
assert_eq!(Balances::free_balance(3), 20);
|
||||
// 100 initial balance and 10 for the judgement.
|
||||
assert_eq!(Balances::free_balance(3), 100 + 10);
|
||||
|
||||
// Re-requesting still won't work as it's erroneous.
|
||||
assert_noop!(
|
||||
@@ -571,7 +621,7 @@ fn requesting_judgement_should_work() {
|
||||
0,
|
||||
10,
|
||||
Judgement::OutOfDate,
|
||||
BlakeTwo256::hash_of(&ten())
|
||||
BlakeTwo256::hash_of(&ten)
|
||||
));
|
||||
assert_ok!(Identity::request_judgement(RuntimeOrigin::signed(10), 0, 10));
|
||||
});
|
||||
@@ -580,12 +630,14 @@ fn requesting_judgement_should_work() {
|
||||
#[test]
|
||||
fn provide_judgement_should_return_judgement_payment_failed_error() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let ten = ten();
|
||||
let id_deposit = id_deposit(&ten);
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(RuntimeOrigin::signed(3), 0, 10));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten.clone())));
|
||||
assert_ok!(Identity::request_judgement(RuntimeOrigin::signed(10), 0, 10));
|
||||
// 10 for the judgement request, 10 for the identity.
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
// 10 for the judgement request and the deposit for the identity.
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit - 10);
|
||||
|
||||
// This forces judgement payment failed error
|
||||
Balances::make_free_balance_be(&3, 0);
|
||||
@@ -595,7 +647,7 @@ fn provide_judgement_should_return_judgement_payment_failed_error() {
|
||||
0,
|
||||
10,
|
||||
Judgement::Erroneous,
|
||||
BlakeTwo256::hash_of(&ten())
|
||||
BlakeTwo256::hash_of(&ten)
|
||||
),
|
||||
Error::<Test>::JudgementPaymentFailed
|
||||
);
|
||||
@@ -607,25 +659,24 @@ fn field_deposit_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(RuntimeOrigin::signed(3), 0, 10));
|
||||
assert_ok!(Identity::set_identity(
|
||||
RuntimeOrigin::signed(10),
|
||||
Box::new(IdentityInfo {
|
||||
additional: vec![
|
||||
(
|
||||
Data::Raw(b"number".to_vec().try_into().unwrap()),
|
||||
Data::Raw(10u32.encode().try_into().unwrap())
|
||||
),
|
||||
(
|
||||
Data::Raw(b"text".to_vec().try_into().unwrap()),
|
||||
Data::Raw(b"10".to_vec().try_into().unwrap())
|
||||
),
|
||||
]
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
..Default::default()
|
||||
})
|
||||
));
|
||||
assert_eq!(Balances::free_balance(10), 70);
|
||||
let id = IdentityInfo {
|
||||
additional: vec![
|
||||
(
|
||||
Data::Raw(b"number".to_vec().try_into().unwrap()),
|
||||
Data::Raw(10u32.encode().try_into().unwrap()),
|
||||
),
|
||||
(
|
||||
Data::Raw(b"text".to_vec().try_into().unwrap()),
|
||||
Data::Raw(b"10".to_vec().try_into().unwrap()),
|
||||
),
|
||||
]
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
..Default::default()
|
||||
};
|
||||
let id_deposit = id_deposit(&id);
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(id)));
|
||||
assert_eq!(Balances::free_balance(10), 1000 - id_deposit);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -649,17 +700,15 @@ fn setting_account_id_should_work() {
|
||||
fn test_has_identity() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert!(Identity::has_identity(&10, SimpleIdentityField::Display as u64));
|
||||
assert!(Identity::has_identity(&10, SimpleIdentityField::Legal as u64));
|
||||
assert!(Identity::has_identity(&10, IdentityField::Display as u64));
|
||||
assert!(Identity::has_identity(&10, IdentityField::Legal as u64));
|
||||
assert!(Identity::has_identity(
|
||||
&10,
|
||||
SimpleIdentityField::Display as u64 | SimpleIdentityField::Legal as u64
|
||||
IdentityField::Display as u64 | IdentityField::Legal as u64
|
||||
));
|
||||
assert!(!Identity::has_identity(
|
||||
&10,
|
||||
SimpleIdentityField::Display as u64 |
|
||||
SimpleIdentityField::Legal as u64 |
|
||||
SimpleIdentityField::Web as u64
|
||||
IdentityField::Display as u64 | IdentityField::Legal as u64 | IdentityField::Web as u64
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,23 +17,23 @@
|
||||
|
||||
use super::*;
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use enumflags2::{BitFlag, BitFlags, _internal::RawBitFlags};
|
||||
use frame_support::{
|
||||
traits::{ConstU32, Get},
|
||||
BoundedVec, CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound,
|
||||
};
|
||||
use scale_info::{
|
||||
build::{Fields, Variants},
|
||||
meta_type, Path, Type, TypeInfo, TypeParameter,
|
||||
Path, Type, TypeInfo,
|
||||
};
|
||||
use sp_runtime::{
|
||||
traits::{Member, Zero},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use sp_runtime::{traits::Zero, RuntimeDebug};
|
||||
use sp_std::{fmt::Debug, iter::once, ops::Add, prelude::*};
|
||||
|
||||
/// An identifier for a single name registrar/identity verification service.
|
||||
pub type RegistrarIndex = u32;
|
||||
|
||||
pub trait U64BitFlag: BitFlag + RawBitFlags<Numeric = u64> {}
|
||||
|
||||
/// Either underlying data blob if it is at most 32 bytes, or a hash of it. If the data is greater
|
||||
/// than 32-bytes then it will be truncated when encoding.
|
||||
///
|
||||
@@ -234,24 +234,19 @@ impl<Balance: Encode + Decode + MaxEncodedLen + Copy + Clone + Debug + Eq + Part
|
||||
pub trait IdentityInformationProvider:
|
||||
Encode + Decode + MaxEncodedLen + Clone + Debug + Eq + PartialEq + TypeInfo
|
||||
{
|
||||
/// Type capable of representing all of the fields present in the identity information as bit
|
||||
/// flags in `u64` format.
|
||||
type IdentityField: Clone + Debug + Eq + PartialEq + TypeInfo + U64BitFlag;
|
||||
/// Type capable of holding information on which identity fields are set.
|
||||
type FieldsIdentifier: Member + Encode + Decode + MaxEncodedLen + TypeInfo + Default;
|
||||
|
||||
/// Check if an identity registered information for some given `fields`.
|
||||
fn has_identity(&self, fields: u64) -> bool;
|
||||
|
||||
/// Interface for providing the number of additional fields this identity information provider
|
||||
/// holds, used to charge for additional storage and weight. This interface is present for
|
||||
/// backwards compatibility reasons only and will be removed as soon as the reference identity
|
||||
/// provider removes additional fields.
|
||||
#[deprecated]
|
||||
fn additional(&self) -> usize {
|
||||
0
|
||||
}
|
||||
fn has_identity(&self, fields: Self::FieldsIdentifier) -> bool;
|
||||
|
||||
/// Create a basic instance of the identity information.
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn create_identity_info(num_fields: u32) -> Self;
|
||||
fn create_identity_info() -> Self;
|
||||
|
||||
/// The identity information representation for all identity fields enabled.
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn all_fields() -> Self::FieldsIdentifier;
|
||||
}
|
||||
|
||||
/// Information on an identity along with judgements from registrars.
|
||||
@@ -262,7 +257,7 @@ pub trait IdentityInformationProvider:
|
||||
CloneNoBound, Encode, Eq, MaxEncodedLen, PartialEqNoBound, RuntimeDebugNoBound, TypeInfo,
|
||||
)]
|
||||
#[codec(mel_bound())]
|
||||
#[scale_info(skip_type_params(MaxJudgements, MaxAdditionalFields))]
|
||||
#[scale_info(skip_type_params(MaxJudgements))]
|
||||
pub struct Registration<
|
||||
Balance: Encode + Decode + MaxEncodedLen + Copy + Clone + Debug + Eq + PartialEq,
|
||||
MaxJudgements: Get<u32>,
|
||||
@@ -311,7 +306,7 @@ impl<
|
||||
pub struct RegistrarInfo<
|
||||
Balance: Encode + Decode + Clone + Debug + Eq + PartialEq,
|
||||
AccountId: Encode + Decode + Clone + Debug + Eq + PartialEq,
|
||||
IdField: Clone + Debug + Eq + PartialEq + TypeInfo + U64BitFlag,
|
||||
IdField: Encode + Decode + Clone + Debug + Default + Eq + PartialEq + TypeInfo + MaxEncodedLen,
|
||||
> {
|
||||
/// The account of the registrar.
|
||||
pub account: AccountId,
|
||||
@@ -321,52 +316,7 @@ pub struct RegistrarInfo<
|
||||
|
||||
/// Relevant fields for this registrar. Registrar judgements are limited to attestations on
|
||||
/// these fields.
|
||||
pub fields: IdentityFields<IdField>,
|
||||
}
|
||||
|
||||
/// Wrapper type for `BitFlags<IdentityField>` that implements `Codec`.
|
||||
#[derive(Clone, Copy, PartialEq, RuntimeDebug)]
|
||||
pub struct IdentityFields<IdField: BitFlag>(pub BitFlags<IdField>);
|
||||
|
||||
impl<IdField: U64BitFlag> Default for IdentityFields<IdField> {
|
||||
fn default() -> Self {
|
||||
Self(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl<IdField: U64BitFlag> MaxEncodedLen for IdentityFields<IdField>
|
||||
where
|
||||
IdentityFields<IdField>: Encode,
|
||||
{
|
||||
fn max_encoded_len() -> usize {
|
||||
u64::max_encoded_len()
|
||||
}
|
||||
}
|
||||
|
||||
impl<IdField: U64BitFlag + PartialEq> Eq for IdentityFields<IdField> {}
|
||||
impl<IdField: U64BitFlag> Encode for IdentityFields<IdField> {
|
||||
fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R {
|
||||
let bits: u64 = self.0.bits();
|
||||
bits.using_encoded(f)
|
||||
}
|
||||
}
|
||||
impl<IdField: U64BitFlag> Decode for IdentityFields<IdField> {
|
||||
fn decode<I: codec::Input>(input: &mut I) -> sp_std::result::Result<Self, codec::Error> {
|
||||
let field = u64::decode(input)?;
|
||||
Ok(Self(<BitFlags<IdField>>::from_bits(field).map_err(|_| "invalid value")?))
|
||||
}
|
||||
}
|
||||
impl<IdField: Clone + Debug + Eq + PartialEq + TypeInfo + U64BitFlag> TypeInfo
|
||||
for IdentityFields<IdField>
|
||||
{
|
||||
type Identity = Self;
|
||||
|
||||
fn type_info() -> Type {
|
||||
Type::builder()
|
||||
.path(Path::new("BitFlags", module_path!()))
|
||||
.type_params(vec![TypeParameter::new("T", Some(meta_type::<IdField>()))])
|
||||
.composite(Fields::unnamed().field(|f| f.ty::<u64>().type_name("IdentityField")))
|
||||
}
|
||||
pub fields: IdField,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Generated
+18
-54
@@ -53,17 +53,17 @@ use core::marker::PhantomData;
|
||||
/// Weight functions needed for pallet_identity.
|
||||
pub trait WeightInfo {
|
||||
fn add_registrar(r: u32, ) -> Weight;
|
||||
fn set_identity(r: u32, x: u32, ) -> Weight;
|
||||
fn set_identity(r: u32, ) -> Weight;
|
||||
fn set_subs_new(s: u32, ) -> Weight;
|
||||
fn set_subs_old(p: u32, ) -> Weight;
|
||||
fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight;
|
||||
fn request_judgement(r: u32, x: u32, ) -> Weight;
|
||||
fn cancel_request(r: u32, x: u32, ) -> Weight;
|
||||
fn clear_identity(r: u32, s: u32, ) -> Weight;
|
||||
fn request_judgement(r: u32, ) -> Weight;
|
||||
fn cancel_request(r: u32, ) -> Weight;
|
||||
fn set_fee(r: u32, ) -> Weight;
|
||||
fn set_account_id(r: u32, ) -> Weight;
|
||||
fn set_fields(r: u32, ) -> Weight;
|
||||
fn provide_judgement(r: u32, x: u32, ) -> Weight;
|
||||
fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight;
|
||||
fn provide_judgement(r: u32, ) -> Weight;
|
||||
fn kill_identity(r: u32, s: u32, ) -> Weight;
|
||||
fn add_sub(s: u32, ) -> Weight;
|
||||
fn rename_sub(s: u32, ) -> Weight;
|
||||
fn remove_sub(s: u32, ) -> Weight;
|
||||
@@ -90,8 +90,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// Storage: Identity IdentityOf (r:1 w:1)
|
||||
/// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 20]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn set_identity(r: u32, x: u32, ) -> Weight {
|
||||
fn set_identity(r: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `442 + r * (5 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -99,8 +98,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
Weight::from_parts(31_329_634, 11003)
|
||||
// Standard Error: 4_496
|
||||
.saturating_add(Weight::from_parts(203_570, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 877
|
||||
.saturating_add(Weight::from_parts(429_346, 0).saturating_mul(x.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
@@ -152,8 +149,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 20]`.
|
||||
/// The range of component `s` is `[0, 100]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight {
|
||||
fn clear_identity(r: u32, s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `469 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -163,8 +159,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
.saturating_add(Weight::from_parts(162_357, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 1_937
|
||||
.saturating_add(Weight::from_parts(1_427_998, 0).saturating_mul(s.into()))
|
||||
// Standard Error: 1_937
|
||||
.saturating_add(Weight::from_parts(247_578, 0).saturating_mul(x.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into())))
|
||||
@@ -174,8 +168,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// Storage: Identity IdentityOf (r:1 w:1)
|
||||
/// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 20]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn request_judgement(r: u32, x: u32, ) -> Weight {
|
||||
fn request_judgement(r: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `367 + r * (57 ±0) + x * (66 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -183,16 +176,13 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
Weight::from_parts(32_207_018, 11003)
|
||||
// Standard Error: 5_247
|
||||
.saturating_add(Weight::from_parts(249_156, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 1_023
|
||||
.saturating_add(Weight::from_parts(458_329, 0).saturating_mul(x.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Identity IdentityOf (r:1 w:1)
|
||||
/// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 20]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn cancel_request(r: u32, x: u32, ) -> Weight {
|
||||
fn cancel_request(r: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `398 + x * (66 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -200,8 +190,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
Weight::from_parts(31_967_170, 11003)
|
||||
// Standard Error: 5_387
|
||||
.saturating_add(Weight::from_parts(42_676, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 1_051
|
||||
.saturating_add(Weight::from_parts(446_213, 0).saturating_mul(x.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
@@ -252,8 +240,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// Storage: Identity IdentityOf (r:1 w:1)
|
||||
/// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 19]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn provide_judgement(r: u32, x: u32, ) -> Weight {
|
||||
fn provide_judgement(r: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `445 + r * (57 ±0) + x * (66 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -261,8 +248,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
Weight::from_parts(17_817_684, 11003)
|
||||
// Standard Error: 8_612
|
||||
.saturating_add(Weight::from_parts(406_251, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 1_593
|
||||
.saturating_add(Weight::from_parts(755_225, 0).saturating_mul(x.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
@@ -276,8 +261,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 20]`.
|
||||
/// The range of component `s` is `[0, 100]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight {
|
||||
fn kill_identity(r: u32, s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `676 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -287,8 +271,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
.saturating_add(Weight::from_parts(145_285, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 2_472
|
||||
.saturating_add(Weight::from_parts(1_421_039, 0).saturating_mul(s.into()))
|
||||
// Standard Error: 2_472
|
||||
.saturating_add(Weight::from_parts(240_907, 0).saturating_mul(x.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into())))
|
||||
@@ -384,8 +366,7 @@ impl WeightInfo for () {
|
||||
/// Storage: Identity IdentityOf (r:1 w:1)
|
||||
/// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 20]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn set_identity(r: u32, x: u32, ) -> Weight {
|
||||
fn set_identity(r: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `442 + r * (5 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -393,8 +374,6 @@ impl WeightInfo for () {
|
||||
Weight::from_parts(31_329_634, 11003)
|
||||
// Standard Error: 4_496
|
||||
.saturating_add(Weight::from_parts(203_570, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 877
|
||||
.saturating_add(Weight::from_parts(429_346, 0).saturating_mul(x.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
@@ -446,8 +425,7 @@ impl WeightInfo for () {
|
||||
/// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 20]`.
|
||||
/// The range of component `s` is `[0, 100]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight {
|
||||
fn clear_identity(r: u32, s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `469 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -457,8 +435,6 @@ impl WeightInfo for () {
|
||||
.saturating_add(Weight::from_parts(162_357, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 1_937
|
||||
.saturating_add(Weight::from_parts(1_427_998, 0).saturating_mul(s.into()))
|
||||
// Standard Error: 1_937
|
||||
.saturating_add(Weight::from_parts(247_578, 0).saturating_mul(x.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into())))
|
||||
@@ -468,8 +444,7 @@ impl WeightInfo for () {
|
||||
/// Storage: Identity IdentityOf (r:1 w:1)
|
||||
/// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 20]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn request_judgement(r: u32, x: u32, ) -> Weight {
|
||||
fn request_judgement(r: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `367 + r * (57 ±0) + x * (66 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -477,16 +452,13 @@ impl WeightInfo for () {
|
||||
Weight::from_parts(32_207_018, 11003)
|
||||
// Standard Error: 5_247
|
||||
.saturating_add(Weight::from_parts(249_156, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 1_023
|
||||
.saturating_add(Weight::from_parts(458_329, 0).saturating_mul(x.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: Identity IdentityOf (r:1 w:1)
|
||||
/// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 20]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn cancel_request(r: u32, x: u32, ) -> Weight {
|
||||
fn cancel_request(r: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `398 + x * (66 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -494,8 +466,6 @@ impl WeightInfo for () {
|
||||
Weight::from_parts(31_967_170, 11003)
|
||||
// Standard Error: 5_387
|
||||
.saturating_add(Weight::from_parts(42_676, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 1_051
|
||||
.saturating_add(Weight::from_parts(446_213, 0).saturating_mul(x.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
@@ -546,8 +516,7 @@ impl WeightInfo for () {
|
||||
/// Storage: Identity IdentityOf (r:1 w:1)
|
||||
/// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 19]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn provide_judgement(r: u32, x: u32, ) -> Weight {
|
||||
fn provide_judgement(r: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `445 + r * (57 ±0) + x * (66 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -555,8 +524,6 @@ impl WeightInfo for () {
|
||||
Weight::from_parts(17_817_684, 11003)
|
||||
// Standard Error: 8_612
|
||||
.saturating_add(Weight::from_parts(406_251, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 1_593
|
||||
.saturating_add(Weight::from_parts(755_225, 0).saturating_mul(x.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
@@ -570,8 +537,7 @@ impl WeightInfo for () {
|
||||
/// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen)
|
||||
/// The range of component `r` is `[1, 20]`.
|
||||
/// The range of component `s` is `[0, 100]`.
|
||||
/// The range of component `x` is `[0, 100]`.
|
||||
fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight {
|
||||
fn kill_identity(r: u32, s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `676 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)`
|
||||
// Estimated: `11003`
|
||||
@@ -581,8 +547,6 @@ impl WeightInfo for () {
|
||||
.saturating_add(Weight::from_parts(145_285, 0).saturating_mul(r.into()))
|
||||
// Standard Error: 2_472
|
||||
.saturating_add(Weight::from_parts(1_421_039, 0).saturating_mul(s.into()))
|
||||
// Standard Error: 2_472
|
||||
.saturating_add(Weight::from_parts(240_907, 0).saturating_mul(x.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into())))
|
||||
|
||||
Reference in New Issue
Block a user