Skip to content

Commit

Permalink
fix migrations (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
girazoki authored Jun 3, 2024
1 parent 1a4b0d6 commit 7163a26
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
39 changes: 37 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test-relay-sproof-builder = { path = "test-sproof-builder", default-features = f
# Moonkit (wasm)
nimbus-primitives = { git = "https://github.com/Moonsong-Labs/moonkit", branch = "main", default-features = false }
pallet-author-inherent = { git = "https://github.com/Moonsong-Labs/moonkit", branch = "main", default-features = false }
pallet-migrations = { git = "https://github.com/Moonsong-Labs/moonkit", branch = "main", default-features = false }

# Substrate (wasm)
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
Expand Down
7 changes: 6 additions & 1 deletion pallets/xcm-executor-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ sp-runtime = { workspace = true }
sp-std = { workspace = true }
staging-xcm = { workspace = true }

# Moonkit
pallet-migrations = { workspace = true }


[features]
default = [ "std" ]
std = [
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"parity-scale-codec/std",
"pallet-migrations/std",
"scale-info/std",
"serde/std",
"sp-runtime/std",
Expand All @@ -47,4 +52,4 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [ "frame-support/try-runtime" ]
try-runtime = [ "frame-support/try-runtime", "pallet-migrations/try-runtime" ]
22 changes: 21 additions & 1 deletion pallets/xcm-executor-utils/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub mod v1 {
}
}

pub struct MigrateToV1<T>(core::marker::PhantomData<T>);
pub struct MigrateToV1<T>(pub core::marker::PhantomData<T>);
use frame_support::StoragePrefixedMap;
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
fn on_runtime_upgrade() -> Weight {
Expand Down Expand Up @@ -141,3 +141,23 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
}
}
}

impl<T: Config> pallet_migrations::Migration for MigrateToV1<T> {
fn friendly_name(&self) -> &str {
"TM_XcmExecutorUtilsMigrateToV1"
}

fn migrate(&self, _available_weight: Weight) -> Weight {
Self::on_runtime_upgrade()
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
<Self as OnRuntimeUpgrade>::pre_upgrade()
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(&self, state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
<Self as OnRuntimeUpgrade>::post_upgrade(state)
}
}

0 comments on commit 7163a26

Please sign in to comment.