1

When creating a genesis config, we have the ability to add a genesis.runtimeGenesis.patch.

What is the main purpose of this patch and why would I use this rather than directly setting the runtimeGenesis?

Some docs: https://docs.rs/sp-genesis-builder/latest/sp_genesis_builder/

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.

1 Answer 1

1

The more relevant doc describing the chain spec format is here: https://paritytech.github.io/polkadot-sdk/master/sc_chain_spec/index.html#

The RuntimeGenesisConfig within a chain-spec can be provided in two formats - full json representation of RuntimeGenesisConfig struct, and patch representation applied to the default value of RuntimeGenesisConfig.

The main purpose of genesis config patch:

  • minimize the maintenance effort when RuntimeGenesisConfig is changed in future (e.g. new pallets added to runtime or pallet's genesis config changed),
  • increase readability - it only contains relevant fields,
  • allows to apply numerous changes in distinct domains (e.g. for zombienet).

Patch is intended for development/testing configurations.

(link to relevant discussion: https://github.com/paritytech/polkadot-sdk/issues/62#issuecomment-1763992444)

2
  • what happens when both a config and patch are included in the same file? Commented Aug 12, 2024 at 18:58
  • I've never tried this scenario. By intention/design they are exclusive, and deserialization shall fail at some point (github.com/paritytech/polkadot-sdk/blob/…), unless some serde directives (which were heavily used in chain-spec implementation) will prevent it. I'd suggest opening issue if that is the case. Commented Aug 13, 2024 at 15:11

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.