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

Migration testing runtime API/Bot #8038

Merged
25 commits merged into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 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
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
2f9ad0e
More grumbles.
kianenigma Feb 18, 2021
6db195c
Merge branch 'master' of github.com:paritytech/substrate into kiz-fin…
kianenigma Feb 18, 2021
b8ab620
relocate remote-ext
kianenigma Feb 19, 2021
be5210d
Merge branch 'master' of github.com:paritytech/substrate into kiz-fin…
kianenigma Feb 19, 2021
b5e394b
Fix build
kianenigma Feb 19, 2021
deb03d4
Merge branch 'master' of github.com:paritytech/substrate into kiz-fin…
kianenigma Feb 19, 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
141 changes: 128 additions & 13 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 @@ -186,6 +186,9 @@ members = [
"utils/fork-tree",
"utils/frame/benchmarking-cli",
"utils/frame/frame-utilities-cli",
"utils/frame/dry-run-runtime-upgrade/remote-externalities",
"utils/frame/dry-run-runtime-upgrade/cli",
"utils/frame/dry-run-runtime-upgrade/api",
"utils/frame/rpc/support",
"utils/frame/rpc/system",
"utils/prometheus",
Expand Down
3 changes: 3 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.8.0", optional = true, path = "../../../client/cli" }
frame-benchmarking-cli = { version = "2.0.0", optional = true, path = "../../../utils/frame/benchmarking-cli" }
node-inspect = { version = "0.8.0", optional = true, path = "../inspect" }
dry-run-runtime-upgrade-cli = { version = "2.0.0", optional = true, path = "../../../utils/frame/dry-run-runtime-upgrade/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 = "2.0.0", optional = true, path = "../../../utils/frame/benchmarking-cli" }
substrate-build-script-utils = { version = "2.0.0", optional = true, path = "../../../utils/build-script-utils" }
substrate-frame-cli = { version = "2.0.0", optional = true, path = "../../../utils/frame/frame-utilities-cli" }
dry-run-runtime-upgrade-cli = { version = "2.0.0", optional = true, path = "../../../utils/frame/dry-run-runtime-upgrade/cli" }

[build-dependencies.sc-cli]
version = "0.8.0"
Expand All @@ -155,6 +157,7 @@ cli = [
"sc-finality-grandpa-warp-sync",
"structopt",
"substrate-build-script-utils",
"dry-run-runtime-upgrade-cli",
]
runtime-benchmarks = [
"node-runtime/runtime-benchmarks",
Expand Down
3 changes: 3 additions & 0 deletions bin/node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub enum Subcommand {
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),

/// DryRun all of the runtime upgrade hooks in the current runtime upon a configurable state.
DryRunRuntimeUpgrade(dry_run_runtime_upgrade_cli::DryRunCmd),

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

Expand Down
7 changes: 7 additions & 0 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,12 @@ pub fn run() -> Result<()> {
Ok((cmd.run(client, backend), task_manager))
})
},
Some(Subcommand::DryRun(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
kianenigma marked this conversation as resolved.
Show resolved Hide resolved
let PartialComponents { task_manager, .. } = new_partial(&config)?;
Ok((cmd.run::<Block, Executor>(config), task_manager))
})
}
}
}
5 changes: 5 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ pallet-transaction-payment = { version = "2.0.0", default-features = false, path
pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" }
pallet-vesting = { version = "2.0.0", default-features = false, path = "../../../frame/vesting" }

dry-run-runtime-upgrade-api = { default-features = false, path = "../../../utils/frame/dry-run-runtime-upgrade/api" }
# TODO: probably best to put this in some primitive pallet, among with types that need to be passed
# back and forth.

[build-dependencies]
substrate-wasm-builder = { version = "3.0.0", path = "../../../utils/wasm-builder" }

Expand Down Expand Up @@ -151,6 +155,7 @@ std = [
"pallet-society/std",
"pallet-recovery/std",
"pallet-vesting/std",
"dry-run-runtime-upgrade-api/std",
]
runtime-benchmarks = [
"frame-benchmarking",
Expand Down
39 changes: 35 additions & 4 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,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 @@ -1323,15 +1330,39 @@ impl_runtime_apis! {
}
}

// TODO: make everything feature gated.
impl dry_run_runtime_upgrade_api::DryRunRuntimeUpgrade<Block> for Runtime {
fn dry_run_runtime_upgrade() -> Weight {
frame_support::debug::RuntimeLogger::init();
frame_support::debug::info!("!!! DRYRUN MIGRATION UP AHEAD !!!");
let weight = Executive::dry_run_runtime_upgrade();
frame_support::debug::info!("!!! DRYRUN MIGRATION DONE !!!");
weight

// \migration_bot pallet:staking state:polkadot
// pseudo code:
// match config.pallet {
// "System" => {
// <Pallet as OnRuntimeUpgrade>::pre_migration();
// <Pallet as OnRuntimeUpgrade>::on_runtime_upgrade();
// <Pallet as OnRuntimeUpgrade>::post_migration();
// },
// "All" => {
// Executive::dry_run_runtime_upgrade()
// }
// }
}
}

#[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
Loading