Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin-Radecki committed Oct 4, 2023
1 parent eaa092a commit 84d6087
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions frame/contracts/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,32 @@ impl<T: Config, const TEST_ALL_STEPS: bool> OnRuntimeUpgrade for Migration<T, TE
);
Ok(Default::default())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), TryRuntimeError> {
if !TEST_ALL_STEPS {
return Ok(())
}

log::info!(target: LOG_TARGET, "=== POST UPGRADE CHECKS ===");

// Ensure that the hashing algorithm is correct for each storage map.
if let Some(hash) = crate::CodeInfoOf::<T>::iter_keys().next() {
crate::CodeInfoOf::<T>::get(hash).expect("CodeInfo exists for hash; qed");
}
if let Some(hash) = crate::PristineCode::<T>::iter_keys().next() {
crate::PristineCode::<T>::get(hash).expect("PristineCode exists for hash; qed");
}
if let Some(account_id) = crate::ContractInfoOf::<T>::iter_keys().next() {
crate::ContractInfoOf::<T>::get(account_id)
.expect("ContractInfo exists for account_id; qed");
}
if let Some(nonce) = crate::DeletionQueue::<T>::iter_keys().next() {
crate::DeletionQueue::<T>::get(nonce).expect("DeletionQueue exists for nonce; qed");
}

Ok(())
}
}

/// The result of running the migration.
Expand Down
2 changes: 1 addition & 1 deletion frame/contracts/src/migration/v12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct CodeInfo<T: Config> {
}

#[storage_alias]
pub type CodeInfoOf<T: Config> = StorageMap<Pallet<T>, Twox64Concat, CodeHash<T>, CodeInfo<T>>;
pub type CodeInfoOf<T: Config> = StorageMap<Pallet<T>, Identity, CodeHash<T>, CodeInfo<T>>;

#[storage_alias]
pub type PristineCode<T: Config> = StorageMap<Pallet<T>, Identity, CodeHash<T>, Vec<u8>>;
Expand Down

0 comments on commit 84d6087

Please sign in to comment.