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

Remove staking delay exits migration #662

Merged
merged 4 commits into from
Aug 4, 2021

Conversation

4meta5
Copy link
Contributor

@4meta5 4meta5 commented Aug 3, 2021

Also adds migrations.md to root of parachain-staking pallet, which will link to migration creation/removal PRs to track migrations. Networks can use these PRs to write custom migrations when they need to jump versions i.e. Nominator1 -> Nominator3.

@4meta5 4meta5 added A0-pleasereview Pull request needs code review. B0-silent Changes should not be mentioned in any release notes labels Aug 3, 2021
Comment on lines -903 to -906
let (reads, writes) = delay_nomination_exits_migration_execution::<T>();
<T as frame_system::Config>::DbWeight::get().reads(reads)
+ <T as frame_system::Config>::DbWeight::get().writes(writes)
+ 5_000_000_000 // 1% of the max block weight, to account for computation
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't notice this until now. Nice actual weight accounting.

Comment on lines 941 to 942
/// True if executed, false by default
type DelayNominationExitsMigration<T: Config> = StorageValue<_, bool, ValueQuery>;
Copy link
Contributor

Choose a reason for hiding this comment

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

We're removing the type from code, but the data will still be stored in the on-chain storage. A single bool will definitely not bloat state in any practical way. Still I wonder if we should clean it up.

If so we could either add the cleanup logic to on_runtime_upgrade which would then have to be removed again later. Or we could do it manually with a set_storage extrinsic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, I think removing it in on_runtime_upgrade is simple and makes sense.

Copy link
Contributor Author

@4meta5 4meta5 Aug 4, 2021

Choose a reason for hiding this comment

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

I added back the storage item, but killed whatever it stored in on_runtime_upgrade. In a future PR after this runtime upgrade is run, I'll remove the storage item itself and the on_runtime_upgrade.

Does kill() mean that it's still storing bool::default() == false in storage? Any suggestions here?

Maybe the extrinsic approach is better...

Copy link
Contributor

Choose a reason for hiding this comment

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

kill() means it is not storing anything in storage. Since you declared it as a ValueQuery however, the runtime and tools like polkadot js will act as if it stored bool::default(). This should be fine though because the migration code is gone so nothing should be reading it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So we need 2 upgrades before removing the on_runtime_upgrade right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, one more after this one

@crystalin crystalin added B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes A8-mergeoncegreen Pull request is reviewed well. and removed B0-silent Changes should not be mentioned in any release notes A0-pleasereview Pull request needs code review. labels Aug 4, 2021
@4meta5 4meta5 merged commit 69a13b0 into master Aug 4, 2021
@4meta5 4meta5 deleted the amar-remove-staking-delay-exits-migration branch August 4, 2021 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A8-mergeoncegreen Pull request is reviewed well. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants