From 799bfcc591c64cb9c87a2d6f9683e6c09d3998c5 Mon Sep 17 00:00:00 2001 From: gilescope Date: Mon, 28 Jun 2021 14:54:42 +0100 Subject: [PATCH 1/8] Move alloc primitive (not used in /pallets) --- Cargo.toml | 2 +- client/executor/common/Cargo.toml | 2 +- client/executor/runtime-test/Cargo.toml | 2 +- client/executor/wasmi/Cargo.toml | 2 +- client/executor/wasmtime/Cargo.toml | 2 +- {primitives => client/primitives}/allocator/Cargo.toml | 6 +++--- {primitives => client/primitives}/allocator/README.md | 0 {primitives => client/primitives}/allocator/src/error.rs | 0 .../primitives}/allocator/src/freeing_bump.rs | 0 {primitives => client/primitives}/allocator/src/lib.rs | 0 10 files changed, 8 insertions(+), 8 deletions(-) rename {primitives => client/primitives}/allocator/Cargo.toml (68%) rename {primitives => client/primitives}/allocator/README.md (100%) rename {primitives => client/primitives}/allocator/src/error.rs (100%) rename {primitives => client/primitives}/allocator/src/freeing_bump.rs (100%) rename {primitives => client/primitives}/allocator/src/lib.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index f7552f0bbbc48..0c0f2daed7f62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ members = [ "client/network/test", "client/offchain", "client/peerset", + "client/primitives/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", diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index cb238f3a96fb0..c367cdd78ad9f 100644 --- a/client/executor/common/Cargo.toml +++ b/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" } +sp-allocator = { version = "3.0.0", path = "../../primitives/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/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 93ad463be16c3..19ae20e411b9a 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/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" } +sp-allocator = { version = "3.0.0", default-features = false, path = "../../primitives/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" } diff --git a/client/executor/wasmi/Cargo.toml b/client/executor/wasmi/Cargo.toml index 4c3054d5d10c2..0673c40b2ba74 100644 --- a/client/executor/wasmi/Cargo.toml +++ b/client/executor/wasmi/Cargo.toml @@ -21,4 +21,4 @@ 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" } +sp-allocator = { version = "3.0.0", path = "../../primitives/allocator" } diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index 1e886d15beb18..9a6b7052d901a 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/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" } +sp-allocator = { version = "3.0.0", path = "../../primitives/allocator" } wasmtime = "0.27.0" [dev-dependencies] diff --git a/primitives/allocator/Cargo.toml b/client/primitives/allocator/Cargo.toml similarity index 68% rename from primitives/allocator/Cargo.toml rename to client/primitives/allocator/Cargo.toml index 1c38cbbb9c26e..3844ce95c9e45 100644 --- a/primitives/allocator/Cargo.toml +++ b/client/primitives/allocator/Cargo.toml @@ -14,9 +14,9 @@ readme = "README.md" 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 } diff --git a/primitives/allocator/README.md b/client/primitives/allocator/README.md similarity index 100% rename from primitives/allocator/README.md rename to client/primitives/allocator/README.md diff --git a/primitives/allocator/src/error.rs b/client/primitives/allocator/src/error.rs similarity index 100% rename from primitives/allocator/src/error.rs rename to client/primitives/allocator/src/error.rs diff --git a/primitives/allocator/src/freeing_bump.rs b/client/primitives/allocator/src/freeing_bump.rs similarity index 100% rename from primitives/allocator/src/freeing_bump.rs rename to client/primitives/allocator/src/freeing_bump.rs diff --git a/primitives/allocator/src/lib.rs b/client/primitives/allocator/src/lib.rs similarity index 100% rename from primitives/allocator/src/lib.rs rename to client/primitives/allocator/src/lib.rs From 5a040330d14605395a2888fc5b0be98314ce8c7a Mon Sep 17 00:00:00 2001 From: gilescope Date: Tue, 29 Jun 2021 10:21:37 +0100 Subject: [PATCH 2/8] Move to alternative location as not shared --- Cargo.toml | 2 +- client/chain-spec/Cargo.toml | 2 +- {primitives => client/primitives}/chain-spec/Cargo.toml | 0 {primitives => client/primitives}/chain-spec/README.md | 0 {primitives => client/primitives}/chain-spec/src/lib.rs | 0 client/rpc-api/Cargo.toml | 2 +- client/rpc/Cargo.toml | 2 +- 7 files changed, 4 insertions(+), 4 deletions(-) rename {primitives => client/primitives}/chain-spec/Cargo.toml (100%) rename {primitives => client/primitives}/chain-spec/README.md (100%) rename {primitives => client/primitives}/chain-spec/src/lib.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 0c0f2daed7f62..f281c8f12316f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,6 +50,7 @@ members = [ "client/offchain", "client/peerset", "client/primitives/allocator", + "client/primitives/chain-spec", "client/proposer-metrics", "client/rpc", "client/rpc-api", @@ -141,7 +142,6 @@ members = [ "primitives/authorship", "primitives/block-builder", "primitives/blockchain", - "primitives/chain-spec", "primitives/consensus/aura", "primitives/consensus/babe", "primitives/consensus/common", diff --git a/client/chain-spec/Cargo.toml b/client/chain-spec/Cargo.toml index 27850cc8400b3..2bc014b0e2364 100644 --- a/client/chain-spec/Cargo.toml +++ b/client/chain-spec/Cargo.toml @@ -20,7 +20,7 @@ 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" } +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/primitives/chain-spec/Cargo.toml b/client/primitives/chain-spec/Cargo.toml similarity index 100% rename from primitives/chain-spec/Cargo.toml rename to client/primitives/chain-spec/Cargo.toml diff --git a/primitives/chain-spec/README.md b/client/primitives/chain-spec/README.md similarity index 100% rename from primitives/chain-spec/README.md rename to client/primitives/chain-spec/README.md diff --git a/primitives/chain-spec/src/lib.rs b/client/primitives/chain-spec/src/lib.rs similarity index 100% rename from primitives/chain-spec/src/lib.rs rename to client/primitives/chain-spec/src/lib.rs diff --git a/client/rpc-api/Cargo.toml b/client/rpc-api/Cargo.toml index 662f4bd16fd4c..dc26f84029071 100644 --- a/client/rpc-api/Cargo.toml +++ b/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"} +sp-chain-spec = { path = "../primitives/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/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index a352e5fc387bd..572465bda4b7b 100644 --- a/client/rpc/Cargo.toml +++ b/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" } +sp-chain-spec = { version = "3.0.0", path = "../primitives/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" } From 940b162331ac6c442d02abcf4bd5b4ee8904d457 Mon Sep 17 00:00:00 2001 From: gilescope Date: Tue, 29 Jun 2021 14:27:12 +0100 Subject: [PATCH 3/8] moved crates to different dir --- Cargo.lock | 30 +++++++++---------- client/executor/common/Cargo.toml | 2 +- client/executor/common/src/error.rs | 2 +- client/executor/runtime-test/Cargo.toml | 4 +-- client/executor/runtime-test/src/lib.rs | 6 ++-- client/executor/wasmi/Cargo.toml | 2 +- client/executor/wasmi/src/lib.rs | 4 +-- client/executor/wasmtime/Cargo.toml | 2 +- client/executor/wasmtime/src/host.rs | 2 +- .../executor/wasmtime/src/instance_wrapper.rs | 6 ++-- client/executor/wasmtime/src/runtime.rs | 2 +- client/primitives/README.md | 3 ++ client/primitives/allocator/Cargo.toml | 4 +-- client/primitives/allocator/README.md | 2 +- .../primitives/allocator/src/freeing_bump.rs | 2 +- frame/identity/src/lib.rs | 3 +- 16 files changed, 39 insertions(+), 37 deletions(-) create mode 100644 client/primitives/README.md diff --git a/Cargo.lock b/Cargo.lock index ee78c31645b43..1f255f6284c60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6991,6 +6991,17 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sc-allocator-primitives" +version = "3.0.0" +dependencies = [ + "log", + "sp-core", + "sp-std", + "sp-wasm-interface", + "thiserror", +] + [[package]] name = "sc-authority-discovery" version = "0.9.0" @@ -7503,7 +7514,7 @@ dependencies = [ "derive_more", "parity-scale-codec", "pwasm-utils", - "sp-allocator", + "sc-allocator-primitives", "sp-core", "sp-maybe-compressed-blob", "sp-serializer", @@ -7518,8 +7529,8 @@ version = "0.9.0" dependencies = [ "log", "parity-scale-codec", + "sc-allocator-primitives", "sc-executor-common", - "sp-allocator", "sp-core", "sp-runtime-interface", "sp-wasm-interface", @@ -7536,9 +7547,9 @@ dependencies = [ "log", "parity-scale-codec", "parity-wasm 0.42.2", + "sc-allocator-primitives", "sc-executor-common", "scoped-tls", - "sp-allocator", "sp-core", "sp-runtime-interface", "sp-wasm-interface", @@ -7958,7 +7969,7 @@ dependencies = [ name = "sc-runtime-test" version = "2.0.0" dependencies = [ - "sp-allocator", + "sc-allocator-primitives", "sp-core", "sp-io", "sp-runtime", @@ -8665,17 +8676,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" diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index c367cdd78ad9f..5ebd8073670fc 100644 --- a/client/executor/common/Cargo.toml +++ b/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-primitives = { version = "3.0.0", path = "../../primitives/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/client/executor/common/src/error.rs b/client/executor/common/src/error.rs index 96329d1680301..4b0cd39887f60 100644 --- a/client/executor/common/src/error.rs +++ b/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_primitives::Error), #[error("Host function {0} execution failed with: {1}")] FunctionExecution(String, String), diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 19ae20e411b9a..9b6d71b57fa6c 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/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-primitives = { version = "3.0.0", default-features = false, path = "../../primitives/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-primitives/std", "sp-core/std", "sp-io/std", "sp-runtime/std", diff --git a/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index 439d4f66b1879..43da095183de0 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/client/executor/runtime-test/src/lib.rs @@ -286,9 +286,9 @@ 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); + // Just some test to make sure that `sc-allocator-primitives` compiles on `no_std`. + fn test_sc_allocator_primitive_compiles() { + sc_allocator_primitives::FreeingBumpHeapAllocator::new(0); } fn test_enter_span() -> u64 { diff --git a/client/executor/wasmi/Cargo.toml b/client/executor/wasmi/Cargo.toml index 0673c40b2ba74..d96a7e752792f 100644 --- a/client/executor/wasmi/Cargo.toml +++ b/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-primitives = { version = "3.0.0", path = "../../primitives/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/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index d4c9f4dc2e806..d44647220aa83 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/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_primitives::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_primitives::FreeingBumpHeapAllocator::new(heap_base), memory: m, table: t, host_functions, diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index 9a6b7052d901a..5efe7e80b0cd8 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/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-primitives = { version = "3.0.0", path = "../../primitives/allocator" } wasmtime = "0.27.0" [dev-dependencies] diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index c1eb77ff81f34..813220e25dec0 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/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_primitives::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/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index 866dbfb2e2bfc..87f6859c93f1c 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/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_primitives::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_primitives::FreeingBumpHeapAllocator, ptr: Pointer, ) -> Result<()> { unsafe { diff --git a/client/executor/wasmtime/src/runtime.rs b/client/executor/wasmtime/src/runtime.rs index 5018b11264d71..18a8f6d105875 100644 --- a/client/executor/wasmtime/src/runtime.rs +++ b/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_primitives::FreeingBumpHeapAllocator; use sp_runtime_interface::unpack_ptr_and_len; use sp_wasm_interface::{Function, Pointer, WordSize, Value}; use wasmtime::{Engine, Store}; diff --git a/client/primitives/README.md b/client/primitives/README.md new file mode 100644 index 0000000000000..2dea85d2ad612 --- /dev/null +++ b/client/primitives/README.md @@ -0,0 +1,3 @@ +# Client Primitives + +The crates below here are primitives crates and as such only store basic types and traits. They are used by the client only (i.e. they are not used directly by pallets). diff --git a/client/primitives/allocator/Cargo.toml b/client/primitives/allocator/Cargo.toml index 3844ce95c9e45..7a1107a3fde12 100644 --- a/client/primitives/allocator/Cargo.toml +++ b/client/primitives/allocator/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sp-allocator" +name = "sc-allocator-primitives" version = "3.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -7,7 +7,7 @@ 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-primitives" readme = "README.md" [package.metadata.docs.rs] diff --git a/client/primitives/allocator/README.md b/client/primitives/allocator/README.md index cd845e2b028eb..99e0eeb1ae351 100644 --- a/client/primitives/allocator/README.md +++ b/client/primitives/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-primitives/latest/sc_allocator_primitives/struct.FreeingBumpHeapAllocator.html) License: Apache-2.0 \ No newline at end of file diff --git a/client/primitives/allocator/src/freeing_bump.rs b/client/primitives/allocator/src/freeing_bump.rs index 36f5bb9c65c0e..3e9b0c9790360 100644 --- a/client/primitives/allocator/src/freeing_bump.rs +++ b/client/primitives/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/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index b71b069ccb74f..d398384887d98 100644 --- a/frame/identity/src/lib.rs +++ b/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() } } - From 6287b13df839aa0fc7c76bd7308222d2689ab022 Mon Sep 17 00:00:00 2001 From: gilescope Date: Tue, 29 Jun 2021 14:41:24 +0100 Subject: [PATCH 4/8] ren sp_chain_spec to sc_chain_spec_primatives --- Cargo.lock | 22 +++++++++++----------- client/chain-spec/Cargo.toml | 2 +- client/chain-spec/src/lib.rs | 2 +- client/primitives/chain-spec/Cargo.toml | 2 +- client/rpc-api/Cargo.toml | 2 +- client/rpc-api/src/system/helpers.rs | 2 +- client/rpc-api/src/system/mod.rs | 4 ++-- client/rpc/Cargo.toml | 2 +- client/rpc/src/system/mod.rs | 4 ++-- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f255f6284c60..e51c715ed75a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7083,6 +7083,7 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", "sc-chain-spec-derive", + "sc-chain-spec-primitives", "sc-consensus-babe", "sc-consensus-epochs", "sc-finality-grandpa", @@ -7090,7 +7091,6 @@ dependencies = [ "sc-telemetry", "serde", "serde_json", - "sp-chain-spec", "sp-consensus-babe", "sp-core", "sp-runtime", @@ -7106,6 +7106,14 @@ dependencies = [ "syn", ] +[[package]] +name = "sc-chain-spec-primitives" +version = "3.0.0" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "sc-cli" version = "0.9.0" @@ -7896,6 +7904,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.11.1", "sc-block-builder", + "sc-chain-spec-primitives", "sc-cli", "sc-client-api", "sc-executor", @@ -7907,7 +7916,6 @@ dependencies = [ "serde_json", "sp-api", "sp-blockchain", - "sp-chain-spec", "sp-core", "sp-io", "sp-keystore", @@ -7937,9 +7945,9 @@ dependencies = [ "log", "parity-scale-codec", "parking_lot 0.11.1", + "sc-chain-spec-primitives", "serde", "serde_json", - "sp-chain-spec", "sp-core", "sp-rpc", "sp-runtime", @@ -8828,14 +8836,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/client/chain-spec/Cargo.toml b/client/chain-spec/Cargo.toml index 2bc014b0e2364..fb2bae1613446 100644 --- a/client/chain-spec/Cargo.toml +++ b/client/chain-spec/Cargo.toml @@ -20,7 +20,7 @@ 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-chain-spec-primitives = { 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/client/chain-spec/src/lib.rs b/client/chain-spec/src/lib.rs index e75dafcfe0255..758565f797074 100644 --- a/client/chain-spec/src/lib.rs +++ b/client/chain-spec/src/lib.rs @@ -115,7 +115,7 @@ 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}; +pub use sc_chain_spec_primitives::{Properties, ChainType}; use serde::{Serialize, de::DeserializeOwned}; use sp_runtime::BuildStorage; diff --git a/client/primitives/chain-spec/Cargo.toml b/client/primitives/chain-spec/Cargo.toml index ec3e731bb0e95..18ecbb5e5a485 100644 --- a/client/primitives/chain-spec/Cargo.toml +++ b/client/primitives/chain-spec/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sp-chain-spec" +name = "sc-chain-spec-primitives" version = "3.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/client/rpc-api/Cargo.toml b/client/rpc-api/Cargo.toml index dc26f84029071..2b4e85d42e542 100644 --- a/client/rpc-api/Cargo.toml +++ b/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-primitives = { path = "../primitives/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/client/rpc-api/src/system/helpers.rs b/client/rpc-api/src/system/helpers.rs index c2fc807471f38..7606f1b87a97e 100644 --- a/client/rpc-api/src/system/helpers.rs +++ b/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_primitives::{Properties, ChainType}; /// Running node's static details. #[derive(Clone, Debug)] diff --git a/client/rpc-api/src/system/mod.rs b/client/rpc-api/src/system/mod.rs index 4252ef20ac22a..2ada5245ca6fe 100644 --- a/client/rpc-api/src/system/mod.rs +++ b/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/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 572465bda4b7b..eceea6b1a57af 100644 --- a/client/rpc/Cargo.toml +++ b/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-primitives = { version = "3.0.0", path = "../primitives/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/client/rpc/src/system/mod.rs b/client/rpc/src/system/mod.rs index 248c2dcfed3c6..534832c7174a8 100644 --- a/client/rpc/src/system/mod.rs +++ b/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()) } From f15b5293e6943aea91afe1b8e320302b9082bb87 Mon Sep 17 00:00:00 2001 From: gilescope Date: Tue, 29 Jun 2021 15:29:03 +0100 Subject: [PATCH 5/8] merged sc-chain-spec and moved allocation up one. --- Cargo.lock | 23 +++------- Cargo.toml | 3 +- client/{primitives => }/allocator/Cargo.toml | 10 ++--- client/{primitives => }/allocator/README.md | 2 +- .../{primitives => }/allocator/src/error.rs | 0 .../allocator/src/freeing_bump.rs | 0 client/{primitives => }/allocator/src/lib.rs | 0 client/chain-spec/Cargo.toml | 1 - client/chain-spec/src/lib.rs | 26 ++++++++++- client/executor/common/Cargo.toml | 2 +- client/executor/common/src/error.rs | 2 +- client/executor/runtime-test/Cargo.toml | 4 +- client/executor/runtime-test/src/lib.rs | 4 +- client/executor/wasmi/Cargo.toml | 2 +- client/executor/wasmi/src/lib.rs | 4 +- client/executor/wasmtime/Cargo.toml | 2 +- client/executor/wasmtime/src/host.rs | 2 +- .../executor/wasmtime/src/instance_wrapper.rs | 4 +- client/executor/wasmtime/src/runtime.rs | 2 +- client/primitives/README.md | 3 -- client/primitives/chain-spec/Cargo.toml | 14 ------ client/primitives/chain-spec/README.md | 3 -- client/primitives/chain-spec/src/lib.rs | 43 ------------------- client/rpc-api/Cargo.toml | 2 +- client/rpc-api/src/system/helpers.rs | 2 +- client/rpc-api/src/system/mod.rs | 4 +- client/rpc/Cargo.toml | 2 +- client/rpc/src/system/mod.rs | 4 +- 28 files changed, 60 insertions(+), 110 deletions(-) rename client/{primitives => }/allocator/Cargo.toml (60%) rename client/{primitives => }/allocator/README.md (64%) rename client/{primitives => }/allocator/src/error.rs (100%) rename client/{primitives => }/allocator/src/freeing_bump.rs (100%) rename client/{primitives => }/allocator/src/lib.rs (100%) delete mode 100644 client/primitives/README.md delete mode 100644 client/primitives/chain-spec/Cargo.toml delete mode 100644 client/primitives/chain-spec/README.md delete mode 100644 client/primitives/chain-spec/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index e51c715ed75a2..737a762d88f0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6992,7 +6992,7 @@ dependencies = [ ] [[package]] -name = "sc-allocator-primitives" +name = "sc-allocator" version = "3.0.0" dependencies = [ "log", @@ -7083,7 +7083,6 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", "sc-chain-spec-derive", - "sc-chain-spec-primitives", "sc-consensus-babe", "sc-consensus-epochs", "sc-finality-grandpa", @@ -7106,14 +7105,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sc-chain-spec-primitives" -version = "3.0.0" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "sc-cli" version = "0.9.0" @@ -7522,7 +7513,7 @@ dependencies = [ "derive_more", "parity-scale-codec", "pwasm-utils", - "sc-allocator-primitives", + "sc-allocator", "sp-core", "sp-maybe-compressed-blob", "sp-serializer", @@ -7537,7 +7528,7 @@ version = "0.9.0" dependencies = [ "log", "parity-scale-codec", - "sc-allocator-primitives", + "sc-allocator", "sc-executor-common", "sp-core", "sp-runtime-interface", @@ -7555,7 +7546,7 @@ dependencies = [ "log", "parity-scale-codec", "parity-wasm 0.42.2", - "sc-allocator-primitives", + "sc-allocator", "sc-executor-common", "scoped-tls", "sp-core", @@ -7904,7 +7895,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.11.1", "sc-block-builder", - "sc-chain-spec-primitives", + "sc-chain-spec", "sc-cli", "sc-client-api", "sc-executor", @@ -7945,7 +7936,7 @@ dependencies = [ "log", "parity-scale-codec", "parking_lot 0.11.1", - "sc-chain-spec-primitives", + "sc-chain-spec", "serde", "serde_json", "sp-core", @@ -7977,7 +7968,7 @@ dependencies = [ name = "sc-runtime-test" version = "2.0.0" dependencies = [ - "sc-allocator-primitives", + "sc-allocator", "sp-core", "sp-io", "sp-runtime", diff --git a/Cargo.toml b/Cargo.toml index f281c8f12316f..d73bf1b52de90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,8 +49,7 @@ members = [ "client/network/test", "client/offchain", "client/peerset", - "client/primitives/allocator", - "client/primitives/chain-spec", + "client/allocator", "client/proposer-metrics", "client/rpc", "client/rpc-api", diff --git a/client/primitives/allocator/Cargo.toml b/client/allocator/Cargo.toml similarity index 60% rename from client/primitives/allocator/Cargo.toml rename to client/allocator/Cargo.toml index 7a1107a3fde12..535300864f1df 100644 --- a/client/primitives/allocator/Cargo.toml +++ b/client/allocator/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sc-allocator-primitives" +name = "sc-allocator" version = "3.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -7,16 +7,16 @@ license = "Apache-2.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" description = "Collection of allocator implementations." -documentation = "https://docs.rs/sc-allocator-primitives" +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 = "../../../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 } +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 } diff --git a/client/primitives/allocator/README.md b/client/allocator/README.md similarity index 64% rename from client/primitives/allocator/README.md rename to client/allocator/README.md index 99e0eeb1ae351..b89348b4c6950 100644 --- a/client/primitives/allocator/README.md +++ b/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/sc-allocator-primitives/latest/sc_allocator_primitives/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/client/primitives/allocator/src/error.rs b/client/allocator/src/error.rs similarity index 100% rename from client/primitives/allocator/src/error.rs rename to client/allocator/src/error.rs diff --git a/client/primitives/allocator/src/freeing_bump.rs b/client/allocator/src/freeing_bump.rs similarity index 100% rename from client/primitives/allocator/src/freeing_bump.rs rename to client/allocator/src/freeing_bump.rs diff --git a/client/primitives/allocator/src/lib.rs b/client/allocator/src/lib.rs similarity index 100% rename from client/primitives/allocator/src/lib.rs rename to client/allocator/src/lib.rs diff --git a/client/chain-spec/Cargo.toml b/client/chain-spec/Cargo.toml index fb2bae1613446..2eddec524cad6 100644 --- a/client/chain-spec/Cargo.toml +++ b/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" } -sc-chain-spec-primitives = { 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/client/chain-spec/src/lib.rs b/client/chain-spec/src/lib.rs index 758565f797074..1bfa1808ee556 100644 --- a/client/chain-spec/src/lib.rs +++ b/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 sc_chain_spec_primitives::{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/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index 5ebd8073670fc..75cfcd3d2d851 100644 --- a/client/executor/common/Cargo.toml +++ b/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" } -sc-allocator-primitives = { 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/client/executor/common/src/error.rs b/client/executor/common/src/error.rs index 4b0cd39887f60..6ad4802e57a8b 100644 --- a/client/executor/common/src/error.rs +++ b/client/executor/common/src/error.rs @@ -77,7 +77,7 @@ pub enum Error { Other(String), #[error(transparent)] - Allocator(#[from] sc_allocator_primitives::Error), + Allocator(#[from] sc_allocator::Error), #[error("Host function {0} execution failed with: {1}")] FunctionExecution(String, String), diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 9b6d71b57fa6c..2f06556644ac4 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -13,7 +13,7 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -sc-allocator-primitives = { 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 = [ - "sc-allocator-primitives/std", + "sc-allocator/std", "sp-core/std", "sp-io/std", "sp-runtime/std", diff --git a/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index 43da095183de0..facbd582c3ba0 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/client/executor/runtime-test/src/lib.rs @@ -286,9 +286,9 @@ sp_core::wasm_export_functions! { run().is_some() } - // Just some test to make sure that `sc-allocator-primitives` compiles on `no_std`. + // Just some test to make sure that `sc-allocator` compiles on `no_std`. fn test_sc_allocator_primitive_compiles() { - sc_allocator_primitives::FreeingBumpHeapAllocator::new(0); + sc_allocator::FreeingBumpHeapAllocator::new(0); } fn test_enter_span() -> u64 { diff --git a/client/executor/wasmi/Cargo.toml b/client/executor/wasmi/Cargo.toml index d96a7e752792f..dbdf26b63d247 100644 --- a/client/executor/wasmi/Cargo.toml +++ b/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-primitives = { 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-runtime-interface = { version = "3.0.0", path = "../../../primitives/runtime-interface" } sp-core = { version = "3.0.0", path = "../../../primitives/core" } diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index d44647220aa83..1bafa39494098 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/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: sc_allocator_primitives::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: sc_allocator_primitives::FreeingBumpHeapAllocator::new(heap_base), + heap: sc_allocator::FreeingBumpHeapAllocator::new(heap_base), memory: m, table: t, host_functions, diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index 5efe7e80b0cd8..bdaae49c24d59 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/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" } -sc-allocator-primitives = { version = "3.0.0", path = "../../primitives/allocator" } +sc-allocator = { version = "3.0.0", path = "../../allocator" } wasmtime = "0.27.0" [dev-dependencies] diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 813220e25dec0..3f5ac0560a6d7 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/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 sc_allocator_primitives::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/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index 87f6859c93f1c..10c4926743cf6 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -351,7 +351,7 @@ impl InstanceWrapper { /// to get more details. pub fn allocate( &self, - allocator: &mut sc_allocator_primitives::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 sc_allocator_primitives::FreeingBumpHeapAllocator, + allocator: &mut sc_allocator::FreeingBumpHeapAllocator, ptr: Pointer, ) -> Result<()> { unsafe { diff --git a/client/executor/wasmtime/src/runtime.rs b/client/executor/wasmtime/src/runtime.rs index 18a8f6d105875..021377eeb20dc 100644 --- a/client/executor/wasmtime/src/runtime.rs +++ b/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 sc_allocator_primitives::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/client/primitives/README.md b/client/primitives/README.md deleted file mode 100644 index 2dea85d2ad612..0000000000000 --- a/client/primitives/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Client Primitives - -The crates below here are primitives crates and as such only store basic types and traits. They are used by the client only (i.e. they are not used directly by pallets). diff --git a/client/primitives/chain-spec/Cargo.toml b/client/primitives/chain-spec/Cargo.toml deleted file mode 100644 index 18ecbb5e5a485..0000000000000 --- a/client/primitives/chain-spec/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "sc-chain-spec-primitives" -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/client/primitives/chain-spec/README.md b/client/primitives/chain-spec/README.md deleted file mode 100644 index 375f14a441ab6..0000000000000 --- a/client/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/client/primitives/chain-spec/src/lib.rs b/client/primitives/chain-spec/src/lib.rs deleted file mode 100644 index 5456718e351d1..0000000000000 --- a/client/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; diff --git a/client/rpc-api/Cargo.toml b/client/rpc-api/Cargo.toml index 2b4e85d42e542..87c4577c72808 100644 --- a/client/rpc-api/Cargo.toml +++ b/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"} -sc-chain-spec-primitives = { 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/client/rpc-api/src/system/helpers.rs b/client/rpc-api/src/system/helpers.rs index 7606f1b87a97e..c8124d9c67526 100644 --- a/client/rpc-api/src/system/helpers.rs +++ b/client/rpc-api/src/system/helpers.rs @@ -20,7 +20,7 @@ use std::fmt; use serde::{Serialize, Deserialize}; -use sc_chain_spec_primitives::{Properties, ChainType}; +use sc_chain_spec::{Properties, ChainType}; /// Running node's static details. #[derive(Clone, Debug)] diff --git a/client/rpc-api/src/system/mod.rs b/client/rpc-api/src/system/mod.rs index 2ada5245ca6fe..e820fb2e702e3 100644 --- a/client/rpc-api/src/system/mod.rs +++ b/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/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index eceea6b1a57af..140039cab7d4e 100644 --- a/client/rpc/Cargo.toml +++ b/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" } -sc-chain-spec-primitives = { 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/client/rpc/src/system/mod.rs b/client/rpc/src/system/mod.rs index 534832c7174a8..d405755731ccb 100644 --- a/client/rpc/src/system/mod.rs +++ b/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()) } From fa3404930433f57ec3e0953e93a2bb8c377f391f Mon Sep 17 00:00:00 2001 From: gilescope Date: Tue, 29 Jun 2021 16:01:23 +0100 Subject: [PATCH 6/8] no no_std --- client/allocator/Cargo.toml | 3 +-- client/allocator/src/error.rs | 8 ++++---- client/allocator/src/lib.rs | 1 - client/executor/runtime-test/src/lib.rs | 5 ----- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/client/allocator/Cargo.toml b/client/allocator/Cargo.toml index 535300864f1df..e2fc69e26db1c 100644 --- a/client/allocator/Cargo.toml +++ b/client/allocator/Cargo.toml @@ -18,7 +18,7 @@ sp-std = { version = "3.0.0", path = "../../primitives/std", default-features = 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/client/allocator/src/error.rs b/client/allocator/src/error.rs index 8464cd225d00e..d28484d34f4cd 100644 --- a/client/allocator/src/error.rs +++ b/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/client/allocator/src/lib.rs b/client/allocator/src/lib.rs index 7d45fb5f368c7..a82c7542199d4 100644 --- a/client/allocator/src/lib.rs +++ b/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/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index facbd582c3ba0..205ed07128c44 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/client/executor/runtime-test/src/lib.rs @@ -286,11 +286,6 @@ sp_core::wasm_export_functions! { run().is_some() } - // Just some test to make sure that `sc-allocator` compiles on `no_std`. - fn test_sc_allocator_primitive_compiles() { - sc_allocator::FreeingBumpHeapAllocator::new(0); - } - fn test_enter_span() -> u64 { wasm_tracing::enter_span(Default::default()) } From 9831f792322f14eb263b71c2ea14ded7255a0a50 Mon Sep 17 00:00:00 2001 From: gilescope Date: Tue, 29 Jun 2021 16:38:44 +0100 Subject: [PATCH 7/8] nudge --- client/executor/runtime-test/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index 205ed07128c44..568f2b13b333b 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/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 ()) { From c9127bfe8b5d7c25c562b9da2927b8830b0a6436 Mon Sep 17 00:00:00 2001 From: gilescope Date: Wed, 30 Jun 2021 08:54:12 +0100 Subject: [PATCH 8/8] Bump CI --- client/executor/runtime-test/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index 568f2b13b333b..af0c9edcc32e2 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/client/executor/runtime-test/src/lib.rs @@ -226,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);