Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

test-runtime: GenesisBuilder runtime API impl + tests #14310

Merged

Conversation

michalkucharczyk
Copy link
Contributor

@michalkucharczyk michalkucharczyk commented Jun 6, 2023

This PR provides implementation of GenesisBuilder API (proposed here: #14131) for substrate-test-runtime, can be considered as reference imiplementation for other runtimes.

The GenesisBuilder implementation is gated by gensis-builder feature.

A small crate (sc-genesis-builder) was added. Its purpose is to provide the implementation of GenesisBuilder API in the form of reusable helper.

Tested scenarios:

  • default GenesisConfig to JSON blob,
  • deserialization of GenesisConfig from custom JSON, and storing its keys into the Storage (genesis storage creation).
  • creation of genesis storage using full JSON definition (not allowing for any defaults),
  • creation of genesis storage using partial JSON definition (as discussed here) on top of default values,
  • checking if invalid/renamed keys in JSON files provides informative errors,

Step towards: paritytech/polkadot-sdk#25

This PR provides implementation of `GenesisBuilder` API for `substrate-test-runtime`, can be considered as reference imiplementation for other runtimes.
The `GenesisBuilder` implementation is gated by `gensis-config` feature.

Tested scenarios:
- default `GenesisConfig` to JSON blob,
- deserialization of `GenesisConfig` from custom JSON, and storing its keys into the Storage (genesis storage creation).
- creation of genesis storage using partial JSON definition,
- checking if invalid/renamed JSON files causes the runtime to panic,
@michalkucharczyk michalkucharczyk added B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Jun 6, 2023
@michalkucharczyk michalkucharczyk changed the title test-runtime: GenesisBuilder runtime API impl + tests test-runtime: GenesisBuilder runtime API impl + tests Jun 9, 2023
test-utils/runtime/src/test_json/readme.md Outdated Show resolved Hide resolved
test-utils/runtime/src/test_json/readme.md Outdated Show resolved Hide resolved
test-utils/runtime/src/test_json/readme.md Outdated Show resolved Hide resolved
client/genesis-builder/src/lib.rs Outdated Show resolved Hide resolved
client/genesis-builder/src/lib.rs Outdated Show resolved Hide resolved
client/genesis-builder/src/lib.rs Outdated Show resolved Hide resolved
test-utils/runtime/Cargo.toml Outdated Show resolved Hide resolved
test-utils/runtime/src/genesismap.rs Outdated Show resolved Hide resolved
test-utils/runtime/src/lib.rs Outdated Show resolved Hide resolved
@davxy davxy requested a review from a team June 19, 2023 18:04
michalkucharczyk and others added 4 commits June 19, 2023 23:10
Co-authored-by: Davide Galassi <davxy@datawok.net>
Co-authored-by: Davide Galassi <davxy@datawok.net>
Co-authored-by: Davide Galassi <davxy@datawok.net>
Co-authored-by: Davide Galassi <davxy@datawok.net>
@michalkucharczyk michalkucharczyk changed the title test-runtime: GenesisBuilder runtime API impl + tests test-runtime: GenesisBuilder runtime API impl + tests Jul 12, 2023
Copy link
Contributor

@skunert skunert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good!
I am also not sure if the genesis-builder feature is useful, but leave it up to you.

frame/support/src/genesis_builder_helper.rs Outdated Show resolved Hide resolved
@michalkucharczyk
Copy link
Contributor Author

bot rebase

@paritytech-processbot
Copy link

Rebased

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than a grumble about naming which I hope to see fixed before this is stabilized.

@michalkucharczyk
Copy link
Contributor Author

bot fmt

@command-bot
Copy link

command-bot bot commented Jul 22, 2023

@michalkucharczyk https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/3240071 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/substrate/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 2-3afdb878-f7a1-4447-9c6d-5268e6ffeec9 to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Jul 22, 2023

@michalkucharczyk Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/3240071 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/3240071/artifacts/download.

@michalkucharczyk
Copy link
Contributor Author

LGTM other than a grumble about naming which I hope to see fixed before this is stabilized.

Created issue for cleaning up naming: paritytech/polkadot-sdk#150

@michalkucharczyk
Copy link
Contributor Author

bot merge

@paritytech-processbot paritytech-processbot bot merged commit 7a762e4 into master Jul 24, 2023
45 checks passed
@paritytech-processbot paritytech-processbot bot deleted the mku-genesis-builder-implemented-for-test-runtime branch July 24, 2023 16:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants