Skip to content

Commit 5c1ecf9

Browse files
1996 update examples and tutorials mentioning genesisconfig (#2005)
* Update samples to reflect RuntimeGenesisConfig in the genesis-configuration.md * Update genesis-configuration.md * Update content/md/en/docs/build/genesis-configuration.md Co-authored-by: Juan <[email protected]> * Apply suggestions from code review Co-authored-by: Juan <[email protected]> * Update genesis-configuration.md * Update genesis-configuration.md * Update genesis-configuration.md --------- Co-authored-by: Juan <[email protected]>
1 parent 55e505a commit 5c1ecf9

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

content/md/en/docs/build/genesis-configuration.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description:
44
keywords:
55
---
66

7-
The first block produced by any blockchain is typically referred to as the genesis block.
7+
The first block produced by any blockchain is referred to as the genesis block.
88
The hash associated with this block is the top-level parent of all blocks produced after that first block.
99

1010
The Substrate node template provides the genesis configuration—the initial state—for a subset of pallets by default.
@@ -16,6 +16,7 @@ Instead, the storage items are defined in the pallets included in the runtime as
1616

1717
After you create storage items for the runtime, you can choose whether they should be set to some initial value as part of the genesis configuration and included in the genesis block.
1818
To specify the storage items that you want to set an initial state for, Substrate provides two specialized FRAME attribute macros.
19+
1920
The macros you can use to initialize storage items as part of the genesis configuration for a chain are:
2021

2122
- The `#[pallet::genesis_config]` macro defines the `GenesisConfig` data type and initializes storage items.
@@ -80,7 +81,7 @@ Now that you have configured the pallet to initialize a storage value in the gen
8081

8182
```rust
8283
use node_template_runtime::{
83-
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig, SystemConfig, TemplateModuleConfig, WASM_BINARY,
84+
AccountId, AuraConfig, BalancesConfig, RuntimeGenesisConfig, GrandpaConfig, Signature, SudoConfig, SystemConfig, TemplateModuleConfig, WASM_BINARY,
8485
};
8586
```
8687

@@ -109,10 +110,10 @@ Now that you have configured the pallet to initialize a storage value in the gen
109110

110111
After you use the [`#[pallet::genesis_config]`](https://paritytech.github.io/substrate/master/frame_support/attr.pallet.html#genesis-config-palletgenesis_config-optional) macro to add the `GenesisConfig` to each pallet where it's needed, you must include the `Config` trait for each pallet in the runtime to enable the runtime to initialize storage items in the genesis block.
111112

112-
All of the `GenesisConfig` types for the pallets that included in the construction of the runtime are then aggregated into a single `GenesisConfig` type for that runtime.
113+
All of the `GenesisConfig` types for the pallets that included in the construction of the runtime are then aggregated into a single `RuntimeGenesisConfig` type for that runtime.
113114

114-
The aggregated `GenesisConfig` implements the [`BuildStorage`](https://paritytech.github.io/substrate/master/sp_runtime/trait.BuildStorage.html) trait to build all of the initial storage items for the runtime.
115-
For example, the node template runtime builds storage items for the following pallets that have a `GenesisConfig` specified by default:
115+
The aggregated `RuntimeGenesisConfig` implements the [`BuildStorage`](https://paritytech.github.io/substrate/master/sp_runtime/trait.BuildStorage.html) trait to build all of the initial storage items for the runtime.
116+
For example, the node template runtime builds storage items for the following pallets that have a `RuntimeGenesisConfig` specified by default:
116117

117118
- [System pallet](#system-pallet)
118119
- [Aura pallet](#aura-pallet)
@@ -177,10 +178,10 @@ For example, the node template runtime builds storage items for the following pa
177178
}
178179
```
179180

180-
Because these pallets include the #[pallet::genesis_config] macro with a `GenesisConfig` and have the `Config` trait defined in the runtime, they are aggregated into [`node_template_runtime::GenesisConfig`](https://paritytech.github.io/substrate/master/node_template_runtime/struct.GenesisConfig.html) struct for the runtime:
181+
Because these pallets include the #[pallet::genesis_config] macro with a `GenesisConfig` and have the `Config` trait defined in the runtime, they are aggregated into [`node_template_runtime::RuntimeGenesisConfig`](https://paritytech.github.io/substrate/master/node_template_runtime/struct.RuntimeGenesisConfig.html) struct for the runtime:
181182

182183
```rust
183-
pub struct GenesisConfig {
184+
pub struct RuntimeGenesisConfig {
184185
pub system: SystemConfig,
185186
pub aura: AuraConfig,
186187
pub grandpa: GrandpaConfig,
@@ -190,7 +191,7 @@ pub struct GenesisConfig {
190191
}
191192
```
192193

193-
Ultimately, the runtime `GenesisConfig` is exposed by way of the [`ChainSpec`](https://paritytech.github.io/substrate/master/sc_chain_spec/trait.ChainSpec.html) trait.
194+
Ultimately, the `RuntimeGenesisConfig` is exposed by way of the [`ChainSpec`](https://paritytech.github.io/substrate/master/sc_chain_spec/trait.ChainSpec.html) trait.
194195

195196
For a more complete example of genesis storage configuration for Substrate, see the [chain specification that ships with the Substrate code base](https://github.com/paritytech/substrate/blob/master/bin/node/cli/src/chain_spec.rs).
196197

@@ -236,7 +237,7 @@ GenesisConfig {
236237

237238
You can also use the `genesis_build` macro to define a `GenesisConfig` attribute that is not bound to a particular storage item.
238239
This can be useful if you want to invoke a private helper function within your pallet that sets several storage items, or to invoke a function defined in some other pallets included within your pallet.
239-
For example, using an imaginary private function called `intitialize_members`, thie code might look like this:
240+
For example, using an imaginary private function called `intitialize_members`, the code might look like this:
240241

241242
In `my_pallet/src/lib.rs`:
242243

0 commit comments

Comments
 (0)