Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

make pool roles optional #11411

Merged
merged 6 commits into from
May 15, 2022
Merged

Conversation

kianenigma
Copy link
Contributor

@kianenigma kianenigma commented May 13, 2022

Main feature that's being added is:

  • The pools now can have explicitly optional roles. One can currently achieve this as well, by setting the role to some address that is publicly known to be key-less, but that's a bit janky. Now, roles can simply be set to None.
  • Now, a pool can express things like:
    • If I set my root to none, I will never change any of the roles again.
    • If I set my nominator to none, I will never change my nominations.
    • If I set my state_toggler to none, I will never be able to destroy this pool (unless if it gets slashed up to 90%, which should really rarely happen).
    • Note that governance can re-set any of the above if needed.

Any pool needs to set nominations at least once. To prevent mistakes about this, the create call MUST specify all roles. Then, a call to update_roles can remove any of the roles that should no longer exist. Similar to a chain, a pool can operate for a while with root and then destroy it.

Other than this

  • I added a test to demonstrate a confusion that you cannot bail out of slashing, if you unbond in the same era

  • made a small change to make maybe_merge_pools a bit more comprehensible. This function is only used in a few instances and should be trivial to check.

  • (unfortunately) Needs a migration that moves the current pool roles in westend and kusama to the new format. This should be fine. This is exactly for now we proposed deploying pools on kusama with a bound on the maximum number of pools (128), so we can do such surgeries easier.

To avoid needing to migrate Polkadot pools as well, we should merge this before 0.23 and deploying anything to Polkadot.

polkadot compnaion: paritytech/polkadot#5524

@kianenigma kianenigma added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. labels May 13, 2022
Comment on lines +52 to +54
log!(
info,
"Running migration with current storage version {:?} / onchain {:?}",
Copy link
Member

Choose a reason for hiding this comment

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

is migration needed? are any pools already there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are on westend and there will be on Kusama by the time this PR makes it into a release.

Comment on lines +1024 to +1025
if let Some(newest_era_to_remove) =
current_era.checked_sub(T::PostUnbondingPoolsWindow::get())
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a subtle change. I assume the value is the same, but just one less storage read?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made a small change to make maybe_merge_pools a bit more comprehensible. This function is only used in a few instances and should be trivial to check.

Should be easy to verify, and it was intentional.

frame/nomination-pools/src/lib.rs Show resolved Hide resolved
frame/nomination-pools/src/migration.rs Show resolved Hide resolved
frame/nomination-pools/src/migration.rs Show resolved Hide resolved
frame/nomination-pools/src/migration.rs Outdated Show resolved Hide resolved
frame/nomination-pools/src/migration.rs Show resolved Hide resolved
@kianenigma kianenigma added B7-runtimenoteworthy and removed B0-silent Changes should not be mentioned in any release notes labels May 14, 2022
@kianenigma
Copy link
Contributor Author

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

Copy link

@AKsphere AKsphere left a comment

Choose a reason for hiding this comment

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

Couldn't have done it without you! 👌

godcodehunter pushed a commit to sensoriumxr/substrate that referenced this pull request Jun 22, 2022
* make pool roles optional

* undo lock file changes?

* add migration

* Fix

* fix review comments
DaviRain-Su pushed a commit to octopus-network/substrate that referenced this pull request Aug 23, 2022
* make pool roles optional

* undo lock file changes?

* add migration

* Fix

* fix review comments
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* make pool roles optional

* undo lock file changes?

* add migration

* Fix

* fix review comments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants