Skip to content

Commit

Permalink
omni-node: --dev starts manual seal and allows --chain to be set
Browse files Browse the repository at this point in the history
Signed-off-by: Iulian Barbu <[email protected]>
  • Loading branch information
iulianbarbu committed Nov 26, 2024
1 parent 6d5f814 commit 9eab6a1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
5 changes: 3 additions & 2 deletions cumulus/polkadot-omni-node/lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ pub struct Cli<Config: CliConfig> {
///
/// This is a dev option, and it won't result in starting or connecting to a parachain network.
/// The resulting node will work on its own, running the wasm blob and artificially producing
/// a block each `dev_block_time` ms, as if it was part of a parachain.
#[arg(long)]
/// a block each `dev_block_time` ms, as if it was part of a parachain. Default to 3000ms if
/// not set when using `--dev` flag.
#[arg(long, requires = "dev")]
pub dev_block_time: Option<u64>,

/// EXPERIMENTAL: Use slot-based collator which can handle elastic scaling.
Expand Down
11 changes: 8 additions & 3 deletions cumulus/polkadot-omni-node/lib/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ use cumulus_client_service::storage_proof_size::HostFunctions as ReclaimHostFunc
use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use log::info;
use sc_cli::{Result, SubstrateCli};
use sc_cli::{CliConfiguration, Result, SubstrateCli};
use sp_runtime::traits::AccountIdConversion;
#[cfg(feature = "runtime-benchmarks")]
use sp_runtime::traits::HashingFor;

const DEFAULT_DEV_BLOCK_TIME_MS: u64 = 3000;

/// Structure that can be used in order to provide customizers for different functionalities of the
/// node binary that is being built using this library.
pub struct RunConfig {
Expand Down Expand Up @@ -230,10 +232,13 @@ pub fn run<CliConfig: crate::cli::CliConfig>(cmd_config: RunConfig) -> Result<()
.ok_or("Could not find parachain extension in chain-spec.")?,
);

if let Some(dev_block_time) = cli.dev_block_time {
if cli.run.base.is_dev() {
// Set default dev block time to 3000ms if not set.
// TODO: take block time from AURA config if set.
let dev_block_time = cli.dev_block_time.unwrap_or(DEFAULT_DEV_BLOCK_TIME_MS);
return node_spec
.start_manual_seal_node(config, para_id, dev_block_time)
.map_err(Into::into)
.map_err(Into::into);
}

// If Statemint (Statemine, Westmint, Rockmine) DB exists and we're using the
Expand Down
16 changes: 6 additions & 10 deletions substrate/client/cli/src/params/shared_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ pub struct SharedParams {

/// Specify the development chain.
///
/// This flag sets `--chain=dev`, `--force-authoring`, `--rpc-cors=all`,
/// `--alice`, and `--tmp` flags, unless explicitly overridden.
/// It also disables local peer discovery (see --no-mdns and --discover-local)
#[arg(long, conflicts_with_all = &["chain"])]
/// This flag sets `--chain=dev` if `--chain`, `--force-authoring`, `--rpc-cors=all`,
/// `--alice`, and `--tmp` flags, unless explicitly overridden. It also disables
/// local peer discovery (see `--no-mdns` and `--discover-local)`.
#[arg(long)]
pub dev: bool,

/// Specify custom base path.
Expand Down Expand Up @@ -109,12 +109,8 @@ impl SharedParams {
pub fn chain_id(&self, is_dev: bool) -> String {
match self.chain {
Some(ref chain) => chain.clone(),
None =>
if is_dev {
"dev".into()
} else {
"".into()
},
None if is_dev => "dev".into(),
_ => "".into(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion templates/minimal/zombienet-omni-node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
default_command = "polkadot-omni-node"
chain = "dev"
chain_spec_path = "<path/to/chain_spec.json>"
default_args = ["--dev-block-time 3000"]
default_args = ["--dev"]

[[relaychain.nodes]]
name = "alice"
Expand Down

0 comments on commit 9eab6a1

Please sign in to comment.