From e94c263734bbff75dd408b136cf36cf9afa3dea5 Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Thu, 21 Nov 2024 10:25:36 +0100 Subject: [PATCH] Remove RawGenesisConfig Not needed after new genesis builder code --- .../service-container-chain/src/chain_spec.rs | 38 ------------------- client/service-container-chain/src/cli.rs | 6 +-- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/client/service-container-chain/src/chain_spec.rs b/client/service-container-chain/src/chain_spec.rs index d6d1c3148..0497992bb 100644 --- a/client/service-container-chain/src/chain_spec.rs +++ b/client/service-container-chain/src/chain_spec.rs @@ -17,49 +17,11 @@ use { sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}, serde::{Deserialize, Serialize}, - std::collections::BTreeMap, }; /// Specialized `ChainSpec` for container chains that only allows raw genesis format. pub type RawChainSpec = sc_service::GenericChainSpec; -/// Helper type that implements the traits needed to be used as a "GenesisConfig", -/// but whose implementation panics because we only expect it to be used with raw ChainSpecs, -/// so it will never be serialized or deserialized. -/// This is because container chains must use raw chain spec files where the "genesis" -/// field only has one field: "raw". -pub struct RawGenesisConfig { - pub storage_raw: BTreeMap, Vec>, -} - -impl Serialize for RawGenesisConfig { - fn serialize(&self, _serializer: S) -> Result - where - S: serde::Serializer, - { - panic!("RawGenesisConfigDummy should never be serialized") - } -} - -impl<'de> Deserialize<'de> for RawGenesisConfig { - fn deserialize(_deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - panic!("Attempted to read a non-raw ContainerChain ChainSpec.\nHelp: add `--raw` flag to `build-spec` command to generate a raw chain spec") - } -} - -impl sp_runtime::BuildStorage for RawGenesisConfig { - fn assimilate_storage(&self, storage: &mut sp_core::storage::Storage) -> Result<(), String> { - storage - .top - .extend(self.storage_raw.iter().map(|(k, v)| (k.clone(), v.clone()))); - - Ok(()) - } -} - /// The extensions for the [`ChainSpec`]. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)] #[serde(deny_unknown_fields)] diff --git a/client/service-container-chain/src/cli.rs b/client/service-container-chain/src/cli.rs index 8aee43a15..91ba36914 100644 --- a/client/service-container-chain/src/cli.rs +++ b/client/service-container-chain/src/cli.rs @@ -15,7 +15,6 @@ // along with Tanssi. If not, see use { - crate::chain_spec::RawGenesisConfig, cumulus_client_cli::{CollatorOptions, RelayChainMode}, dc_orchestrator_chain_interface::ContainerChainGenesisData, dp_container_chain_genesis_data::json::properties_to_map, @@ -181,9 +180,6 @@ impl ContainerChainCli { relay_chain, para_id, }; - let raw_genesis_config = RawGenesisConfig { - storage_raw: storage_raw.clone(), - }; let chain_spec = crate::chain_spec::RawChainSpec::builder( // This code is not used, we override it in `set_storage` below @@ -210,7 +206,7 @@ impl ContainerChainCli { let mut chain_spec = chain_spec.build(); chain_spec.set_storage(Storage { - top: raw_genesis_config.storage_raw, + top: storage_raw, children_default: Default::default(), });