Skip to content
Snippets Groups Projects
Unverified Commit cf52a0d9 authored by seemantaggarwal's avatar seemantaggarwal Committed by GitHub
Browse files

effort towards getting chainspecbuilder into omni-node fix 5567 (#7619)

Adding chain-spec-builder as a subcommand into Polkadot omni node
parent 16ed0296
No related merge requests found
Pipeline #516642 waiting for manual action with stages
in 1 hour, 47 minutes, and 56 seconds
...@@ -18454,6 +18454,7 @@ dependencies = [ ...@@ -18454,6 +18454,7 @@ dependencies = [
"sp-transaction-pool 26.0.0", "sp-transaction-pool 26.0.0",
"sp-version 29.0.0", "sp-version 29.0.0",
"sp-weights 27.0.0", "sp-weights 27.0.0",
"staging-chain-spec-builder",
"substrate-frame-rpc-system", "substrate-frame-rpc-system",
"substrate-prometheus-endpoint", "substrate-prometheus-endpoint",
"substrate-state-trie-migration-rpc", "substrate-state-trie-migration-rpc",
...@@ -21234,7 +21235,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -21234,7 +21235,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
dependencies = [ dependencies = [
"rand_chacha 0.9.0", "rand_chacha 0.9.0",
"rand_core 0.9.1", "rand_core 0.9.2",
"zerocopy 0.8.20", "zerocopy 0.8.20",
] ]
   
...@@ -21255,7 +21256,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -21255,7 +21256,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [ dependencies = [
"ppv-lite86", "ppv-lite86",
"rand_core 0.9.1", "rand_core 0.9.2",
] ]
   
[[package]] [[package]]
...@@ -21275,9 +21276,9 @@ dependencies = [ ...@@ -21275,9 +21276,9 @@ dependencies = [
   
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.9.1" version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a88e0da7a2c97baa202165137c158d0a2e824ac465d13d81046727b34cb247d3" checksum = "7a509b1a2ffbe92afab0e55c8fd99dea1c280e8171bd2d88682bb20bc41cbc2c"
dependencies = [ dependencies = [
"getrandom 0.3.1", "getrandom 0.3.1",
"zerocopy 0.8.20", "zerocopy 0.8.20",
...@@ -29836,9 +29837,9 @@ checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" ...@@ -29836,9 +29837,9 @@ checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a"
   
[[package]] [[package]]
name = "target-triple" name = "target-triple"
version = "0.1.3" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42a4d50cdb458045afc8131fd91b64904da29548bcb63c7236e0844936c13078" checksum = "1ac9aa371f599d22256307c24a9d748c041e548cbf599f35d890f9d365361790"
   
[[package]] [[package]]
name = "tempfile" name = "tempfile"
......
...@@ -16,6 +16,7 @@ path = "src/lib.rs" ...@@ -16,6 +16,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
async-trait = { workspace = true } async-trait = { workspace = true }
chain-spec-builder = { workspace = true }
clap = { features = ["derive"], workspace = true } clap = { features = ["derive"], workspace = true }
codec = { workspace = true, default-features = true } codec = { workspace = true, default-features = true }
color-print = { workspace = true } color-print = { workspace = true }
......
...@@ -23,6 +23,7 @@ use crate::{ ...@@ -23,6 +23,7 @@ use crate::{
NodeExtraArgs, NodeExtraArgs,
}, },
}; };
use chain_spec_builder::ChainSpecBuilder;
use clap::{Command, CommandFactory, FromArgMatches}; use clap::{Command, CommandFactory, FromArgMatches};
use sc_chain_spec::ChainSpec; use sc_chain_spec::ChainSpec;
use sc_cli::{ use sc_cli::{
...@@ -31,7 +32,6 @@ use sc_cli::{ ...@@ -31,7 +32,6 @@ use sc_cli::{
}; };
use sc_service::{config::PrometheusConfig, BasePath}; use sc_service::{config::PrometheusConfig, BasePath};
use std::{fmt::Debug, marker::PhantomData, path::PathBuf}; use std::{fmt::Debug, marker::PhantomData, path::PathBuf};
/// Trait that can be used to customize some of the customer-facing info related to the node binary /// Trait that can be used to customize some of the customer-facing info related to the node binary
/// that is being built using this library. /// that is being built using this library.
/// ///
...@@ -89,9 +89,16 @@ pub enum Subcommand { ...@@ -89,9 +89,16 @@ pub enum Subcommand {
/// Revert the chain to a previous state. /// Revert the chain to a previous state.
Revert(sc_cli::RevertCmd), Revert(sc_cli::RevertCmd),
/// Subcommand for generating and managing chain specifications.
///
/// Unlike `build-spec`, which generates a chain specification based on existing
/// configurations, `chain-spec-builder` provides a more interactive and customizable approach
/// to defining a chain spec. It allows users to create specifications with additional
/// parameters and validation steps before finalizing the output.
ChainSpecBuilder(ChainSpecBuilder),
/// Remove the whole chain. /// Remove the whole chain.
PurgeChain(cumulus_client_cli::PurgeChainCmd), PurgeChain(cumulus_client_cli::PurgeChainCmd),
/// Export the genesis state of the parachain. /// Export the genesis state of the parachain.
#[command(alias = "export-genesis-state")] #[command(alias = "export-genesis-state")]
ExportGenesisHead(cumulus_client_cli::ExportGenesisHeadCommand), ExportGenesisHead(cumulus_client_cli::ExportGenesisHeadCommand),
......
...@@ -148,6 +148,9 @@ pub fn run<CliConfig: crate::cli::CliConfig>(cmd_config: RunConfig) -> Result<() ...@@ -148,6 +148,9 @@ pub fn run<CliConfig: crate::cli::CliConfig>(cmd_config: RunConfig) -> Result<()
node.prepare_revert_cmd(config, cmd) node.prepare_revert_cmd(config, cmd)
}) })
}, },
Some(Subcommand::ChainSpecBuilder(cmd)) =>
cmd.run().map_err(|err| sc_cli::Error::Application(err.into())),
Some(Subcommand::PurgeChain(cmd)) => { Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?; let runner = cli.create_runner(cmd)?;
let polkadot_cli = let polkadot_cli =
......
title: 'Add chain-spec-builder as a subcommand to the polkadot-omni-node'
doc:
- audience: Runtime Dev
description: |-
This PR add chain-spec-builder as a subcommand to the polkadot-omni-node
crates:
- name: polkadot-omni-node-lib
bump: major
- name: staging-chain-spec-builder
bump: patch
...@@ -224,10 +224,10 @@ type ChainSpec = GenericChainSpec<()>; ...@@ -224,10 +224,10 @@ type ChainSpec = GenericChainSpec<()>;
impl ChainSpecBuilder { impl ChainSpecBuilder {
/// Executes the internal command. /// Executes the internal command.
pub fn run(self) -> Result<(), String> { pub fn run(&self) -> Result<(), String> {
let chain_spec_path = self.chain_spec_path.to_path_buf(); let chain_spec_path = self.chain_spec_path.to_path_buf();
match self.command { match &self.command {
ChainSpecBuilderCmd::Create(cmd) => { ChainSpecBuilderCmd::Create(cmd) => {
let chain_spec_json = generate_chain_spec_for_runtime(&cmd)?; let chain_spec_json = generate_chain_spec_for_runtime(&cmd)?;
fs::write(chain_spec_path, chain_spec_json).map_err(|err| err.to_string())?; fs::write(chain_spec_path, chain_spec_json).map_err(|err| err.to_string())?;
...@@ -259,7 +259,7 @@ impl ChainSpecBuilder { ...@@ -259,7 +259,7 @@ impl ChainSpecBuilder {
&mut chain_spec_json, &mut chain_spec_json,
&fs::read(runtime.as_path()) &fs::read(runtime.as_path())
.map_err(|e| format!("Wasm blob file could not be read: {e}"))?[..], .map_err(|e| format!("Wasm blob file could not be read: {e}"))?[..],
block_height, *block_height,
); );
let chain_spec_json = serde_json::to_string_pretty(&chain_spec_json) let chain_spec_json = serde_json::to_string_pretty(&chain_spec_json)
.map_err(|e| format!("to pretty failed: {e}"))?; .map_err(|e| format!("to pretty failed: {e}"))?;
......
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