22 releases (breaking)

0.15.1 Sep 25, 2024
0.15.0 Jul 18, 2024
0.14.0 Jun 21, 2024
0.10.0 Mar 18, 2024
0.1.0-dev.2 Jul 27, 2023

#7 in #preset

Download history 3203/week @ 2024-08-27 2360/week @ 2024-09-03 3475/week @ 2024-09-10 2952/week @ 2024-09-17 4345/week @ 2024-09-24 3956/week @ 2024-10-01 3176/week @ 2024-10-08 3902/week @ 2024-10-15 4935/week @ 2024-10-22 4160/week @ 2024-10-29 5221/week @ 2024-11-05 28625/week @ 2024-11-12 29688/week @ 2024-11-19 30524/week @ 2024-11-26 29747/week @ 2024-12-03 24857/week @ 2024-12-10

120,300 downloads per month
Used in 403 crates (38 directly)

Apache-2.0

440KB
6.5K SLoC

Substrate genesis builder.

Refer to the module doc for more details.

License: Apache-2.0

Release

Polkadot SDK stable2409


lib.rs:

Substrate genesis config builder

For FRAME based runtimes, this runtime interface provides means to interact with RuntimeGenesisConfig. Runtime provides a default RuntimeGenesisConfig structure in a form of the JSON blob.

For non-FRAME runtimes this interface is intended to build genesis state of the runtime basing on some input arbitrary bytes array. This documentation uses term RuntimeGenesisConfig, which for non-FRAME runtimes may be understood as the runtime-side entity representing initial runtime configuration. The representation of the preset is an arbitrary Vec<u8> and does not necessarily have to represent a JSON blob.

The runtime may provide a number of partial predefined RuntimeGenesisConfig configurations in the form of patches which shall be applied on top of the default RuntimeGenesisConfig. The patch is a JSON blob, which essentially comprises the list of key-value pairs that are to be customized in the default runtime genesis config. These predefined configurations are referred to as presets.

This allows the runtime to provide a number of predefined configs (e.g. for different testnets or development) without neccessity to leak the runtime types outside the itself (e.g. node or chain-spec related tools).

This Runtime API allows to interact with RuntimeGenesisConfig, in particular:

  • provide the list of available preset names,
  • provide a number of named presets of RuntimeGenesisConfig,
  • provide a JSON represention of the default RuntimeGenesisConfig (by simply serializing the default RuntimeGenesisConfig struct into JSON format),
  • deserialize the full RuntimeGenesisConfig from given JSON blob and put the resulting RuntimeGenesisConfig structure into the state storage creating the initial runtime's state. Allows to build customized genesis. This operation internally calls GenesisBuild::build function for all runtime pallets.

Providing externalities with an empty storage and putting RuntimeGenesisConfig into storage (by calling build_state) allows to construct the raw storage of RuntimeGenesisConfig which is the foundation for genesis block.

Dependencies

~16–29MB
~466K SLoC