You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/md/en/docs/build/genesis-configuration.md
+10-9Lines changed: 10 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description:
4
4
keywords:
5
5
---
6
6
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.
8
8
The hash associated with this block is the top-level parent of all blocks produced after that first block.
9
9
10
10
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
16
16
17
17
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.
18
18
To specify the storage items that you want to set an initial state for, Substrate provides two specialized FRAME attribute macros.
19
+
19
20
The macros you can use to initialize storage items as part of the genesis configuration for a chain are:
20
21
21
22
- 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
@@ -109,10 +110,10 @@ Now that you have configured the pallet to initialize a storage value in the gen
109
110
110
111
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.
111
112
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.
113
114
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:
116
117
117
118
-[System pallet](#system-pallet)
118
119
-[Aura pallet](#aura-pallet)
@@ -177,10 +178,10 @@ For example, the node template runtime builds storage items for the following pa
177
178
}
178
179
```
179
180
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:
181
182
182
183
```rust
183
-
pubstructGenesisConfig {
184
+
pubstructRuntimeGenesisConfig {
184
185
pubsystem:SystemConfig,
185
186
pubaura:AuraConfig,
186
187
pubgrandpa:GrandpaConfig,
@@ -190,7 +191,7 @@ pub struct GenesisConfig {
190
191
}
191
192
```
192
193
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.
194
195
195
196
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).
196
197
@@ -236,7 +237,7 @@ GenesisConfig {
236
237
237
238
You can also use the `genesis_build` macro to define a `GenesisConfig` attribute that is not bound to a particular storage item.
238
239
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:
0 commit comments