Files
pezkuwi-subxt/polkadot/utils/generate-bags/src/main.rs
T
Bastian Köcher bf90cb0b73 Remove kusama and polkadot runtime crates (#1731)
This pull request is removing the Kusama and Polkadot runtime crates. As
still some crates dependent on the runtime crates, this pull request is
doing some more changes.

- It removes the `hostperfcheck` CLI command. This CLI command could
compare the current node against the standard hardware by doing some
checks. Later we added the hardware benchmark feature to Substrate. This
hardware benchmark is running on every node startup and prints a warning
if the current node is too slow. This makes this CLI command a duplicate
that was also depending on the kusama runtime.

- The pull request is removing the emulated integration tests that were
requiring the Kusama or Polkadot runtime crates.
2023-09-29 09:54:11 +02:00

71 lines
2.2 KiB
Rust

// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Make the set of voting bag thresholds to be used in `voter_bags.rs`.
//!
//! Generally speaking this script can be run once per runtime and never
//! touched again. It can be reused to regenerate a wholly different
//! quantity of bags, or if the existential deposit changes, etc.
use clap::{Parser, ValueEnum};
use generate_bags::generate_thresholds;
use std::path::{Path, PathBuf};
use westend_runtime::Runtime as WestendRuntime;
#[derive(Clone, Debug, ValueEnum)]
#[value(rename_all = "PascalCase")]
enum Runtime {
Westend,
}
impl Runtime {
fn generate_thresholds_fn(
&self,
) -> Box<dyn FnOnce(usize, &Path, u128, u128) -> Result<(), std::io::Error>> {
match self {
Runtime::Westend => Box::new(generate_thresholds::<WestendRuntime>),
}
}
}
#[derive(Debug, Parser)]
struct Opt {
/// How many bags to generate.
#[arg(long, default_value_t = 200)]
n_bags: usize,
/// Which runtime to generate.
#[arg(long, ignore_case = true, value_enum, default_value_t = Runtime::Westend)]
runtime: Runtime,
/// Where to write the output.
output: PathBuf,
/// The total issuance of the native currency.
#[arg(short, long)]
total_issuance: u128,
/// The minimum account balance (i.e. existential deposit) for the native currency.
#[arg(short, long)]
minimum_balance: u128,
}
fn main() -> Result<(), std::io::Error> {
let Opt { n_bags, output, runtime, total_issuance, minimum_balance } = Opt::parse();
runtime.generate_thresholds_fn()(n_bags, &output, total_issuance, minimum_balance)
}