fix: on-chain storage version for pallets where it is missing#458
Merged
fix: on-chain storage version for pallets where it is missing#458
Conversation
ntn-x2
commented
Jan 26, 2023
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "try-runtime")] |
Contributor
Author
There was a problem hiding this comment.
Did not find a better way to make the dependencies that are only used with try-runtime optional.
Contributor
There was a problem hiding this comment.
Can you not make the pre_ and post_ implementation optional?
Contributor
Author
There was a problem hiding this comment.
Yes but you can't import crates only for that. The point of this solution is that the crates for the pallets are imported only when the feature is enabled.
Contributor
Author
There was a problem hiding this comment.
Hence the dependency for those can be made optional.
Contributor
There was a problem hiding this comment.
ah you are referring to the where clause
5 tasks
weichweich
approved these changes
Jan 30, 2023
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A while ago, we have migrated to using the
StorageVersionway of declaring the storage version for our pallets. Nevertheless, we were not aware that such a change would only be written to storage either explicitly in a storage migration for live chains, or at genesis for new chains.This means that we have few places where the declared storage version, which is a
constinside each pallet, does not reflect what is written on chain in the relative entry.This means that, for the future, every time we add a new pallet we must also include the storage migration to write the value of the storage version on chain.
Peregrine
The
attestationandpublicCredentialspallet expose aStorageVersionof 1, but the on-chain value is 0.Spiritnet
It has the same issue as Peregrine, with the addition of the
web3Namespallet as well.This PR then exposes a pre-runtime hook that logs with a warning all pallets that suffer from this inconsistency, and a post-runtime check that verifies that everything has been fixed.
Note
The migration that updates the storage version has to be run last, so that pre- and post- runtime hooks don't trigger any unexpected behaviour.
How to test
Compile the
kilt-parachainbinary withcargo build -p kilt-parachain --features try-runtime.For Peregrine, run:
For Spiritnet, run: