referrerpolicy=no-referrer-when-downgrade

frame_try_runtime/
inner.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Supporting types for try-runtime, testing and dry-running commands.
19
20pub use frame_support::traits::{TryStateSelect, UpgradeCheckSelect};
21use frame_support::weights::Weight;
22
23sp_api::decl_runtime_apis! {
24	/// Runtime api for testing the execution of a runtime upgrade.
25	pub trait TryRuntime {
26		/// dry-run runtime upgrades, returning the total weight consumed.
27		///
28		/// This should do EXACTLY the same operations as the runtime would have done in the case of
29		/// a runtime upgrade (e.g. pallet ordering must be the same)
30		///
31		/// Returns the consumed weight of the migration in case of a successful one, combined with
32		/// the total allowed block weight of the runtime.
33		///
34		/// If `checks` is `true`, `pre_migrate` and `post_migrate` of each migration and
35		/// `try_state` of all pallets will be executed. Else, no. If checks are executed, the PoV
36		/// tracking is likely inaccurate.
37		fn on_runtime_upgrade(checks: UpgradeCheckSelect) -> (Weight, Weight);
38
39		/// Execute the given block, but optionally disable state-root and signature checks.
40		///
41		/// Optionally, a number of `try_state` hooks can also be executed after the block
42		/// execution.
43		fn execute_block(
44			block: Block,
45			state_root_check: bool,
46			signature_check: bool,
47			try_state: TryStateSelect,
48		) -> Weight;
49	}
50}