-
Notifications
You must be signed in to change notification settings - Fork 85
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
AssetRegistry: protect asset_registry migration #1594
Conversation
match (loc_count, meta_count) { | ||
(loc, meta) | ||
if (loc, meta) == (ALTAIR_ASSET_LOC_COUNT, ALTAIR_ASSET_METADATA_COUNT) => | ||
{ |
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.
Check moved to the migration itself
|
||
log::info!("💎 AssetRegistryMultilocationToXCMV3: on_runtime_upgrade: completed!"); | ||
RocksDbWeight::get().reads_writes( | ||
2, | ||
loc_count.saturating_add(meta_count).into(), |
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.
I think we should add the cost of reading the previous keys here
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.
Great catch, I agree. StorageMap::clear(n, None)
should have n
reads and writes each!
@@ -185,7 +175,7 @@ impl< | |||
{ | |||
fn get_key_counts() -> (u32, u32) { | |||
// let loc_count = | |||
// orml_asset_registry::LocationToAssetId::<T>::iter_keys().count() as u32; | |||
// orml_asset_registry::LocationToAssetId::<T>::iter_keys().count() as u32; |
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.
Not sure why the commented line doesn't work
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.
I remember that these commented lines did not work because of the existing decoding failure(s) on Altair related to these storages. Keys which cannot be decoded are not counted whereas count_storage_keys
does not try to decode and thus counts correctly.
In the end these commented lines should have not been merged, sorry about that.
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.
Keys which cannot be decoded are not counted whereas count_storage_keys does not try to decode and thus counts correctly.
Good point! Thanks for expanding it.
BTW, not sure if this migration should still be there or can be removed from altair (?) |
Confirmed, it's needed |
Yes. Next release must include Altair for sure. We have not treated it properly due to limited capacity. |
Checked against
|
cfad34e
to
6353ab0
Compare
|
||
log::info!("💎 AssetRegistryMultilocationToXCMV3: on_runtime_upgrade: completed!"); | ||
RocksDbWeight::get().reads_writes( | ||
2, | ||
loc_count.saturating_add(meta_count).into(), |
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.
Great catch, I agree. StorageMap::clear(n, None)
should have n
reads and writes each!
@@ -185,7 +175,7 @@ impl< | |||
{ | |||
fn get_key_counts() -> (u32, u32) { | |||
// let loc_count = | |||
// orml_asset_registry::LocationToAssetId::<T>::iter_keys().count() as u32; | |||
// orml_asset_registry::LocationToAssetId::<T>::iter_keys().count() as u32; |
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.
I remember that these commented lines did not work because of the existing decoding failure(s) on Altair related to these storages. Keys which cannot be decoded are not counted whereas count_storage_keys
does not try to decode and thus counts correctly.
In the end these commented lines should have not been merged, sorry about that.
Thanks for your fast review as always @william! |
Description
The check for the expected state of
asset_registry
migration is checked undertry-runtime
, if the chain state changes, the new state sets an empty vector, removing all currencies.This PR modifies the migration only to take effect if the chain state is the expected state.