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:
georgepisaltu
2023-11-03 21:38:26 +02:00
committed by GitHub
parent ca5f10567a
commit 21fbc00d04
15 changed files with 353 additions and 459 deletions
+7 -11
View File
@@ -112,7 +112,6 @@ use frame_support::{
},
weights::Weight,
};
use pallet_identity::simple::IdentityField;
use scale_info::TypeInfo;
pub use pallet::*;
@@ -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;
@@ -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
}
@@ -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.
@@ -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),