-
Notifications
You must be signed in to change notification settings - Fork 693
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] Decouple usernames from identities #5554
[Identity] Decouple usernames from identities #5554
Conversation
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
The CI pipeline was cancelled due to failure one of the required jobs. |
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
}, | ||
Provider::Allocation => { | ||
// We don't refund the allocation, it is lost, but we refund some weight. | ||
T::WeightInfo::remove_expired_approval(1) |
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.
maybe having some const or enum instead of 0 and 1 would make it more readable.
But it is good to me.
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.
Could just pass the Provider Enum? Similarly in other places.
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
@@ -265,33 +297,47 @@ pub mod pallet { | |||
|
|||
/// A map of the accounts who are authorized to grant usernames. | |||
#[pallet::storage] | |||
pub type UsernameAuthorities<T: Config> = | |||
StorageMap<_, Twox64Concat, T::AccountId, AuthorityPropertiesOf<T>, OptionQuery>; | |||
pub type AuthorityOf<T: Config> = |
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.
This implies for a given suffix, there can be only one authority? Wasn't clear from the docs.
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.
Yes, one authority per suffix. I will update the docs.
/// A username has been removed. | ||
UsernameRemoved { username: Username<T> }, | ||
/// A username has been killed. | ||
UsernameKilled { username: Username<T> }, |
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.
UsernameRemoved
and UsernameKilled
sounds very synonymous. May be should call it as ForceUsernameRemoved
?
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.
From pallet terminology in docs, "removed" and "killed" are different things. I'd prefer to stick to even naming convention of 2 word events and defer to call documentation. I could write more comprehensive docs for the event enum variants.
substrate/frame/identity/src/lib.rs
Outdated
// The authority may already exist, but we don't need to check. They might be changing | ||
// their suffix or adding allocation, so we just want to overwrite whatever was there. |
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.
Comment needs to be updated.
Do we still don't need to check for overwrite? This might be overwriting authority for a given suffix.
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'll rethink this section.
@@ -1041,11 +1087,15 @@ pub mod pallet { | |||
#[pallet::weight(T::WeightInfo::remove_username_authority())] | |||
pub fn remove_username_authority( | |||
origin: OriginFor<T>, | |||
suffix: Vec<u8>, | |||
authority: AccountIdLookupOf<T>, |
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.
Don't strictly need authority as input anymore. But fine either way.
pub fn set_username_for( | ||
origin: OriginFor<T>, | ||
who: AccountIdLookupOf<T>, | ||
username: Vec<u8>, | ||
signature: Option<T::OffchainSignature>, | ||
use_allocation: bool, |
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.
Update fn rustdoc about use_allocation
flag? Currently it only says authority must have an allocation
.
}, | ||
Provider::Allocation => { | ||
// We don't refund the allocation, it is lost, but we refund some weight. | ||
T::WeightInfo::remove_expired_approval(1) |
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.
Could just pass the Provider Enum? Similarly in other places.
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
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.
Looks good to me
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
I implemented the try-runtime checks. There is a unit test for the migration and I manually tested the |
…-refactor Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
This PR refactors `pallet-identity` to decouple usernames from identities. Main changes in this PR: - Separate usernames from identities in storage, allowing for correct deposit accounting - Introduce the option for username authorities to put up a deposit to issue a username - Allow authorities to remove usernames by declaring the intent to do so, then removing the username after the grace period expires - Refactor the authority storage to be keyed by suffix rather than owner account. - Introduce the concept of a system provider for a username, different from a governance allocation, allowing for usernames set by the system and not a specific authority - Implement multi-block migration to enable all of the changes described above --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io> Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com>
This PR refactors `pallet-identity` to decouple usernames from identities. Main changes in this PR: - Separate usernames from identities in storage, allowing for correct deposit accounting - Introduce the option for username authorities to put up a deposit to issue a username - Allow authorities to remove usernames by declaring the intent to do so, then removing the username after the grace period expires - Refactor the authority storage to be keyed by suffix rather than owner account. - Introduce the concept of a system provider for a username, different from a governance allocation, allowing for usernames set by the system and not a specific authority - Implement multi-block migration to enable all of the changes described above --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io> Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com>
This PR refactors
pallet-identity
to decouple usernames from identities.Main changes in this PR: