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

Dedup nomination targets #6307

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AurevoirXavier
Copy link
Contributor

@AurevoirXavier AurevoirXavier commented Oct 31, 2024

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?


@kianenigma
Copy link
Contributor

@gpestana @Ank4n

Copy link
Contributor

@Ank4n Ank4n left a 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!

substrate/frame/staking/src/pallet/mod.rs Outdated Show resolved Hide resolved
@Ank4n Ank4n requested a review from gpestana October 31, 2024 10:36
@@ -1291,6 +1291,8 @@ pub mod pallet {
Error::<T>::TooManyTargets
);

targets.dedup();
Copy link
Contributor

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?

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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))
Copy link
Contributor Author

@AurevoirXavier AurevoirXavier Nov 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants