Skip to content

Commit fc486e5

Browse files
kianenigmaiulianbarbuskunertmichalkucharczyk
authored
Polkadot OmniNode Docs (#6094)
provides low-level documentation on how the omni-node is meant to work. This is meant to act as reusable material for other teams (e.g. Papermoon and W3F) to use and integrate into the high level Polkadot documentation. Broadly speaking, for omni-node to have great rust-docs, we need to focus on the following crates, all of which got a bit of love in this PR: 1. `sp-genesis-builder` 2. `polkadot-omni-node` 3. `polkadot-omni-node-lib` 4. `frame-omni-bencher` On top of this, we have now: * `polkadot_sdk_docs::guides` contains two new steps demonstrating the most basic version of composing your pallet, putting it into a runtime, and putting that runtime into omni-node * `polkadot_sdk_docs::reference_docs::omni_node` to explain in more detail how omni-node differs from the old-school node. * `polkadot_sdk_docs::reference_docs::frame_weight_benchmarking` to finally have a minimal reference about weights and benchmarking. * It provides tests for some of the steps in #5568 closes #5568 closes #4781 Next steps - [x] Ensure the README of the parachain template is up-to-date. @iulianbarbu - [ ] Readme for `polkadot-omni-node` and similar is updated. For now, use `cargo-readme` and copy over the rust-docs. To build the branch locally and run this: https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/meta_contributing/index.html#how-to-develop-locally --------- Co-authored-by: Iulian Barbu <[email protected]> Co-authored-by: Sebastian Kunert <[email protected]> Co-authored-by: Michal Kucharczyk <[email protected]>
1 parent ed23182 commit fc486e5

File tree

38 files changed

+2071
-229
lines changed

38 files changed

+2071
-229
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ runtime/wasm/target/
4141
substrate.code-workspace
4242
target/
4343
*.scale
44+
justfile

Cargo.lock

Lines changed: 44 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ members = [
149149
"cumulus/test/service",
150150
"cumulus/xcm/xcm-emulator",
151151
"docs/sdk",
152+
"docs/sdk/packages/guides/first-pallet",
153+
"docs/sdk/packages/guides/first-runtime",
152154
"docs/sdk/src/reference_docs/chain_spec_runtime",
153155
"polkadot",
154156
"polkadot/cli",
@@ -806,6 +808,8 @@ hyper = { version = "1.3.1", default-features = false }
806808
hyper-rustls = { version = "0.24.2" }
807809
hyper-util = { version = "0.1.5", default-features = false }
808810
# TODO: remove hyper v0.14 https://github.com/paritytech/polkadot-sdk/issues/4896
811+
first-pallet = { package = "polkadot-sdk-docs-first-pallet", path = "docs/sdk/packages/guides/first-pallet", default-features = false }
812+
first-runtime = { package = "polkadot-sdk-docs-first-runtime", path = "docs/sdk/packages/guides/first-runtime", default-features = false }
809813
hyperv14 = { package = "hyper", version = "0.14.29", default-features = false }
810814
impl-serde = { version = "0.5.0", default-features = false }
811815
impl-trait-for-tuples = { version = "0.2.2" }

cumulus/polkadot-omni-node/lib/src/cli.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
1616

17+
//! CLI options of the omni-node. See [`Command`].
18+
1719
use crate::{
1820
chain_spec::DiskChainSpecLoader,
1921
common::{
@@ -103,6 +105,7 @@ pub enum Subcommand {
103105
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
104106
}
105107

108+
/// CLI Options shipped with `polkadot-omni-node`.
106109
#[derive(clap::Parser)]
107110
#[command(
108111
propagate_version = true,
@@ -113,9 +116,11 @@ pub struct Cli<Config: CliConfig> {
113116
#[arg(skip)]
114117
pub(crate) chain_spec_loader: Option<Box<dyn LoadSpec>>,
115118

119+
/// Possible subcommands. See [`Subcommand`].
116120
#[command(subcommand)]
117121
pub subcommand: Option<Subcommand>,
118122

123+
/// The shared parameters with all cumulus-based parachain nodes.
119124
#[command(flatten)]
120125
pub run: cumulus_client_cli::RunCmd,
121126

@@ -200,6 +205,7 @@ impl<Config: CliConfig> SubstrateCli for Cli<Config> {
200205
}
201206
}
202207

208+
/// The relay chain CLI flags. These are passed in after a `--` at the end.
203209
#[derive(Debug)]
204210
pub struct RelayChainCli<Config: CliConfig> {
205211
/// The actual relay chain cli object.

cumulus/polkadot-omni-node/lib/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
1616

17+
//! # Polkadot Omni Node Library
18+
//!
1719
//! Helper library that can be used to run a parachain node.
1820
//!
1921
//! ## Overview
@@ -37,11 +39,18 @@
3739
//!
3840
//! ## Examples
3941
//!
40-
//! For an example, see the `polkadot-parachain-bin` crate.
42+
//! For an example, see the [`polkadot-parachain-bin`](https://crates.io/crates/polkadot-parachain-bin) crate.
43+
//!
44+
//! ## Binary
45+
//!
46+
//! It can be used to start a parachain node from a provided chain spec file.
47+
//! It is only compatible with runtimes that use block number `u32` and `Aura` consensus.
48+
//!
49+
//! Example: `polkadot-omni-node --chain <chain_spec.json>`
4150
4251
#![deny(missing_docs)]
4352

44-
mod cli;
53+
pub mod cli;
4554
mod command;
4655
mod common;
4756
mod fake_runtime_api;

cumulus/polkadot-omni-node/lib/src/nodes/manual_seal.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use sc_network::NetworkBackend;
2828
use sc_service::{build_polkadot_syncing_strategy, Configuration, PartialComponents, TaskManager};
2929
use sc_telemetry::TelemetryHandle;
3030
use sp_runtime::traits::Header;
31-
use sp_timestamp::Timestamp;
3231
use std::{marker::PhantomData, sync::Arc};
3332

3433
pub struct ManualSealNode<NodeSpec>(PhantomData<NodeSpec>);
@@ -182,7 +181,10 @@ impl<NodeSpec: NodeSpecT> ManualSealNode<NodeSpec> {
182181
additional_key_values: None,
183182
};
184183
Ok((
185-
sp_timestamp::InherentDataProvider::new(Timestamp::new(0)),
184+
// This is intentional, as the runtime that we expect to run against this
185+
// will never receive the aura-related inherents/digests, and providing
186+
// real timestamps would cause aura <> timestamp checking to fail.
187+
sp_timestamp::InherentDataProvider::new(sp_timestamp::Timestamp::new(0)),
186188
mocked_parachain,
187189
))
188190
}

cumulus/polkadot-omni-node/src/main.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
1616

17-
//! Basic polkadot omni-node.
17+
//! White labeled polkadot omni-node.
1818
//!
19-
//! It can be used to start a parachain node from a provided chain spec file.
20-
//! It is only compatible with runtimes that use block number `u32` and `Aura` consensus.
21-
//!
22-
//! Example: `polkadot-omni-node --chain [chain_spec.json]`
19+
//! For documentation, see [`polkadot_omni_node_lib`].
2320
2421
#![warn(missing_docs)]
2522
#![warn(unused_extern_crates)]

docs/mermaid/IA.mmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ flowchart
88

99
polkadot_sdk --> substrate
1010
polkadot_sdk --> frame
11-
polkadot_sdk --> polkadot[polkadot node]
1211
polkadot_sdk --> xcm
1312
polkadot_sdk --> templates

docs/sdk/Cargo.toml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pallet-example-offchain-worker = { workspace = true, default-features = true }
2929
# How we build docs in rust-docs
3030
simple-mermaid = "0.1.1"
3131
docify = { workspace = true }
32+
serde_json = { workspace = true }
3233

3334
# Polkadot SDK deps, typically all should only be in scope such that we can link to their doc item.
3435
polkadot-sdk = { features = ["runtime-full"], workspace = true, default-features = true }
@@ -39,6 +40,7 @@ subkey = { workspace = true, default-features = true }
3940
frame-system = { workspace = true }
4041
frame-support = { workspace = true }
4142
frame-executive = { workspace = true }
43+
frame-benchmarking = { workspace = true }
4244
pallet-example-authorization-tx-extension = { workspace = true, default-features = true }
4345
pallet-example-single-block-migrations = { workspace = true, default-features = true }
4446
frame-metadata-hash-extension = { workspace = true, default-features = true }
@@ -70,6 +72,9 @@ cumulus-primitives-proof-size-hostfunction = { workspace = true, default-feature
7072
cumulus-client-service = { workspace = true, default-features = true }
7173
cumulus-primitives-storage-weight-reclaim = { workspace = true, default-features = true }
7274

75+
# Omni Node
76+
polkadot-omni-node-lib = { workspace = true, default-features = true }
77+
7378
# Pallets and FRAME internals
7479
pallet-aura = { workspace = true, default-features = true }
7580
pallet-timestamp = { workspace = true, default-features = true }
@@ -92,6 +97,7 @@ pallet-scheduler = { workspace = true, default-features = true }
9297
pallet-referenda = { workspace = true, default-features = true }
9398
pallet-broker = { workspace = true, default-features = true }
9499
pallet-babe = { workspace = true, default-features = true }
100+
pallet-grandpa = { workspace = true, default-features = true }
95101

96102
# Primitives
97103
sp-io = { workspace = true, default-features = true }
@@ -106,6 +112,7 @@ sp-arithmetic = { workspace = true, default-features = true }
106112
sp-genesis-builder = { workspace = true, default-features = true }
107113
sp-offchain = { workspace = true, default-features = true }
108114
sp-version = { workspace = true, default-features = true }
115+
sp-weights = { workspace = true, default-features = true }
109116

110117

111118
# XCM
@@ -117,9 +124,18 @@ xcm-simulator = { workspace = true }
117124
pallet-xcm = { workspace = true }
118125

119126
# runtime guides
120-
chain-spec-guide-runtime = { workspace = true }
127+
128+
chain-spec-guide-runtime = { workspace = true, default-features = true }
121129

122130
# Templates
123-
minimal-template-runtime = { workspace = true }
124-
solochain-template-runtime = { workspace = true }
125-
parachain-template-runtime = { workspace = true }
131+
minimal-template-runtime = { workspace = true, default-features = true }
132+
solochain-template-runtime = { workspace = true, default-features = true }
133+
parachain-template-runtime = { workspace = true, default-features = true }
134+
135+
# local packages
136+
first-runtime = { workspace = true, default-features = true }
137+
first-pallet = { workspace = true, default-features = true }
138+
139+
[dev-dependencies]
140+
assert_cmd = "2.0.14"
141+
rand = "0.8"

docs/sdk/assets/theme.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@
66
--polkadot-purple: #552BBF;
77
}
88

9+
/* Light theme */
10+
html[data-theme="light"] {
11+
--quote-background: #f9f9f9;
12+
--quote-border: #ccc;
13+
--quote-text: #333;
14+
}
15+
16+
/* Dark theme */
17+
html[data-theme="dark"] {
18+
--quote-background: #333;
19+
--quote-border: #555;
20+
--quote-text: #f9f9f9;
21+
}
22+
23+
/* Ayu theme */
24+
html[data-theme="ayu"] {
25+
--quote-background: #272822;
26+
--quote-border: #383830;
27+
--quote-text: #f8f8f2;
28+
}
29+
930
body.sdk-docs {
1031
nav.sidebar>div.sidebar-crate>a>img {
1132
width: 190px;
@@ -20,3 +41,17 @@ body.sdk-docs {
2041
html[data-theme="light"] .sidebar-crate > .logo-container > img {
2142
content: url("https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/docs/images/Polkadot_Logo_Horizontal_Pink_Black.png");
2243
}
44+
45+
/* Custom styles for blockquotes */
46+
blockquote {
47+
background-color: var(--quote-background);
48+
border-left: 5px solid var(--quote-border);
49+
color: var(--quote-text);
50+
margin: 1em 0;
51+
padding: 1em 1.5em;
52+
/* font-style: italic; */
53+
}
54+
55+
blockquote p {
56+
margin: 0;
57+
}

0 commit comments

Comments
 (0)