Skip to content

Commit

Permalink
Remove tx factory (paritytech#5890)
Browse files Browse the repository at this point in the history
* Remove tx factory files.

* Remove unused imports.

* Revert cargo lock.
  • Loading branch information
seerscode authored May 5, 2020
1 parent 9f51b41 commit 318dc7a
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 539 deletions.
19 changes: 0 additions & 19 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ members = [
"bin/node/rpc",
"bin/node/runtime",
"bin/node/testing",
"bin/node/transaction-factory",
"bin/utils/subkey",
"bin/utils/chain-spec-builder",
"client/api",
Expand Down
3 changes: 0 additions & 3 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ node-executor = { version = "2.0.0-dev", path = "../executor" }
# CLI-specific dependencies
sc-cli = { version = "0.8.0-dev", optional = true, path = "../../../client/cli" }
frame-benchmarking-cli = { version = "2.0.0-dev", optional = true, path = "../../../utils/frame/benchmarking-cli" }
node-transaction-factory = { version = "0.8.0-dev", optional = true, path = "../transaction-factory" }
node-inspect = { version = "0.8.0-dev", optional = true, path = "../inspect" }

# WASM-specific dependencies
Expand Down Expand Up @@ -126,7 +125,6 @@ platforms = "0.2.1"

[build-dependencies]
structopt = { version = "0.3.8", optional = true }
node-transaction-factory = { version = "0.8.0-dev", optional = true, path = "../transaction-factory" }
node-inspect = { version = "0.8.0-dev", optional = true, path = "../inspect" }
frame-benchmarking-cli = { version = "2.0.0-dev", optional = true, path = "../../../utils/frame/benchmarking-cli" }
substrate-build-script-utils = { version = "2.0.0-dev", optional = true, path = "../../../utils/build-script-utils" }
Expand All @@ -147,7 +145,6 @@ browser = [
cli = [
"node-executor/wasmi-errno",
"node-inspect",
"node-transaction-factory",
"sc-cli",
"frame-benchmarking-cli",
"sc-service/db",
Expand Down
30 changes: 1 addition & 29 deletions bin/node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

use sc_cli::{ImportParams, RunCmd, SharedParams};
use sc_cli::RunCmd;
use structopt::StructOpt;

/// An overarching CLI command definition.
Expand All @@ -34,13 +34,6 @@ pub enum Subcommand {
/// A set of base subcommands handled by `sc_cli`.
#[structopt(flatten)]
Base(sc_cli::Subcommand),
/// The custom factory subcommmand for manufacturing transactions.
#[structopt(
name = "factory",
about = "Manufactures num transactions from Alice to random accounts. \
Only supported for development or local testnet."
)]
Factory(FactoryCmd),

/// The custom inspect subcommmand for decoding blocks and extrinsics.
#[structopt(
Expand All @@ -53,24 +46,3 @@ pub enum Subcommand {
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
}

/// The `factory` command used to generate transactions.
/// Please note: this command currently only works on an empty database!
#[derive(Debug, StructOpt, Clone)]
pub struct FactoryCmd {
/// Number of blocks to generate.
#[structopt(long = "blocks", default_value = "1")]
pub blocks: u32,

/// Number of transactions to push per block.
#[structopt(long = "transactions", default_value = "8")]
pub transactions: u32,

#[allow(missing_docs)]
#[structopt(flatten)]
pub shared_params: SharedParams,

#[allow(missing_docs)]
#[structopt(flatten)]
pub import_params: ImportParams,
}
52 changes: 2 additions & 50 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

use crate::{chain_spec, factory_impl::FactoryState, service, Cli, FactoryCmd, Subcommand};
use crate::{chain_spec, service, Cli, Subcommand};
use node_executor::Executor;
use node_runtime::{Block, RuntimeApi};
use node_transaction_factory::RuntimeAdapter;
use sc_cli::{CliConfiguration, ImportParams, Result, SharedParams, SubstrateCli};
use sc_service::Configuration;
use sc_cli::{Result, SubstrateCli};

impl SubstrateCli for Cli {
fn impl_name() -> &'static str {
Expand Down Expand Up @@ -94,56 +92,10 @@ pub fn run() -> Result<()> {
Ok(())
}
}
Some(Subcommand::Factory(cmd)) => {
let runner = cli.create_runner(cmd)?;

runner.sync_run(|config| cmd.run(config))
}
Some(Subcommand::Base(subcommand)) => {
let runner = cli.create_runner(subcommand)?;

runner.run_subcommand(subcommand, |config| Ok(new_full_start!(config).0))
}
}
}

impl CliConfiguration for FactoryCmd {
fn shared_params(&self) -> &SharedParams {
&self.shared_params
}

fn import_params(&self) -> Option<&ImportParams> {
Some(&self.import_params)
}
}

impl FactoryCmd {
fn run(&self, config: Configuration) -> Result<()> {
match config.chain_spec.id() {
"dev" | "local" => {}
_ => return Err("Factory is only supported for development and local testnet.".into()),
}

// Setup tracing.
if let Some(tracing_targets) = self.import_params.tracing_targets.as_ref() {
let subscriber = sc_tracing::ProfilingSubscriber::new(
self.import_params.tracing_receiver.into(),
tracing_targets,
);
if let Err(e) = tracing::subscriber::set_global_default(subscriber) {
return Err(format!("Unable to set global default subscriber {}", e).into());
}
}

let factory_state = FactoryState::new(self.blocks, self.transactions);

let service_builder = new_full_start!(config).0;
node_transaction_factory::factory(
factory_state,
service_builder.client(),
service_builder
.select_chain()
.expect("The select_chain is always initialized by new_full_start!; qed"),
)
}
}
203 changes: 0 additions & 203 deletions bin/node/cli/src/factory_impl.rs

This file was deleted.

2 changes: 0 additions & 2 deletions bin/node/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ mod browser;
#[cfg(feature = "cli")]
mod cli;
#[cfg(feature = "cli")]
mod factory_impl;
#[cfg(feature = "cli")]
mod command;

#[cfg(feature = "browser")]
Expand Down
Loading

0 comments on commit 318dc7a

Please sign in to comment.