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

fix: more try-runtime unwraps. #4648

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion state-chain/pallets/cf-broadcast/src/migrations/v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Migration<T, I> {
broadcasts_with_failed_broadcasters,
broadcast_retry_queue,
timeout_broadcasts,
} = MigrationVerification::<T>::decode(&mut &state[..]).unwrap();
} = MigrationVerification::<T>::decode(&mut &state[..])
.expect("Pre-migration should encode valid MigrationVerification");

// Ensure all failed broadcasters storage are migrated.
broadcasts_with_failed_broadcasters.into_iter().for_each(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ impl<T: Config<Instance3, TargetChain = Bitcoin>> OnRuntimeUpgrade for Migration

#[cfg(feature = "try-runtime")]
fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError> {
let number_of_channels_in_lookup_pre_migration = <u32>::decode(&mut &state[..]).unwrap();
let number_of_channels_in_lookup_pre_migration = <u32>::decode(&mut &state[..])
.expect("Pre-migration should insert number of channels in lookup storage.");
ensure!(
DepositChannelLookup::<T, Instance3>::iter_keys().count() as u32 ==
number_of_channels_in_lookup_pre_migration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Migration<T, I> {

#[cfg(feature = "try-runtime")]
fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError> {
let number_of_channels_in_lookup_pre_migration = <u32>::decode(&mut &state[..]).unwrap();
let number_of_channels_in_lookup_pre_migration =
<u32>::decode(&mut &state[..]).expect("Pre-migration should encode a u32.");
ensure!(
DepositChannelLookup::<T, I>::iter_keys().count() as u32 ==
number_of_channels_in_lookup_pre_migration,
Expand Down
3 changes: 2 additions & 1 deletion state-chain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1833,7 +1833,8 @@ impl_runtime_apis! {
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
// have a backtrace here. If any of the pre/post migration checks fail, we shall stop
// right here and right now.
let weight = Executive::try_runtime_upgrade(checks).unwrap();
let weight = Executive::try_runtime_upgrade(checks)
.inspect_err(|e| log::error!("try_runtime_upgrade failed with: {:?}", e)).unwrap();
(weight, BlockWeights::get().max_block)
}

Expand Down
Loading