polkadot_cli/cli.rs
1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16
17//! Polkadot CLI library.
18
19pub use polkadot_node_primitives::NODE_VERSION;
20
21use clap::Parser;
22use std::path::PathBuf;
23
24#[allow(missing_docs)]
25#[derive(Debug, Parser)]
26pub enum Subcommand {
27 /// Build a chain specification.
28 /// DEPRECATED: `build-spec` command will be removed after 1/04/2026. Use `export-chain-spec`
29 /// command instead.
30 #[deprecated(
31 note = "build-spec command will be removed after 1/04/2026. Use export-chain-spec command instead"
32 )]
33 BuildSpec(sc_cli::BuildSpecCmd),
34
35 /// Export the chain specification.
36 ExportChainSpec(sc_cli::ExportChainSpecCmd),
37
38 /// Validate blocks.
39 CheckBlock(sc_cli::CheckBlockCmd),
40
41 /// Export blocks.
42 ExportBlocks(sc_cli::ExportBlocksCmd),
43
44 /// Export the state of a given block into a chain spec.
45 ExportState(sc_cli::ExportStateCmd),
46
47 /// Import blocks.
48 ImportBlocks(sc_cli::ImportBlocksCmd),
49
50 /// Remove the whole chain.
51 PurgeChain(sc_cli::PurgeChainCmd),
52
53 /// Revert the chain to a previous state.
54 Revert(sc_cli::RevertCmd),
55
56 /// Sub-commands concerned with benchmarking.
57 /// The pallet benchmarking moved to the `pallet` sub-command.
58 #[command(subcommand)]
59 Benchmark(frame_benchmarking_cli::BenchmarkCmd),
60
61 /// Key management CLI utilities
62 #[command(subcommand)]
63 Key(sc_cli::KeySubcommand),
64
65 /// Db meta columns information.
66 ChainInfo(sc_cli::ChainInfoCmd),
67}
68
69#[allow(missing_docs)]
70#[derive(Debug, Parser)]
71#[group(skip)]
72pub struct RunCmd {
73 #[clap(flatten)]
74 pub base: sc_cli::RunCmd,
75
76 /// Force using Kusama native runtime.
77 #[arg(long = "force-kusama")]
78 pub force_kusama: bool,
79
80 /// Force using Westend native runtime.
81 #[arg(long = "force-westend")]
82 pub force_westend: bool,
83
84 /// Force using Rococo native runtime.
85 #[arg(long = "force-rococo")]
86 pub force_rococo: bool,
87
88 /// Disable the BEEFY gadget.
89 ///
90 /// Currently enabled by default.
91 #[arg(long)]
92 pub no_beefy: bool,
93
94 /// Allows a validator to run insecurely outside of Secure Validator Mode. Security features
95 /// are still enabled on a best-effort basis, but missing features are no longer required. For
96 /// more information see <https://github.com/w3f/polkadot-wiki/issues/4881>.
97 #[arg(long = "insecure-validator-i-know-what-i-do", requires = "validator")]
98 pub insecure_validator: bool,
99
100 /// Enable the block authoring backoff that is triggered when finality is lagging.
101 #[arg(long)]
102 pub force_authoring_backoff: bool,
103
104 /// Add the destination address to the `pyroscope` agent.
105 ///
106 /// Must be valid socket address, of format `IP:Port` (commonly `127.0.0.1:4040`).
107 #[arg(long)]
108 pub pyroscope_server: Option<String>,
109
110 /// Disable automatic hardware benchmarks.
111 ///
112 /// By default these benchmarks are automatically ran at startup and measure
113 /// the CPU speed, the memory bandwidth and the disk speed.
114 ///
115 /// The results are then printed out in the logs, and also sent as part of
116 /// telemetry, if telemetry is enabled.
117 #[arg(long)]
118 pub no_hardware_benchmarks: bool,
119
120 /// Overseer message capacity override.
121 ///
122 /// **Dangerous!** Do not touch unless explicitly advised to.
123 #[arg(long)]
124 pub overseer_channel_capacity_override: Option<usize>,
125
126 /// Path to the directory where auxiliary worker binaries reside.
127 ///
128 /// If not specified, the main binary's directory is searched first, then
129 /// `/usr/lib/polkadot` is searched.
130 ///
131 /// TESTING ONLY: if the path points to an executable rather then directory,
132 /// that executable is used both as preparation and execution worker.
133 #[arg(long, value_name = "PATH")]
134 pub workers_path: Option<PathBuf>,
135
136 /// Override the maximum number of pvf execute workers.
137 ///
138 /// **Dangerous!** Do not touch unless explicitly advised to.
139 #[arg(long)]
140 pub execute_workers_max_num: Option<usize>,
141 /// Override the maximum number of pvf workers that can be spawned in the pvf prepare
142 /// pool for tasks with the priority below critical.
143 ///
144 /// **Dangerous!** Do not touch unless explicitly advised to.
145
146 #[arg(long)]
147 pub prepare_workers_soft_max_num: Option<usize>,
148 /// Override the absolute number of pvf workers that can be spawned in the pvf prepare pool.
149 ///
150 /// **Dangerous!** Do not touch unless explicitly advised to.
151 #[arg(long)]
152 pub prepare_workers_hard_max_num: Option<usize>,
153 /// TESTING ONLY: disable the version check between nodes and workers.
154 #[arg(long, hide = true)]
155 pub disable_worker_version_check: bool,
156
157 /// How long finalized data should be kept in the availability store (in hours).
158 /// Only used for testnets. If not specified, set to 1 hour. Always set to 25 hours for live
159 /// networks.
160 #[arg(long)]
161 pub keep_finalized_for: Option<u32>,
162}
163
164#[allow(missing_docs)]
165#[derive(Debug, Parser)]
166pub struct Cli {
167 #[command(subcommand)]
168 pub subcommand: Option<Subcommand>,
169
170 #[clap(flatten)]
171 pub run: RunCmd,
172
173 #[clap(flatten)]
174 pub storage_monitor: sc_storage_monitor::StorageMonitorParams,
175}