diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index ee78c31645..737a762d88 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -6991,6 +6991,17 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sc-allocator" +version = "3.0.0" +dependencies = [ + "log", + "sp-core", + "sp-std", + "sp-wasm-interface", + "thiserror", +] + [[package]] name = "sc-authority-discovery" version = "0.9.0" @@ -7079,7 +7090,6 @@ dependencies = [ "sc-telemetry", "serde", "serde_json", - "sp-chain-spec", "sp-consensus-babe", "sp-core", "sp-runtime", @@ -7503,7 +7513,7 @@ dependencies = [ "derive_more", "parity-scale-codec", "pwasm-utils", - "sp-allocator", + "sc-allocator", "sp-core", "sp-maybe-compressed-blob", "sp-serializer", @@ -7518,8 +7528,8 @@ version = "0.9.0" dependencies = [ "log", "parity-scale-codec", + "sc-allocator", "sc-executor-common", - "sp-allocator", "sp-core", "sp-runtime-interface", "sp-wasm-interface", @@ -7536,9 +7546,9 @@ dependencies = [ "log", "parity-scale-codec", "parity-wasm 0.42.2", + "sc-allocator", "sc-executor-common", "scoped-tls", - "sp-allocator", "sp-core", "sp-runtime-interface", "sp-wasm-interface", @@ -7885,6 +7895,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.11.1", "sc-block-builder", + "sc-chain-spec", "sc-cli", "sc-client-api", "sc-executor", @@ -7896,7 +7907,6 @@ dependencies = [ "serde_json", "sp-api", "sp-blockchain", - "sp-chain-spec", "sp-core", "sp-io", "sp-keystore", @@ -7926,9 +7936,9 @@ dependencies = [ "log", "parity-scale-codec", "parking_lot 0.11.1", + "sc-chain-spec", "serde", "serde_json", - "sp-chain-spec", "sp-core", "sp-rpc", "sp-runtime", @@ -7958,7 +7968,7 @@ dependencies = [ name = "sc-runtime-test" version = "2.0.0" dependencies = [ - "sp-allocator", + "sc-allocator", "sp-core", "sp-io", "sp-runtime", @@ -8665,17 +8675,6 @@ dependencies = [ "sha-1 0.9.4", ] -[[package]] -name = "sp-allocator" -version = "3.0.0" -dependencies = [ - "log", - "sp-core", - "sp-std", - "sp-wasm-interface", - "thiserror", -] - [[package]] name = "sp-api" version = "3.0.0" @@ -8828,14 +8827,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "sp-chain-spec" -version = "3.0.0" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "sp-consensus" version = "0.9.0" diff --git a/substrate/Cargo.toml b/substrate/Cargo.toml index f7552f0bbb..d73bf1b52d 100644 --- a/substrate/Cargo.toml +++ b/substrate/Cargo.toml @@ -49,6 +49,7 @@ members = [ "client/network/test", "client/offchain", "client/peerset", + "client/allocator", "client/proposer-metrics", "client/rpc", "client/rpc-api", @@ -129,7 +130,6 @@ members = [ "frame/uniques", "frame/utility", "frame/vesting", - "primitives/allocator", "primitives/api", "primitives/api/proc-macro", "primitives/api/test", @@ -141,7 +141,6 @@ members = [ "primitives/authorship", "primitives/block-builder", "primitives/blockchain", - "primitives/chain-spec", "primitives/consensus/aura", "primitives/consensus/babe", "primitives/consensus/common", diff --git a/substrate/primitives/allocator/Cargo.toml b/substrate/client/allocator/Cargo.toml similarity index 57% rename from substrate/primitives/allocator/Cargo.toml rename to substrate/client/allocator/Cargo.toml index 1c38cbbb9c..e2fc69e26d 100644 --- a/substrate/primitives/allocator/Cargo.toml +++ b/substrate/client/allocator/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sp-allocator" +name = "sc-allocator" version = "3.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -7,18 +7,18 @@ license = "Apache-2.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" description = "Collection of allocator implementations." -documentation = "https://docs.rs/sp-allocator" +documentation = "https://docs.rs/sc-allocator" readme = "README.md" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies] -sp-std = { version = "3.0.0", path = "../std", default-features = false } -sp-core = { version = "3.0.0", path = "../core", default-features = false } -sp-wasm-interface = { version = "3.0.0", path = "../wasm-interface", default-features = false } +sp-std = { version = "3.0.0", path = "../../primitives/std", default-features = false } +sp-core = { version = "3.0.0", path = "../../primitives/core", default-features = false } +sp-wasm-interface = { version = "3.0.0", path = "../../primitives/wasm-interface", default-features = false } log = { version = "0.4.11", optional = true } -thiserror = { version = "1.0.21", optional = true } +thiserror = { version = "1.0.21" } [features] default = [ "std" ] @@ -27,5 +27,4 @@ std = [ "sp-core/std", "sp-wasm-interface/std", "log", - "thiserror", ] diff --git a/substrate/primitives/allocator/README.md b/substrate/client/allocator/README.md similarity index 76% rename from substrate/primitives/allocator/README.md rename to substrate/client/allocator/README.md index cd845e2b02..b89348b4c6 100644 --- a/substrate/primitives/allocator/README.md +++ b/substrate/client/allocator/README.md @@ -1,6 +1,6 @@ Collection of allocator implementations. This crate provides the following allocator implementations: -- A freeing-bump allocator: [`FreeingBumpHeapAllocator`](https://docs.rs/sp-allocator/latest/sp_allocator/struct.FreeingBumpHeapAllocator.html) +- A freeing-bump allocator: [`FreeingBumpHeapAllocator`](https://docs.rs/sc-allocator/latest/sc_allocator/struct.FreeingBumpHeapAllocator.html) License: Apache-2.0 \ No newline at end of file diff --git a/substrate/primitives/allocator/src/error.rs b/substrate/client/allocator/src/error.rs similarity index 79% rename from substrate/primitives/allocator/src/error.rs rename to substrate/client/allocator/src/error.rs index 8464cd225d..d28484d34f 100644 --- a/substrate/primitives/allocator/src/error.rs +++ b/substrate/client/allocator/src/error.rs @@ -17,15 +17,15 @@ /// The error type used by the allocators. #[derive(sp_core::RuntimeDebug)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(thiserror::Error)] pub enum Error { /// Someone tried to allocate more memory than the allowed maximum per allocation. - #[cfg_attr(feature = "std", error("Requested allocation size is too large"))] + #[error("Requested allocation size is too large")] RequestedAllocationTooLarge, /// Allocator run out of space. - #[cfg_attr(feature = "std", error("Allocator ran out of space"))] + #[error("Allocator ran out of space")] AllocatorOutOfSpace, /// Some other error occurred. - #[cfg_attr(feature = "std", error("Other: {0}"))] + #[error("Other: {0}")] Other(&'static str) } diff --git a/substrate/primitives/allocator/src/freeing_bump.rs b/substrate/client/allocator/src/freeing_bump.rs similarity index 99% rename from substrate/primitives/allocator/src/freeing_bump.rs rename to substrate/client/allocator/src/freeing_bump.rs index 36f5bb9c65..3e9b0c9790 100644 --- a/substrate/primitives/allocator/src/freeing_bump.rs +++ b/substrate/client/allocator/src/freeing_bump.rs @@ -495,7 +495,7 @@ impl Memory for [u8] { let range = heap_range(ptr, 8, self.len()).ok_or_else(|| error("write out of heap bounds"))?; let bytes = val.to_le_bytes(); - &mut self[range].copy_from_slice(&bytes[..]); + self[range].copy_from_slice(&bytes[..]); Ok(()) } fn size(&self) -> u32 { diff --git a/substrate/primitives/allocator/src/lib.rs b/substrate/client/allocator/src/lib.rs similarity index 95% rename from substrate/primitives/allocator/src/lib.rs rename to substrate/client/allocator/src/lib.rs index 7d45fb5f36..a82c754219 100644 --- a/substrate/primitives/allocator/src/lib.rs +++ b/substrate/client/allocator/src/lib.rs @@ -20,7 +20,6 @@ //! This crate provides the following allocator implementations: //! - A freeing-bump allocator: [`FreeingBumpHeapAllocator`](freeing_bump::FreeingBumpHeapAllocator) -#![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs)] mod error; diff --git a/substrate/client/chain-spec/Cargo.toml b/substrate/client/chain-spec/Cargo.toml index 27850cc840..2eddec524c 100644 --- a/substrate/client/chain-spec/Cargo.toml +++ b/substrate/client/chain-spec/Cargo.toml @@ -20,7 +20,6 @@ sp-core = { version = "3.0.0", path = "../../primitives/core" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" sp-runtime = { version = "3.0.0", path = "../../primitives/runtime" } -sp-chain-spec = { version = "3.0.0", path = "../../primitives/chain-spec" } sc-telemetry = { version = "3.0.0", path = "../telemetry" } codec = { package = "parity-scale-codec", version = "2.0.0" } sc-consensus-babe = { version = "0.9.0", path = "../consensus/babe" } diff --git a/substrate/client/chain-spec/src/lib.rs b/substrate/client/chain-spec/src/lib.rs index e75dafcfe0..1bfa1808ee 100644 --- a/substrate/client/chain-spec/src/lib.rs +++ b/substrate/client/chain-spec/src/lib.rs @@ -115,7 +115,6 @@ pub use chain_spec::{ }; pub use extension::{Group, Fork, Forks, Extension, GetExtension, get_extension}; pub use sc_chain_spec_derive::{ChainSpecExtension, ChainSpecGroup}; -pub use sp_chain_spec::{Properties, ChainType}; use serde::{Serialize, de::DeserializeOwned}; use sp_runtime::BuildStorage; @@ -123,6 +122,31 @@ use sc_network::config::MultiaddrWithPeerId; use sc_telemetry::TelemetryEndpoints; use sp_core::storage::Storage; +/// The type of a chain. +/// +/// This can be used by tools to determine the type of a chain for displaying +/// additional information or enabling additional features. +#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)] +pub enum ChainType { + /// A development chain that runs mainly on one node. + Development, + /// A local chain that runs locally on multiple nodes for testing purposes. + Local, + /// A live chain. + Live, + /// Some custom chain type. + Custom(String), +} + +impl Default for ChainType { + fn default() -> Self { + Self::Live + } +} + +/// Arbitrary properties defined in chain spec as a JSON object +pub type Properties = serde_json::map::Map; + /// A set of traits for the runtime genesis config. pub trait RuntimeGenesis: Serialize + DeserializeOwned + BuildStorage {} impl RuntimeGenesis for T {} diff --git a/substrate/client/executor/common/Cargo.toml b/substrate/client/executor/common/Cargo.toml index cb238f3a96..75cfcd3d2d 100644 --- a/substrate/client/executor/common/Cargo.toml +++ b/substrate/client/executor/common/Cargo.toml @@ -19,7 +19,7 @@ pwasm-utils = "0.18.0" codec = { package = "parity-scale-codec", version = "2.0.0" } wasmi = "0.9.0" sp-core = { version = "3.0.0", path = "../../../primitives/core" } -sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" } +sc-allocator = { version = "3.0.0", path = "../../allocator" } sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" } sp-maybe-compressed-blob = { version = "3.0.0", path = "../../../primitives/maybe-compressed-blob" } sp-serializer = { version = "3.0.0", path = "../../../primitives/serializer" } diff --git a/substrate/client/executor/common/src/error.rs b/substrate/client/executor/common/src/error.rs index 96329d1680..6ad4802e57 100644 --- a/substrate/client/executor/common/src/error.rs +++ b/substrate/client/executor/common/src/error.rs @@ -77,7 +77,7 @@ pub enum Error { Other(String), #[error(transparent)] - Allocator(#[from] sp_allocator::Error), + Allocator(#[from] sc_allocator::Error), #[error("Host function {0} execution failed with: {1}")] FunctionExecution(String, String), diff --git a/substrate/client/executor/runtime-test/Cargo.toml b/substrate/client/executor/runtime-test/Cargo.toml index 93ad463be1..2f06556644 100644 --- a/substrate/client/executor/runtime-test/Cargo.toml +++ b/substrate/client/executor/runtime-test/Cargo.toml @@ -13,7 +13,7 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -sp-allocator = { version = "3.0.0", default-features = false, path = "../../../primitives/allocator" } +sc-allocator = { version = "3.0.0", default-features = false, path = "../../allocator" } sp-core = { version = "3.0.0", default-features = false, path = "../../../primitives/core" } sp-io = { version = "3.0.0", default-features = false, path = "../../../primitives/io" } sp-runtime = { version = "3.0.0", default-features = false, path = "../../../primitives/runtime" } @@ -27,7 +27,7 @@ substrate-wasm-builder = { version = "4.0.0", path = "../../../utils/wasm-builde [features] default = [ "std" ] std = [ - "sp-allocator/std", + "sc-allocator/std", "sp-core/std", "sp-io/std", "sp-runtime/std", diff --git a/substrate/client/executor/runtime-test/src/lib.rs b/substrate/client/executor/runtime-test/src/lib.rs index 439d4f66b1..af0c9edcc3 100644 --- a/substrate/client/executor/runtime-test/src/lib.rs +++ b/substrate/client/executor/runtime-test/src/lib.rs @@ -211,7 +211,6 @@ sp_core::wasm_export_functions! { code } - fn test_sandbox_get_global_val(code: Vec) -> i64 { let env_builder = sp_sandbox::EnvironmentDefinitionBuilder::new(); let instance = if let Ok(i) = sp_sandbox::Instance::new(&code, &env_builder, &mut ()) { @@ -227,12 +226,10 @@ sp_core::wasm_export_functions! { } } - fn test_offchain_index_set() { sp_io::offchain_index::set(b"k", b"v"); } - fn test_offchain_local_storage() -> bool { let kind = sp_core::offchain::StorageKind::PERSISTENT; assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), None); @@ -286,11 +283,6 @@ sp_core::wasm_export_functions! { run().is_some() } - // Just some test to make sure that `sp-allocator` compiles on `no_std`. - fn test_sp_allocator_compiles() { - sp_allocator::FreeingBumpHeapAllocator::new(0); - } - fn test_enter_span() -> u64 { wasm_tracing::enter_span(Default::default()) } diff --git a/substrate/client/executor/wasmi/Cargo.toml b/substrate/client/executor/wasmi/Cargo.toml index 4c3054d5d1..dbdf26b63d 100644 --- a/substrate/client/executor/wasmi/Cargo.toml +++ b/substrate/client/executor/wasmi/Cargo.toml @@ -18,7 +18,7 @@ log = "0.4.8" wasmi = "0.9.0" codec = { package = "parity-scale-codec", version = "2.0.0" } sc-executor-common = { version = "0.9.0", path = "../common" } +sc-allocator = { version = "3.0.0", path = "../../allocator" } sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" } sp-runtime-interface = { version = "3.0.0", path = "../../../primitives/runtime-interface" } sp-core = { version = "3.0.0", path = "../../../primitives/core" } -sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" } diff --git a/substrate/client/executor/wasmi/src/lib.rs b/substrate/client/executor/wasmi/src/lib.rs index d4c9f4dc2e..1bafa39494 100644 --- a/substrate/client/executor/wasmi/src/lib.rs +++ b/substrate/client/executor/wasmi/src/lib.rs @@ -40,7 +40,7 @@ use sc_executor_common::runtime_blob::{RuntimeBlob, DataSegmentsSnapshot}; struct FunctionExecutor<'a> { sandbox_store: sandbox::Store, - heap: sp_allocator::FreeingBumpHeapAllocator, + heap: sc_allocator::FreeingBumpHeapAllocator, memory: MemoryRef, table: Option, host_functions: &'a [&'static dyn Function], @@ -59,7 +59,7 @@ impl<'a> FunctionExecutor<'a> { ) -> Result { Ok(FunctionExecutor { sandbox_store: sandbox::Store::new(), - heap: sp_allocator::FreeingBumpHeapAllocator::new(heap_base), + heap: sc_allocator::FreeingBumpHeapAllocator::new(heap_base), memory: m, table: t, host_functions, diff --git a/substrate/client/executor/wasmtime/Cargo.toml b/substrate/client/executor/wasmtime/Cargo.toml index 1e886d15be..bdaae49c24 100644 --- a/substrate/client/executor/wasmtime/Cargo.toml +++ b/substrate/client/executor/wasmtime/Cargo.toml @@ -23,7 +23,7 @@ sc-executor-common = { version = "0.9.0", path = "../common" } sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" } sp-runtime-interface = { version = "3.0.0", path = "../../../primitives/runtime-interface" } sp-core = { version = "3.0.0", path = "../../../primitives/core" } -sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" } +sc-allocator = { version = "3.0.0", path = "../../allocator" } wasmtime = "0.27.0" [dev-dependencies] diff --git a/substrate/client/executor/wasmtime/src/host.rs b/substrate/client/executor/wasmtime/src/host.rs index c1eb77ff81..3f5ac0560a 100644 --- a/substrate/client/executor/wasmtime/src/host.rs +++ b/substrate/client/executor/wasmtime/src/host.rs @@ -24,7 +24,7 @@ use crate::util; use std::{cell::RefCell, rc::Rc}; use log::trace; use codec::{Encode, Decode}; -use sp_allocator::FreeingBumpHeapAllocator; +use sc_allocator::FreeingBumpHeapAllocator; use sc_executor_common::error::Result; use sc_executor_common::sandbox::{self, SandboxCapabilities, SupervisorFuncIndex}; use sp_core::sandbox as sandbox_primitives; diff --git a/substrate/client/executor/wasmtime/src/instance_wrapper.rs b/substrate/client/executor/wasmtime/src/instance_wrapper.rs index 866dbfb2e2..10c4926743 100644 --- a/substrate/client/executor/wasmtime/src/instance_wrapper.rs +++ b/substrate/client/executor/wasmtime/src/instance_wrapper.rs @@ -340,7 +340,7 @@ impl InstanceWrapper { let range = util::checked_range(address.into(), data.len(), memory.len()) .ok_or_else(|| Error::Other("memory write is out of bounds".into()))?; - &mut memory[range].copy_from_slice(data); + memory[range].copy_from_slice(data); Ok(()) } } @@ -351,7 +351,7 @@ impl InstanceWrapper { /// to get more details. pub fn allocate( &self, - allocator: &mut sp_allocator::FreeingBumpHeapAllocator, + allocator: &mut sc_allocator::FreeingBumpHeapAllocator, size: WordSize, ) -> Result> { unsafe { @@ -368,7 +368,7 @@ impl InstanceWrapper { /// Returns `Err` in case the given memory region cannot be deallocated. pub fn deallocate( &self, - allocator: &mut sp_allocator::FreeingBumpHeapAllocator, + allocator: &mut sc_allocator::FreeingBumpHeapAllocator, ptr: Pointer, ) -> Result<()> { unsafe { diff --git a/substrate/client/executor/wasmtime/src/runtime.rs b/substrate/client/executor/wasmtime/src/runtime.rs index 5018b11264..021377eeb2 100644 --- a/substrate/client/executor/wasmtime/src/runtime.rs +++ b/substrate/client/executor/wasmtime/src/runtime.rs @@ -31,7 +31,7 @@ use sc_executor_common::{ runtime_blob::{DataSegmentsSnapshot, ExposedMutableGlobalsSet, GlobalsSnapshot, RuntimeBlob}, wasm_runtime::{WasmModule, WasmInstance, InvokeMethod}, }; -use sp_allocator::FreeingBumpHeapAllocator; +use sc_allocator::FreeingBumpHeapAllocator; use sp_runtime_interface::unpack_ptr_and_len; use sp_wasm_interface::{Function, Pointer, WordSize, Value}; use wasmtime::{Engine, Store}; diff --git a/substrate/client/rpc-api/Cargo.toml b/substrate/client/rpc-api/Cargo.toml index 662f4bd16f..87c4577c72 100644 --- a/substrate/client/rpc-api/Cargo.toml +++ b/substrate/client/rpc-api/Cargo.toml @@ -25,7 +25,7 @@ parking_lot = "0.11.1" sp-core = { version = "3.0.0", path = "../../primitives/core" } sp-version = { version = "3.0.0", path = "../../primitives/version" } sp-runtime = { path = "../../primitives/runtime" , version = "3.0.0"} -sp-chain-spec = { path = "../../primitives/chain-spec" , version = "3.0.0"} +sc-chain-spec = { path = "../chain-spec" , version = "3.0.0"} serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" sp-transaction-pool = { version = "3.0.0", path = "../../primitives/transaction-pool" } diff --git a/substrate/client/rpc-api/src/system/helpers.rs b/substrate/client/rpc-api/src/system/helpers.rs index c2fc807471..c8124d9c67 100644 --- a/substrate/client/rpc-api/src/system/helpers.rs +++ b/substrate/client/rpc-api/src/system/helpers.rs @@ -20,7 +20,7 @@ use std::fmt; use serde::{Serialize, Deserialize}; -use sp_chain_spec::{Properties, ChainType}; +use sc_chain_spec::{Properties, ChainType}; /// Running node's static details. #[derive(Clone, Debug)] diff --git a/substrate/client/rpc-api/src/system/mod.rs b/substrate/client/rpc-api/src/system/mod.rs index 4252ef20ac..e820fb2e70 100644 --- a/substrate/client/rpc-api/src/system/mod.rs +++ b/substrate/client/rpc-api/src/system/mod.rs @@ -47,11 +47,11 @@ pub trait SystemApi { /// Get the chain's type. #[rpc(name = "system_chainType")] - fn system_type(&self) -> SystemResult; + fn system_type(&self) -> SystemResult; /// Get a custom set of properties as a JSON object, defined in the chain spec. #[rpc(name = "system_properties")] - fn system_properties(&self) -> SystemResult; + fn system_properties(&self) -> SystemResult; /// Return health status of the node. /// diff --git a/substrate/client/rpc/Cargo.toml b/substrate/client/rpc/Cargo.toml index a352e5fc38..140039cab7 100644 --- a/substrate/client/rpc/Cargo.toml +++ b/substrate/client/rpc/Cargo.toml @@ -31,7 +31,7 @@ sp-utils = { version = "3.0.0", path = "../../primitives/utils" } sp-rpc = { version = "3.0.0", path = "../../primitives/rpc" } sp-keystore = { version = "0.9.0", path = "../../primitives/keystore" } sp-state-machine = { version = "0.9.0", path = "../../primitives/state-machine" } -sp-chain-spec = { version = "3.0.0", path = "../../primitives/chain-spec" } +sc-chain-spec = { version = "3.0.0", path = "../chain-spec" } sc-executor = { version = "0.9.0", path = "../executor" } sc-block-builder = { version = "0.9.0", path = "../block-builder" } sc-keystore = { version = "3.0.0", path = "../keystore" } diff --git a/substrate/client/rpc/src/system/mod.rs b/substrate/client/rpc/src/system/mod.rs index 248c2dcfed..d405755731 100644 --- a/substrate/client/rpc/src/system/mod.rs +++ b/substrate/client/rpc/src/system/mod.rs @@ -106,11 +106,11 @@ impl SystemApi::Number> for Sy Ok(self.info.chain_name.clone()) } - fn system_type(&self) -> Result { + fn system_type(&self) -> Result { Ok(self.info.chain_type.clone()) } - fn system_properties(&self) -> Result { + fn system_properties(&self) -> Result { Ok(self.info.properties.clone()) } diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index b71b069ccb..d398384887 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -141,7 +141,7 @@ impl Encode for Data { Data::Raw(ref x) => { let l = x.len().min(32); let mut r = vec![l as u8 + 1; l + 1]; - &mut r[1..].copy_from_slice(&x[..l as usize]); + r[1..].copy_from_slice(&x[..l as usize]); r } Data::BlakeTwo256(ref h) => once(34u8).chain(h.iter().cloned()).collect(), @@ -1161,4 +1161,3 @@ impl Pallet { .collect() } } - diff --git a/substrate/primitives/chain-spec/Cargo.toml b/substrate/primitives/chain-spec/Cargo.toml deleted file mode 100644 index ec3e731bb0..0000000000 --- a/substrate/primitives/chain-spec/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "sp-chain-spec" -version = "3.0.0" -authors = ["Parity Technologies "] -edition = "2018" -license = "Apache-2.0" -homepage = "https://substrate.dev" -repository = "https://github.com/paritytech/substrate/" -description = "Substrate chain configurations types." -readme = "README.md" - -[dependencies] -serde = { version = "1.0.101", features = ["derive"] } -serde_json = "1.0.41" diff --git a/substrate/primitives/chain-spec/README.md b/substrate/primitives/chain-spec/README.md deleted file mode 100644 index 375f14a441..0000000000 --- a/substrate/primitives/chain-spec/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Types and traits related to chain specifications. - -License: Apache-2.0 \ No newline at end of file diff --git a/substrate/primitives/chain-spec/src/lib.rs b/substrate/primitives/chain-spec/src/lib.rs deleted file mode 100644 index 5456718e35..0000000000 --- a/substrate/primitives/chain-spec/src/lib.rs +++ /dev/null @@ -1,43 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Types and traits related to chain specifications. - -/// The type of a chain. -/// -/// This can be used by tools to determine the type of a chain for displaying -/// additional information or enabling additional features. -#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)] -pub enum ChainType { - /// A development chain that runs mainly on one node. - Development, - /// A local chain that runs locally on multiple nodes for testing purposes. - Local, - /// A live chain. - Live, - /// Some custom chain type. - Custom(String), -} - -impl Default for ChainType { - fn default() -> Self { - Self::Live - } -} - -/// Arbitrary properties defined in chain spec as a JSON object -pub type Properties = serde_json::map::Map;