Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pallet-balances] Add SimpleStorageUpdate to migrate balances without any additional inactive tracks #6313

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add SimpleStorageUpdate to migrate balances without any additional in…
…active tracks
  • Loading branch information
dmitrylavrenov committed Oct 31, 2024
commit 382a753a1131121ec04cd773cce27816d773966a
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 @@
}
}
}

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)
}
}
}
Loading