Skip to content
Draft
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,17 @@ pub fn rework_billing_loop_insertion<T: Config>() -> frame_support::weights::Wei
Weight::zero()
}
}

pub struct CheckStorageState<T: Config>(PhantomData<T>);

impl<T: Config> OnRuntimeUpgrade for CheckStorageState<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
info!("current pallet version: {:?}", PalletVersion::<T>::get());
assert!(PalletVersion::<T>::get() == types::StorageVersion::V10);

migrations::v9::check_pallet_smart_contract::<T>();

Ok(vec![])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<T: Config> OnRuntimeUpgrade for ExtendContractLock<T> {
debug!("current pallet version: {:?}", PalletVersion::<T>::get());
assert!(PalletVersion::<T>::get() >= types::StorageVersion::V11);

check_contract_lock_v11::<T>();
check_contract_lock::<T>();

debug!(
"👥 Smart Contract pallet to {:?} passes POST migrate checks ✅",
Expand Down Expand Up @@ -86,7 +86,35 @@ pub fn migrate_to_version_11<T: Config>() -> frame_support::weights::Weight {
T::DbWeight::get().reads_writes(r, w)
}

pub fn check_contract_lock_v11<T: Config>() {
pub struct CheckStorageState<T: Config>(PhantomData<T>);

impl<T: Config> OnRuntimeUpgrade for CheckStorageState<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
info!("current pallet version: {:?}", PalletVersion::<T>::get());
assert!(PalletVersion::<T>::get() == types::StorageVersion::V11);

check_pallet_smart_contract::<T>();

Ok(vec![])
}
}

pub fn check_pallet_smart_contract<T: Config>() {
info!("💥💥💥💥💥 CHECKING PALLET SMART CONTRACT STORAGE 💥💥💥💥💥");
migrations::v9::check_contracts::<T>();
migrations::v9::check_contracts_to_bill_at::<T>();
migrations::v9::check_active_node_contracts::<T>();
migrations::v9::check_active_rent_contract_for_node::<T>();
migrations::v9::check_contract_id_by_node_id_and_hash::<T>();
migrations::v9::check_contract_id_by_name_registration::<T>();
check_contract_lock::<T>();
migrations::v9::check_solution_providers::<T>();
migrations::v9::check_contract_billing_information_by_id::<T>();
migrations::v9::check_node_contract_resources::<T>();
}

fn check_contract_lock<T: Config>() {
debug!(
"🔎 Smart Contract pallet {:?} checking ContractLock storage map START",
PalletVersion::<T>::get()
Expand Down
24 changes: 14 additions & 10 deletions substrate-node/pallets/pallet-smart-contract/src/migrations/v9.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ use scale_info::prelude::string::String;
use sp_core::Get;
use sp_std::{marker::PhantomData, vec, vec::Vec};

pub struct CheckStorageState<T: Config>(PhantomData<T>);

impl<T: Config> OnRuntimeUpgrade for CheckStorageState<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
info!("current pallet version: {:?}", PalletVersion::<T>::get());
assert!(PalletVersion::<T>::get() >= types::StorageVersion::V8);

check_pallet_smart_contract::<T>();

Ok(vec![])
}
}

pub struct CleanStorageState<T: Config>(PhantomData<T>);

impl<T: Config> OnRuntimeUpgrade for CleanStorageState<T> {
Expand All @@ -22,16 +36,6 @@ impl<T: Config> OnRuntimeUpgrade for CleanStorageState<T> {
Weight::zero()
}
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
info!("current pallet version: {:?}", PalletVersion::<T>::get());
assert!(PalletVersion::<T>::get() == types::StorageVersion::V8 || PalletVersion::<T>::get() == types::StorageVersion::V9);

check_pallet_smart_contract::<T>();

Ok(vec![])
}
}

pub fn check_pallet_smart_contract<T: Config>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ pub mod v11;
pub mod v12;
pub mod v13;
pub mod v14;
//pub mod v15;
pub mod v15;
pub mod v16;
pub mod v17;
Loading