Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit bce077b

Browse files
authored
minor updates to the substrate doc crate (#14614)
1 parent 0cbea58 commit bce077b

File tree

4 files changed

+61
-7
lines changed

4 files changed

+61
-7
lines changed

bin/utils/chain-spec-builder/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@
2020
//!
2121
//! A chain-spec is short for `chain-configuration`. See the [`sc-chain-spec`] for more information.
2222
//!
23+
//! Note that this binary is analogous to the `build-spec` subcommand, contained in typical
24+
//! substrate-based nodes. This particular binary is capable of building a more sophisticated chain
25+
//! specification that can be used with the substrate-node, ie. [`node-cli`].
26+
//!
2327
//! See [`ChainSpecBuilder`] for a list of available commands.
28+
//!
29+
//! [`sc-chain-spec`]: ../sc_chain_spec/index.html
30+
//! [`node-cli`]: ../node_cli/index.html
2431
2532
use std::path::{Path, PathBuf};
2633

client/chain-spec/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,19 @@
116116
//! ```json
117117
//! // The human readable name of the chain.
118118
//! "name": "Flaming Fir",
119+
//!
119120
//! // The id of the chain.
120121
//! "id": "flamingfir9",
122+
//!
121123
//! // The chain type of this chain.
122124
//! // Possible values are `Live`, `Development`, `Local`.
123125
//! "chainType": "Live",
126+
//!
124127
//! // A list of multi addresses that belong to boot nodes of the chain.
125128
//! "bootNodes": [
126129
//! "/dns/0.flamingfir.paritytech.net/tcp/30333/p2p/12D3KooWLK2gMLhWsYJzjW3q35zAs9FDDVqfqVfVuskiGZGRSMvR",
127130
//! ],
131+
//!
128132
//! // Optional list of "multi address, verbosity" of telemetry endpoints.
129133
//! // The verbosity goes from `0` to `9`. With `0` being the mode with the lowest verbosity.
130134
//! "telemetryEndpoints": [
@@ -133,19 +137,24 @@
133137
//! 0
134138
//! ]
135139
//! ],
140+
//!
136141
//! // Optional networking protocol id that identifies the chain.
137142
//! "protocolId": "fir9",
143+
//!
138144
//! // Optional fork id. Should most likely be left empty.
139145
//! // Can be used to signal a fork on the network level when two chains have the
140146
//! // same genesis hash.
141147
//! "forkId": "random_fork",
148+
//!
142149
//! // Custom properties.
143150
//! "properties": {
144151
//! "tokenDecimals": 15,
145152
//! "tokenSymbol": "FIR"
146153
//! },
154+
//!
147155
//! // Deprecated field. Should be ignored.
148156
//! "consensusEngine": null,
157+
//!
149158
//! // The genesis declaration of the chain.
150159
//! //
151160
//! // `runtime`, `raw`, `stateRootHash` denote the type of the genesis declaration.
@@ -159,6 +168,7 @@
159168
//! // type depends on the hash used by the chain.
160169
//! //
161170
//! "genesis": { "runtime": {} },
171+
//!
162172
//! /// Optional map of `block_number` to `wasm_code`.
163173
//! ///
164174
//! /// The given `wasm_code` will be used to substitute the on-chain wasm code starting with the
@@ -172,6 +182,8 @@
172182
//! "codeSubstitutes": [],
173183
//! ```
174184
//!
185+
//! See [`ChainSpec`] for a trait representation of the above.
186+
//!
175187
//! The chain spec can be extended with other fields that are opaque to the default chain spec.
176188
//! Specific node implementations will need to be able to deserialize these extensions.
177189

scripts/ci/gitlab/pipeline/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ build-rustdoc:
153153
- .test-refs
154154
variables:
155155
SKIP_WASM_BUILD: 1
156-
DOC_INDEX_PAGE: "sc_service/index.html" # default redirected page
156+
DOC_INDEX_PAGE: "substrate/index.html" # default redirected page
157157
# this variable gets overriden by "rusty-cachier environment inject", use the value as default
158158
CARGO_TARGET_DIR: "$CI_PROJECT_DIR/target"
159159
artifacts:

src/lib.rs

+41-6
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,51 @@
105105
//! * `pallet-*` and `frame-*` crates, located under `./frame` folder. These are the crates related
106106
//! to FRAME. See [`frame_support`] for more information.
107107
//!
108+
//! ### Wasm Build
109+
//!
110+
//! Many of the Substrate crates, such as entire `sp-*`, need to compile to both Wasm (when a Wasm
111+
//! runtime is being generated) and native (for example, when testing). To achieve this, Substrate
112+
//! follows the convention of the Rust community, and uses a `feature = "std"` to signify that a
113+
//! crate is being built with the standard library, and is built for native. Otherwise, it is built
114+
//! for `no_std`.
115+
//!
116+
//! This can be summarized in `#![cfg_attr(not(feature = "std"), no_std)]`, which you can often find
117+
//! in any Substrate-based runtime.
118+
//!
119+
//! Substrate-based runtimes use [`substrate-wasm-builder`] in their `build.rs` to automatically
120+
//! build their Wasm files as a part of normal build commandsOnce built, the wasm file is placed in
121+
//! `./target/{debug|release}/wbuild/{runtime_name}.wasm`.
122+
//!
108123
//! ### Binaries
109124
//!
110125
//! Multiple binaries are shipped with substrate, the most important of which are located in the
111126
//! `./bin` folder.
112127
//!
113128
//! * [`node`] is an extensive substrate node that contains the superset of all runtime and client
114129
//! side features. The corresponding runtime, called [`kitchensink_runtime`] contains all of the
115-
//! modules that are provided with `FRAME`. This node and runtime is only used for testing.
130+
//! modules that are provided with `FRAME`. This node and runtime is only used for testing and
131+
//! demonstration.
132+
//! * [`chain-spec-builder`]: Utility to build more detailed chain-specs for the aforementioned
133+
//! node. Other projects typically contain a `build-spec` subcommand that does the same.
116134
//! * [`node-template`]: a template node that contains a minimal set of features and can act as a
117135
//! starting point of a project.
118136
//! * [`subkey`]: Substrate's key management utility.
119-
//! * [`chain-spec-builder`]: Substrate's utility to build *chain specifications*. Such
120-
//! specifications can then be used with `--chain` argument of a typical substrate node's CLI.
137+
//!
138+
//! ### Anatomy of a Binary Crate
139+
//!
140+
//! From the above, [`node`] and [`node-template`] are essentially blueprints of a substrate-based
141+
//! project, as the name of the latter is implying. Each substrate-based project typically contains
142+
//! the following:
143+
//!
144+
//! * Under `./runtime`, a `./runtime/src/lib.rs` which is the top level runtime amalgamator file.
145+
//! This file typically contains the [`frame_support::construct_runtime`] macro, which is the
146+
//! final definition of a runtime.
147+
//!
148+
//! * Under `./node`, a `main.rs`, which is the point, and a `./service.rs`, which contains all the
149+
//! client side components. Skimming this file yields an overview of the networking, database,
150+
//! consensus and similar client side components.
151+
//!
152+
//! > The above two are conventions, not rules.
121153
//!
122154
//! ## Parachain?
123155
//!
@@ -132,7 +164,7 @@
132164
//!
133165
//! Additional noteworthy crates within substrate:
134166
//!
135-
//! - RPC APIs of a Substrate node: [`sc-rpc-api`]
167+
//! - RPC APIs of a Substrate node: [`sc-rpc-api`]/[`sc-rpc`]
136168
//! - CLI Options of a Substrate node: [`sc-cli`]
137169
//! - All of the consensus related crates provided by Substrate:
138170
//! - [`sc-consensus-aura`]
@@ -151,6 +183,7 @@
151183
//!
152184
//! Notable upstream crates:
153185
//!
186+
//! - [`parity-scale-codec`](https://github.com/paritytech/parity-scale-codec)
154187
//! - [`parity-db`](https://github.com/paritytech/parity-db)
155188
//! - [`trie`](https://github.com/paritytech/trie)
156189
//! - [`parity-common`](https://github.com/paritytech/parity-common)
@@ -172,6 +205,7 @@
172205
//! [`sc-client-db`]: ../sc_client_db/index.html
173206
//! [`sc-network`]: ../sc_network/index.html
174207
//! [`sc-rpc-api`]: ../sc_rpc_api/index.html
208+
//! [`sc-rpc`]: ../sc_rpc/index.html
175209
//! [`sc-cli`]: ../sc_cli/index.html
176210
//! [`sc-consensus-aura`]: ../sc_consensus_aura/index.html
177211
//! [`sc-consensus-babe`]: ../sc_consensus_babe/index.html
@@ -182,8 +216,9 @@
182216
//! [`node`]: ../node_cli/index.html
183217
//! [`node-template`]: ../node_template/index.html
184218
//! [`kitchensink_runtime`]: ../kitchensink_runtime/index.html
185-
//! [`subkey`]: ..//subkey/index.html
186-
//! [`chian-spec-builder`]: ../chain_spec_builder/index.html
219+
//! [`subkey`]: ../subkey/index.html
220+
//! [`chain-spec-builder`]: ../chain_spec_builder/index.html
221+
//! [`substrate-wasm-builder`]: https://crates.io/crates/substrate-wasm-builder
187222
188223
#![deny(rustdoc::broken_intra_doc_links)]
189224
#![deny(rustdoc::private_intra_doc_links)]

0 commit comments

Comments
 (0)