-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add GenesisConfig to identity pallet #14774
base: master
Are you sure you want to change the base?
Add GenesisConfig to identity pallet #14774
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pr.
On the right track but needs some changes and tests.
frame/identity/src/lib.rs
Outdated
@@ -201,6 +202,44 @@ pub mod pallet { | |||
ValueQuery, | |||
>; | |||
|
|||
#[pallet::genesis_config] | |||
pub struct GenesisConfig<T: Config> { | |||
pub identities: Vec<(T::AccountId, String)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want this
pub identities: Vec<(T::AccountId, String)>, | |
pub identities: Vec<(T::AccountId, IdentityInfo)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this was done to not require trait bounds on the IdentityInfo
type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even so, it seems much more preferable to be able to specify all other identity-related fields in genesis config, so let's figure out what the trait bounds should be here...
Oh, it's just T::MaxAdditionalFields
, so we should just use that:
pub identities: Vec<(T::AccountId, String)>, | |
pub identities: Vec<(T::AccountId, IdentityInfo<T::MaxAdditionalFields>)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for comments both, I didn't use IdentityInfo
initially as it wanted Deserialize<'_>
, I agree it is preferable to support this though, I will try to add serde::[Des|S]erialize
on these types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is what i meant with trait bounds. Normally we just use POD types here to not having to use Serde from within the runtime.
I think its fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Vec<u8>
would be a bit less biased than a String - otherwise the encoding is not fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll probably need BoundedVec
then, no reason to not make this derive MEL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, uses BoundedVec
now
bin/node/testing/src/genesis.rs
Outdated
@@ -52,6 +52,9 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> Run | |||
code: code.map(|x| x.to_vec()).unwrap_or_else(|| wasm_binary_unwrap().to_vec()), | |||
..Default::default() | |||
}, | |||
identity: IdentityConfig { | |||
identities: vec![(alice(), "Alice".to_string()), (bob(), "Bob".to_string())], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be mindful that Data
in IdentityInfo
is truncated to 32 bytes (see docs), so it is recommended to pass a hash of the data rather than the data itself for stuff like display
.
035b752
to
232fdf0
Compare
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
frame/identity/src/lib.rs
Outdated
web: Data::None, | ||
additional: BoundedVec::default(), | ||
}, | ||
judgements: BoundedVec::default(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much sense does it make not to provide any judgments?
Having no judgement is as good as having no identity at all.
But not sure if its possible without also adding a genesis judge…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you suggested it, we are now depending upon you to implement a genesis identity judge :)
Description
This change adds a
GenesisConfig
to the identity pallet, allowing downstream users to automatically seed Identities via chainspec config.Checklist
A
,B
,C
andD
required)