-
Notifications
You must be signed in to change notification settings - Fork 798
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
State Diff Recorder + Guard #240
Comments
Nice! I see two general ways to go about this: either try and use a proof recorded with externalities, and try and extract the list of keys changed from the proof, although this might be a bit cumbersome. Perhaps we can use a custom proof recorded. Or, implement alternative |
I think it is trivial to do via iterating |
Also we should have a guard that makes sure all storage is decodable. This is how I would go about it: @@ -1737,8 +1737,24 @@ type Migrations = (
pallet_nomination_pools::migration::v2::MigrateToV2<Runtime>,
pallet_alliance::migration::Migration<Runtime>,
pallet_contracts::Migration<Runtime>,
+ DecodeAll<Runtime>,
);
+struct DecodeAll;
+impl OnRuntimeUpgrade for DecodeAll {
+ fn on_runtime_upgrade() -> Weight {
+ //
+ }
+
+ #[cfg(feature = "try-runtime")]
+ fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> {
+ // - iterate metadata
+ // - list all storage keys
+ // - decode all of ths
+ Ok(())
+ }
+} |
This is what i created this issue for #241 |
@ggwpez this is an interesting one, would like to work on it. I am guessing |
Yea, but its rather small. It is a big design space, but starting small with a good foundation should be fine since it can then be extended later. Note that this is rather difficult to get right first try, but if you can do it then its great 😄 |
yeah, I see. I was thinking of writing something that simply checks if must change prefixes are actually changed. And then gradually tackle the |
Yes sounds fine. One way would be to take a snapshot of the storage and then compare it. Maybe creating a storage transaction could also work 🤔 yea just try it out a bit. |
In migrations and tests it is sometimes desirable to know and restrict which storage keys change. Further it is nice to get a diff of all changes, if some unexpected changes happened.
For example a pallet migration would whitelist all storage keys with a specific prefix as "expected to change". Then later on when the migration finishes it is possible to assert that only exactly these keys changed. Otherwise a diff is printed and it panics.
Migration example of
Pallet
whereOtherPallet
can also change but nothing else:You could also try it without a builder and instead use single
assert!
statements, but then something likeAnythingElse
does not work anymore. The builder pattern helps here by holding a context.cc @cor @kianenigma
The text was updated successfully, but these errors were encountered: