mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 19:37:56 +00:00
support upgrade hooks to directly pass data (#12185)
* update interfaces of OnRuntimeUpgrade & Hooks Signed-off-by: linning <linningde25@gmail.com> * remove try-runtime for PreStateDigest Signed-off-by: linning <linningde25@gmail.com> * remove the Default bound of PreStateDigest Signed-off-by: linning <linningde25@gmail.com> * remove try-runtime for PreStateDigest & pre_upgrade Signed-off-by: linning <linningde25@gmail.com> * remove tmp storage between upgrade hooks Signed-off-by: linning <linningde25@gmail.com> * ensure hooks are storage noop Signed-off-by: linning <linningde25@gmail.com> * remove OnRuntimeUpgradeHelpersExt Signed-off-by: linning <linningde25@gmail.com> * cargo check & fmt Signed-off-by: linning <linningde25@gmail.com> * rename PreStateDigest to PreUpgradeState Signed-off-by: linning <linningde25@gmail.com> * replace associate type with codec & vec Signed-off-by: linning <linningde25@gmail.com> * add helper strcut to help encode/decode tuple Signed-off-by: linning <linningde25@gmail.com> * update comment Signed-off-by: linning <linningde25@gmail.com> * fix Signed-off-by: linning <linningde25@gmail.com> * add test Signed-off-by: linning <linningde25@gmail.com> * address comment Signed-off-by: linning <linningde25@gmail.com> * fix doc Signed-off-by: linning <linningde25@gmail.com> * fix ci Signed-off-by: linning <linningde25@gmail.com> * address comment Signed-off-by: linning <linningde25@gmail.com> * add more test cases Signed-off-by: linning <linningde25@gmail.com> * make clippy happy Signed-off-by: linning <linningde25@gmail.com> * fmt Signed-off-by: linning <linningde25@gmail.com> * update comment Signed-off-by: linning <linningde25@gmail.com> * fmt Signed-off-by: linning <linningde25@gmail.com> Signed-off-by: linning <linningde25@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
use super::*;
|
||||
use crate::log;
|
||||
use frame_support::traits::OnRuntimeUpgrade;
|
||||
use sp_std::collections::btree_map::BTreeMap;
|
||||
use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
|
||||
|
||||
pub mod v1 {
|
||||
use super::*;
|
||||
@@ -97,7 +97,7 @@ pub mod v1 {
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade() -> Result<(), &'static str> {
|
||||
fn post_upgrade(_: Vec<u8>) -> Result<(), &'static str> {
|
||||
// new version must be set.
|
||||
assert_eq!(Pallet::<T>::on_chain_storage_version(), 1);
|
||||
Pallet::<T>::try_state(frame_system::Pallet::<T>::block_number())?;
|
||||
@@ -347,7 +347,7 @@ pub mod v2 {
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<(), &'static str> {
|
||||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
|
||||
// all reward accounts must have more than ED.
|
||||
RewardPools::<T>::iter().for_each(|(id, _)| {
|
||||
assert!(
|
||||
@@ -356,11 +356,11 @@ pub mod v2 {
|
||||
)
|
||||
});
|
||||
|
||||
Ok(())
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade() -> Result<(), &'static str> {
|
||||
fn post_upgrade(_: Vec<u8>) -> Result<(), &'static str> {
|
||||
// new version must be set.
|
||||
assert_eq!(Pallet::<T>::on_chain_storage_version(), 2);
|
||||
|
||||
@@ -430,16 +430,16 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<(), &'static str> {
|
||||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
|
||||
ensure!(
|
||||
Pallet::<T>::current_storage_version() > Pallet::<T>::on_chain_storage_version(),
|
||||
"the on_chain version is equal or more than the current one"
|
||||
);
|
||||
Ok(())
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade() -> Result<(), &'static str> {
|
||||
fn post_upgrade(_: Vec<u8>) -> Result<(), &'static str> {
|
||||
ensure!(
|
||||
Metadata::<T>::iter_keys().all(|id| BondedPools::<T>::contains_key(&id)),
|
||||
"not all of the stale metadata has been removed"
|
||||
|
||||
Reference in New Issue
Block a user