Skip to content

Commit

Permalink
Identity pallet improvements (#2048)
Browse files Browse the repository at this point in the history
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](#1661 (comment))

> 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](#1661 (comment)).

> 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](#2088).

---------

Signed-off-by: georgepisaltu <[email protected]>
Co-authored-by: joepetrowski <[email protected]>
  • Loading branch information
georgepisaltu and joepetrowski authored Nov 3, 2023
1 parent ca5f105 commit 21fbc00
Show file tree
Hide file tree
Showing 15 changed files with 356 additions and 462 deletions.
7 changes: 3 additions & 4 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_identity::simple::IdentityInfo;
use pallet_identity::legacy::IdentityInfo;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_session::historical as session_historical;
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
Expand Down Expand Up @@ -596,7 +596,7 @@ impl claims::Config for Runtime {
parameter_types! {
// Minimum 100 bytes/ROC deposited (1 CENT/byte)
pub const BasicDeposit: Balance = 1000 * CENTS; // 258 bytes on-chain
pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain
pub const ByteDeposit: Balance = deposit(0, 1);
pub const SubAccountDeposit: Balance = 200 * CENTS; // 53 bytes on-chain
pub const MaxSubAccounts: u32 = 100;
pub const MaxAdditionalFields: u32 = 100;
Expand All @@ -607,10 +607,9 @@ impl pallet_identity::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BasicDeposit = BasicDeposit;
type FieldDeposit = FieldDeposit;
type ByteDeposit = ByteDeposit;
type SubAccountDeposit = SubAccountDeposit;
type MaxSubAccounts = MaxSubAccounts;
type MaxAdditionalFields = MaxAdditionalFields;
type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
type MaxRegistrars = MaxRegistrars;
type Slashed = Treasury;
Expand Down
31 changes: 7 additions & 24 deletions polkadot/runtime/rococo/src/weights/pallet_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<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`
Expand All @@ -75,8 +74,6 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 11003))
// Standard Error: 2_307
.saturating_add(Weight::from_parts(92_753, 0).saturating_mul(r.into()))
// Standard Error: 450
.saturating_add(Weight::from_parts(449_529, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand Down Expand Up @@ -130,8 +127,7 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<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`
Expand All @@ -140,8 +136,6 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 11003))
// Standard Error: 1_353
.saturating_add(Weight::from_parts(1_074_019, 0).saturating_mul(s.into()))
// Standard Error: 1_353
.saturating_add(Weight::from_parts(229_947, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into())))
Expand All @@ -151,8 +145,7 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<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`
Expand All @@ -161,16 +154,14 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 11003))
// Standard Error: 2_214
.saturating_add(Weight::from_parts(83_822, 0).saturating_mul(r.into()))
// Standard Error: 432
.saturating_add(Weight::from_parts(458_801, 0).saturating_mul(x.into()))

.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// 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`
Expand All @@ -179,8 +170,6 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 11003))
// Standard Error: 2_528
.saturating_add(Weight::from_parts(85_593, 0).saturating_mul(r.into()))
// Standard Error: 493
.saturating_add(Weight::from_parts(468_140, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand Down Expand Up @@ -234,8 +223,7 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<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`
Expand All @@ -244,8 +232,6 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 11003))
// Standard Error: 2_881
.saturating_add(Weight::from_parts(109_812, 0).saturating_mul(r.into()))
// Standard Error: 533
.saturating_add(Weight::from_parts(733_244, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand All @@ -259,8 +245,7 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<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`
Expand All @@ -271,8 +256,6 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(15_486, 0).saturating_mul(r.into()))
// Standard Error: 1_275
.saturating_add(Weight::from_parts(1_085_117, 0).saturating_mul(s.into()))
// Standard Error: 1_275
.saturating_add(Weight::from_parts(228_226, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into())))
Expand Down
7 changes: 3 additions & 4 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_identity::simple::IdentityInfo;
use pallet_identity::legacy::IdentityInfo;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_session::historical as session_historical;
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
Expand Down Expand Up @@ -863,7 +863,7 @@ where
parameter_types! {
// Minimum 100 bytes/KSM deposited (1 CENT/byte)
pub const BasicDeposit: Balance = 1000 * CENTS; // 258 bytes on-chain
pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain
pub const ByteDeposit: Balance = deposit(0, 1);
pub const SubAccountDeposit: Balance = 200 * CENTS; // 53 bytes on-chain
pub const MaxSubAccounts: u32 = 100;
pub const MaxAdditionalFields: u32 = 100;
Expand All @@ -875,10 +875,9 @@ impl pallet_identity::Config for Runtime {
type Currency = Balances;
type Slashed = ();
type BasicDeposit = BasicDeposit;
type FieldDeposit = FieldDeposit;
type ByteDeposit = ByteDeposit;
type SubAccountDeposit = SubAccountDeposit;
type MaxSubAccounts = MaxSubAccounts;
type MaxAdditionalFields = MaxAdditionalFields;
type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
type MaxRegistrars = MaxRegistrars;
type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
Expand Down
30 changes: 6 additions & 24 deletions polkadot/runtime/westend/src/weights/pallet_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<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`
Expand All @@ -78,8 +77,6 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 11003))
// Standard Error: 7_269
.saturating_add(Weight::from_parts(250_439, 0).saturating_mul(r.into()))
// Standard Error: 1_418
.saturating_add(Weight::from_parts(483_981, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand Down Expand Up @@ -133,8 +130,7 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<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`
Expand All @@ -145,8 +141,6 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(475_120, 0).saturating_mul(r.into()))
// Standard Error: 4_092
.saturating_add(Weight::from_parts(1_348_869, 0).saturating_mul(s.into()))
// Standard Error: 4_092
.saturating_add(Weight::from_parts(314_033, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into())))
Expand All @@ -156,8 +150,7 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<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`
Expand All @@ -166,16 +159,13 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 11003))
// Standard Error: 7_973
.saturating_add(Weight::from_parts(124_283, 0).saturating_mul(r.into()))
// Standard Error: 1_555
.saturating_add(Weight::from_parts(512_825, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// 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`
Expand All @@ -184,8 +174,6 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 11003))
// Standard Error: 5_154
.saturating_add(Weight::from_parts(147_560, 0).saturating_mul(r.into()))
// Standard Error: 1_005
.saturating_add(Weight::from_parts(490_754, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand Down Expand Up @@ -239,8 +227,7 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<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`
Expand All @@ -249,8 +236,6 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 11003))
// Standard Error: 10_027
.saturating_add(Weight::from_parts(154_816, 0).saturating_mul(r.into()))
// Standard Error: 1_855
.saturating_add(Weight::from_parts(803_084, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand All @@ -264,8 +249,7 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<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`
Expand All @@ -276,8 +260,6 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(666_376, 0).saturating_mul(r.into()))
// Standard Error: 4_433
.saturating_add(Weight::from_parts(1_396_065, 0).saturating_mul(s.into()))
// Standard Error: 4_433
.saturating_add(Weight::from_parts(300_762, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into())))
Expand Down
5 changes: 3 additions & 2 deletions substrate/bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use frame_support::{
};
use pallet_alliance::{IdentityVerifier, ProposalIndex, ProposalProvider};
use pallet_asset_tx_payment::HandleCredit;
use pallet_identity::legacy::IdentityField;
use sp_std::prelude::*;

use crate::{
Expand Down Expand Up @@ -56,8 +57,8 @@ impl HandleCredit<AccountId, Assets> for CreditToBlockAuthor {

pub struct AllianceIdentityVerifier;
impl IdentityVerifier<AccountId> for AllianceIdentityVerifier {
fn has_identity(who: &AccountId, fields: u64) -> bool {
crate::Identity::has_identity(who, fields)
fn has_required_identities(who: &AccountId) -> bool {
crate::Identity::has_identity(who, (IdentityField::Display | IdentityField::Web).bits())
}

fn has_good_judgement(who: &AccountId) -> bool {
Expand Down
11 changes: 6 additions & 5 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Moment, Nonce};
use pallet_asset_conversion::{NativeOrAssetId, NativeOrAssetIdConverter};
use pallet_broker::{CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600};
use pallet_election_provider_multi_phase::{GeometricDepositBase, SolutionAccuracyOf};
use pallet_identity::simple::IdentityInfo;
use pallet_identity::legacy::IdentityInfo;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_nfts::PalletFeatures;
use pallet_nis::WithMaximumOf;
Expand Down Expand Up @@ -1459,8 +1459,10 @@ impl pallet_grandpa::Config for Runtime {
}

parameter_types! {
pub const BasicDeposit: Balance = 10 * DOLLARS; // 258 bytes on-chain
pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain
// difference of 26 bytes on-chain for the registration and 9 bytes on-chain for the identity
// information, already accounted for by the byte deposit
pub const BasicDeposit: Balance = deposit(1, 17);
pub const ByteDeposit: Balance = deposit(0, 1);
pub const SubAccountDeposit: Balance = 2 * DOLLARS; // 53 bytes on-chain
pub const MaxSubAccounts: u32 = 100;
pub const MaxAdditionalFields: u32 = 100;
Expand All @@ -1471,10 +1473,9 @@ impl pallet_identity::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BasicDeposit = BasicDeposit;
type FieldDeposit = FieldDeposit;
type ByteDeposit = ByteDeposit;
type SubAccountDeposit = SubAccountDeposit;
type MaxSubAccounts = MaxSubAccounts;
type MaxAdditionalFields = MaxAdditionalFields;
type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
type MaxRegistrars = MaxRegistrars;
type Slashed = Treasury;
Expand Down
18 changes: 7 additions & 11 deletions substrate/frame/alliance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ use frame_support::{
},
weights::Weight,
};
use pallet_identity::simple::IdentityField;
use scale_info::TypeInfo;

pub use pallet::*;
Expand All @@ -135,9 +134,9 @@ type NegativeImbalanceOf<T, I> = <<T as Config<I>>::Currency as Currency<

/// Interface required for identity verification.
pub trait IdentityVerifier<AccountId> {
/// Function that returns whether an account has an identity registered with the identity
/// provider.
fn has_identity(who: &AccountId, fields: u64) -> bool;
/// Function that returns whether an account has the required identities registered with the
/// identity provider.
fn has_required_identities(who: &AccountId) -> bool;

/// Whether an account has been deemed "good" by the provider.
fn has_good_judgement(who: &AccountId) -> bool;
Expand All @@ -149,7 +148,7 @@ pub trait IdentityVerifier<AccountId> {

/// The non-provider. Imposes no restrictions on account identity.
impl<AccountId> IdentityVerifier<AccountId> for () {
fn has_identity(_who: &AccountId, _fields: u64) -> bool {
fn has_required_identities(_who: &AccountId) -> bool {
true
}

Expand Down Expand Up @@ -339,7 +338,7 @@ pub mod pallet {
/// Balance is insufficient for the required deposit.
InsufficientFunds,
/// The account's identity does not have display field and website field.
WithoutIdentityDisplayAndWebsite,
WithoutRequiredIdentityFields,
/// The account's identity has no good judgement.
WithoutGoodIdentityJudgement,
/// The proposal hash is not found.
Expand Down Expand Up @@ -1082,13 +1081,10 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
}

fn has_identity(who: &T::AccountId) -> DispatchResult {
const IDENTITY_FIELD_DISPLAY: u64 = IdentityField::Display as u64;
const IDENTITY_FIELD_WEB: u64 = IdentityField::Web as u64;

let judgement = |who: &T::AccountId| -> DispatchResult {
ensure!(
T::IdentityVerifier::has_identity(who, IDENTITY_FIELD_DISPLAY | IDENTITY_FIELD_WEB),
Error::<T, I>::WithoutIdentityDisplayAndWebsite
T::IdentityVerifier::has_required_identities(who),
Error::<T, I>::WithoutRequiredIdentityFields
);
ensure!(
T::IdentityVerifier::has_good_judgement(who),
Expand Down
Loading

0 comments on commit 21fbc00

Please sign in to comment.