From 26405a9ab42155100f97b0c0457f203febc59026 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:13:31 +0100 Subject: [PATCH 01/14] using merge_preserve_keys instead of merge --- cumulus/test/service/src/chain_spec.rs | 4 ++-- substrate/bin/utils/chain-spec-builder/src/lib.rs | 2 +- substrate/client/chain-spec/src/chain_spec.rs | 8 ++++---- substrate/test-utils/runtime/src/lib.rs | 2 +- .../utils/frame/benchmarking-cli/src/overhead/command.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cumulus/test/service/src/chain_spec.rs b/cumulus/test/service/src/chain_spec.rs index 3d4e4dca5f8d..4b261baa885a 100644 --- a/cumulus/test/service/src/chain_spec.rs +++ b/cumulus/test/service/src/chain_spec.rs @@ -75,7 +75,7 @@ pub fn get_chain_spec_with_extra_endowed( if let Some(id) = id { // Merge parachain ID if given, otherwise use the one from the preset. - sc_chain_spec::json_merge( + sc_chain_spec::json_patch::merge_preserve_keys( &mut patch_json, json!({ "parachainInfo": { @@ -85,7 +85,7 @@ pub fn get_chain_spec_with_extra_endowed( ); }; - sc_chain_spec::json_merge(&mut development_preset, patch_json.into()); + sc_chain_spec::json_patch::merge_preserve_keys(&mut development_preset, patch_json.into()); ChainSpec::builder( code, diff --git a/substrate/bin/utils/chain-spec-builder/src/lib.rs b/substrate/bin/utils/chain-spec-builder/src/lib.rs index 98ff480b8ceb..069b36dd4917 100644 --- a/substrate/bin/utils/chain-spec-builder/src/lib.rs +++ b/substrate/bin/utils/chain-spec-builder/src/lib.rs @@ -420,7 +420,7 @@ pub fn generate_chain_spec_for_runtime(cmd: &CreateCmd) -> Result) -> Value { // This ensures compatibility with the inherents that we provide to successfully build a // block. if let Some(para_id) = para_id { - sc_chain_spec::json_patch::merge( + sc_chain_spec::json_patch::merge_preserve_keys( &mut input_value, json!({ "parachainInfo": { From 01e3d4f55f8aa566f72ea4ef7d683b26aa46f9dd Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:14:25 +0100 Subject: [PATCH 02/14] genesis_config_builder: actual fix --- substrate/client/chain-spec/src/genesis_config_builder.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/substrate/client/chain-spec/src/genesis_config_builder.rs b/substrate/client/chain-spec/src/genesis_config_builder.rs index 66989495d423..e6256b6c91de 100644 --- a/substrate/client/chain-spec/src/genesis_config_builder.rs +++ b/substrate/client/chain-spec/src/genesis_config_builder.rs @@ -142,16 +142,14 @@ where /// 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. + /// in the patch (also applies to `null` values). /// 2. If a key exists in the patch but not in the default configuration, it will be added to /// the resulting `RuntimeGenesisConfig`. - /// 3. Keys in the default configuration that have null values in the patch will be removed from - /// the resulting `RuntimeGenesisConfig`. This is helpful for changing enum variant value. /// /// Please note that the patch may contain full `RuntimeGenesisConfig`. pub fn get_storage_for_patch(&self, patch: Value) -> core::result::Result { let mut config = self.get_default_config()?; - crate::json_patch::merge(&mut config, patch); + crate::json_patch::merge_preserve_keys(&mut config, patch); self.get_storage_for_config(config) } From b33c024d7fcc2e701d537b9528633bf20a32b4e3 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:16:04 +0100 Subject: [PATCH 03/14] json_patch: fix --- substrate/client/chain-spec/src/json_patch.rs | 87 ++++++++++++++++--- substrate/client/chain-spec/src/lib.rs | 1 - 2 files changed, 75 insertions(+), 13 deletions(-) diff --git a/substrate/client/chain-spec/src/json_patch.rs b/substrate/client/chain-spec/src/json_patch.rs index c3930069a60d..f3a127cd79d1 100644 --- a/substrate/client/chain-spec/src/json_patch.rs +++ b/substrate/client/chain-spec/src/json_patch.rs @@ -20,6 +20,21 @@ use serde_json::Value; +/// Refer to description of `merge` function. +fn merge_impl(a: &mut Value, b: Value, allow_removal: bool) { + match (a, b) { + (Value::Object(a), Value::Object(b)) => + for (k, v) in b { + if allow_removal && v.is_null() { + a.remove(&k); + } else { + merge_impl(a.entry(k).or_insert(Value::Null), v, allow_removal); + } + }, + (a, b) => *a = b, + }; +} + /// Recursively merges two JSON objects, `a` and `b`, into a single object. /// /// If a key exists in both objects, the value from `b` will override the value from `a`. @@ -31,17 +46,22 @@ use serde_json::Value; /// * `a` - A mutable reference to the target JSON object to merge into. /// * `b` - The JSON object to merge with `a`. pub fn merge(a: &mut Value, b: Value) { - match (a, b) { - (Value::Object(a), Value::Object(b)) => - for (k, v) in b { - if v.is_null() { - a.remove(&k); - } else { - merge(a.entry(k).or_insert(Value::Null), v); - } - }, - (a, b) => *a = b, - }; + merge_impl(a, b, true); +} + +/// Recursively merges two JSON objects, `a` and `b`, into a single object. +/// +/// If a key exists in both objects, the value from `b` will override the value from `a` (also if +/// value in `b` is `null`). +/// If a key exists only in `b` and not in `a`, it will be added to `a`. +/// No keys will be removed from `a`. +/// +/// # Arguments +/// +/// * `a` - A mutable reference to the target JSON object to merge into. +/// * `b` - The JSON object to merge with `a`. +pub fn merge_preserve_keys(a: &mut Value, b: Value) { + merge_impl(a, b, false); } #[cfg(test)] @@ -186,6 +206,49 @@ mod tests { }); merge(&mut j1, j2); - assert_eq!(j1, json!({ "a": {"name":"xxx", "value":456, "enum_variant_2": 32 }})); + assert_eq!( + j1, + json!({ + "a": { + "name":"xxx", + "value":456, + "enum_variant_2": 32 + } + }) + ); + } + + #[test] + fn test6_additive_patch_does_not_remove_keys_if_null() { + let mut j1 = json!({ + "a": { + "name": "xxx", + "value": 123, + "enum_variant_1": { + "name": "yyy", + } + }, + }); + + let j2 = json!({ + "a": { + "value": 456, + "enum_variant_1": null, + "enum_variant_2": 32, + } + }); + + merge_preserve_keys(&mut j1, j2); + assert_eq!( + j1, + json!({ + "a": { + "name":"xxx", + "value":456, + "enum_variant_1": null, + "enum_variant_2": 32 + } + }) + ); } } diff --git a/substrate/client/chain-spec/src/lib.rs b/substrate/client/chain-spec/src/lib.rs index 43639ffb5aae..f26a8d0016a3 100644 --- a/substrate/client/chain-spec/src/lib.rs +++ b/substrate/client/chain-spec/src/lib.rs @@ -350,7 +350,6 @@ pub use self::{ genesis_config_builder::{ GenesisConfigBuilderRuntimeCaller, DEV_RUNTIME_PRESET, LOCAL_TESTNET_RUNTIME_PRESET, }, - json_patch::merge as json_merge, }; pub use sc_chain_spec_derive::{ChainSpecExtension, ChainSpecGroup}; From 567a0dc448942eda6343904700224b4c72d99672 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 6 Nov 2024 10:52:31 +0000 Subject: [PATCH 04/14] Update from michalkucharczyk running command 'prdoc --bump major --audience node_dev' --- prdoc/pr_6382.prdoc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 prdoc/pr_6382.prdoc diff --git a/prdoc/pr_6382.prdoc b/prdoc/pr_6382.prdoc new file mode 100644 index 000000000000..d6d6a1e31527 --- /dev/null +++ b/prdoc/pr_6382.prdoc @@ -0,0 +1,24 @@ +title: 'gensis-config: patching default `RuntimeGenesisConfig` fixed' +doc: +- audience: Node Dev + description: |- + This PR fixes issue reported in #6306. + + It adds new function `json_patch::merge_preserve_keys` which does not remove any keys from the base JSON object. + The old function `json_patch::merge` is kept, and its [functionality](https://www.rfc-editor.org/rfc/rfc7386) is not changed. + + I also removed the `json_merge` re-export in the favor of using `json_patch::merge`. + + **Notes for reviewer:** + All the usages of `json_patch::merge` across the codebase where the keys removal was not intention were changed to ` + json_patch::merge_preserve_keys`. It was done for clarity, even if it was not really neccessary as patches did contain any null values. + + + fixes: #6306 +crates: +- name: staging-chain-spec-builder + bump: major +- name: sc-chain-spec + bump: major +- name: frame-benchmarking-cli + bump: major From c5e6d2852b385e6c9c527618b75192d94c0e5af6 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:16:03 +0100 Subject: [PATCH 05/14] Revert "using merge_preserve_keys instead of merge" This reverts commit 26405a9ab42155100f97b0c0457f203febc59026. --- cumulus/test/service/src/chain_spec.rs | 4 ++-- substrate/bin/utils/chain-spec-builder/src/lib.rs | 2 +- substrate/client/chain-spec/src/chain_spec.rs | 8 ++++---- substrate/test-utils/runtime/src/lib.rs | 2 +- .../utils/frame/benchmarking-cli/src/overhead/command.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cumulus/test/service/src/chain_spec.rs b/cumulus/test/service/src/chain_spec.rs index 4b261baa885a..3d4e4dca5f8d 100644 --- a/cumulus/test/service/src/chain_spec.rs +++ b/cumulus/test/service/src/chain_spec.rs @@ -75,7 +75,7 @@ pub fn get_chain_spec_with_extra_endowed( if let Some(id) = id { // Merge parachain ID if given, otherwise use the one from the preset. - sc_chain_spec::json_patch::merge_preserve_keys( + sc_chain_spec::json_merge( &mut patch_json, json!({ "parachainInfo": { @@ -85,7 +85,7 @@ pub fn get_chain_spec_with_extra_endowed( ); }; - sc_chain_spec::json_patch::merge_preserve_keys(&mut development_preset, patch_json.into()); + sc_chain_spec::json_merge(&mut development_preset, patch_json.into()); ChainSpec::builder( code, diff --git a/substrate/bin/utils/chain-spec-builder/src/lib.rs b/substrate/bin/utils/chain-spec-builder/src/lib.rs index 069b36dd4917..98ff480b8ceb 100644 --- a/substrate/bin/utils/chain-spec-builder/src/lib.rs +++ b/substrate/bin/utils/chain-spec-builder/src/lib.rs @@ -420,7 +420,7 @@ pub fn generate_chain_spec_for_runtime(cmd: &CreateCmd) -> Result) -> Value { // This ensures compatibility with the inherents that we provide to successfully build a // block. if let Some(para_id) = para_id { - sc_chain_spec::json_patch::merge_preserve_keys( + sc_chain_spec::json_patch::merge( &mut input_value, json!({ "parachainInfo": { From 51c3eb5ce3d8d6cee5a83bfbcb387d50c7f41cfc Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:12:08 +0100 Subject: [PATCH 06/14] chain_spec: merge is the only function --- substrate/client/chain-spec/src/json_patch.rs | 74 +++---------------- 1 file changed, 9 insertions(+), 65 deletions(-) diff --git a/substrate/client/chain-spec/src/json_patch.rs b/substrate/client/chain-spec/src/json_patch.rs index f3a127cd79d1..a223792374e0 100644 --- a/substrate/client/chain-spec/src/json_patch.rs +++ b/substrate/client/chain-spec/src/json_patch.rs @@ -20,35 +20,6 @@ use serde_json::Value; -/// Refer to description of `merge` function. -fn merge_impl(a: &mut Value, b: Value, allow_removal: bool) { - match (a, b) { - (Value::Object(a), Value::Object(b)) => - for (k, v) in b { - if allow_removal && v.is_null() { - a.remove(&k); - } else { - merge_impl(a.entry(k).or_insert(Value::Null), v, allow_removal); - } - }, - (a, b) => *a = b, - }; -} - -/// Recursively merges two JSON objects, `a` and `b`, into a single object. -/// -/// If a key exists in both objects, the value from `b` will override the value from `a`. -/// If a key exists in `b` with a `null` value, it will be removed from `a`. -/// If a key exists only in `b` and not in `a`, it will be added to `a`. -/// -/// # Arguments -/// -/// * `a` - A mutable reference to the target JSON object to merge into. -/// * `b` - The JSON object to merge with `a`. -pub fn merge(a: &mut Value, b: Value) { - merge_impl(a, b, true); -} - /// Recursively merges two JSON objects, `a` and `b`, into a single object. /// /// If a key exists in both objects, the value from `b` will override the value from `a` (also if @@ -60,8 +31,14 @@ pub fn merge(a: &mut Value, b: Value) { /// /// * `a` - A mutable reference to the target JSON object to merge into. /// * `b` - The JSON object to merge with `a`. -pub fn merge_preserve_keys(a: &mut Value, b: Value) { - merge_impl(a, b, false); +pub fn merge(a: &mut Value, b: Value) { + match (a, b) { + (Value::Object(a), Value::Object(b)) => + for (k, v) in b { + merge(a.entry(k).or_insert(Value::Null), v); + }, + (a, b) => *a = b, + }; } #[cfg(test)] @@ -186,7 +163,7 @@ mod tests { } #[test] - fn test6_patch_removes_keys_if_null() { + fn test6_patch_does_not_remove_keys_if_null() { let mut j1 = json!({ "a": { "name": "xxx", @@ -206,39 +183,6 @@ mod tests { }); merge(&mut j1, j2); - assert_eq!( - j1, - json!({ - "a": { - "name":"xxx", - "value":456, - "enum_variant_2": 32 - } - }) - ); - } - - #[test] - fn test6_additive_patch_does_not_remove_keys_if_null() { - let mut j1 = json!({ - "a": { - "name": "xxx", - "value": 123, - "enum_variant_1": { - "name": "yyy", - } - }, - }); - - let j2 = json!({ - "a": { - "value": 456, - "enum_variant_1": null, - "enum_variant_2": 32, - } - }); - - merge_preserve_keys(&mut j1, j2); assert_eq!( j1, json!({ From 6f2e8b6b79663e052d94990cb503889b0de33f2b Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:12:44 +0100 Subject: [PATCH 07/14] chain_spec: merge_preserve_keys -> merge --- substrate/client/chain-spec/src/genesis_config_builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/client/chain-spec/src/genesis_config_builder.rs b/substrate/client/chain-spec/src/genesis_config_builder.rs index e6256b6c91de..5fe8f9dc053c 100644 --- a/substrate/client/chain-spec/src/genesis_config_builder.rs +++ b/substrate/client/chain-spec/src/genesis_config_builder.rs @@ -149,7 +149,7 @@ where /// Please note that the patch may contain full `RuntimeGenesisConfig`. pub fn get_storage_for_patch(&self, patch: Value) -> core::result::Result { let mut config = self.get_default_config()?; - crate::json_patch::merge_preserve_keys(&mut config, patch); + crate::json_patch::merge(&mut config, patch); self.get_storage_for_config(config) } From 98532211290352cbdca24aef56d2c4a43b90934c Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:13:28 +0100 Subject: [PATCH 08/14] chain-spec-builder: manually remove unwanted json entries --- .../bin/utils/chain-spec-builder/src/lib.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/substrate/bin/utils/chain-spec-builder/src/lib.rs b/substrate/bin/utils/chain-spec-builder/src/lib.rs index 98ff480b8ceb..c860f5b969f9 100644 --- a/substrate/bin/utils/chain-spec-builder/src/lib.rs +++ b/substrate/bin/utils/chain-spec-builder/src/lib.rs @@ -261,19 +261,23 @@ impl ChainSpecBuilder { .map_err(|e| format!("Conversion to json failed: {e}"))?; // We want to extract only raw genesis ("genesis::raw" key), and apply it as a patch - // for the original json file. However, the file also contains original plain - // genesis ("genesis::runtimeGenesis") so set it to null so the patch will erase it. + // for the original json file. genesis_json.as_object_mut().map(|map| { map.retain(|key, _| key == "genesis"); + }); + + let mut org_chain_spec_json = extract_chain_spec_json(input_chain_spec.as_path())?; + + // The original plain genesis ("genesis::runtimeGenesis") is no longer needed, so + // just remove it: + org_chain_spec_json.as_object_mut().map(|map| { map.get_mut("genesis").map(|genesis| { - genesis.as_object_mut().map(|genesis_map| { - genesis_map - .insert("runtimeGenesis".to_string(), serde_json::Value::Null); - }); + genesis + .as_object_mut() + .map(|genesis_map| genesis_map.remove("runtimeGenesis")); }); }); - let mut org_chain_spec_json = extract_chain_spec_json(input_chain_spec.as_path())?; json_patch::merge(&mut org_chain_spec_json, genesis_json); let chain_spec_json = serde_json::to_string_pretty(&org_chain_spec_json) From b9b1006c1c2f42d82e8630becfa3e808e99f3745 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:15:30 +0100 Subject: [PATCH 09/14] json_merge re-export added again --- substrate/client/chain-spec/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/substrate/client/chain-spec/src/lib.rs b/substrate/client/chain-spec/src/lib.rs index f26a8d0016a3..43639ffb5aae 100644 --- a/substrate/client/chain-spec/src/lib.rs +++ b/substrate/client/chain-spec/src/lib.rs @@ -350,6 +350,7 @@ pub use self::{ genesis_config_builder::{ GenesisConfigBuilderRuntimeCaller, DEV_RUNTIME_PRESET, LOCAL_TESTNET_RUNTIME_PRESET, }, + json_patch::merge as json_merge, }; pub use sc_chain_spec_derive::{ChainSpecExtension, ChainSpecGroup}; From edffac55f4aecc74bbaf0e7593ab22f1c10acee9 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:44:21 +0100 Subject: [PATCH 10/14] prdoc updated --- prdoc/pr_6382.prdoc | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/prdoc/pr_6382.prdoc b/prdoc/pr_6382.prdoc index d6d6a1e31527..471d5bfdc182 100644 --- a/prdoc/pr_6382.prdoc +++ b/prdoc/pr_6382.prdoc @@ -3,18 +3,8 @@ doc: - audience: Node Dev description: |- This PR fixes issue reported in #6306. + It changes the behavior of `sc_chain_spec::json_patch::merge` function which no longer removes any keys from the base JSON object. - It adds new function `json_patch::merge_preserve_keys` which does not remove any keys from the base JSON object. - The old function `json_patch::merge` is kept, and its [functionality](https://www.rfc-editor.org/rfc/rfc7386) is not changed. - - I also removed the `json_merge` re-export in the favor of using `json_patch::merge`. - - **Notes for reviewer:** - All the usages of `json_patch::merge` across the codebase where the keys removal was not intention were changed to ` - json_patch::merge_preserve_keys`. It was done for clarity, even if it was not really neccessary as patches did contain any null values. - - - fixes: #6306 crates: - name: staging-chain-spec-builder bump: major From a70d25889fd1397d008c5642927dae9f819d1314 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:54:19 +0100 Subject: [PATCH 11/14] Update prdoc/pr_6382.prdoc --- prdoc/pr_6382.prdoc | 2 -- 1 file changed, 2 deletions(-) diff --git a/prdoc/pr_6382.prdoc b/prdoc/pr_6382.prdoc index 471d5bfdc182..ac6821c1100a 100644 --- a/prdoc/pr_6382.prdoc +++ b/prdoc/pr_6382.prdoc @@ -10,5 +10,3 @@ crates: bump: major - name: sc-chain-spec bump: major -- name: frame-benchmarking-cli - bump: major From c95cfa18e9c2a38824ee08607d497556185780ae Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:02:44 +0100 Subject: [PATCH 12/14] review suggestions --- substrate/bin/utils/chain-spec-builder/src/lib.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/substrate/bin/utils/chain-spec-builder/src/lib.rs b/substrate/bin/utils/chain-spec-builder/src/lib.rs index 96b6a1397a73..eefc7315c267 100644 --- a/substrate/bin/utils/chain-spec-builder/src/lib.rs +++ b/substrate/bin/utils/chain-spec-builder/src/lib.rs @@ -270,13 +270,11 @@ impl ChainSpecBuilder { // The original plain genesis ("genesis::runtimeGenesis") is no longer needed, so // just remove it: - org_chain_spec_json.as_object_mut().map(|map| { - map.get_mut("genesis").map(|genesis| { - genesis - .as_object_mut() - .map(|genesis_map| genesis_map.remove("runtimeGenesis")); - }); - }); + org_chain_spec_json + .as_object_mut() + .and_then(|map| map.get_mut("genesis")) + .and_then(|genesis| genesis.as_object_mut()) + .and_then(|genesis| genesis.remove("runtimeGenesis")); json_patch::merge(&mut org_chain_spec_json, genesis_json); From 62a780fd77dff8ee52af52c00abdbcdaff86bca7 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:18:35 +0100 Subject: [PATCH 13/14] json again --- substrate/bin/utils/chain-spec-builder/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/substrate/bin/utils/chain-spec-builder/src/lib.rs b/substrate/bin/utils/chain-spec-builder/src/lib.rs index eefc7315c267..f347359cd096 100644 --- a/substrate/bin/utils/chain-spec-builder/src/lib.rs +++ b/substrate/bin/utils/chain-spec-builder/src/lib.rs @@ -271,10 +271,14 @@ impl ChainSpecBuilder { // The original plain genesis ("genesis::runtimeGenesis") is no longer needed, so // just remove it: org_chain_spec_json - .as_object_mut() - .and_then(|map| map.get_mut("genesis")) + .get_mut("genesis") .and_then(|genesis| genesis.as_object_mut()) .and_then(|genesis| genesis.remove("runtimeGenesis")); + // org_chain_spec_json + // .as_object_mut() + // .and_then(|map| map.get_mut("genesis")) + // .and_then(|genesis| genesis.as_object_mut()) + // .and_then(|genesis| genesis.remove("runtimeGenesis")); json_patch::merge(&mut org_chain_spec_json, genesis_json); From 1bcf2b8db4e8df85a9912a56333f58e670c17291 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:29:45 +0100 Subject: [PATCH 14/14] Update substrate/bin/utils/chain-spec-builder/src/lib.rs --- substrate/bin/utils/chain-spec-builder/src/lib.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/substrate/bin/utils/chain-spec-builder/src/lib.rs b/substrate/bin/utils/chain-spec-builder/src/lib.rs index f347359cd096..73c2868b3312 100644 --- a/substrate/bin/utils/chain-spec-builder/src/lib.rs +++ b/substrate/bin/utils/chain-spec-builder/src/lib.rs @@ -274,12 +274,6 @@ impl ChainSpecBuilder { .get_mut("genesis") .and_then(|genesis| genesis.as_object_mut()) .and_then(|genesis| genesis.remove("runtimeGenesis")); - // org_chain_spec_json - // .as_object_mut() - // .and_then(|map| map.get_mut("genesis")) - // .and_then(|genesis| genesis.as_object_mut()) - // .and_then(|genesis| genesis.remove("runtimeGenesis")); - json_patch::merge(&mut org_chain_spec_json, genesis_json); let chain_spec_json = serde_json::to_string_pretty(&org_chain_spec_json)