Skip to content

Commit

Permalink
Add SimpleStorageUpdate to migrate balances without any additional in…
Browse files Browse the repository at this point in the history
…active tracks
  • Loading branch information
dmitrylavrenov committed Oct 31, 2024
1 parent 935eeb5 commit 382a753
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions substrate/frame/balances/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,24 @@ impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for ResetInactive<T, I> {
}
}
}

pub struct SimpleStorageUpdate<T, I = ()>(PhantomData<(T, I)>);
impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for SimpleStorageUpdate<T, I> {
fn on_runtime_upgrade() -> Weight {
let current_storage_version = <Pallet<T>>::current_storage_version();

Check failure on line 108 in substrate/frame/balances/src/migration.rs

View workflow job for this annotation

GitHub Actions / cargo-check-all-crate-macos

the function or associated item `current_storage_version` exists for struct `Pallet<T>`, but its trait bounds were not satisfied
let on_chain_version = Pallet::<T, I>::on_chain_storage_version();

if onchain_storage_version == 0 && current_storage_version != 0 {

Check failure on line 111 in substrate/frame/balances/src/migration.rs

View workflow job for this annotation

GitHub Actions / cargo-check-all-crate-macos

cannot find value `onchain_storage_version` in this scope
current_storage_version.put::<Pallet<T>>();

log::info!(target: LOG_TARGET, "Storage to version {current_storage_version}");
T::DbWeight::get().reads_writes(1, 1)
} else {
log::info!(
target: LOG_TARGET,
"Migration did not execute. This probably should be removed"
);
T::DbWeight::get().reads(1)
}
}
}

0 comments on commit 382a753

Please sign in to comment.