diff --git a/src/chain_spec/structs.rs b/src/chain_spec/structs.rs index 6c6e5cdca1..428778153a 100644 --- a/src/chain_spec/structs.rs +++ b/src/chain_spec/structs.rs @@ -36,20 +36,15 @@ pub(super) struct ClientSpec { #[serde(default)] pub(super) chain_type: ChainType, - /// Each key is a block hash. Values are a hex-encoded runtime code (normally found in the - /// `:code` storage key). The descendants of the block with the given hash that share the same - /// [`crate::executor::CoreVersionRef::spec_version`] as the Wasm runtime code in the value - /// should instead use that Wasm runtime code. In other words, the substitution stops when - /// the `spec_version` is modified. - /// The block with that hash uses its unmodified runtime code. Only its children can be - /// affected. + /// Mapping from a block number to a hex-encoded wasm runtime code (normally found in the + /// `:code` storage key). /// - /// This can be used in order to substitute faulty runtimes with functioning ones. - /// - /// See also . + /// The given runtime code will be used to substitute the on-chain runtime code starting with + /// the given block number until the `spec_version` + /// ([`crate::executor::CoreVersionRef::spec_version`]) on chain changes. #[serde(default)] // TODO: make use of this - pub(super) code_substitutes: HashMap, + pub(super) code_substitutes: HashMap, pub(super) boot_nodes: Vec, pub(super) telemetry_endpoints: Option>, pub(super) protocol_id: Option, @@ -143,39 +138,6 @@ impl<'a> serde::Deserialize<'a> for HexString { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub(super) struct NumberAsString(pub(super) u64); - -impl serde::Serialize for NumberAsString { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - self.0.serialize(serializer) - } -} - -impl<'a> serde::Deserialize<'a> for NumberAsString { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'a>, - { - let string = String::deserialize(deserializer)?; - - if let Some(hex) = string.strip_prefix("0x") { - // TODO: the hexadecimal format support is just a complete hack during a transition period for https://github.com/paritytech/substrate/pull/10600 ; must be removed before we actually make use of the code substitutes - let _bytes = hex::decode(&hex).map_err(serde::de::Error::custom)?; - Ok(NumberAsString(0)) - } else if let Ok(num) = string.parse() { - Ok(NumberAsString(num)) - } else { - Err(serde::de::Error::custom( - "block number is neither hexadecimal nor decimal", - )) - } - } -} - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] #[serde(deny_unknown_fields)]