-
Notifications
You must be signed in to change notification settings - Fork 710
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
Dedup nomination targets #6307
base: master
Are you sure you want to change the base?
Dedup nomination targets #6307
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.
Just one comment; otherwise, lgtm!
We don’t need to migrate the single account. When they update their nomination, any duplicates will be removed automatically. (You could add a unit test to demonstrate that updating nominations removes old duplicates as well.)
Thank you for your PR!
@@ -1291,6 +1291,8 @@ pub mod pallet { | |||
Error::<T>::TooManyTargets | |||
); | |||
|
|||
targets.dedup(); |
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 removes only consecutive duplicates, do we enforce it is sorted somewhere?
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.
6131b21
to
134f7f6
Compare
@@ -1296,21 +1296,26 @@ pub mod pallet { | |||
Error::<T>::TooManyTargets | |||
); | |||
|
|||
let mut targets = targets | |||
.into_iter() | |||
.map(|t| T::Lookup::lookup(t).map_err(DispatchError::from)) |
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 we use AccountId
here? I'm not sure why we are using the Lookup
type here.
Deduplicate the targets during the nomination process.
And I'm not pretty sure this is designed to be liked this.
This was found by the Subscan team. There is only one such special account in Polkadot(need a migration?). The Polkadot Apps UI will filter the selected targets for the users. I assume this uses a custom client to submit the extrinsic.
Note: the targets length affect the weight.
Or should we just return an error?