Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identity pallet improvements #2048

Merged
merged 34 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ac9f37e
Rename `simple` module to `legacy`
georgepisaltu Oct 25, 2023
e3ce237
Fix benchmarks incorrectly using `additional`
georgepisaltu Oct 25, 2023
0e72dc1
Implement byte deposit
georgepisaltu Oct 25, 2023
3112da8
Add `poke_deposit` extrinsic
georgepisaltu Oct 26, 2023
f41d3f0
Move max identity size to constant out of pallet
georgepisaltu Oct 26, 2023
c6e7bf0
Remove obsolete config and fix alliance tests
georgepisaltu Oct 26, 2023
e84fdca
Address review comments
georgepisaltu Oct 27, 2023
2ff0b51
Add more checked arithmetic
georgepisaltu Oct 27, 2023
09cdec0
Remove explicit `IdentityFields` parameter
georgepisaltu Oct 26, 2023
bf3eca5
Merge remote-tracking branch 'origin' into george/fix-identity-pallet
georgepisaltu Oct 27, 2023
47ae9b6
Fix formatting
georgepisaltu Oct 27, 2023
41b3d81
Fix clippy
georgepisaltu Oct 27, 2023
d0d23a2
Remove `poke_deposit` extrinsic
georgepisaltu Oct 31, 2023
28564c8
Merge remote-tracking branch 'origin' into george/fix-identity-pallet
georgepisaltu Oct 31, 2023
609bbf3
Merge remote-tracking branch 'origin' into george/fix-identity-pallet
georgepisaltu Oct 31, 2023
07b24e3
Fix doc comment
georgepisaltu Oct 31, 2023
f84b0bf
Base substrate node basic deposit on byte size
georgepisaltu Nov 1, 2023
98f8ce4
Merge remote-tracking branch 'origin' into george/fix-identity-pallet
georgepisaltu Nov 1, 2023
70abd0d
Use correct max additional fields in legacy
georgepisaltu Nov 1, 2023
d92dfff
Add integrity test for identity max size
georgepisaltu Nov 1, 2023
e8f094f
Merge remote-tracking branch 'origin' into george/fix-identity-pallet
georgepisaltu Nov 1, 2023
4d742cb
Refine identity field impl
georgepisaltu Nov 2, 2023
810cbd7
Adapt alliance pallet to new identity impl
georgepisaltu Nov 2, 2023
cf03bae
Rename `IdentityField` to `FieldsBitFlags`
georgepisaltu Nov 2, 2023
b6f914b
Move `MAX_IDENTITY_SIZE` to pallet config
georgepisaltu Nov 2, 2023
7a18853
Fix substrate-node alliance impl
georgepisaltu Nov 2, 2023
34719cc
Merge remote-tracking branch 'origin' into george/fix-identity-pallet
georgepisaltu Nov 2, 2023
de46783
Collapse alliance required id functions
georgepisaltu Nov 3, 2023
8d713cc
Minor refactoring
georgepisaltu Nov 3, 2023
63e952e
Remove `MaxIdentitySize` from config
georgepisaltu Nov 3, 2023
b01a556
Improve docs for `IdentityInformationProvider`
georgepisaltu Nov 3, 2023
9d5405a
Rename `FieldsBitFlags` to `FieldsIdentifier`
georgepisaltu Nov 3, 2023
19151c5
Merge remote-tracking branch 'origin' into george/fix-identity-pallet
georgepisaltu Nov 3, 2023
0d17140
Remove unused import in substrate node impls
georgepisaltu Nov 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading