-
Notifications
You must be signed in to change notification settings - Fork 252
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
Add fallback decoding for the pallet-domains v3 storage migration #3407
Conversation
8b4a9ca
to
ebce745
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense! just one nit.
let mut domain_obj = | ||
Pallet::<T>::domain_registry_fallback(domain_id).ok_or(Error::DomainNotFound)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue only shortly exists in runtime API calls on the block that contains the runtime upgrade.
While do_update_domain_allow_list
(and also do_register_operator
) is only called during block execution, where it is either using the old runtime and before migration or the new runtime and after the migration, it should not have the issue so not needed to use domain_registry_fallback
.
Though it is also no harm to use domain_registry_fallback
thus non-blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine by me 👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thank you!
let mut domain_obj = | ||
Pallet::<T>::domain_registry_fallback(domain_id).ok_or(Error::DomainNotFound)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine by me 👍🏼
This PR makes all production reads of the domain registry go through a new
domain_registry_fallback()
method. This method first tries decoding as the v3 storage format, then tries v2 if that doesn't work.This is required so that code which queries the domain registry between runtime activation and storage migration still works.
Early writes to the storage using the v3 format are fine: they will be skipped as "corrupted" by the migration (which reads as v2), and be read as v3 correctly by the fallback decoder:
https://docs.rs/frame-support/latest/frame_support/storage/types/struct.StorageMap.html#method.translate_values
During local
dev
testing, the upgrade block logs some spurious corrupted state warnings, then the next block imports without any warnings:Code contributor checklist: