Add GenesisConfig to identity pallet#14774
Conversation
liamaharon
left a comment
There was a problem hiding this comment.
Thanks for the pr.
On the right track but needs some changes and tests.
frame/identity/src/lib.rs
Outdated
|
|
||
| #[pallet::genesis_config] | ||
| pub struct GenesisConfig<T: Config> { | ||
| pub identities: Vec<(T::AccountId, String)>, |
There was a problem hiding this comment.
I think you want this
| pub identities: Vec<(T::AccountId, String)>, | |
| pub identities: Vec<(T::AccountId, IdentityInfo)>, |
There was a problem hiding this comment.
I assume this was done to not require trait bounds on the IdentityInfo type?
There was a problem hiding this comment.
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.
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.
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.
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.
We'll probably need BoundedVec then, no reason to not make this derive MEL.
bin/node/testing/src/genesis.rs
Outdated
| ..Default::default() | ||
| }, | ||
| identity: IdentityConfig { | ||
| identities: vec![(alice(), "Alice".to_string()), (bob(), "Bob".to_string())], |
There was a problem hiding this comment.
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.
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.
Since you suggested it, we are now depending upon you to implement a genesis identity judge :)
Description
This change adds a
GenesisConfigto the identity pallet, allowing downstream users to automatically seed Identities via chainspec config.Checklist
A,B,CandDrequired)