Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Better identifier and logging for runtime upgrades #8123

Merged
42 commits merged into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4c0abc5
A clean new attempt
kianenigma Feb 3, 2021
7f9b5b8
Checkpoint to move remote.
kianenigma Feb 10, 2021
4883812
A lot of dependency wiring to make it feature gated.
kianenigma Feb 10, 2021
be549b4
bad macro, bad macro.
kianenigma Feb 10, 2021
8e97733
Master.into()
kianenigma Feb 11, 2021
d84dad4
Undo the DB mess.
kianenigma Feb 11, 2021
aeb7a0e
Update frame/support/src/traits.rs
kianenigma Feb 11, 2021
d968f58
Apply suggestions from code review
kianenigma Feb 11, 2021
ce4128b
unbreak the build
kianenigma Feb 13, 2021
ee8ae08
Merge branch 'kiz-finally-finally-finally-finally-migration-testing-2…
kianenigma Feb 13, 2021
87baef8
Better logging and ids for migrations
kianenigma Feb 15, 2021
01298eb
Fix doc.
kianenigma Feb 15, 2021
14bf87f
Test
kianenigma Feb 15, 2021
62be119
Master.into()
kianenigma Feb 16, 2021
712c240
Update frame/try-runtime/src/lib.rs
kianenigma Feb 18, 2021
9a23940
Update utils/frame/try-runtime/cli/Cargo.toml
kianenigma Feb 18, 2021
93f299a
Update frame/try-runtime/Cargo.toml
kianenigma Feb 18, 2021
3cea840
Address most review grumbles.
kianenigma Feb 18, 2021
ab9d4a3
Upstream.into()
kianenigma Feb 18, 2021
b13ea31
Fix build
kianenigma Feb 18, 2021
d3a2368
Add some comments
kianenigma Feb 18, 2021
c8ba546
Remove allowing one pallet at a time.
kianenigma Feb 18, 2021
726f0b6
Merge branch 'kiz-finally-finally-finally-finally-migration-testing-2…
kianenigma Feb 18, 2021
ce123d1
Rework the PR
kianenigma Feb 18, 2021
67eead2
nit
kianenigma Feb 18, 2021
a444530
Master.into()
kianenigma Feb 19, 2021
511db92
Slightly better error handling.
kianenigma Feb 19, 2021
96d8ecf
Remove files
kianenigma Feb 19, 2021
1e41e0c
Update utils/frame/remote-externalities/src/lib.rs
kianenigma Feb 23, 2021
2655290
Merge branch 'master' of github.com:paritytech/substrate into kiz-mig…
kianenigma Feb 23, 2021
7ed0ecd
Update frame/support/src/dispatch.rs
kianenigma Feb 23, 2021
be547cb
Master.into
kianenigma Feb 23, 2021
415bca9
Update frame/support/src/dispatch.rs
kianenigma Feb 23, 2021
bdad8a5
Fix test
kianenigma Feb 23, 2021
2d6df71
Merge branch 'kiz-migration-testin-2' of github.com:paritytech/substr…
kianenigma Feb 23, 2021
05a5daf
Merge branch 'master' of github.com:paritytech/substrate into kiz-mig…
kianenigma Feb 23, 2021
d6e7b8b
Make extension trait.
kianenigma Feb 23, 2021
6714bfc
Bring back try-runtime/std
kianenigma Feb 24, 2021
d06d069
Merge branch 'master' of github.com:paritytech/substrate into kiz-mig…
kianenigma Feb 25, 2021
4e154f0
remove bincode
kianenigma Feb 25, 2021
280666f
Remove warning
kianenigma Feb 25, 2021
6ff2845
Change test features
kianenigma Feb 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ rls*.log
**/hfuzz_workspace/
.cargo/
.cargo-remote.toml
*.bin
62 changes: 62 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ members = [
"frame/contracts/rpc",
"frame/contracts/rpc/runtime-api",
"frame/democracy",
"frame/try-runtime",
"frame/elections",
"frame/example",
"frame/example-offchain-worker",
Expand Down Expand Up @@ -186,6 +187,8 @@ members = [
"utils/fork-tree",
"utils/frame/benchmarking-cli",
"utils/frame/frame-utilities-cli",
"utils/frame/try-runtime/remote-externalities",
"utils/frame/try-runtime/cli",
"utils/frame/rpc/support",
"utils/frame/rpc/system",
"utils/prometheus",
Expand Down
7 changes: 7 additions & 0 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ node-executor = { version = "2.0.0", path = "../executor" }
sc-cli = { version = "0.9.0", optional = true, path = "../../../client/cli" }
frame-benchmarking-cli = { version = "3.0.0", optional = true, path = "../../../utils/frame/benchmarking-cli" }
node-inspect = { version = "0.8.0", optional = true, path = "../inspect" }
try-runtime-cli = { version = "3.0.0", optional = true, path = "../../../utils/frame/try-runtime/cli" }

# WASM-specific dependencies
wasm-bindgen = { version = "0.2.57", optional = true }
Expand Down Expand Up @@ -131,6 +132,7 @@ node-inspect = { version = "0.8.0", optional = true, path = "../inspect" }
frame-benchmarking-cli = { version = "3.0.0", optional = true, path = "../../../utils/frame/benchmarking-cli" }
substrate-build-script-utils = { version = "3.0.0", optional = true, path = "../../../utils/build-script-utils" }
substrate-frame-cli = { version = "3.0.0", optional = true, path = "../../../utils/frame/frame-utilities-cli" }
try-runtime-cli = { version = "3.0.0", optional = true, path = "../../../utils/frame/try-runtime/cli" }

[build-dependencies.sc-cli]
version = "0.9.0"
Expand All @@ -155,8 +157,13 @@ cli = [
"sc-finality-grandpa-warp-sync",
"structopt",
"substrate-build-script-utils",
"try-runtime-cli",
]
runtime-benchmarks = [
"node-runtime/runtime-benchmarks",
"frame-benchmarking-cli",
]
try-runtime = [
"node-runtime/try-runtime",
"try-runtime-cli",
]
4 changes: 4 additions & 0 deletions bin/node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ pub enum Subcommand {
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),

/// Try some experimental command on the runtime. This includes migration and runtime-upgrade
/// testing.
TryRuntime(try_runtime_cli::TryRuntimeCmd),

/// Verify a signature for a message, provided on STDIN, with a given (public or secret) key.
Verify(VerifyCmd),

Expand Down
16 changes: 16 additions & 0 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,21 @@ pub fn run() -> Result<()> {
Ok((cmd.run(client, backend), task_manager))
})
},
Some(Subcommand::TryRuntime(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
use sc_service::TaskManager;
// we don't need any of the components of new_partial, just a runtime, or a task
// manager to do `async_run`.
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager = TaskManager::new(
config.task_executor.clone(),
registry,
config.telemetry_span.clone(),
).unwrap();

Ok((cmd.run::<Block, Executor>(config), task_manager))
})
}
}
}
6 changes: 6 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ frame-support = { version = "3.0.0", default-features = false, path = "../../../
frame-system = { version = "3.0.0", default-features = false, path = "../../../frame/system" }
frame-system-benchmarking = { version = "3.0.0", default-features = false, path = "../../../frame/system/benchmarking", optional = true }
frame-system-rpc-runtime-api = { version = "3.0.0", default-features = false, path = "../../../frame/system/rpc/runtime-api/" }
frame-try-runtime = { version = "3.0.0", default-features = false, path = "../../../frame/try-runtime", optional = true }
pallet-assets = { version = "3.0.0", default-features = false, path = "../../../frame/assets" }
pallet-authority-discovery = { version = "3.0.0", default-features = false, path = "../../../frame/authority-discovery" }
pallet-authorship = { version = "3.0.0", default-features = false, path = "../../../frame/authorship" }
Expand Down Expand Up @@ -151,6 +152,7 @@ std = [
"pallet-society/std",
"pallet-recovery/std",
"pallet-vesting/std",
"frame-try-runtime/std",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is needed because otherwise we can't compile node-runtime with try-runtime features and std :-/
the unused dependency on std should harm to much, and this is what we do for frame-benchmarking.

]
runtime-benchmarks = [
"frame-benchmarking",
Expand Down Expand Up @@ -186,3 +188,7 @@ runtime-benchmarks = [
"frame-system-benchmarking",
"hex-literal",
]
try-runtime = [
"frame-executive/try-runtime",
"frame-try-runtime",
]
46 changes: 42 additions & 4 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,14 @@ pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllModules>;
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
(),
>;

/// MMR helper types.
mod mmr {
Expand Down Expand Up @@ -1325,15 +1332,46 @@ impl_runtime_apis! {
}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(target: frame_try_runtime::Target) -> Weight {
frame_support::debug::RuntimeLogger::init();

let weight = match target {
frame_try_runtime::Target::All => {
frame_support::debug::info!("Dry-running all on-runtime-upgrades.");
Executive::try_runtime_upgrade()
},
frame_try_runtime::Target::Pallet(name) => {
let name = sp_std::str::from_utf8(&name).unwrap();
frame_support::debug::info!("Dry-running on-runtime-upgrade of {}.", name);

frame_try_runtime::match_pallet_on_runtime_upgrade!(name,
System, Utility, Babe, Timestamp, Authorship, Indices, Balances,
TransactionPayment, Staking, Session, Democracy, Council,
TechnicalCommittee, Elections, TechnicalMembership, Grandpa, Treasury,
Contracts, Sudo, ImOnline, AuthorityDiscovery, Offences, Historical,
RandomnessCollectiveFlip, Identity, Society, Recovery, Vesting, Scheduler,
Proxy, Multisig, Bounties, Tips, Assets, Mmr, Lottery,
)
// TODO: ^^ this can be done better, or generated by construct runtime at the
// least.
}
};

weight
}
}

#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
// Trying to add benchmarks directly to the Session Pallet caused cyclic dependency issues.
// To get around that, we separated the Session benchmarks into its own crate, which is why
// we need these two lines below.
// Trying to add benchmarks directly to the Session Pallet caused cyclic dependency
// issues. To get around that, we separated the Session benchmarks into its own crate,
// which is why we need these two lines below.
use pallet_session_benchmarking::Module as SessionBench;
use pallet_offences_benchmarking::Module as OffencesBench;
use frame_system_benchmarking::Module as SystemBench;
Expand Down
2 changes: 1 addition & 1 deletion client/service/src/task_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub struct TaskManager {
impl TaskManager {
/// If a Prometheus registry is passed, it will be used to report statistics about the
/// service tasks.
pub(super) fn new(
pub fn new(
executor: TaskExecutor,
prometheus_registry: Option<&Registry>,
telemetry_span: Option<TelemetrySpan>,
Expand Down
8 changes: 4 additions & 4 deletions client/state-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
//! Canonicalization window tracks a tree of blocks identified by header hash. The in-memory
//! overlay allows to get any node that was inserted in any of the blocks within the window.
//! The tree is journaled to the backing database and rebuilt on startup.
//! Canonicalization function selects one root from the top of the tree and discards all other roots and
//! their subtrees.
//! Canonicalization function selects one root from the top of the tree and discards all other roots
//! and their subtrees.
//!
//! # Pruning.
//! See `RefWindow` for pruning algorithm details. `StateDb` prunes on each canonicalization until pruning
//! constraints are satisfied.
//! See `RefWindow` for pruning algorithm details. `StateDb` prunes on each canonicalization until
//! pruning constraints are satisfied.

mod noncanonical;
mod pruning;
Expand Down
3 changes: 3 additions & 0 deletions frame/executive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ std = [
"sp-tracing/std",
"sp-std/std",
]
try-runtime = [
"frame-support/try-runtime"
]
Loading