Fix substrate factory CLI command (#3239)

* CLI execution flag for import-blocks and factory.

* Fix minimum_balance bug with CLI factory.
This commit is contained in:
Jim Posen
2019-07-29 17:06:13 +02:00
committed by Bastian Köcher
parent c9c0ad4756
commit 8aa367c27a
8 changed files with 54 additions and 19 deletions
+6 -4
View File
@@ -23,11 +23,13 @@ use rand::rngs::StdRng;
use parity_codec::Decode;
use keyring::sr25519::Keyring;
use node_runtime::{Call, CheckedExtrinsic, UncheckedExtrinsic, SignedExtra, BalancesCall};
use node_primitives::Hash;
use node_runtime::{Call, CheckedExtrinsic, UncheckedExtrinsic, SignedExtra, BalancesCall, ExistentialDeposit};
use primitives::{sr25519, crypto::Pair};
use parity_codec::Encode;
use sr_primitives::{generic::Era, traits::{Block as BlockT, Header as HeaderT, SignedExtension}};
use substrate_service::ServiceFactory;
use support::traits::Get;
use transaction_factory::RuntimeAdapter;
use transaction_factory::modes::Mode;
use crate::service;
@@ -133,7 +135,7 @@ impl RuntimeAdapter for FactoryState<Number> {
sender: &Self::AccountId,
key: &Self::Secret,
destination: &Self::AccountId,
amount: &Self::Number,
amount: &Self::Balance,
prior_block_hash: &<Self::Block as BlockT>::Hash,
) -> <Self::Block as BlockT>::Extrinsic {
let index = self.extract_index(&sender, prior_block_hash);
@@ -161,9 +163,9 @@ impl RuntimeAdapter for FactoryState<Number> {
inherent
}
fn minimum_balance() -> Self::Number {
fn minimum_balance() -> Self::Balance {
// TODO get correct amount via api. See #2587.
1337
ExistentialDeposit::get()
}
fn master_account_id() -> Self::AccountId {
+21 -2
View File
@@ -26,7 +26,7 @@ mod factory_impl;
use tokio::prelude::Future;
use tokio::runtime::{Builder as RuntimeBuilder, Runtime};
pub use cli::{VersionInfo, IntoExit, NoCustom, SharedParams};
pub use cli::{VersionInfo, IntoExit, NoCustom, SharedParams, ExecutionStrategyParam};
use substrate_service::{ServiceFactory, Roles as ServiceRoles};
use std::ops::Deref;
use log::info;
@@ -34,6 +34,7 @@ use structopt::{StructOpt, clap::App};
use cli::{AugmentClap, GetLogFilter};
use crate::factory_impl::FactoryState;
use transaction_factory::RuntimeAdapter;
use client::ExecutionStrategies;
/// The chain specification option.
#[derive(Clone, Debug, PartialEq)]
@@ -102,6 +103,18 @@ pub struct FactoryCmd {
#[allow(missing_docs)]
#[structopt(flatten)]
pub shared_params: SharedParams,
/// The means of execution used when calling into the runtime while importing blocks.
#[structopt(
long = "execution",
value_name = "STRATEGY",
raw(
possible_values = "&ExecutionStrategyParam::variants()",
case_insensitive = "true",
default_value = r#""NativeElseWasm""#
)
)]
pub execution: ExecutionStrategyParam,
}
impl AugmentClap for FactoryCmd {
@@ -173,11 +186,17 @@ pub fn run<I, T, E>(args: I, exit: E, version: cli::VersionInfo) -> error::Resul
match &ret {
Ok(Some(CustomSubcommands::Factory(cli_args))) => {
let config = cli::create_config_with_db_path::<service::Factory, _>(
let mut config = cli::create_config_with_db_path::<service::Factory, _>(
load_spec,
&cli_args.shared_params,
&version,
)?;
config.execution_strategies = ExecutionStrategies {
importing: cli_args.execution.into(),
block_construction: cli_args.execution.into(),
other: cli_args.execution.into(),
..Default::default()
};
match ChainSpec::from(config.chain_spec.id()) {
Some(ref c) if c == &ChainSpec::Development || c == &ChainSpec::LocalTestnet => {},