diff --git a/.gitlab/pipeline/check.yml b/.gitlab/pipeline/check.yml index cd26003d88c150c7139573b8672ec29970840713..ce3a6155792071390a38766fb2ea15fffed2f7ec 100644 --- a/.gitlab/pipeline/check.yml +++ b/.gitlab/pipeline/check.yml @@ -107,7 +107,7 @@ check-rust-feature-propagation: echo "---------- Building ${PACKAGE} runtime ----------" time cargo build --release --locked -p "$PACKAGE" --features try-runtime - echo "---------- Executing `on-runtime-upgrade` for ${NETWORK} ----------" + echo "---------- Executing on-runtime-upgrade for ${NETWORK} ----------" time ./try-runtime \ --runtime ./target/release/wbuild/"$PACKAGE"/"$WASM" \ on-runtime-upgrade --checks=pre-and-post ${EXTRA_ARGS} live --uri ${URI} diff --git a/substrate/frame/contracts/src/migration.rs b/substrate/frame/contracts/src/migration.rs index 2714620731201b225485805e67a5ccc431217a2c..1873ef2765b1fb181138e8b331d3ca362befa1cd 100644 --- a/substrate/frame/contracts/src/migration.rs +++ b/substrate/frame/contracts/src/migration.rs @@ -263,14 +263,14 @@ impl<T: Config, const TEST_ALL_STEPS: bool> Migration<T, TEST_ALL_STEPS> { impl<T: Config, const TEST_ALL_STEPS: bool> OnRuntimeUpgrade for Migration<T, TEST_ALL_STEPS> { fn on_runtime_upgrade() -> Weight { let name = <Pallet<T>>::name(); - let latest_version = <Pallet<T>>::current_storage_version(); - let storage_version = <Pallet<T>>::on_chain_storage_version(); + let current_version = <Pallet<T>>::current_storage_version(); + let on_chain_version = <Pallet<T>>::on_chain_storage_version(); - if storage_version == latest_version { + if on_chain_version == current_version { log::warn!( target: LOG_TARGET, "{name}: No Migration performed storage_version = latest_version = {:?}", - &storage_version + &on_chain_version ); return T::WeightInfo::on_runtime_upgrade_noop() } @@ -281,7 +281,7 @@ impl<T: Config, const TEST_ALL_STEPS: bool> OnRuntimeUpgrade for Migration<T, TE log::warn!( target: LOG_TARGET, "{name}: Migration already in progress {:?}", - &storage_version + &on_chain_version ); return T::WeightInfo::on_runtime_upgrade_in_progress() @@ -289,10 +289,10 @@ impl<T: Config, const TEST_ALL_STEPS: bool> OnRuntimeUpgrade for Migration<T, TE log::info!( target: LOG_TARGET, - "{name}: Upgrading storage from {storage_version:?} to {latest_version:?}.", + "{name}: Upgrading storage from {on_chain_version:?} to {current_version:?}.", ); - let cursor = T::Migrations::new(storage_version + 1); + let cursor = T::Migrations::new(on_chain_version + 1); MigrationInProgress::<T>::set(Some(cursor)); #[cfg(feature = "try-runtime")] @@ -308,24 +308,25 @@ impl<T: Config, const TEST_ALL_STEPS: bool> OnRuntimeUpgrade for Migration<T, TE // We can't really do much here as our migrations do not happen during the runtime upgrade. // Instead, we call the migrations `pre_upgrade` and `post_upgrade` hooks when we iterate // over our migrations. - let storage_version = <Pallet<T>>::on_chain_storage_version(); - let target_version = <Pallet<T>>::current_storage_version(); + let on_chain_version = <Pallet<T>>::on_chain_storage_version(); + let current_version = <Pallet<T>>::current_storage_version(); - ensure!( - storage_version != target_version, - "No upgrade: Please remove this migration from your runtime upgrade configuration." - ); + if on_chain_version == current_version { + log::warn!( + target: LOG_TARGET, + "No upgrade: Please remove this migration from your Migrations tuple" + ) + } log::debug!( target: LOG_TARGET, "Requested migration of {} from {:?}(on-chain storage version) to {:?}(current storage version)", - <Pallet<T>>::name(), storage_version, target_version + <Pallet<T>>::name(), on_chain_version, current_version ); - ensure!( - T::Migrations::is_upgrade_supported(storage_version, target_version), - "Unsupported upgrade: VERSION_RANGE should be (on-chain storage version + 1, current storage version)" - ); + if !T::Migrations::is_upgrade_supported(on_chain_version, current_version) { + log::warn!(target: LOG_TARGET, "Unsupported upgrade: VERSION_RANGE should be (on-chain storage version + 1, current storage version)") + } Ok(Default::default()) }