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
serde
feature, regardless ofstd
. - We are proposing to integrate the
serde
crate (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 introduceserde
orgenesis-config
features into pallets (this includesDefault
implementation forGenesisConfig
). - At the runtime level, we’re suggesting a
genesis-config
feature. We expect that disabling this feature will restrict linking anyserde
orGenesisConfig
related functionality from pallets and the runtime into the WASM blob. - To enhance interaction with
GenesisConfig
for 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:
-
serde
support inprimitives
: https://github.com/paritytech/substrate/pull/13027 -
GenesisBuilder
API proposal: `GenesisBuilder` Runtime API: preliminary proposal by michalkucharczyk · Pull Request #14131 · paritytech/substrate · GitHub - Enabling
GenesisConfig
in frame forno_std
: frame: Enable GenesisConfig in no_std by michalkucharczyk · Pull Request #14108 · paritytech/substrate · GitHub - Activating
GenesisBuild::build
forno_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: