From 2474e843b5b6547698676c16245d33546b6d89c2 Mon Sep 17 00:00:00 2001 From: Robert Gabriel Jakabosky Date: Fri, 18 Oct 2024 23:49:40 +0800 Subject: [PATCH] Fixup staging asset id maps (#1745) * Fixup for staging to resolve AssetID -> AssetId rename issue. * Spec bump. --- pallets/asset/src/lib.rs | 3 +++ pallets/asset/src/migrations.rs | 15 +++++++++++++++ pallets/runtime/develop/src/runtime.rs | 2 +- pallets/runtime/mainnet/src/runtime.rs | 2 +- pallets/runtime/testnet/src/runtime.rs | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pallets/asset/src/lib.rs b/pallets/asset/src/lib.rs index 345d90252..b1aadb31b 100644 --- a/pallets/asset/src/lib.rs +++ b/pallets/asset/src/lib.rs @@ -292,6 +292,9 @@ decl_module! { storage_migrate_on!(StorageVersion, 5, { migrations::migrate_to_v5::(); }); + // Only needed on staging, but safe to run on other networks. + migrations::migrate_to_v5_fixup_asset_id_maps::(); + Weight::zero() } diff --git a/pallets/asset/src/migrations.rs b/pallets/asset/src/migrations.rs index 2eceeb061..946c65d80 100644 --- a/pallets/asset/src/migrations.rs +++ b/pallets/asset/src/migrations.rs @@ -93,6 +93,9 @@ mod v4 { // This storage has been removed. pub AssetMetadataNextGlobalKey get(fn asset_metadata_next_global_key): AssetMetadataGlobalKey; + + pub AssetIDTicker get(fn asset_id_ticker): map hasher(blake2_128_concat) AssetId => Option; + pub TickerAssetID get(fn ticker_asset_id): map hasher(blake2_128_concat) Ticker => Option; } } @@ -101,6 +104,18 @@ mod v4 { } } +pub(crate) fn migrate_to_v5_fixup_asset_id_maps() { + // Move renamed storage maps. + move_prefix( + &v4::AssetIDTicker::final_prefix(), + &AssetIdTicker::final_prefix(), + ); + move_prefix( + &v4::TickerAssetID::final_prefix(), + &TickerAssetId::final_prefix(), + ); +} + pub(crate) fn migrate_to_v5() { RuntimeLogger::init(); let mut ticker_to_asset_id = BTreeMap::new(); diff --git a/pallets/runtime/develop/src/runtime.rs b/pallets/runtime/develop/src/runtime.rs index 9dd53356f..c3e9c73c7 100644 --- a/pallets/runtime/develop/src/runtime.rs +++ b/pallets/runtime/develop/src/runtime.rs @@ -57,7 +57,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { authoring_version: 1, // `spec_version: aaa_bbb_ccd` should match node version v`aaa.bbb.cc` // N.B. `d` is unpinned from the binary version - spec_version: 7_000_002, + spec_version: 7_000_003, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 7, diff --git a/pallets/runtime/mainnet/src/runtime.rs b/pallets/runtime/mainnet/src/runtime.rs index a26a3ebec..c76350970 100644 --- a/pallets/runtime/mainnet/src/runtime.rs +++ b/pallets/runtime/mainnet/src/runtime.rs @@ -53,7 +53,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { authoring_version: 1, // `spec_version: aaa_bbb_ccd` should match node version v`aaa.bbb.cc` // N.B. `d` is unpinned from the binary version - spec_version: 7_000_002, + spec_version: 7_000_003, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 7, diff --git a/pallets/runtime/testnet/src/runtime.rs b/pallets/runtime/testnet/src/runtime.rs index a8bf28af3..70aeafe02 100644 --- a/pallets/runtime/testnet/src/runtime.rs +++ b/pallets/runtime/testnet/src/runtime.rs @@ -55,7 +55,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { authoring_version: 1, // `spec_version: aaa_bbb_ccd` should match node version v`aaa.bbb.cc` // N.B. `d` is unpinned from the binary version - spec_version: 7_000_002, + spec_version: 7_000_003, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 7,