Select Git revision
-
Hugo Trentesaux authored
* fix gtest runtime type name * add embeded client spec and genesis in binary (this re-buids chainspecs at each run) * refac chainspecs generation * add what is needed to build gtest chainspecs
Hugo Trentesaux authored* fix gtest runtime type name * add embeded client spec and genesis in binary (this re-buids chainspecs at each run) * refac chainspecs generation * add what is needed to build gtest chainspecs
command.rs 20.05 KiB
// This file is part of Substrate.
// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pub mod key;
pub mod utils;
#[cfg(feature = "gtest")]
use crate::chain_spec::{gtest, gtest_genesis};
use crate::cli::{Cli, Subcommand};
#[cfg(feature = "g1")]
use crate::service::G1Executor;
#[cfg(feature = "gdev")]
use crate::service::GDevExecutor;
#[cfg(feature = "gtest")]
use crate::service::GTestExecutor;
use crate::service::{IdentifyRuntimeType, RuntimeType};
use crate::{chain_spec, service};
use clap::CommandFactory;
#[cfg(feature = "runtime-benchmarks")]
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
// TODO: create our own reference hardware
/*
lazy_static! {
/// The hardware requirements as measured on reference hardware.
pub static ref REFERENCE_HARDWARE: Requirements = {
let raw = include_bytes!("reference_hardware.json").as_slice();
serde_json::from_slice(raw).expect("Hardcoded data is known good; qed")
};
}*/
//Currently, only `gdev-benchmark` supports the benchmark of all the extrinsics. Storage and overhead are equivalent with `gdev-benchmark` and `gdev`, so we enforce `gdev-benchmark` for all benchmark-related commands.
#[cfg(feature = "runtime-benchmarks")]
fn ensure_dev(spec: &Box<dyn sc_service::ChainSpec>) -> std::result::Result<(), String> {
if spec.id() == "gdev-benchmark" {
Ok(())
} else {
Err(format!(
"{}{}",
"can only use subcommand with --chain [gdev-benchmark], got ",
spec.id()
))
}
}
/// Unwraps a [`crate::client::Client`] into the concrete runtime client.
#[cfg(feature = "runtime-benchmarks")]
macro_rules! unwrap_client {
(
$client:ident,
$code:expr
) => {
match $client.as_ref() {
#[cfg(feature = "g1")]
crate::service::client::Client::G1($client) => $code,