diff --git a/Cargo.lock b/Cargo.lock index 125b49be7e0dc..264fc8efb0f2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18454,6 +18454,7 @@ dependencies = [ "sp-transaction-pool 26.0.0", "sp-version 29.0.0", "sp-weights 27.0.0", + "staging-chain-spec-builder", "substrate-frame-rpc-system", "substrate-prometheus-endpoint", "substrate-state-trie-migration-rpc", @@ -21234,7 +21235,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", - "rand_core 0.9.1", + "rand_core 0.9.2", "zerocopy 0.8.20", ] @@ -21255,7 +21256,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.1", + "rand_core 0.9.2", ] [[package]] @@ -21275,9 +21276,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88e0da7a2c97baa202165137c158d0a2e824ac465d13d81046727b34cb247d3" +checksum = "7a509b1a2ffbe92afab0e55c8fd99dea1c280e8171bd2d88682bb20bc41cbc2c" dependencies = [ "getrandom 0.3.1", "zerocopy 0.8.20", @@ -29836,9 +29837,9 @@ checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" [[package]] name = "target-triple" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a4d50cdb458045afc8131fd91b64904da29548bcb63c7236e0844936c13078" +checksum = "1ac9aa371f599d22256307c24a9d748c041e548cbf599f35d890f9d365361790" [[package]] name = "tempfile" diff --git a/cumulus/polkadot-omni-node/lib/Cargo.toml b/cumulus/polkadot-omni-node/lib/Cargo.toml index 020d980d3d9d6..9cc4c0c635b53 100644 --- a/cumulus/polkadot-omni-node/lib/Cargo.toml +++ b/cumulus/polkadot-omni-node/lib/Cargo.toml @@ -16,6 +16,7 @@ path = "src/lib.rs" [dependencies] async-trait = { workspace = true } +chain-spec-builder = { workspace = true } clap = { features = ["derive"], workspace = true } codec = { workspace = true, default-features = true } color-print = { workspace = true } diff --git a/cumulus/polkadot-omni-node/lib/src/cli.rs b/cumulus/polkadot-omni-node/lib/src/cli.rs index 1c47eae57738f..995a50b2e489f 100644 --- a/cumulus/polkadot-omni-node/lib/src/cli.rs +++ b/cumulus/polkadot-omni-node/lib/src/cli.rs @@ -23,6 +23,7 @@ use crate::{ NodeExtraArgs, }, }; +use chain_spec_builder::ChainSpecBuilder; use clap::{Command, CommandFactory, FromArgMatches}; use sc_chain_spec::ChainSpec; use sc_cli::{ @@ -31,7 +32,6 @@ use sc_cli::{ }; use sc_service::{config::PrometheusConfig, BasePath}; 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 /// that is being built using this library. /// @@ -89,9 +89,16 @@ pub enum Subcommand { /// Revert the chain to a previous state. 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. PurgeChain(cumulus_client_cli::PurgeChainCmd), - /// Export the genesis state of the parachain. #[command(alias = "export-genesis-state")] ExportGenesisHead(cumulus_client_cli::ExportGenesisHeadCommand), diff --git a/cumulus/polkadot-omni-node/lib/src/command.rs b/cumulus/polkadot-omni-node/lib/src/command.rs index bf0d264e8c9ca..b4d89b151bfd1 100644 --- a/cumulus/polkadot-omni-node/lib/src/command.rs +++ b/cumulus/polkadot-omni-node/lib/src/command.rs @@ -148,6 +148,9 @@ pub fn run(cmd_config: RunConfig) -> Result<() 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)) => { let runner = cli.create_runner(cmd)?; let polkadot_cli = diff --git a/prdoc/pr_7619.prdoc b/prdoc/pr_7619.prdoc new file mode 100644 index 0000000000000..29f82d9dcfd23 --- /dev/null +++ b/prdoc/pr_7619.prdoc @@ -0,0 +1,11 @@ +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 diff --git a/substrate/bin/utils/chain-spec-builder/src/lib.rs b/substrate/bin/utils/chain-spec-builder/src/lib.rs index 972958eda439e..b98eb12e215e9 100644 --- a/substrate/bin/utils/chain-spec-builder/src/lib.rs +++ b/substrate/bin/utils/chain-spec-builder/src/lib.rs @@ -224,10 +224,10 @@ type ChainSpec = GenericChainSpec<()>; impl ChainSpecBuilder { /// 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(); - match self.command { + match &self.command { ChainSpecBuilderCmd::Create(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())?; @@ -259,7 +259,7 @@ impl ChainSpecBuilder { &mut chain_spec_json, &fs::read(runtime.as_path()) .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) .map_err(|e| format!("to pretty failed: {e}"))?; diff --git a/substrate/frame/delegated-staking/src/tests.rs b/substrate/frame/delegated-staking/src/tests.rs index df4a20e42e0f1..aa7e79f59fa3b 100644 --- a/substrate/frame/delegated-staking/src/tests.rs +++ b/substrate/frame/delegated-staking/src/tests.rs @@ -1366,8 +1366,6 @@ mod pool_integration { #[test] fn stakers_cannot_join_pool() { - // A pool member is able to stake directly since staking only uses free funds but once a - // staker, they cannot join/add extra bond to the pool. They can still withdraw funds. ExtBuilder::default().build_and_execute(|| { start_era(1); // GIVEN: a pool.