At present, the GenesisConfig is not compatible with WASM environments. My current mission is to rectify this and fully incorporate GenesisConfig functionality into the WASM runtime. This is an important step for the progression towards a non-native runtime environment.
The primary problem we’re addressing and proposed high-level plan are thoroughly detailed in this issue: `GenesisConfig` in a native runtime free world · Issue #13334 · paritytech/substrate · GitHub
This post aims to shed further light on the issue, outline our strategy, and share the progress we have made so far.
Here’s an overview of our planned modifications:
- We intend to enable serialization support in substrate primitives by introducing a
serdefeature, regardless ofstd. - We are proposing to integrate the
serdecrate (featuring Serialize/Deserialize traits) into the WASM runtime by default, without the need for a gate feature. -
GenesisConfig-related code will always be compiled for WASM, without the necessity to introduceserdeorgenesis-configfeatures into pallets (this includesDefaultimplementation forGenesisConfig). - At the runtime level, we’re suggesting a
genesis-configfeature. We expect that disabling this feature will restrict linking anyserdeorGenesisConfigrelated functionality from pallets and the runtime into the WASM blob. - To enhance interaction with
GenesisConfigfor the runtime, we’ve proposed a new runtime API calledGenesisBuilder. This API simplifies the instantiation of a defaultGenesisConfig, its serialization to a JSON blob, deserialization from a given JSON blob, and storage of theGenesisConfig.
Several pull requests have already been initiated in this regard:
-
serdesupport inprimitives: https://github.com/paritytech/substrate/pull/13027 -
GenesisBuilderAPI proposal: `GenesisBuilder` Runtime API: preliminary proposal by michalkucharczyk · Pull Request #14131 · paritytech/substrate · GitHub - Enabling
GenesisConfigin frame forno_std: frame: Enable GenesisConfig in no_std by michalkucharczyk · Pull Request #14108 · paritytech/substrate · GitHub - Activating
GenesisBuild::buildforno_std: frame: GenesisBuild::build allowed in no_std by michalkucharczyk · Pull Request #14107 · paritytech/substrate · GitHub
For a practical demonstration of the new API’s usage and implementation on runtime side, check out our draft/proof of concept here: