Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecated type 'GenesisConfig' #3378

Merged
merged 26 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cfad225
remove deprecated type 'GenesisConfig'
RomarQ Feb 18, 2024
57b6407
doc: add prdoc
RomarQ Feb 18, 2024
fbb8814
Merge branch 'master' into rq/remove-genesis-config
RomarQ Feb 18, 2024
ea02381
Merge branch 'master' into rq/remove-genesis-config
RomarQ Feb 19, 2024
90bea09
test: update ui test result
RomarQ Feb 19, 2024
9b24930
doc: update prdoc
RomarQ Feb 19, 2024
82a3d4c
doc: fix crate field in prdoc
RomarQ Feb 19, 2024
74c4626
Revert "test: update ui test result"
RomarQ Feb 19, 2024
985b372
Merge branch 'master' into rq/remove-genesis-config
liamaharon Feb 20, 2024
be39b9c
Merge branch 'master' into rq/remove-genesis-config
RomarQ Feb 21, 2024
0f6e543
Merge branch 'master' into rq/remove-genesis-config
RomarQ Feb 25, 2024
43d8b26
fix frame-ui test artifact
RomarQ Feb 25, 2024
c4b775e
Merge branch 'master' into rq/remove-genesis-config
RomarQ Feb 26, 2024
a85059c
Merge branch 'master' into rq/remove-genesis-config
RomarQ Feb 26, 2024
eb6d1a3
Merge branch 'master' into rq/remove-genesis-config
RomarQ Feb 27, 2024
7a174ce
Merge branch 'master' into rq/remove-genesis-config
RomarQ Feb 28, 2024
a723b5f
Merge branch 'master' into rq/remove-genesis-config
RomarQ Mar 1, 2024
04c82ad
Merge branch 'master' into rq/remove-genesis-config
RomarQ Mar 3, 2024
f0d06bf
raname GenesisConfig in doc comments
RomarQ Mar 4, 2024
7ce804f
Update substrate/client/chain-spec/src/genesis_config_builder.rs
RomarQ Mar 4, 2024
ed0ff00
Update substrate/client/chain-spec/src/genesis_config_builder.rs
RomarQ Mar 4, 2024
22ce32e
Update substrate/client/chain-spec/src/genesis_config_builder.rs
RomarQ Mar 4, 2024
c804178
Merge branch 'master' into rq/remove-genesis-config
RomarQ Mar 4, 2024
56ac266
Merge branch 'master' into rq/remove-genesis-config
RomarQ Mar 5, 2024
6b546d2
format
RomarQ Mar 5, 2024
aef705e
Merge branch 'master' into rq/remove-genesis-config
RomarQ Mar 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions prdoc/pr_3378.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Remove deprecated GenesisConfig

doc:
- audience: Runtime Dev
description: |
Removes deprecated type `GenesisConfig`, it was replaced by `RuntimeGenesisConfig` on May 24 of 2023.
The type `GenesisConfig` was deprecated on May 24 of 2023 [#14210](https://github.com/paritytech/substrate/pull/14210)
RomarQ marked this conversation as resolved.
Show resolved Hide resolved

crates:
- name: frame-support-procedural
20 changes: 10 additions & 10 deletions substrate/client/chain-spec/src/genesis_config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ where
.0
}

/// Returns the default `GenesisConfig` provided by the `runtime`.
/// Returns a json representation of the default `RuntimeGenesisConfig` provided by the `runtime`.
///
/// Calls [`GenesisBuilder::create_default_config`](sp_genesis_builder::GenesisBuilder::create_default_config) in the `runtime`.
pub fn get_default_config(&self) -> core::result::Result<Value, String> {
Expand All @@ -94,7 +94,7 @@ where
Ok(from_slice(&default_config[..]).expect("returned value is json. qed."))
}

/// Build the given `GenesisConfig` and returns the genesis state.
/// Builds `RuntimeGenesisConfig` from given json blob and returns the genesis state.
///
/// Calls [`GenesisBuilder::build_config`](sp_genesis_builder::GenesisBuilder::build_config)
/// provided by the `runtime`.
Expand All @@ -111,25 +111,25 @@ where
Ok(ext.into_storages())
}

/// Creates the genesis state by patching the default `GenesisConfig` and applying it.
/// Creates the genesis state by patching the default `RuntimeGenesisConfig`.
///
/// This function generates the `GenesisConfig` for the runtime by applying a provided JSON
/// patch. The patch modifies the default `GenesisConfig` allowing customization of the specific
/// keys. The resulting `GenesisConfig` is then deserialized from the patched JSON
/// This function generates the `RuntimeGenesisConfig` for the runtime by applying a provided JSON
/// patch. The patch modifies the default `RuntimeGenesisConfig` allowing customization of the specific
/// keys. The resulting `RuntimeGenesisConfig` is then deserialized from the patched JSON
/// representation and stored in the storage.
///
/// If the provided JSON patch is incorrect or the deserialization fails the error will be
/// returned.
///
/// The patching process modifies the default `GenesisConfig` according to the following rules:
/// The patching process modifies the default `RuntimeGenesisConfig` according to the following rules:
/// 1. Existing keys in the default configuration will be overridden by the corresponding values
/// in the patch.
/// 2. If a key exists in the patch but not in the default configuration, it will be added to
/// the resulting `GenesisConfig`.
/// the resulting `RuntimeGenesisConfig`.
/// 3. Keys in the default configuration that have null values in the patch will be removed from
/// the resulting `GenesisConfig`. This is helpful for changing enum variant value.
/// the resulting `RuntimeGenesisConfig`. This is helpful for changing enum variant value.
///
/// Please note that the patch may contain full `GenesisConfig`.
/// Please note that the patch may contain full `RuntimeGenesisConfig`.
pub fn get_storage_for_patch(&self, patch: Value) -> core::result::Result<Storage, String> {
let mut config = self.get_default_config()?;
crate::json_patch::merge(&mut config, patch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ pub fn expand_outer_config(
#fields
}

#[cfg(any(feature = "std", test))]
#[deprecated(note = "GenesisConfig is planned to be removed in December 2023. Use `RuntimeGenesisConfig` instead.")]
pub type GenesisConfig = RuntimeGenesisConfig;
Copy link
Contributor

Choose a reason for hiding this comment

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

if you see in FRAME, there are a few more deprecated items that we can already remove. You do them in a follow up if interested :) Assuming min 6mo has passed since being marked deprecated


#[cfg(any(feature = "std", test))]
impl #scrate::sp_runtime::BuildStorage for RuntimeGenesisConfig {
fn assimilate_storage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied
26 | System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
| ^^^^^^ the trait `Config` is not implemented for `Runtime`
|
note: required by a bound in `frame_system::GenesisConfig`
RomarQ marked this conversation as resolved.
Show resolved Hide resolved
note: required by a bound in `GenesisConfig`
--> $WORKSPACE/substrate/frame/system/src/lib.rs
|
| pub struct GenesisConfig<T: Config> {
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/genesis-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage = "https://substrate.io"
repository.workspace = true
description = "Substrate GenesisConfig builder API"
description = "Substrate RuntimeGenesisConfig builder API"
readme = "README.md"

[lints]
Expand Down
26 changes: 13 additions & 13 deletions substrate/primitives/genesis-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,36 @@

//! Substrate genesis config builder
//!
//! This Runtime API allows to construct `GenesisConfig`, in particular:
//! - serialize the runtime default `GenesisConfig` struct into json format,
//! - put the GenesisConfig struct into the storage. Internally this operation calls
//! This Runtime API allows to construct `RuntimeGenesisConfig`, in particular:
//! - serialize the runtime default `RuntimeGenesisConfig` struct into json format,
//! - put the RuntimeGenesisConfig struct into the storage. Internally this operation calls
//! `GenesisBuild::build` function for all runtime pallets, which is typically provided by
//! pallet's author.
//! - deserialize the `GenesisConfig` from given json blob and put `GenesisConfig` into the state
//! - deserialize the `RuntimeGenesisConfig` from given json blob and put `RuntimeGenesisConfig` into the state
//! storage. Allows to build customized configuration.
//!
//! Providing externalities with empty storage and putting `GenesisConfig` into storage allows to
//! catch and build the raw storage of `GenesisConfig` which is the foundation for genesis block.
//! Providing externalities with empty storage and putting `RuntimeGenesisConfig` into storage allows to
//! catch and build the raw storage of `RuntimeGenesisConfig` which is the foundation for genesis block.

/// The result type alias, used in build methods. `Err` contains formatted error message.
pub type Result = core::result::Result<(), sp_runtime::RuntimeString>;

sp_api::decl_runtime_apis! {
/// API to interact with GenesisConfig for the runtime
/// API to interact with RuntimeGenesisConfig for the runtime
pub trait GenesisBuilder {
/// Creates the default `GenesisConfig` and returns it as a JSON blob.
/// Creates the default `RuntimeGenesisConfig` and returns it as a JSON blob.
///
/// This function instantiates the default `GenesisConfig` struct for the runtime and serializes it into a JSON
/// blob. It returns a `Vec<u8>` containing the JSON representation of the default `GenesisConfig`.
/// This function instantiates the default `RuntimeGenesisConfig` struct for the runtime and serializes it into a JSON
/// blob. It returns a `Vec<u8>` containing the JSON representation of the default `RuntimeGenesisConfig`.
fn create_default_config() -> sp_std::vec::Vec<u8>;

/// Build `GenesisConfig` from a JSON blob not using any defaults and store it in the storage.
/// Build `RuntimeGenesisConfig` from a JSON blob not using any defaults and store it in the storage.
///
/// This function deserializes the full `GenesisConfig` from the given JSON blob and puts it into the storage.
/// This function deserializes the full `RuntimeGenesisConfig` from the given JSON blob and puts it into the storage.
/// If the provided JSON blob is incorrect or incomplete or the deserialization fails, an error is returned.
/// It is recommended to log any errors encountered during the process.
///
/// Please note that provided json blob must contain all `GenesisConfig` fields, no defaults will be used.
/// Please note that provided json blob must contain all `RuntimeGenesisConfig` fields, no defaults will be used.
fn build_config(json: sp_std::vec::Vec<u8>) -> Result;
}
}
Loading