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

Validator manager pallet fails to unapprove validators. #116

Closed
PopcornPaws opened this issue Mar 7, 2023 · 1 comment · Fixed by #117
Closed

Validator manager pallet fails to unapprove validators. #116

PopcornPaws opened this issue Mar 7, 2023 · 1 comment · Fixed by #117
Assignees
Labels
bug something isn't working as intended

Comments

@PopcornPaws
Copy link
Contributor

Description

The validator manager pallet has three functions exposed:

  • add_validator
  • remove_validator
  • add_validator_again

And two main storage items:

  • Validators (active validator set)
  • ApprovedValidators (validators who were once added by a sudo entity, however they might not be active at the moment)

When running remove_validator the pallet is supposed to run do_remove_validator which removes the account from Validators and then run unapprove_validator which removes the account from the ApprovedValidators storage.

However, the pallet doesn't remove accounts from the ApprovedValidators set, only from the Validators set. Therefore, when you attempt to add the validator again, you get a Duplicate error, because the validator is already included in ApprovedValidators even though it was removed from Validators.

Solution

There's a missing line in unapprove_validator that actually overwrites the storage with the removed entry:

let mut approved_set = <ApprovedValidators<T>>::get();
approved_set.retain(|v| *v != validator_id);
<ApprovedValidators<T>>::put(approved_set); // MISSING
@PopcornPaws PopcornPaws added the bug something isn't working as intended label Mar 7, 2023
@PopcornPaws PopcornPaws self-assigned this Mar 7, 2023
@PopcornPaws
Copy link
Contributor Author

Not a high priority right now, we can circumvent this problem. Although, this functionality might be intended at some level, because the im-online pallet only removes active validators (when they go offline) and not approved validators. Thus, when a validator comes back online, they can re-join the network as validators because they are still approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant