This repository was archived by the owner on Nov 15, 2023. It is now read-only.
FRAME: Initialize StorageVersion on runtime upgrade#13430
Closed
FRAME: Initialize StorageVersion on runtime upgrade#13430
StorageVersion on runtime upgrade#13430Conversation
Member
|
Basti is working on something similar #13417 |
Member
|
There exists a migration for this substrate/frame/support/src/migrations.rs Line 63 in e374a33 This was added as we introduced storage version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The initial
StorageVersionof a pallet is only set in itsOnGenesisimplementation. This works for pallets which exist at genesis. However, if a pallet is added later with a runtime upgrade the version will be uninitialized in storage.Runtime authors need to manually make sure that they initialize this value when adding a pallet. If they forget it can have bad consequences: An uninitialized value will make
StorageVersion::get()return0. This might lead to storage migrations falsely triggering. This actually happened to some chains addingpallet-contracts.Downside is that this adds one storage read per pallet on runtime upgrades. The added safety and convenience might be worth it.
Maybe we should also write the genesis configuration of the added pallet (if it exists) to storage if no storage version was set (we assume the pallet was added).