mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 12:11:09 +00:00
allow to write pre and post runtime upgrade in pallet macro (#8194)
This commit is contained in:
committed by
GitHub
parent
f0c3656489
commit
5232e8ad5c
@@ -46,3 +46,4 @@ runtime-benchmarks = [
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -37,3 +37,4 @@ std = [
|
||||
"sp-io/std",
|
||||
"sp-core/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -45,3 +45,4 @@ std = [
|
||||
"sp-timestamp/std",
|
||||
"pallet-timestamp/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -41,3 +41,4 @@ std = [
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -38,3 +38,4 @@ std = [
|
||||
"frame-system/std",
|
||||
"sp-authorship/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -61,3 +61,4 @@ std = [
|
||||
"sp-timestamp/std",
|
||||
]
|
||||
runtime-benchmarks = ["frame-benchmarking"]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -38,3 +38,4 @@ std = [
|
||||
"frame-system/std",
|
||||
]
|
||||
runtime-benchmarks = ["frame-benchmarking"]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -45,3 +45,4 @@ runtime-benchmarks = [
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -44,3 +44,4 @@ runtime-benchmarks = [
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -69,3 +69,4 @@ runtime-benchmarks = [
|
||||
"rand",
|
||||
"rand_pcg",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -48,3 +48,4 @@ runtime-benchmarks = [
|
||||
"frame-support/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -64,3 +64,4 @@ runtime-benchmarks = [
|
||||
"frame-benchmarking",
|
||||
"rand",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -45,3 +45,4 @@ runtime-benchmarks = [
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -38,3 +38,4 @@ std = [
|
||||
"sp-runtime/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -38,3 +38,4 @@ std = [
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -36,3 +36,4 @@ std = [
|
||||
"sp-std/std",
|
||||
"sp-tasks/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -59,3 +59,4 @@ std = [
|
||||
"pallet-session/std",
|
||||
]
|
||||
runtime-benchmarks = ["frame-benchmarking"]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -40,3 +40,4 @@ std = [
|
||||
"frame-system/std",
|
||||
]
|
||||
runtime-benchmarks = ["frame-benchmarking"]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -46,3 +46,4 @@ std = [
|
||||
"frame-system/std",
|
||||
]
|
||||
runtime-benchmarks = ["frame-benchmarking"]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -45,3 +45,4 @@ runtime-benchmarks = [
|
||||
"frame-benchmarking",
|
||||
"frame-support/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -41,3 +41,4 @@ runtime-benchmarks = [
|
||||
"frame-system/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -35,3 +35,4 @@ std = [
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -44,3 +44,4 @@ std = [
|
||||
"sp-std/std",
|
||||
]
|
||||
runtime-benchmarks = ["frame-benchmarking"]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -43,3 +43,4 @@ runtime-benchmarks = [
|
||||
"frame-benchmarking",
|
||||
"frame-support/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -36,3 +36,4 @@ std = [
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -33,3 +33,4 @@ std = [
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -39,3 +39,4 @@ std = [
|
||||
"frame-system/std",
|
||||
]
|
||||
runtime-benchmarks = []
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -44,3 +44,4 @@ runtime-benchmarks = [
|
||||
"frame-benchmarking",
|
||||
"frame-support/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -35,3 +35,4 @@ std = [
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -37,3 +37,4 @@ std = [
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -41,3 +41,4 @@ runtime-benchmarks = [
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -36,3 +36,4 @@ std = [
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -47,3 +47,4 @@ std = [
|
||||
"pallet-timestamp/std",
|
||||
"sp-trie/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -41,3 +41,4 @@ runtime-benchmarks = [
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -69,3 +69,4 @@ runtime-benchmarks = [
|
||||
"sp-election-providers/runtime-benchmarks",
|
||||
"rand_chacha",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -35,3 +35,4 @@ std = [
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -75,6 +75,24 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
|
||||
|
||||
result.saturating_add(additional_write)
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<(), &'static str> {
|
||||
<
|
||||
Self
|
||||
as
|
||||
#frame_support::traits::Hooks<<T as #frame_system::Config>::BlockNumber>
|
||||
>::pre_upgrade()
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade() -> Result<(), &'static str> {
|
||||
<
|
||||
Self
|
||||
as
|
||||
#frame_support::traits::Hooks<<T as #frame_system::Config>::BlockNumber>
|
||||
>::post_upgrade()
|
||||
}
|
||||
}
|
||||
|
||||
impl<#type_impl_gen>
|
||||
|
||||
@@ -1334,6 +1334,16 @@ macro_rules! decl_module {
|
||||
|
||||
result.saturating_add(additional_write)
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade() -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1356,6 +1366,16 @@ macro_rules! decl_module {
|
||||
<$trait_instance as $system::Config>::DbWeight as $crate::traits::Get<_>
|
||||
>::get().writes(1)
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade() -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1575,17 +1575,13 @@ pub trait OnRuntimeUpgrade {
|
||||
///
|
||||
/// This hook is never meant to be executed on-chain but is meant to be used by testing tools.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
fn pre_upgrade() -> Result<(), &'static str>;
|
||||
|
||||
/// Execute some post-checks after a runtime upgrade.
|
||||
///
|
||||
/// This hook is never meant to be executed on-chain but is meant to be used by testing tools.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade() -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
fn post_upgrade() -> Result<(), &'static str>;
|
||||
}
|
||||
|
||||
#[impl_for_tuples(30)]
|
||||
@@ -2012,6 +2008,22 @@ pub trait Hooks<BlockNumber> {
|
||||
/// Return the non-negotiable weight consumed for runtime upgrade.
|
||||
fn on_runtime_upgrade() -> crate::weights::Weight { 0 }
|
||||
|
||||
/// Execute some pre-checks prior to a runtime upgrade.
|
||||
///
|
||||
/// This hook is never meant to be executed on-chain but is meant to be used by testing tools.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Execute some post-checks after a runtime upgrade.
|
||||
///
|
||||
/// This hook is never meant to be executed on-chain but is meant to be used by testing tools.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade() -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Implementing this function on a module allows you to perform long-running tasks
|
||||
/// that make (by default) validators generate transactions that feed results
|
||||
/// of those long-running computations back on chain.
|
||||
|
||||
@@ -44,6 +44,7 @@ runtime-benchmarks = [
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
[[bench]]
|
||||
name = "bench"
|
||||
|
||||
@@ -45,3 +45,4 @@ std = [
|
||||
"sp-timestamp/std"
|
||||
]
|
||||
runtime-benchmarks = ["frame-benchmarking", "sp-io"]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -45,3 +45,4 @@ runtime-benchmarks = [
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -40,3 +40,4 @@ std = [
|
||||
"sp-io/std",
|
||||
"sp-core/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -45,3 +45,4 @@ runtime-benchmarks = [
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -43,3 +43,4 @@ runtime-benchmarks = [
|
||||
"frame-benchmarking",
|
||||
"frame-support/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -40,3 +40,4 @@ std = [
|
||||
"frame-system/std",
|
||||
]
|
||||
runtime-benchmarks = ["frame-benchmarking"]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
Reference in New Issue
Block a user