Add migration for ForeignAssetCreator#581
Conversation
| // Write to the new storage with removed and added fields | ||
| for (asset_id, old_location) in asset_id_to_foreign_asset_data { | ||
| if let Ok(new_location) = Runtime::ForeignAsset::try_from(old_location) { | ||
| AssetIdToForeignAsset::<Runtime>::insert(asset_id, new_location); |
There was a problem hiding this comment.
YOu can probably do both migrations here and not iterate twice
There was a problem hiding this comment.
Hmm. But, that would mean I am assuming the semantics of these two storage items in runtime.
runtime/common/src/migrations.rs
Outdated
| Runtime::DbWeight::get() | ||
| .reads(migrated_count as u64) | ||
| .saturating_add(Runtime::DbWeight::get().writes(migrated_count as u64 + 3u64)) | ||
| .saturating_add(Runtime::DbWeight::get().writes(foreign_asset_to_asset_id_count as u64)) |
There was a problem hiding this comment.
Dont you need to multiply by 2 here? (as you are writing twice per foreign_asset_to_asset_id_count
There was a problem hiding this comment.
The other write is calculated above in migrated_count
9f08bab to
076476e
Compare
runtime/common/src/migrations.rs
Outdated
| // Removing older entries with old location as key | ||
| let mut removal_result = storage::unhashed::clear_prefix( | ||
| &ForeignAssetToAssetId::<Runtime>::final_prefix(), | ||
| None, | ||
| None, | ||
| ); | ||
| while removal_result.maybe_cursor.is_some() { | ||
| removal_result = storage::unhashed::clear_prefix( | ||
| &ForeignAssetToAssetId::<Runtime>::final_prefix(), | ||
| None, | ||
| removal_result.maybe_cursor.as_deref(), | ||
| ); | ||
| } |
There was a problem hiding this comment.
This may not be needed because storage_key_iter().drain() above already removes from storage
There was a problem hiding this comment.
Oh. I did not know that drain also removes the item from storage.
There was a problem hiding this comment.
Me neither, I had to look at docs: https://paritytech.github.io/polkadot-sdk/master/frame_support/storage/struct.PrefixIterator.html#method.drain
There was a problem hiding this comment.
Removed this call in next commit.
8ef4430 to
cb15a21
Compare
runtime/common/src/migrations.rs
Outdated
| //! This module acts as a registry where each migration is defined. Each migration should implement | ||
| //! the "Migration" trait declared in the pallet-migrations crate. | ||
|
|
||
| use frame_support::__private::log; |
There was a problem hiding this comment.
| use frame_support::__private::log; |
| } | ||
|
|
||
| // One db read and one db write per element, plus the on-chain storage | ||
| Runtime::DbWeight::get().reads_writes(migrated_count as u64, 2 * migrated_count as u64) |
There was a problem hiding this comment.
I see, 1 write when using drain, and another write when using insert...
* first branches * removfe try runtime and start updating * start working on fixes * advances * fixes before rt * dancebox compiles * flashbox compiles * fix a million things * node changes * update lock * fixes2 * fix xcm-primtiives * remove from dancebox * add primitive-types to cargo.toml * fix cargo.lock * add primitive-types/std to dancebox * Add PoV size host function to runtimes * Fix zombienet config * let's see if now tomls are fixed * fix currencyAdapter * Update mocks * Rest of mocks and unit tests fixes * fix dev tests execution * remove build output * FMT * chopsticks * fix custom policy test * fix scripts typescript api gen * base fee * update packageS * fmt * use ResolveTo, although we lose the event * resolveto * fmt * Update polkadot-sdk commit, solving dup import * fix different message when invalid params returned from rpc * Fix XCMv4 types in tests * XCM * FMT * Update lock * Config get * fmt * VersionedXcmV4 * different fixes * fmt * brings back event for on demand * left overs from merge * Fix xcm-core-buyer tests * start putting migrations in * lock file update Signed-off-by: girazoki <gorka.irazoki@gmail.com> * fix zombienet upgrade jobs * Add migration for ForeignAssetCreator (#581) * Add migration for ForeignAssetCreator * use accurate weight --------- Signed-off-by: girazoki <gorka.irazoki@gmail.com> Co-authored-by: Agusrodri <agusrodriguez2456@gmail.com> Co-authored-by: Tomasz Polaczyk <tmpolaczyk@gmail.com> Co-authored-by: Francisco Gamundi <francisco@moonsonglabs.com> Co-authored-by: Parth <desaiparth08@gmail.com>
No description provided.