diff --git a/Cargo.lock b/Cargo.lock index 0da887cdabde0f3c4a88734abff546b594f9c01b..bea13a15d8dcc020b53da17857b3e12d32c2e870 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1465,6 +1465,7 @@ dependencies = [ "frame-support", "frame-system", "frame-system-benchmarking", + "frame-try-runtime", "pallet-authority-members", "pallet-babe", "pallet-balances", @@ -3437,6 +3438,7 @@ dependencies = [ "frame-system", "frame-system-benchmarking", "frame-system-rpc-runtime-api", + "frame-try-runtime", "hex-literal", "log", "node-primitives", @@ -3510,6 +3512,7 @@ dependencies = [ "frame-system", "frame-system-benchmarking", "frame-system-rpc-runtime-api", + "frame-try-runtime", "hex-literal", "log", "node-primitives", diff --git a/node/Cargo.toml b/node/Cargo.toml index fc62d177c502f1a993b1ce4021866451d795e04b..4f1958cfa1ae9af016fc9d201ef89c384d148ef8 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -48,6 +48,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", ] try-runtime = [ + "runtime-benchmarks", "common-runtime/try-runtime", "dc-distance/try-runtime", "distance-oracle?/try-runtime", diff --git a/node/src/cli.rs b/node/src/cli.rs index effac655de2fd519c2a098967d56a53128fcc601..175ffa56a601623feb9a1ffcc87836a6576178c4 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -83,7 +83,7 @@ pub enum Subcommand { /// Try some command against runtime state. #[cfg(feature = "try-runtime")] - TryRuntime(try_runtime_cli::TryRuntimeCmd), + TryRuntime, /// Try some command against runtime state. Note: `try-runtime` feature must be enabled. #[cfg(not(feature = "try-runtime"))] diff --git a/node/src/command.rs b/node/src/command.rs index c1ce8bfff81d42ab2d9bfb0ca03d1ec2964a5f3a..83ab2b62d24859caa4a5d8f9eb4d8b2a559fe7e0 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -358,39 +358,7 @@ pub fn run() -> sc_cli::Result<()> { .into()) } #[cfg(feature = "try-runtime")] - Some(Subcommand::TryRuntime(cmd)) => { - let runner = cli.create_runner(cmd)?; - let chain_spec = &runner.config().chain_spec; - - use sc_service::TaskManager; - let registry = &runner - .config() - .prometheus_config - .as_ref() - .map(|cfg| &cfg.registry); - let task_manager = TaskManager::new(runner.config().tokio_handle.clone(), *registry) - .map_err(|e| { - sc_cli::Error::Application(format!("Fail to create TaskManager: {}", e).into()) - })?; - - // Ensure dev spec - if !chain_spec.id().ends_with("dev") { - return Err(sc_cli::Error::Application( - "try-runtime only support dev specs".into(), - )); - } - - match chain_spec.runtime_type() { - #[cfg(feature = "gdev")] - RuntimeType::GDev => runner.async_run(|config| { - Ok(( - cmd.run::<gdev_runtime::Block, Executor>(config), - task_manager, - )) - }), - _ => Err(sc_cli::Error::Application("unknown runtime type".into())), - } - } + Some(Subcommand::TryRuntime) => Err(try_runtime_cli::DEPRECATION_NOTICE.into()), #[cfg(not(feature = "try-runtime"))] Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node. \ You can enable it with `--features try-runtime`." diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 4dae708319da060ab31d88f70a9f7ff399b6a4e8..0c25cfa2978244059215f86185d3efa8f96219d2 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -54,6 +54,7 @@ std = [ "frame-support/std", "frame-system-benchmarking?/std", "frame-system/std", + "frame-try-runtime/std", "pallet-authority-members/std", "pallet-babe/std", "pallet-balances/std", @@ -96,6 +97,7 @@ try-runtime = [ "duniter-primitives/try-runtime", "frame-support/try-runtime", "frame-system/try-runtime", + "frame-try-runtime/try-runtime", "pallet-authority-members/try-runtime", "pallet-babe/try-runtime", "pallet-balances/try-runtime", @@ -134,6 +136,7 @@ frame-benchmarking = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } frame-system-benchmarking = { workspace = true, optional = true } +frame-try-runtime = { workspace = true, optional = true } pallet-authority-members = { workspace = true } pallet-babe = { workspace = true } pallet-balances = { workspace = true } diff --git a/runtime/common/src/apis.rs b/runtime/common/src/apis.rs index af95e113f640d2a2318d6f464d20722c1b760f63..e654b92494695406deb993d44962350b59a62c3f 100644 --- a/runtime/common/src/apis.rs +++ b/runtime/common/src/apis.rs @@ -231,23 +231,19 @@ macro_rules! runtime_apis { } #[cfg(feature = "try-runtime")] - impl frame_try_runtime::TryRuntime<Block> for Runtime where <Runtime as frame_system::Config>::BlockNumber: Clone + sp_std::fmt::Debug + sp_runtime::traits::AtLeast32BitUnsigned { - fn on_runtime_upgrade() -> (Weight, Weight) { - log::info!("try-runtime::on_runtime_upgrade."); - todo!() - // TODO solve the problem to uncomment this: - //let weight = Executive::try_runtime_upgrade().unwrap(); - //(weight, BlockWeights::get().max_block) + impl frame_try_runtime::TryRuntime<Block> for Runtime { + fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { + let weight = Executive::try_runtime_upgrade(checks).unwrap(); + (weight, BlockWeights::get().max_block) } fn execute_block( block: Block, state_root_check: bool, + signature_check: bool, select: frame_try_runtime::TryStateSelect, ) -> Weight { - todo!() - // TODO solve the problem to uncomment this: - //Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed") + Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed") } } diff --git a/runtime/g1/Cargo.toml b/runtime/g1/Cargo.toml index 76c98358b332ebbdd5e5289daf76d18bf2a39775..94b683b12f8e9a7c3dbffafd51f120e85c0314d0 100644 --- a/runtime/g1/Cargo.toml +++ b/runtime/g1/Cargo.toml @@ -60,6 +60,7 @@ std = [ "frame-system-benchmarking/std", "frame-system-rpc-runtime-api/std", "frame-system/std", + "frame-try-runtime/std", "log/std", "node-primitives/std", "pallet-atomic-swap/std", @@ -124,6 +125,7 @@ try-runtime = [ "frame-executive/try-runtime", "frame-support/try-runtime", "frame-system/try-runtime", + "frame-try-runtime/try-runtime", "pallet-atomic-swap/try-runtime", "pallet-authority-discovery/try-runtime", "pallet-authority-members/try-runtime", @@ -178,6 +180,7 @@ frame-benchmarking = { workspace = true } frame-system-benchmarking = { workspace = true } frame-system = { workspace = true } frame-system-rpc-runtime-api = { workspace = true } +frame-try-runtime = { workspace = true, optional = true } hex-literal = { workspace = true, optional = true } log = { workspace = true } pallet-atomic-swap = { workspace = true } diff --git a/runtime/gdev/Cargo.toml b/runtime/gdev/Cargo.toml index ef804b7e94e0c75568108ba79655475c39aa64ea..76c167816194255171006124e51020cbf00b2d56 100644 --- a/runtime/gdev/Cargo.toml +++ b/runtime/gdev/Cargo.toml @@ -60,6 +60,7 @@ std = [ "frame-system-benchmarking/std", "frame-system-rpc-runtime-api/std", "frame-system/std", + "frame-try-runtime/std", "log/std", "node-primitives/std", "pallet-atomic-swap/std", @@ -126,6 +127,7 @@ try-runtime = [ "frame-executive/try-runtime", "frame-support/try-runtime", "frame-system/try-runtime", + "frame-try-runtime/try-runtime", "pallet-atomic-swap/try-runtime", "pallet-authority-discovery/try-runtime", "pallet-authority-members/try-runtime", @@ -182,6 +184,7 @@ frame-support = { workspace = true } frame-system = { workspace = true } frame-system-benchmarking = { workspace = true, optional = true } frame-system-rpc-runtime-api = { workspace = true } +frame-try-runtime = { workspace = true, optional = true } hex-literal = { workspace = true, optional = true } log = { workspace = true } node-primitives = { workspace = true } diff --git a/runtime/gtest/Cargo.toml b/runtime/gtest/Cargo.toml index 2b7cbbcc1edcc490efac4a91f96e4d980a7d180d..3e14eae2708c8c29770c63a430375dd5dc76b1f4 100644 --- a/runtime/gtest/Cargo.toml +++ b/runtime/gtest/Cargo.toml @@ -59,7 +59,7 @@ std = [ "frame-system-benchmarking/std", "frame-system-rpc-runtime-api/std", "frame-system/std", - "frame-try-runtime?/std", + "frame-try-runtime/std", "log/std", "node-primitives/std", "pallet-atomic-swap/std", @@ -124,7 +124,7 @@ try-runtime = [ "frame-executive/try-runtime", "frame-support/try-runtime", "frame-system/try-runtime", - "frame-try-runtime?/try-runtime", + "frame-try-runtime/try-runtime", "pallet-atomic-swap/try-runtime", "pallet-authority-discovery/try-runtime", "pallet-authority-members/try-runtime",