From 9eab6a1d679eb6a562e154c0e8cf2c7373beb7d1 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 26 Nov 2024 00:33:18 +0200 Subject: [PATCH 01/19] omni-node: --dev starts manual seal and allows --chain to be set Signed-off-by: Iulian Barbu --- cumulus/polkadot-omni-node/lib/src/cli.rs | 5 +++-- cumulus/polkadot-omni-node/lib/src/command.rs | 11 ++++++++--- substrate/client/cli/src/params/shared_params.rs | 16 ++++++---------- templates/minimal/zombienet-omni-node.toml | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/cumulus/polkadot-omni-node/lib/src/cli.rs b/cumulus/polkadot-omni-node/lib/src/cli.rs index dc59c185d909..9245f2de0ea6 100644 --- a/cumulus/polkadot-omni-node/lib/src/cli.rs +++ b/cumulus/polkadot-omni-node/lib/src/cli.rs @@ -128,8 +128,9 @@ pub struct Cli { /// /// 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, /// EXPERIMENTAL: Use slot-based collator which can handle elastic scaling. diff --git a/cumulus/polkadot-omni-node/lib/src/command.rs b/cumulus/polkadot-omni-node/lib/src/command.rs index cf283819966f..f591b48c8ce0 100644 --- a/cumulus/polkadot-omni-node/lib/src/command.rs +++ b/cumulus/polkadot-omni-node/lib/src/command.rs @@ -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 { @@ -230,10 +232,13 @@ pub fn run(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 diff --git a/substrate/client/cli/src/params/shared_params.rs b/substrate/client/cli/src/params/shared_params.rs index 465372fba17d..59d9f6050791 100644 --- a/substrate/client/cli/src/params/shared_params.rs +++ b/substrate/client/cli/src/params/shared_params.rs @@ -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. @@ -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(), } } diff --git a/templates/minimal/zombienet-omni-node.toml b/templates/minimal/zombienet-omni-node.toml index 33b0fceba68c..acd5b121c674 100644 --- a/templates/minimal/zombienet-omni-node.toml +++ b/templates/minimal/zombienet-omni-node.toml @@ -2,7 +2,7 @@ default_command = "polkadot-omni-node" chain = "dev" chain_spec_path = "" -default_args = ["--dev-block-time 3000"] +default_args = ["--dev"] [[relaychain.nodes]] name = "alice" From e321830d5f340fe460a8fecb3474f922738bfa55 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 26 Nov 2024 12:46:40 +0200 Subject: [PATCH 02/19] comments fixes Signed-off-by: Iulian Barbu --- substrate/client/cli/src/params/shared_params.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/client/cli/src/params/shared_params.rs b/substrate/client/cli/src/params/shared_params.rs index 59d9f6050791..fed2e0dd5035 100644 --- a/substrate/client/cli/src/params/shared_params.rs +++ b/substrate/client/cli/src/params/shared_params.rs @@ -33,9 +33,9 @@ pub struct SharedParams { /// Specify the development 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)`. + /// 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)] pub dev: bool, From 922285c901931b31d3ad70c0ce6fd95908fb8f7a Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 26 Nov 2024 12:47:45 +0200 Subject: [PATCH 03/19] fix comments Signed-off-by: Iulian Barbu --- substrate/client/cli/src/params/shared_params.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/client/cli/src/params/shared_params.rs b/substrate/client/cli/src/params/shared_params.rs index fed2e0dd5035..5717f567a3ac 100644 --- a/substrate/client/cli/src/params/shared_params.rs +++ b/substrate/client/cli/src/params/shared_params.rs @@ -35,7 +35,7 @@ pub struct SharedParams { /// /// 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)`. + /// and `--discover-local`). #[arg(long)] pub dev: bool, From c5838ce3289764725e2ef906d5d886ebd4c37f85 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 26 Nov 2024 13:05:38 +0200 Subject: [PATCH 04/19] add prdoc Signed-off-by: Iulian Barbu --- prdoc/pr_6646.prdoc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 prdoc/pr_6646.prdoc diff --git a/prdoc/pr_6646.prdoc b/prdoc/pr_6646.prdoc new file mode 100644 index 000000000000..a77a6af36648 --- /dev/null +++ b/prdoc/pr_6646.prdoc @@ -0,0 +1,18 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: OmniNode --dev flag starts node with manual seal + +doc: + - audience: [ Runtime Dev, Node Dev ] + description: | + `polkadot-omni-node` lib supports `--dev` flag now by allowing also to pass over a chain spec, + and starts the node with manual seal. It will seal the node at each `dev_block_time` milliseconds, + which can be set via `--dev-block-time`, and if not set will default to `3000ms`. + + +crates: + - name: sc-cli + bump: minor + - name: polkadot-omni-node-lib + bump: minor From 8b923a854f7348b84b025e18579eab4edeaea6ca Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 26 Nov 2024 13:07:41 +0200 Subject: [PATCH 05/19] fix prdoc Signed-off-by: Iulian Barbu --- prdoc/pr_6646.prdoc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/prdoc/pr_6646.prdoc b/prdoc/pr_6646.prdoc index a77a6af36648..d1833017243b 100644 --- a/prdoc/pr_6646.prdoc +++ b/prdoc/pr_6646.prdoc @@ -6,10 +6,9 @@ title: OmniNode --dev flag starts node with manual seal doc: - audience: [ Runtime Dev, Node Dev ] description: | - `polkadot-omni-node` lib supports `--dev` flag now by allowing also to pass over a chain spec, - and starts the node with manual seal. It will seal the node at each `dev_block_time` milliseconds, - which can be set via `--dev-block-time`, and if not set will default to `3000ms`. - + `polkadot-omni-node` lib supports `--dev` flag now by allowing also to pass over a chain spec, + and starts the node with manual seal. It will seal the node at each `dev_block_time` milliseconds, + which can be set via `--dev-block-time`, and if not set will default to `3000ms`. crates: - name: sc-cli From 3e96f982ac67ab969ad5863f9c305b4d82906828 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 26 Nov 2024 13:27:11 +0200 Subject: [PATCH 06/19] add docs and fix clippy Signed-off-by: Iulian Barbu --- cumulus/polkadot-omni-node/README.md | 4 ++-- cumulus/polkadot-omni-node/lib/src/command.rs | 2 +- templates/minimal/README.md | 2 +- templates/parachain/README.md | 7 +++---- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cumulus/polkadot-omni-node/README.md b/cumulus/polkadot-omni-node/README.md index d87b3b63c407..015019961c9f 100644 --- a/cumulus/polkadot-omni-node/README.md +++ b/cumulus/polkadot-omni-node/README.md @@ -49,10 +49,10 @@ chain-spec-builder create --relay-chain --para-id -r +polkadot-omni-node --dev --chain ``` ## Useful links diff --git a/cumulus/polkadot-omni-node/lib/src/command.rs b/cumulus/polkadot-omni-node/lib/src/command.rs index f591b48c8ce0..73cb54155efb 100644 --- a/cumulus/polkadot-omni-node/lib/src/command.rs +++ b/cumulus/polkadot-omni-node/lib/src/command.rs @@ -232,7 +232,7 @@ pub fn run(cmd_config: RunConfig) -> Result<() .ok_or("Could not find parachain extension in chain-spec.")?, ); - if cli.run.base.is_dev() { + 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); diff --git a/templates/minimal/README.md b/templates/minimal/README.md index cf43d71d8849..543535788ea5 100644 --- a/templates/minimal/README.md +++ b/templates/minimal/README.md @@ -110,7 +110,7 @@ chain spec. We'll use `--tmp` flag to start the node with its configurations sto temporary directory, which will be deleted at the end of the process. ```sh -polkadot-omni-node --chain --dev-block-time 3000 --tmp +polkadot-omni-node --chain --dev ``` ### Minimal Template Node diff --git a/templates/parachain/README.md b/templates/parachain/README.md index 65a6979041f2..714aba91dfc8 100644 --- a/templates/parachain/README.md +++ b/templates/parachain/README.md @@ -107,12 +107,11 @@ with the relay chain ID where this instantiation of parachain-template will conn #### Run Omni Node -Start Omni Node with the generated chain spec. We'll start it development mode (without a relay chain config), -with a temporary directory for configuration (given `--tmp`), and block production set to create a block with -every second. +Start Omni Node with the generated chain spec. We'll start it in development mode (without a relay chain config), producing +and finalizing blocks based on manual seal, configured below to seal a block with each second. ```bash -polkadot-omni-node --chain --tmp --dev-block-time 1000 +polkadot-omni-node --chain --dev --dev-block-time 1000 ``` From dbb1d1ef13951e1073403e67fd77fbb84c4b6984 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 26 Nov 2024 14:18:50 +0200 Subject: [PATCH 07/19] fix doc test Signed-off-by: Iulian Barbu --- docs/sdk/src/guides/your_first_node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sdk/src/guides/your_first_node.rs b/docs/sdk/src/guides/your_first_node.rs index da37c11c206f..992e2066a174 100644 --- a/docs/sdk/src/guides/your_first_node.rs +++ b/docs/sdk/src/guides/your_first_node.rs @@ -246,7 +246,7 @@ mod tests { let output = Command::new(omni_node) .arg("--tmp") .args(["--chain", chain_spec_file.to_str().unwrap()]) - .args(["--dev-block-time", block_time.to_string().as_str()]) + .args(["--dev", "--dev-block-time", block_time.to_string().as_str()]) .timeout(std::time::Duration::from_secs(10)) .output() .unwrap(); From 6f9e5e8d0bbf66120b266d5ca512543c494ca70e Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 26 Nov 2024 14:20:19 +0200 Subject: [PATCH 08/19] prdoc fix Signed-off-by: Iulian Barbu --- prdoc/pr_6646.prdoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/prdoc/pr_6646.prdoc b/prdoc/pr_6646.prdoc index d1833017243b..4dcda8d41bda 100644 --- a/prdoc/pr_6646.prdoc +++ b/prdoc/pr_6646.prdoc @@ -12,6 +12,8 @@ doc: crates: - name: sc-cli - bump: minor + bump: patch - name: polkadot-omni-node-lib - bump: minor + bump: patch + - name: polkadot-omni-node + bump: patch From 897ea81b9b17f1ae5a59cb448c7006c97a8162a8 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Wed, 27 Nov 2024 02:34:15 +0200 Subject: [PATCH 09/19] a few more docs Signed-off-by: Iulian Barbu --- templates/minimal/README.md | 5 ++--- templates/parachain/README.md | 11 ++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/templates/minimal/README.md b/templates/minimal/README.md index 543535788ea5..99890a7da5f2 100644 --- a/templates/minimal/README.md +++ b/templates/minimal/README.md @@ -105,9 +105,8 @@ Omni Node, nonetheless. #### Run Omni Node -Start Omni Node with manual seal (3 seconds block times), minimal template runtime based -chain spec. We'll use `--tmp` flag to start the node with its configurations stored in a -temporary directory, which will be deleted at the end of the process. +Start Omni Node in development mode (sets up block production and finalization based on manual seal, +sealing a new block every 3 seconds), with a minimal template runtime chain spec. ```sh polkadot-omni-node --chain --dev diff --git a/templates/parachain/README.md b/templates/parachain/README.md index 714aba91dfc8..91c3a90e537e 100644 --- a/templates/parachain/README.md +++ b/templates/parachain/README.md @@ -27,6 +27,7 @@ - [Connect with the Polkadot-JS Apps Front-End](#connect-with-the-polkadot-js-apps-front-end) - [Takeaways](#takeaways) +- [Runtime development](#runtime-development) - [Contributing](#contributing) - [Getting Help](#getting-help) @@ -112,7 +113,6 @@ and finalizing blocks based on manual seal, configured below to seal a block wit ```bash polkadot-omni-node --chain --dev --dev-block-time 1000 - ``` However, such a setup is not close to what would run in production, and for that we need to setup a local @@ -196,6 +196,15 @@ Development parachains: - 💰 Are preconfigured with a genesis state that includes several prefunded development accounts. - 🧑‍⚖️ Development accounts are used as validators, collators, and `sudo` accounts. +## Runtime development + +We recommend using [`chopsticks`](https://github.com/AcalaNetwork/chopsticks) when the focus is more on the runtime +development and `OmniNode` is enough as is. + +`OmniNode` can be still used for runtime development if using the `--dev` flag, while `parachain-template-node` doesn't +support it at this moment (but it can still be used to test a runtime in a full setup where it is started alongside a +relay chain network, as we do with the `zombienet.toml` file). + ## Contributing - 🔄 This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk). From f913cec4225d0e22aaeeedb3539f6038340442c8 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Wed, 27 Nov 2024 14:31:40 +0200 Subject: [PATCH 10/19] add choptsticks guide Signed-off-by: Iulian Barbu --- templates/parachain/README.md | 29 +++++++++++++++++-- .../parachain/runtime/src/configs/mod.rs | 5 ++-- templates/parachain/runtime/src/lib.rs | 3 ++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/templates/parachain/README.md b/templates/parachain/README.md index 91c3a90e537e..385b0cfd7a38 100644 --- a/templates/parachain/README.md +++ b/templates/parachain/README.md @@ -201,9 +201,34 @@ Development parachains: We recommend using [`chopsticks`](https://github.com/AcalaNetwork/chopsticks) when the focus is more on the runtime development and `OmniNode` is enough as is. +### Install chopsticks + +To use `chopsticks`, please install the latest version according to the installation [guide](https://github.com/AcalaNetwork/chopsticks?tab=readme-ov-file#install). + +### Build a raw chain spec + +Build the `parachain-template-runtime` as mentioned before in this guide and use `chain-spec-builder` +again but this time by passing `--raw-storage` flag: + +```sh +chain-spec-builder create --raw-storage --relay-chain "rococo-local" --para-id 1000 --runtime \ + target/release/wbuild/parachain-template-runtime/parachain_template_runtime.wasm named-preset development +``` + +### Start `chopsticks` with the chain spec + +We'll also need to set `--allow-unresolved-imports=true` because the `parachain-template-runtime` is not built +with the benchmarking feature, and some of the host functions required for it are missing. + +```sh +npx @acala-network/chopsticks@latest --chain-spec --allow-unresolved-imports=true +``` + +### Alternatives + `OmniNode` can be still used for runtime development if using the `--dev` flag, while `parachain-template-node` doesn't -support it at this moment (but it can still be used to test a runtime in a full setup where it is started alongside a -relay chain network, as we do with the `zombienet.toml` file). +support it at this moment. It can still be used to test a runtime in a full setup where it is started alongside a +relay chain network (see [Parachain Template node](#parachain-template-node) setup). ## Contributing diff --git a/templates/parachain/runtime/src/configs/mod.rs b/templates/parachain/runtime/src/configs/mod.rs index ba4c71c7f218..57bb8e7c1470 100644 --- a/templates/parachain/runtime/src/configs/mod.rs +++ b/templates/parachain/runtime/src/configs/mod.rs @@ -63,7 +63,8 @@ use super::{ MessageQueue, Nonce, PalletInfo, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Session, SessionKeys, System, WeightToFee, XcmpQueue, AVERAGE_ON_INITIALIZE_RATIO, EXISTENTIAL_DEPOSIT, HOURS, - MAXIMUM_BLOCK_WEIGHT, MICRO_UNIT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, VERSION, + MAXIMUM_BLOCK_WEIGHT, MICRO_UNIT, MINIMUM_PERIOD, NORMAL_DISPATCH_RATIO, SLOT_DURATION, + VERSION, }; use xcm_config::{RelayLocation, XcmOriginToTransactDispatchOrigin}; @@ -133,7 +134,7 @@ impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; type OnTimestampSet = Aura; - type MinimumPeriod = ConstU64<0>; + type MinimumPeriod = ConstU64; type WeightInfo = (); } diff --git a/templates/parachain/runtime/src/lib.rs b/templates/parachain/runtime/src/lib.rs index 43e76dba0591..d21f33d4da6b 100644 --- a/templates/parachain/runtime/src/lib.rs +++ b/templates/parachain/runtime/src/lib.rs @@ -187,6 +187,9 @@ mod block_times { // NOTE: Currently it is not possible to change the slot duration after the chain has started. // Attempting to do so will brick block production. pub const SLOT_DURATION: u64 = MILLI_SECS_PER_BLOCK; + + /// Minimum period between blocks set for the `pallet_timestamp`. + pub const MINIMUM_PERIOD: u64 = SLOT_DURATION / 2; } pub use block_times::*; From f6969094b6af59df36d0fb90c61d51609f7f58bd Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Wed, 27 Nov 2024 16:58:34 +0200 Subject: [PATCH 11/19] no need to use allow-unresolved-imports Signed-off-by: Iulian Barbu --- templates/parachain/README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/templates/parachain/README.md b/templates/parachain/README.md index 385b0cfd7a38..c1e333df9e9e 100644 --- a/templates/parachain/README.md +++ b/templates/parachain/README.md @@ -217,11 +217,8 @@ chain-spec-builder create --raw-storage --relay-chain "rococo-local" --para-id 1 ### Start `chopsticks` with the chain spec -We'll also need to set `--allow-unresolved-imports=true` because the `parachain-template-runtime` is not built -with the benchmarking feature, and some of the host functions required for it are missing. - ```sh -npx @acala-network/chopsticks@latest --chain-spec --allow-unresolved-imports=true +npx @acala-network/chopsticks@latest --chain-spec ``` ### Alternatives From 06bbd5e6c54a657dc989db2d5032764b32475ccf Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Wed, 27 Nov 2024 18:32:17 +0200 Subject: [PATCH 12/19] remake dev-block-time standalone Signed-off-by: Iulian Barbu --- cumulus/polkadot-omni-node/lib/src/cli.rs | 6 +++--- cumulus/polkadot-omni-node/lib/src/command.rs | 6 ++++++ docs/sdk/src/guides/your_first_node.rs | 2 +- templates/minimal/README.md | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cumulus/polkadot-omni-node/lib/src/cli.rs b/cumulus/polkadot-omni-node/lib/src/cli.rs index 9245f2de0ea6..4917ae1dd320 100644 --- a/cumulus/polkadot-omni-node/lib/src/cli.rs +++ b/cumulus/polkadot-omni-node/lib/src/cli.rs @@ -128,9 +128,9 @@ pub struct Cli { /// /// 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. Default to 3000ms if - /// not set when using `--dev` flag. - #[arg(long, requires = "dev")] + /// a block each `dev_block_time` ms, as if it was part of a parachain. Defaults to 3000ms if + /// not set and `--dev` is used. + #[arg(long)] pub dev_block_time: Option, /// EXPERIMENTAL: Use slot-based collator which can handle elastic scaling. diff --git a/cumulus/polkadot-omni-node/lib/src/command.rs b/cumulus/polkadot-omni-node/lib/src/command.rs index 73cb54155efb..fe7f7cac0971 100644 --- a/cumulus/polkadot-omni-node/lib/src/command.rs +++ b/cumulus/polkadot-omni-node/lib/src/command.rs @@ -241,6 +241,12 @@ pub fn run(cmd_config: RunConfig) -> Result<() .map_err(Into::into); } + if let Some(dev_block_time) = cli.dev_block_time { + return node_spec + .start_manual_seal_node(config, para_id, dev_block_time) + .map_err(Into::into); + } + // If Statemint (Statemine, Westmint, Rockmine) DB exists and we're using the // asset-hub chain spec, then rename the base path to the new chain ID. In the case // that both file paths exist, the node will exit, as the user must decide (by diff --git a/docs/sdk/src/guides/your_first_node.rs b/docs/sdk/src/guides/your_first_node.rs index 992e2066a174..da37c11c206f 100644 --- a/docs/sdk/src/guides/your_first_node.rs +++ b/docs/sdk/src/guides/your_first_node.rs @@ -246,7 +246,7 @@ mod tests { let output = Command::new(omni_node) .arg("--tmp") .args(["--chain", chain_spec_file.to_str().unwrap()]) - .args(["--dev", "--dev-block-time", block_time.to_string().as_str()]) + .args(["--dev-block-time", block_time.to_string().as_str()]) .timeout(std::time::Duration::from_secs(10)) .output() .unwrap(); diff --git a/templates/minimal/README.md b/templates/minimal/README.md index 99890a7da5f2..22f396c243ef 100644 --- a/templates/minimal/README.md +++ b/templates/minimal/README.md @@ -159,7 +159,7 @@ Then make the changes in the network specification like so: # ... chain = "dev" chain_spec_path = "" -default_args = ["--dev-block-time 3000"] +default_args = ["--dev"] # .. ``` From d6faae78623e90ec34135283bbb9cb4f590c3d37 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Thu, 28 Nov 2024 08:47:54 +0000 Subject: [PATCH 13/19] polish public docs Signed-off-by: Iulian Barbu --- cumulus/polkadot-omni-node/lib/src/cli.rs | 13 ++++++++----- substrate/client/cli/src/params/shared_params.rs | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cumulus/polkadot-omni-node/lib/src/cli.rs b/cumulus/polkadot-omni-node/lib/src/cli.rs index 4917ae1dd320..e4052025e240 100644 --- a/cumulus/polkadot-omni-node/lib/src/cli.rs +++ b/cumulus/polkadot-omni-node/lib/src/cli.rs @@ -126,11 +126,14 @@ pub struct Cli { /// Start a dev node that produces a block each `dev_block_time` ms. /// - /// 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. Defaults to 3000ms if - /// not set and `--dev` is used. - #[arg(long)] + /// This is a dev option. It enables a manual sealing, meaning blocks are produced manually + /// rather than being part of an actual network consensus process. Using the option 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. + /// + /// The `--dev` flag sets the `dev_block_time` to a default value of 3000ms unless explicitly + /// provided. #[arg(long)] pub dev_block_time: Option, /// EXPERIMENTAL: Use slot-based collator which can handle elastic scaling. diff --git a/substrate/client/cli/src/params/shared_params.rs b/substrate/client/cli/src/params/shared_params.rs index 5717f567a3ac..e0c52deb44ca 100644 --- a/substrate/client/cli/src/params/shared_params.rs +++ b/substrate/client/cli/src/params/shared_params.rs @@ -35,7 +35,9 @@ pub struct SharedParams { /// /// 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`). + /// and `--discover-local`). With this flag some nodes might start with manual seal, producing + /// blocks at certain events (e.g. `polkadot-omni-node`, which produces blocks at certain + /// intervals dictated by `--dev-block-time`). #[arg(long)] pub dev: bool, From 7210dc90581ef2ea6e02b35b9c472f07d5ad2835 Mon Sep 17 00:00:00 2001 From: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Date: Thu, 28 Nov 2024 14:26:05 +0200 Subject: [PATCH 14/19] Update cumulus/polkadot-omni-node/lib/src/cli.rs Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> --- cumulus/polkadot-omni-node/lib/src/cli.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cumulus/polkadot-omni-node/lib/src/cli.rs b/cumulus/polkadot-omni-node/lib/src/cli.rs index e4052025e240..9f44792a1c75 100644 --- a/cumulus/polkadot-omni-node/lib/src/cli.rs +++ b/cumulus/polkadot-omni-node/lib/src/cli.rs @@ -133,7 +133,8 @@ pub struct Cli { /// as if it was part of a parachain. /// /// The `--dev` flag sets the `dev_block_time` to a default value of 3000ms unless explicitly - /// provided. #[arg(long)] + /// provided. + #[arg(long)] pub dev_block_time: Option, /// EXPERIMENTAL: Use slot-based collator which can handle elastic scaling. From 1833acde8c6acef64ab9733cbf35e4ae82e30f15 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Thu, 28 Nov 2024 13:38:21 +0000 Subject: [PATCH 15/19] fix fmt Signed-off-by: Iulian Barbu --- cumulus/polkadot-omni-node/lib/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/polkadot-omni-node/lib/src/cli.rs b/cumulus/polkadot-omni-node/lib/src/cli.rs index 9f44792a1c75..9c4e2561592d 100644 --- a/cumulus/polkadot-omni-node/lib/src/cli.rs +++ b/cumulus/polkadot-omni-node/lib/src/cli.rs @@ -133,7 +133,7 @@ pub struct Cli { /// as if it was part of a parachain. /// /// The `--dev` flag sets the `dev_block_time` to a default value of 3000ms unless explicitly - /// provided. + /// provided. #[arg(long)] pub dev_block_time: Option, From 405485a41910189f8492e165d4abad2c70c614af Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Fri, 29 Nov 2024 17:14:04 +0000 Subject: [PATCH 16/19] test-stable without cache Signed-off-by: Iulian Barbu --- .github/workflows/tests-linux-stable.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests-linux-stable.yml b/.github/workflows/tests-linux-stable.yml index 3f8dc4fe1240..fcf3686f1f80 100644 --- a/.github/workflows/tests-linux-stable.yml +++ b/.github/workflows/tests-linux-stable.yml @@ -100,7 +100,7 @@ jobs: run: | # Fixes "detected dubious ownership" error in the ci git config --global --add safe.directory '*' - forklift cargo nextest run \ + cargo nextest run \ --workspace \ --locked \ --release \ @@ -111,7 +111,7 @@ jobs: # run runtime-api tests with `enable-staging-api` feature on the 1st node - name: runtime-api tests if: ${{ matrix.partition == '1/3' }} - run: forklift cargo nextest run -p sp-api-test --features enable-staging-api --cargo-quiet + run: cargo nextest run -p sp-api-test --features enable-staging-api --cargo-quiet - name: Stop all workflows if failed if: ${{ failure() && steps.required.conclusion == 'failure' && !github.event.pull_request.head.repo.fork }} uses: ./.github/actions/workflow-stopper @@ -146,7 +146,7 @@ jobs: - name: script id: required run: | - forklift cargo nextest run --workspace \ + cargo nextest run --workspace \ --locked \ --release \ --no-fail-fast \ From 5d32b1699743a52933a91b2fb3f88d64e67ff529 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Sat, 30 Nov 2024 23:32:04 +0000 Subject: [PATCH 17/19] revert MinimumPeriod Signed-off-by: Iulian Barbu --- templates/parachain/runtime/src/configs/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/parachain/runtime/src/configs/mod.rs b/templates/parachain/runtime/src/configs/mod.rs index 57bb8e7c1470..0cde069b65da 100644 --- a/templates/parachain/runtime/src/configs/mod.rs +++ b/templates/parachain/runtime/src/configs/mod.rs @@ -134,7 +134,7 @@ impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; type OnTimestampSet = Aura; - type MinimumPeriod = ConstU64; + type MinimumPeriod = ConstU64<0>; type WeightInfo = (); } From 4729516fff4e339e897a8e97a7a2ef2490ee2700 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Sun, 1 Dec 2024 00:16:39 +0000 Subject: [PATCH 18/19] fix clippy Signed-off-by: Iulian Barbu --- templates/parachain/runtime/src/configs/mod.rs | 3 +-- templates/parachain/runtime/src/lib.rs | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/templates/parachain/runtime/src/configs/mod.rs b/templates/parachain/runtime/src/configs/mod.rs index 0cde069b65da..ba4c71c7f218 100644 --- a/templates/parachain/runtime/src/configs/mod.rs +++ b/templates/parachain/runtime/src/configs/mod.rs @@ -63,8 +63,7 @@ use super::{ MessageQueue, Nonce, PalletInfo, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Session, SessionKeys, System, WeightToFee, XcmpQueue, AVERAGE_ON_INITIALIZE_RATIO, EXISTENTIAL_DEPOSIT, HOURS, - MAXIMUM_BLOCK_WEIGHT, MICRO_UNIT, MINIMUM_PERIOD, NORMAL_DISPATCH_RATIO, SLOT_DURATION, - VERSION, + MAXIMUM_BLOCK_WEIGHT, MICRO_UNIT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, VERSION, }; use xcm_config::{RelayLocation, XcmOriginToTransactDispatchOrigin}; diff --git a/templates/parachain/runtime/src/lib.rs b/templates/parachain/runtime/src/lib.rs index d21f33d4da6b..43e76dba0591 100644 --- a/templates/parachain/runtime/src/lib.rs +++ b/templates/parachain/runtime/src/lib.rs @@ -187,9 +187,6 @@ mod block_times { // NOTE: Currently it is not possible to change the slot duration after the chain has started. // Attempting to do so will brick block production. pub const SLOT_DURATION: u64 = MILLI_SECS_PER_BLOCK; - - /// Minimum period between blocks set for the `pallet_timestamp`. - pub const MINIMUM_PERIOD: u64 = SLOT_DURATION / 2; } pub use block_times::*; From 81bd3eb94d80c2c6920dcc0f2cee467b68eb126d Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Sun, 1 Dec 2024 02:07:29 +0000 Subject: [PATCH 19/19] Revert "test-stable without cache" This reverts commit 405485a41910189f8492e165d4abad2c70c614af. --- .github/workflows/tests-linux-stable.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests-linux-stable.yml b/.github/workflows/tests-linux-stable.yml index fcf3686f1f80..3f8dc4fe1240 100644 --- a/.github/workflows/tests-linux-stable.yml +++ b/.github/workflows/tests-linux-stable.yml @@ -100,7 +100,7 @@ jobs: run: | # Fixes "detected dubious ownership" error in the ci git config --global --add safe.directory '*' - cargo nextest run \ + forklift cargo nextest run \ --workspace \ --locked \ --release \ @@ -111,7 +111,7 @@ jobs: # run runtime-api tests with `enable-staging-api` feature on the 1st node - name: runtime-api tests if: ${{ matrix.partition == '1/3' }} - run: cargo nextest run -p sp-api-test --features enable-staging-api --cargo-quiet + run: forklift cargo nextest run -p sp-api-test --features enable-staging-api --cargo-quiet - name: Stop all workflows if failed if: ${{ failure() && steps.required.conclusion == 'failure' && !github.event.pull_request.head.repo.fork }} uses: ./.github/actions/workflow-stopper @@ -146,7 +146,7 @@ jobs: - name: script id: required run: | - cargo nextest run --workspace \ + forklift cargo nextest run --workspace \ --locked \ --release \ --no-fail-fast \