Skip to content

Commit

Permalink
Fixup staging asset id maps (#1745)
Browse files Browse the repository at this point in the history
* Fixup for staging to resolve AssetID -> AssetId rename issue.

* Spec bump.
  • Loading branch information
Neopallium authored Oct 18, 2024
1 parent 527e7ec commit 2474e84
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pallets/asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ decl_module! {
storage_migrate_on!(StorageVersion, 5, {
migrations::migrate_to_v5::<T>();
});
// Only needed on staging, but safe to run on other networks.
migrations::migrate_to_v5_fixup_asset_id_maps::<T>();

Weight::zero()
}

Expand Down
15 changes: 15 additions & 0 deletions pallets/asset/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ticker>;
pub TickerAssetID get(fn ticker_asset_id): map hasher(blake2_128_concat) Ticker => Option<AssetId>;
}
}

Expand All @@ -101,6 +104,18 @@ mod v4 {
}
}

pub(crate) fn migrate_to_v5_fixup_asset_id_maps<T: Config>() {
// 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<T: Config>() {
RuntimeLogger::init();
let mut ticker_to_asset_id = BTreeMap::new();
Expand Down
2 changes: 1 addition & 1 deletion pallets/runtime/develop/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pallets/runtime/mainnet/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pallets/runtime/testnet/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2474e84

Please sign in to comment.