Move client only primitives to another dir (#9220)

* Move alloc primitive (not used in /pallets)

* Move to alternative location as not shared

* moved crates to different dir

* ren sp_chain_spec to sc_chain_spec_primatives

* merged sc-chain-spec and moved allocation up one.

* no no_std

* nudge

* Bump CI
This commit is contained in:
Squirrel
2021-06-30 11:06:39 +01:00
committed by GitHub
parent b707a48737
commit d7804c0929
28 changed files with 76 additions and 134 deletions
+17 -26
View File
@@ -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"
+1 -2
View File
@@ -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",
@@ -1,5 +1,5 @@
[package]
name = "sp-allocator"
name = "sc-allocator"
version = "3.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
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",
]
@@ -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
@@ -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)
}
@@ -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 {
@@ -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;
-1
View File
@@ -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" }
+25 -1
View File
@@ -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<String, serde_json::Value>;
/// A set of traits for the runtime genesis config.
pub trait RuntimeGenesis: Serialize + DeserializeOwned + BuildStorage {}
impl<T: Serialize + DeserializeOwned + BuildStorage> RuntimeGenesis for T {}
+1 -1
View File
@@ -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" }
@@ -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),
@@ -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",
@@ -211,7 +211,6 @@ sp_core::wasm_export_functions! {
code
}
fn test_sandbox_get_global_val(code: Vec<u8>) -> 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())
}
+1 -1
View File
@@ -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" }
+2 -2
View File
@@ -40,7 +40,7 @@ use sc_executor_common::runtime_blob::{RuntimeBlob, DataSegmentsSnapshot};
struct FunctionExecutor<'a> {
sandbox_store: sandbox::Store<wasmi::FuncRef>,
heap: sp_allocator::FreeingBumpHeapAllocator,
heap: sc_allocator::FreeingBumpHeapAllocator,
memory: MemoryRef,
table: Option<TableRef>,
host_functions: &'a [&'static dyn Function],
@@ -59,7 +59,7 @@ impl<'a> FunctionExecutor<'a> {
) -> Result<Self, Error> {
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,
@@ -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]
@@ -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;
@@ -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<Pointer<u8>> {
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<u8>,
) -> Result<()> {
unsafe {
@@ -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};
+1 -1
View File
@@ -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" }
@@ -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)]
+2 -2
View File
@@ -47,11 +47,11 @@ pub trait SystemApi<Hash, Number> {
/// Get the chain's type.
#[rpc(name = "system_chainType")]
fn system_type(&self) -> SystemResult<sp_chain_spec::ChainType>;
fn system_type(&self) -> SystemResult<sc_chain_spec::ChainType>;
/// Get a custom set of properties as a JSON object, defined in the chain spec.
#[rpc(name = "system_properties")]
fn system_properties(&self) -> SystemResult<sp_chain_spec::Properties>;
fn system_properties(&self) -> SystemResult<sc_chain_spec::Properties>;
/// Return health status of the node.
///
+1 -1
View File
@@ -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" }
+2 -2
View File
@@ -106,11 +106,11 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
Ok(self.info.chain_name.clone())
}
fn system_type(&self) -> Result<sp_chain_spec::ChainType> {
fn system_type(&self) -> Result<sc_chain_spec::ChainType> {
Ok(self.info.chain_type.clone())
}
fn system_properties(&self) -> Result<sp_chain_spec::Properties> {
fn system_properties(&self) -> Result<sc_chain_spec::Properties> {
Ok(self.info.properties.clone())
}
+1 -2
View File
@@ -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<T: Config> Pallet<T> {
.collect()
}
}
@@ -1,14 +0,0 @@
[package]
name = "sp-chain-spec"
version = "3.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
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"
@@ -1,3 +0,0 @@
Types and traits related to chain specifications.
License: Apache-2.0
@@ -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<String, serde_json::Value>;