Selectable on-runtime-upgrade checks (#13045)

* Make try-runtime checks selectable

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update frame/support/src/traits/try_runtime.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Add Clap wrapper for enum UpgradeCheckSelect

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Revert "Add Clap wrapper for enum UpgradeCheckSelect"

This reverts commit e29538c1a79d1711b43addc9400d871f6aa32844.

* fix pools sanity check

* Set default for --checks to None

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Make --checks backwards comp

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Add clap attr comment

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: kianenigma <kian@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2023-01-04 13:44:41 +01:00
committed by GitHub
parent 7ead16802e
commit d0bbec32ad
8 changed files with 79 additions and 21 deletions
@@ -16,6 +16,7 @@
// limitations under the License.
use crate::{build_executor, state_machine_call_with_proof, SharedParams, State, LOG_TARGET};
use frame_try_runtime::UpgradeCheckSelect;
use parity_scale_codec::{Decode, Encode};
use sc_executor::sp_wasm_interface::HostFunctions;
use sp_runtime::traits::{Block as BlockT, NumberFor};
@@ -29,12 +30,22 @@ pub struct OnRuntimeUpgradeCmd {
#[command(subcommand)]
pub state: State,
/// Execute `try_state`, `pre_upgrade` and `post_upgrade` checks as well.
/// Select which optional checks to perform. Selects all when no value is given.
///
/// This will perform more checks, but it will also makes the reported PoV/Weight be
/// inaccurate.
#[clap(long)]
pub checks: bool,
/// - `none`: Perform no checks (default when the arg is not present).
/// - `all`: Perform all checks (default when the arg is present).
/// - `pre-and-post`: Perform pre- and post-upgrade checks.
/// - `try-state`: Perform the try-state checks.
///
/// Performing any checks will potentially invalidate the measured PoV/Weight.
// NOTE: The clap attributes make it backwards compatible with the previous `--checks` flag.
#[clap(long,
default_value = "None",
default_missing_value = "All",
num_args = 0..=1,
require_equals = true,
verbatim_doc_comment)]
pub checks: UpgradeCheckSelect,
}
pub(crate) async fn on_runtime_upgrade<Block, HostFns>(