Skip to content
Snippets Groups Projects
Commit 21bc247c authored by Seemant Aggarwal's avatar Seemant Aggarwal
Browse files

addressing comments and fixes

parent 4a92e35f
Branches
No related merge requests found
Pipeline #518310 waiting for manual action with stages
in 18 minutes and 47 seconds
......@@ -25,6 +25,7 @@ use std::path::PathBuf;
#[derive(Debug, Parser)]
pub enum Subcommand {
/// Build a chain specification.
#[deprecated(note = "build-spec will be removed after 1/04/2026. Use export-chain-spec instead")]
BuildSpec(sc_cli::BuildSpecCmd),
/// Export the chain specification.
......
......@@ -287,14 +287,15 @@ pub fn run() -> Result<()> {
None,
polkadot_node_metrics::logger_hook(),
),
#[allow(deprecated)]
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
Ok(runner.sync_run(|config| cmd.run(config.chain_spec, config.network))?)
},
Some(Subcommand::ExportChainSpec(cmd)) => {
// Directly load the embedded chain spec using the CLI’s load_spec method.
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
cmd.run(spec).map_err(Into::into)
let runner = cli.create_runner(cmd)?;
Ok(runner.sync_run(|config| cmd.run(config.chain_spec))?)
},
Some(Subcommand::CheckBlock(cmd)) => {
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
......
......@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use polkadot_sdk::{sc_cli::ExportChainSpecCmd, *};
use polkadot_sdk::*;
/// An overarching CLI command definition.
#[derive(Debug, clap::Parser)]
......@@ -78,10 +78,11 @@ pub enum Subcommand {
Sign(sc_cli::SignCmd),
/// Build a chain specification.
#[deprecated(note = "build-spec will be removed after 1/04/2026. Use export-chain-spec instead")]
BuildSpec(sc_cli::BuildSpecCmd),
/// Export the chain specification.
ExportChainSpec(ExportChainSpecCmd),
ExportChainSpec(sc_cli::ExportChainSpecCmd),
/// Validate blocks.
CheckBlock(sc_cli::CheckBlockCmd),
......
......@@ -95,8 +95,8 @@ pub fn run() -> Result<()> {
},
Some(Subcommand::ExportChainSpec(cmd)) => {
// Directly load the embedded chain spec using the CLI’s load_spec method.
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
cmd.run(spec)
let runner = cli.create_runner(cmd)?;
Ok(runner.sync_run(|config| cmd.run(config.chain_spec))?)
},
Some(Subcommand::Benchmark(cmd)) => {
let runner = cli.create_runner(cmd)?;
......@@ -178,6 +178,7 @@ pub fn run() -> Result<()> {
Some(Subcommand::Sign(cmd)) => cmd.run(),
Some(Subcommand::Verify(cmd)) => cmd.run(),
Some(Subcommand::Vanity(cmd)) => cmd.run(),
#[allow(deprecated)]
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
......
......@@ -23,8 +23,8 @@ use std::{
io::{self, Write},
path::PathBuf,
};
use crate::{error::Result, SharedParams};
use std::thread::sleep;
use crate::{error::Result, BuildSpecCmd, CliConfiguration, NodeKeyParams, SharedParams};
/// Export a chain-spec to a JSON file in plain or in raw storage format.
///
......@@ -42,9 +42,8 @@ use crate::{error::Result, SharedParams};
#[derive(Debug, Clone, Parser)]
pub struct ExportChainSpecCmd {
/// The chain spec identifier to export.
#[allow(missing_docs)]
#[clap(flatten)]
pub shared_params: SharedParams,
#[arg(long, default_value = "local")]
pub chain: String,
/// `chain-spec` JSON file path. If omitted, prints to stdout.
#[arg(long)]
......@@ -69,3 +68,15 @@ impl ExportChainSpecCmd {
Ok(())
}
}
impl CliConfiguration for ExportChainSpecCmd {
// If ExportChainSpecCmd doesn’t have shared_params, you must provide some implementation.
fn shared_params(&self) -> &SharedParams {
unimplemented!("ExportChainSpecCmd does not implement shared_params")
}
// Implement the chain_id method to return the chain identifier.
fn chain_id(&self, _is_dev: bool) -> Result<String> {
Ok(self.chain.clone())
}
}
......@@ -15,10 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use polkadot_sdk::{
sc_cli::{ExportChainSpecCmd, RunCmd},
*,
};
use polkadot_sdk::*;
#[derive(Debug, Clone)]
pub enum Consensus {
......@@ -52,7 +49,7 @@ pub struct Cli {
pub consensus: Consensus,
#[clap(flatten)]
pub run: RunCmd,
pub run: sc_cli::RunCmd,
}
#[derive(Debug, clap::Subcommand)]
......@@ -62,10 +59,11 @@ pub enum Subcommand {
Key(sc_cli::KeySubcommand),
/// Build a chain specification.
#[deprecated(note = "build-spec will be removed after 1/04/2026. Use export-chain-spec instead")]
BuildSpec(sc_cli::BuildSpecCmd),
/// Export the chain specification.
ExportChainSpec(ExportChainSpecCmd),
ExportChainSpec(sc_cli::ExportChainSpecCmd),
/// Validate blocks.
CheckBlock(sc_cli::CheckBlockCmd),
......
......@@ -62,6 +62,7 @@ pub fn run() -> sc_cli::Result<()> {
match &cli.subcommand {
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
#[allow(deprecated)]
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
......@@ -76,8 +77,8 @@ pub fn run() -> sc_cli::Result<()> {
},
Some(Subcommand::ExportChainSpec(cmd)) => {
// Directly load the embedded chain spec using the CLI’s load_spec method.
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
cmd.run(&*spec)
let runner = cli.create_runner(cmd)?;
Ok(runner.sync_run(|config| cmd.run(config.chain_spec))?)
},
Some(Subcommand::ExportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
......
use polkadot_sdk::{sc_cli::ExportChainSpecCmd, *};
use polkadot_sdk::*;
use std::path::PathBuf;
/// Sub-commands supported by the collator.
......@@ -6,10 +6,11 @@ use std::path::PathBuf;
#[derive(Debug, clap::Subcommand)]
pub enum Subcommand {
/// Build a chain specification.
#[deprecated(note = "build-spec will be removed after 1/04/2026. Use export-chain-spec instead")]
BuildSpec(sc_cli::BuildSpecCmd),
/// Export the chain specification.
ExportChainSpec(ExportChainSpecCmd),
ExportChainSpec(sc_cli::ExportChainSpecCmd),
/// Validate blocks.
CheckBlock(sc_cli::CheckBlockCmd),
......
......@@ -114,6 +114,7 @@ pub fn run() -> Result<()> {
let cli = Cli::from_args();
match &cli.subcommand {
#[allow(deprecated)]
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
......@@ -124,9 +125,8 @@ pub fn run() -> Result<()> {
})
},
Some(Subcommand::ExportChainSpec(cmd)) => {
// Directly load the embedded chain spec using the CLI’s load_spec method.
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
cmd.run(&*spec)
let runner = cli.create_runner(cmd)?;
Ok(runner.sync_run(|config| cmd.run(config.chain_spec))?)
},
Some(Subcommand::ExportBlocks(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
......
use sc_cli::{ExportChainSpecCmd, RunCmd};
#[derive(Debug, clap::Parser)]
pub struct Cli {
#[command(subcommand)]
pub subcommand: Option<Subcommand>,
#[clap(flatten)]
pub run: RunCmd,
pub run: sc_cli::RunCmd,
}
#[derive(Debug, clap::Subcommand)]
......@@ -17,10 +15,11 @@ pub enum Subcommand {
Key(sc_cli::KeySubcommand),
/// Build a chain specification.
#[deprecated(note = "build-spec will be removed after 1/04/2026. Use export-chain-spec instead")]
BuildSpec(sc_cli::BuildSpecCmd),
/// Export the chain specification.
ExportChainSpec(ExportChainSpecCmd),
ExportChainSpec(sc_cli::ExportChainSpecCmd),
/// Validate blocks.
CheckBlock(sc_cli::CheckBlockCmd),
......
......@@ -51,6 +51,7 @@ pub fn run() -> sc_cli::Result<()> {
match &cli.subcommand {
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
#[allow(deprecated)]
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
......@@ -65,8 +66,8 @@ pub fn run() -> sc_cli::Result<()> {
},
Some(Subcommand::ExportChainSpec(cmd)) => {
// Directly load the embedded chain spec using the CLI’s load_spec method.
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
cmd.run(&*spec)
let runner = cli.create_runner(cmd)?;
Ok(runner.sync_run(|config| cmd.run(config.chain_spec))?)
},
Some(Subcommand::ExportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment