Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
1446ea3
sc-chain-spec: getting ready for non-native world
michalkucharczyk Aug 28, 2023
037c5ae
polkadot: chain-specs getting ready for non-native world
michalkucharczyk Aug 28, 2023
3eb5768
cumulus: chain-specs getting ready for non-native world
michalkucharczyk Aug 28, 2023
a2d2152
Cargo.lock updated
michalkucharczyk Aug 29, 2023
8e4c7ca
Merge branch 'master' into mku-chain-spec-support-ready-for-non-native
michalkucharczyk Aug 29, 2023
b2bdc55
fixing some missed rebase-relating issues
michalkucharczyk Aug 29, 2023
8f46827
fmt
michalkucharczyk Aug 29, 2023
bf9bbaf
".git/.scripts/commands/fmt/fmt.sh"
Aug 29, 2023
21a4fa0
zepter fmt
michalkucharczyk Aug 29, 2023
141f7cc
cumulus: TestClientBuilder genesis_storage fix
michalkucharczyk Aug 29, 2023
e499a0b
polkadot: parachains::HostConfiguration fix
michalkucharczyk Aug 30, 2023
65ae3a2
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Aug 30, 2023
125de59
Cargo.lock updated
michalkucharczyk Aug 30, 2023
a247f58
gitlab: enabled fact-runtime for rococo runtime
michalkucharczyk Aug 30, 2023
3de595a
Revert "gitlab: enabled fact-runtime for rococo runtime"
michalkucharczyk Aug 31, 2023
6bfc04d
chain-spec: always output backward compatible spec (tests check)
michalkucharczyk Aug 31, 2023
fb433fb
Revert "chain-spec: always output backward compatible spec (tests che…
michalkucharczyk Sep 1, 2023
a9ab958
trying to make zombienet tests work
michalkucharczyk Sep 1, 2023
c121b80
fix
michalkucharczyk Sep 1, 2023
cb71977
zombienet test fix
michalkucharczyk Sep 1, 2023
86bacb1
zombienet dev version used
michalkucharczyk Sep 1, 2023
dcfd2f7
...
michalkucharczyk Sep 1, 2023
569cdaa
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Sep 1, 2023
72d0c5a
experimenting with chain-spec path
michalkucharczyk Sep 2, 2023
153ff6e
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Sep 2, 2023
dc458e9
chain-spec: removed optional fields from ChainSpecBuilder
michalkucharczyk Sep 4, 2023
224b0d3
__raw -> _raw
michalkucharczyk Sep 4, 2023
a784a72
code review suggestions
michalkucharczyk Sep 4, 2023
678cbfa
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Sep 4, 2023
a370177
json-patch: dependency removed, merging implemented in-place
michalkucharczyk Sep 4, 2023
76c5574
license added to new file
michalkucharczyk Sep 4, 2023
d18a393
Code review suggestions
michalkucharczyk Sep 5, 2023
88df79c
Update .gitlab-ci.yml
michalkucharczyk Sep 5, 2023
4b09014
Update substrate/client/chain-spec/src/chain_spec.rs
michalkucharczyk Sep 8, 2023
4f6157e
doc fixed
michalkucharczyk Sep 8, 2023
4694e89
Apply suggestions from code review
michalkucharczyk Sep 8, 2023
5f953e5
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Sep 8, 2023
4a23546
merge master fixes
michalkucharczyk Sep 8, 2023
bcce94e
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Sep 22, 2023
ef77c7a
Cargo.lock updated
michalkucharczyk Sep 22, 2023
21d73f5
fixes
michalkucharczyk Sep 22, 2023
7468963
more fixes
michalkucharczyk Sep 22, 2023
1459e59
fix
michalkucharczyk Sep 22, 2023
1163c53
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Sep 27, 2023
fbc2b96
merge fixes
michalkucharczyk Sep 27, 2023
55d9585
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Sep 28, 2023
992af8f
merging fix
michalkucharczyk Sep 28, 2023
d663916
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Sep 28, 2023
8018987
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Sep 29, 2023
ec400d8
Merge branch 'master' into mku-chain-spec-support-ready-for-non-native
michalkucharczyk Oct 4, 2023
3038707
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 9, 2023
e56f1bc
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 10, 2023
c038d26
Cargo.lock update
michalkucharczyk Oct 10, 2023
37a9701
test fixed
michalkucharczyk Oct 10, 2023
fb9b3d5
zombienet dev (fixing test)
michalkucharczyk Oct 11, 2023
ca85b96
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 16, 2023
6f8e125
chain-spec doc reworked
michalkucharczyk Oct 17, 2023
0687f81
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 17, 2023
a654716
Merge branch 'master' into mku-chain-spec-support-ready-for-non-native
franciscoaguirre Oct 17, 2023
6da1de6
".git/.scripts/commands/fmt/fmt.sh"
Oct 17, 2023
987a8d1
doc improvements
michalkucharczyk Oct 17, 2023
d4010cd
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 17, 2023
83a3f73
polishing doc
michalkucharczyk Oct 17, 2023
074e36a
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 17, 2023
b23e073
doc improvements
michalkucharczyk Oct 18, 2023
afa6ede
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 18, 2023
6f6596e
genesis-builder: implemented for asset-hub-rococo runtime
michalkucharczyk Oct 18, 2023
56ec31c
merging improvements
michalkucharczyk Oct 18, 2023
3ee6fc9
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 18, 2023
aee8fd8
Cargo.lock udpated
michalkucharczyk Oct 18, 2023
5a7e2c1
fix
michalkucharczyk Oct 18, 2023
b40484a
substrate-doc: added chain-spec to umbrella crate
michalkucharczyk Oct 18, 2023
3c62e17
Cargo.lock
michalkucharczyk Oct 18, 2023
7a86589
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 18, 2023
f57a227
code review - doc fixes
michalkucharczyk Oct 18, 2023
ce4a355
Merge branch 'master' into mku-chain-spec-support-ready-for-non-native
michalkucharczyk Oct 18, 2023
ddaac44
".git/.scripts/commands/fmt/fmt.sh"
Oct 18, 2023
454b9e5
Merge branch 'master' into mku-chain-spec-support-ready-for-non-native
michalkucharczyk Oct 19, 2023
271a642
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 20, 2023
8f83e65
prdoc added
michalkucharczyk Oct 20, 2023
03fe6d2
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 23, 2023
7c821ca
commented code removed
michalkucharczyk Oct 23, 2023
5754843
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 23, 2023
6473b91
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 23, 2023
b9e850d
".git/.scripts/commands/fmt/fmt.sh"
Oct 23, 2023
6a7c717
Merge branch 'master' into mku-chain-spec-support-ready-for-non-native
michalkucharczyk Oct 26, 2023
4d71564
Merge branch 'master' into mku-chain-spec-support-ready-for-non-native
michalkucharczyk Oct 27, 2023
dec047a
minimal node: genesis builder support
michalkucharczyk Oct 30, 2023
5f7781f
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 30, 2023
ea2e1f1
review suggestions for documentation
michalkucharczyk Oct 30, 2023
69f0aeb
not build <> not built
michalkucharczyk Oct 30, 2023
8564093
Update substrate/client/chain-spec/src/lib.rs
michalkucharczyk Oct 30, 2023
aedaf4f
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Oct 30, 2023
8c7d66f
".git/.scripts/commands/fmt/fmt.sh"
Oct 30, 2023
69442e3
Merge branch 'master' into mku-chain-spec-support-ready-for-non-native
michalkucharczyk Oct 30, 2023
f1ad7ba
Merge branch 'master' into mku-chain-spec-support-ready-for-non-native
michalkucharczyk Oct 31, 2023
3d8347e
Update prdoc/pr_1256.prdoc
michalkucharczyk Nov 1, 2023
ceb6b16
Update substrate/client/chain-spec/src/chain_spec.rs
michalkucharczyk Nov 1, 2023
87e60ac
Code review suggestions
michalkucharczyk Nov 1, 2023
88369c6
fix
michalkucharczyk Nov 1, 2023
fc3cef2
doc fix
michalkucharczyk Nov 1, 2023
c3b99aa
chain-spec: code field move to RuntimeGenesis
michalkucharczyk Nov 1, 2023
2702ef6
fmt
michalkucharczyk Nov 1, 2023
91bc747
fixes
michalkucharczyk Nov 1, 2023
60dae23
clippy happy happy me
michalkucharczyk Nov 1, 2023
ffc779e
doc fix
michalkucharczyk Nov 1, 2023
8d29feb
zombienet image for testing
michalkucharczyk Nov 2, 2023
14d8e04
zombienet version bumped for testing
michalkucharczyk Nov 2, 2023
54e6ba8
zombienet: path to genesis config patch corrected
michalkucharczyk Nov 2, 2023
2e2c749
fixes
michalkucharczyk Nov 2, 2023
c82e634
fix reverted
michalkucharczyk Nov 2, 2023
1ca2238
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Nov 2, 2023
ac41e78
fixes
michalkucharczyk Nov 2, 2023
f687591
".git/.scripts/commands/fmt/fmt.sh"
Nov 2, 2023
e6b9866
test + fixes
michalkucharczyk Nov 2, 2023
98a53d0
fix (me wants green ci)
michalkucharczyk Nov 2, 2023
8dc196e
fixes
michalkucharczyk Nov 3, 2023
ed7b137
fix
michalkucharczyk Nov 3, 2023
30ffe7c
cumulus-test-service: GenesisExt removed
michalkucharczyk Nov 3, 2023
253aabe
cumulus-test: chainspec
michalkucharczyk Nov 3, 2023
af239cb
some fixes
michalkucharczyk Nov 3, 2023
cbb493e
fixes
michalkucharczyk Nov 3, 2023
e94b476
genesis-builder implemented for cumulus-test-runtime
michalkucharczyk Nov 4, 2023
c41092a
Merge remote-tracking branch 'origin/master' into mku-chain-spec-supp…
michalkucharczyk Nov 4, 2023
8e85faf
test and doc for legacy
michalkucharczyk Nov 4, 2023
00ca55d
fix
michalkucharczyk Nov 4, 2023
670e837
Apply suggestions from code review
michalkucharczyk Nov 5, 2023
393ce9d
Apply suggestions from code review
michalkucharczyk Nov 5, 2023
3df6b4d
review suggestions + fixes
michalkucharczyk Nov 5, 2023
cf70573
fmt
michalkucharczyk Nov 5, 2023
1393fcb
deprecation date updated to 05.24
michalkucharczyk Nov 5, 2023
03ae1bc
prdoc: updated
michalkucharczyk Nov 5, 2023
f4d3f32
json vs legacy tests removed
michalkucharczyk Nov 5, 2023
45a03d6
zombienet image bumped
michalkucharczyk Nov 5, 2023
09862df
Merge branch 'master' into mku-chain-spec-support-ready-for-non-native
michalkucharczyk Nov 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
polishing doc
  • Loading branch information
michalkucharczyk committed Oct 17, 2023
commit 83a3f73f5b518df472338a78b60dccea2a56a8dd
118 changes: 84 additions & 34 deletions substrate/client/chain-spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@

#![allow(rustdoc::private_intra_doc_links)]

//! # Substrate chain configurations.
//! This crate includes structs and utilities for defining configuration files (known as chain
//! specification) for both runtime and node.
//!
//! The chain specification is a JSON file that describes the properties and initial state of the
//! chain.
//! # Intro: chain specification.
//!
//! In summary, though not restirced to, the main role of the chain spec is to provide a list of
//! The chain specification is a collection of information that describes the properties and an
//! initial state of a chain. Typically user interacts with the JSON representation of the chain
//! spec. Internally the chain spec is embodied by [`GenericChainSpec`] struct, specific
//! properties can be accessed using the [`ChainSpec`] trait.
//!
//! In summary, though not restirced to, the primary role of the chain spec is to provide a list of
//! well-known boot nodes for the blockchain network and the means for initializing the genesis
//! storage. This initialization is necessary for creating a genesis block upon which subsequent
//! blocks are built. When the node is launched for the first time, it reads the chain spec,
Expand Down Expand Up @@ -108,51 +111,98 @@
//! </tbody>
//! </table>
//!
//! # Initial runtime state aka genesis storage
//! # `genesis`: initial runtime state
//!
//! All nodes in the network must build subsequent blocks upon exactly the same genesis block.
//!
//! The information configured in the `genesis` section of a chain specification is used to build
//! the genesis storage, which is essential for creating the genesis block, since the block header
//! includes the storage root hash.
//!
//! The `genesis` key of the chain specification definition describes the
//! initial state of the runtime. For example it may contain:
//! - initial list of funded accounts,
//! - the sudo key,
//! - the administrative account that controls the sudo key
//! - initial authorities set for consensus, etc.
//!
//! The compiled WASM blob of the runtime code is stored in the state (and therefore on the chain).
//! As a result, the initial runtime must also be provided within the chain specification (under the
//! `code` field).
//!
//! The genesis state can be represented in the formats described by [`chain_spec::Genesis<G>`]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to do here. chain_spec::Genesis<G> is private (and I believe it should be).
But the list below just shows all the variants of this enum which is not desirable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are describing here the format of the file based on some internal structures. This is wrong. The internal structures only exist to parse the format, but they don't dictate the format.

//! enum. It includes:
//! <table>
//! <thead>
//! <tr>
//! <th>Format</th>
//! <th>Description</th>
//! </tr>
//! </thead>
//! <tbody>
//! <tr>
//! <td><code>runtime</code></td>
//! <td>A JSON object that provides an explicit and comprehensive representation of the
//! <code>RuntimeGenesisConfig</code> struct. This struct is declared by the runtime and is opaque
//! to the node.</td>
//! </tr>
//! <tr>
//! <td><code>runtimeGenesisConfig</code></td>
//! <td>An alias for the <code>runtime</code> format.</td>
//! </tr>
//! <tr>
//! <td><code>runtimeGenesisConfigPatch</code></td>
//! <td>A JSON object that offers a partial representation of the
//! <code>RuntimeGenesisConfig</code>
//! provided by the runtime. It contains a patch, which is essentially a list of keys to customize
//! in the default runtime's <code>RuntimeGenesisConfig</code>. It is opaque to the node.</td>
//! </tr>
//! <tr>
//! <td><code>raw</code></td>
//! <td>A JSON object with two fields: <code>top</code> and <code>children_default</code> Each
//! field is a map of <code>key => value</code> pairs representing entries in a genesis storage
//! trie.</td> </tr>
//! <tr>
//! <td><code>stateRootHash</code></td>
//! <td>A single hex-encoded hash representing the genesis hash. The hash type
//! depends on the hash used by the chain.</td>
//! </tr>
//! </tbody>
//! </table>
//!
//! - `runtime` - a JSON object that is an explicit and comprehensive representation of the
//! `RuntimeGenesisConfig` struct. The `RuntimeGenesisConfig` struct is declared by the runtime
//! and opaque to the node.
//! - `runtimeGenesisConfig` - an alias for `runtime`,
//! - `runtimeGenesisConfigPatch` - a JSON object that is partial representation of
//! `RuntimeGenesisConfig` provided by runtime. It contains a patch which is essentially a list of
//! keys that are to be customized in the default runtime's `RuntimeGenesisConfig`. It is opaque
//! to the node.
//! - `raw` is a JSON object with two fields `top` and `children_default`. Each of these fields is a
//! map of `key => value`. These key/value pairs represent the entries in a genesis storage trie.
//! - `stateRootHash` is a single hex encoded hash that represents the genesis hash. The hash type
//! depends on the hash used by the chain.
//!
//! For production or long living chain specification `raw` format is recommended.
//! For production or long lasting chain specification `raw` format is recommended.
//!
//! JSON examples in the [following section](#json-chain-specification-example) illustrate the `raw`
//! and `runtimeGenesisConfigPatch` genesis fields.
//!
//! # From initial state to raw genesis.
//!
//! To generate a raw genesis storage from the JSON representation of the runtime genesis config the
//! node needs to interact with the runtime.
//!
//! This interaction involves passing the runtime genesis config JSON blob to the runtime using the
//! [`sp_genesis_builder::GenesisBuilder::build_config`] function. It is a crucial step for
//! computing the storage root hash, which is a key component in determining the genesis hash.
//! [`sp_genesis_builder::GenesisBuilder::build_config`] function. During this operation runtime
//! converts the JSON representation of genesis config into [`sp_io::storage`] items. It is a
//! crucial step for computing the storage root hash, which is a key component in determining the
//! genesis hash.
//!
//! Consequently, the runtime must support the [`sp_genesis_builder::GenesisBuilder`] API to
//! utilize either [`chain_spec::Genesis<G>::RuntimeGenesisConfigPatch`] or
//! [`chain_spec::Genesis<G>::RuntimeGenesisConfig`] formats.
//! utilize either [`RuntimeGenesisConfigPatch`][patch] or [`RuntimeGenesisConfig`][full] formats.
//!
//! [patch]: chain_spec::Genesis<G>::RuntimeGenesisConfigPatch
//! [full]: chain_spec::Genesis<G>::RuntimeGenesisConfig
//!
//! This whole process is encapsulated within the implementation of the [`BuildStorage`] trait,
//! which can be accessed through the [`ChainSpec::as_storage_builder`] method.
//! This entire process is encapsulated within the implementation of the [`BuildStorage`] trait,
//! which can be accessed through the [`ChainSpec::as_storage_builder`] method. There is an
//! intermediate internal helper that facilitates this interaction,
//! [`GenesisConfigBuilderRuntimeCaller`], which serves as a straightforward wrapper for
//! [`sc_executor::WasmExecutor`].
//!
//! In case of `raw` genesis state the node does not interact with the runtime regarding the
//! computation of initial state.
//!
//! The plain and `raw` chain specification JSON blobs can be found in
//! [JSON examples](#json-chain-specification-example) section.
//!
//! # Optional code mapping
//! Optional map of `block_number` to `wasm_code`.
//!
Expand All @@ -165,24 +215,24 @@
//! there is no other way around it and only patch the problematic bug, the rest should be done
//! with a on-chain runtime upgrade.
//!
//! The [`ChainSpec`] trait represents the API to access values defined in JSON chain specification.
//!
//! # Building a chain specification.
//! The [`ChainSpecBuilder`] shall be used to create an instance of chain specification. Its API
//! allows to configure all fields of the chain spec. For details on how to generate a JSON
//! representation of chain specification refer to [`ChainSpec::as_json`].
//! allows to configure all fields of the chain spec. To generate a JSON representation of chain
//! specification, use [`ChainSpec::as_json`].
//!
//! The sample code to generate a chain spec is as follows:
#![doc = docify::embed!("src/chain_spec.rs", build_chain_spec_with_patch_works)]
//! # JSON chain specification example
//! The following are the `raw` and plain versions of the chain specification JSON files, resulting
//! from executing above example:
//! ```
//! The following are the plain and `raw` ersions of the chain specification JSON files, resulting
//! from executing of the above [example](#building-a-chain-specification):
//! ```ignore
#![doc = include_str!("../res/substrate_test_runtime_from_patch.json")]
//! ```
//! ```
//! ```ignore
#![doc = include_str!("../res/substrate_test_runtime_from_patch_raw.json")]
//! ```
//! The [`ChainSpec`] trait represents the API to access values defined in JSON chain specification.
//!
//! # Custom chain spec extensions
//! Basic chain spec type containing all required parameters is [`GenericChainSpec`]. It can be
//! extended with additional options that contain configuration specific to your chain. Usually the
Expand Down