sp-std removal from substrate/primitives (#3274)

This PR removes sp-std crate from substrate/primitives sub-directories.

For now crates that have `pub use` of sp-std or export macros that would
necessitate users of the macros to `extern crate alloc` have been
excluded from this PR.

There should be no breaking changes in this PR.

---------

Co-authored-by: Koute <koute@users.noreply.github.com>
This commit is contained in:
Squirrel
2024-03-18 05:29:35 +00:00
committed by GitHub
parent 6b1179f13b
commit 1b5f4243d1
110 changed files with 254 additions and 278 deletions
Generated
-31
View File
@@ -18402,7 +18402,6 @@ dependencies = [
"scale-info",
"serde",
"sp-crypto-hashing",
"sp-std 14.0.0",
"static_assertions",
]
@@ -18444,7 +18443,6 @@ dependencies = [
"sp-api",
"sp-application-crypto",
"sp-runtime",
"sp-std 14.0.0",
]
[[package]]
@@ -18454,7 +18452,6 @@ dependencies = [
"sp-api",
"sp-inherents",
"sp-runtime",
"sp-std 14.0.0",
]
[[package]]
@@ -18501,7 +18498,6 @@ dependencies = [
"sp-consensus-slots",
"sp-inherents",
"sp-runtime",
"sp-std 14.0.0",
"sp-timestamp",
]
@@ -18519,7 +18515,6 @@ dependencies = [
"sp-core",
"sp-inherents",
"sp-runtime",
"sp-std 14.0.0",
"sp-timestamp",
]
@@ -18540,7 +18535,6 @@ dependencies = [
"sp-keystore",
"sp-mmr-primitives",
"sp-runtime",
"sp-std 14.0.0",
"strum 0.24.1",
"w3f-bls",
]
@@ -18559,7 +18553,6 @@ dependencies = [
"sp-core",
"sp-keystore",
"sp-runtime",
"sp-std 14.0.0",
]
[[package]]
@@ -18570,7 +18563,6 @@ dependencies = [
"sp-api",
"sp-core",
"sp-runtime",
"sp-std 14.0.0",
]
[[package]]
@@ -18585,7 +18577,6 @@ dependencies = [
"sp-consensus-slots",
"sp-core",
"sp-runtime",
"sp-std 14.0.0",
]
[[package]]
@@ -18595,7 +18586,6 @@ dependencies = [
"parity-scale-codec",
"scale-info",
"serde",
"sp-std 14.0.0",
"sp-timestamp",
]
@@ -18711,7 +18701,6 @@ dependencies = [
"ark-ed-on-bls12-381-bandersnatch-ext",
"ark-scale 0.0.12",
"sp-runtime-interface 24.0.0",
"sp-std 14.0.0",
]
[[package]]
@@ -18781,7 +18770,6 @@ version = "0.25.0"
dependencies = [
"environmental",
"parity-scale-codec",
"sp-std 14.0.0",
"sp-storage 19.0.0",
]
@@ -18792,7 +18780,6 @@ dependencies = [
"serde_json",
"sp-api",
"sp-runtime",
"sp-std 14.0.0",
]
[[package]]
@@ -18805,7 +18792,6 @@ dependencies = [
"parity-scale-codec",
"scale-info",
"sp-runtime",
"sp-std 14.0.0",
"thiserror",
]
@@ -18870,7 +18856,6 @@ dependencies = [
"frame-metadata",
"parity-scale-codec",
"scale-info",
"sp-std 14.0.0",
]
[[package]]
@@ -18881,7 +18866,6 @@ dependencies = [
"scale-info",
"sp-api",
"sp-application-crypto",
"sp-std 14.0.0",
]
[[package]]
@@ -18898,7 +18882,6 @@ dependencies = [
"sp-core",
"sp-debug-derive 14.0.0",
"sp-runtime",
"sp-std 14.0.0",
"thiserror",
]
@@ -18913,7 +18896,6 @@ dependencies = [
"sp-arithmetic",
"sp-core",
"sp-runtime",
"sp-std 14.0.0",
"substrate-test-utils",
]
@@ -19100,7 +19082,6 @@ dependencies = [
"sp-keystore",
"sp-runtime",
"sp-staking",
"sp-std 14.0.0",
]
[[package]]
@@ -19113,7 +19094,6 @@ dependencies = [
"serde",
"sp-core",
"sp-runtime",
"sp-std 14.0.0",
]
[[package]]
@@ -19133,7 +19113,6 @@ dependencies = [
"sp-externalities 0.25.0",
"sp-panic-handler",
"sp-runtime",
"sp-std 14.0.0",
"sp-trie",
"thiserror",
"tracing",
@@ -19159,7 +19138,6 @@ dependencies = [
"sp-externalities 0.25.0",
"sp-runtime",
"sp-runtime-interface 24.0.0",
"sp-std 14.0.0",
"thiserror",
"x25519-dalek 2.0.0",
]
@@ -19195,7 +19173,6 @@ dependencies = [
"ref-cast",
"serde",
"sp-debug-derive 14.0.0",
"sp-std 14.0.0",
]
[[package]]
@@ -19208,7 +19185,6 @@ dependencies = [
"sp-application-crypto",
"sp-core",
"sp-runtime",
"sp-std 14.0.0",
]
[[package]]
@@ -19219,7 +19195,6 @@ dependencies = [
"parity-scale-codec",
"sp-inherents",
"sp-runtime",
"sp-std 14.0.0",
"thiserror",
]
@@ -19240,7 +19215,6 @@ name = "sp-tracing"
version = "16.0.0"
dependencies = [
"parity-scale-codec",
"sp-std 14.0.0",
"tracing",
"tracing-core",
"tracing-subscriber 0.2.25",
@@ -19264,7 +19238,6 @@ dependencies = [
"sp-core",
"sp-inherents",
"sp-runtime",
"sp-std 14.0.0",
"sp-trie",
]
@@ -19287,7 +19260,6 @@ dependencies = [
"sp-core",
"sp-externalities 0.25.0",
"sp-runtime",
"sp-std 14.0.0",
"thiserror",
"tracing",
"trie-bench",
@@ -19344,7 +19316,6 @@ dependencies = [
"impl-trait-for-tuples",
"log",
"parity-scale-codec",
"sp-std 14.0.0",
"wasmtime",
]
@@ -19360,7 +19331,6 @@ dependencies = [
"smallvec",
"sp-arithmetic",
"sp-debug-derive 14.0.0",
"sp-std 14.0.0",
]
[[package]]
@@ -19971,7 +19941,6 @@ dependencies = [
"sp-runtime",
"sp-session",
"sp-state-machine",
"sp-std 14.0.0",
"sp-tracing 16.0.0",
"sp-transaction-pool",
"sp-trie",
@@ -26,7 +26,6 @@ num-traits = { version = "0.2.17", default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
serde = { features = ["alloc", "derive"], optional = true, workspace = true }
static_assertions = "1.1.0"
sp-std = { path = "../std", default-features = false }
[dev-dependencies]
criterion = "0.4.0"
@@ -42,7 +41,6 @@ std = [
"scale-info/std",
"serde/std",
"sp-crypto-hashing/std",
"sp-std/std",
]
# Serde support without relying on std features.
serde = ["dep:serde", "scale-info/serde"]
@@ -17,9 +17,10 @@
//! Infinite precision unsigned integer for substrate runtime.
use alloc::{vec, vec::Vec};
use codec::{Decode, Encode};
use core::{cell::RefCell, cmp::Ordering, ops};
use num_traits::{One, Zero};
use sp_std::{cell::RefCell, cmp::Ordering, ops, prelude::*, vec};
// A sensible value for this would be half of the dword size of the host machine. Since the
// runtime is compiled to 32bit webassembly, using 32 and 64 for single and double respectively
@@ -35,7 +36,7 @@ const SHIFT: usize = 32;
const B: Double = Single::max_value() as Double + 1;
static_assertions::const_assert!(
sp_std::mem::size_of::<Double>() - sp_std::mem::size_of::<Single>() == SHIFT / 8
core::mem::size_of::<Double>() - core::mem::size_of::<Single>() == SHIFT / 8
);
/// Splits a [`Double`] limb number into a tuple of two [`Single`] limb numbers.
@@ -438,9 +439,9 @@ impl BigUint {
}
}
impl sp_std::fmt::Debug for BigUint {
impl core::fmt::Debug for BigUint {
#[cfg(feature = "std")]
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(
f,
"BigUint {{ {:?} ({:?})}}",
@@ -450,7 +451,7 @@ impl sp_std::fmt::Debug for BigUint {
}
#[cfg(not(feature = "std"))]
fn fmt(&self, _: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
fn fmt(&self, _: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Ok(())
}
}
@@ -26,17 +26,16 @@ use crate::{
PerThing, Perbill, Rounding, SignedRounding,
};
use codec::{CompactAs, Decode, Encode};
use sp_std::{
use core::{
fmt::Debug,
ops::{self, Add, Div, Mul, Sub},
prelude::*,
};
#[cfg(feature = "serde")]
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
#[cfg(all(not(feature = "std"), feature = "serde"))]
use sp_std::alloc::string::{String, ToString};
use alloc::string::{String, ToString};
/// Integer types that can be used to interact with `FixedPointNumber` implementations.
pub trait FixedPointOperand:
@@ -899,9 +898,9 @@ macro_rules! implement_fixed {
}
}
impl sp_std::fmt::Debug for $name {
impl ::core::fmt::Debug for $name {
#[cfg(feature = "std")]
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let integral = {
let int = self.0 / Self::accuracy();
let signum_for_zero = if int == 0 && self.is_negative() { "-" } else { "" };
@@ -917,7 +916,7 @@ macro_rules! implement_fixed {
}
#[cfg(not(feature = "std"))]
fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
fn fmt(&self, _: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
Ok(())
}
}
@@ -933,13 +932,13 @@ macro_rules! implement_fixed {
}
}
impl sp_std::fmt::Display for $name {
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
impl ::core::fmt::Display for $name {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
write!(f, "{}", self.0)
}
}
impl sp_std::str::FromStr for $name {
impl ::core::str::FromStr for $name {
type Err = &'static str;
fn from_str(s: &str) -> Result<Self, Self::Err> {
@@ -969,7 +968,7 @@ macro_rules! implement_fixed {
where
D: Deserializer<'de>,
{
use sp_std::str::FromStr;
use ::core::str::FromStr;
let s = String::deserialize(deserializer)?;
$name::from_str(&s).map_err(de::Error::custom)
}
+5 -2
View File
@@ -19,6 +19,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
/// Copied from `sp-runtime` and documented there.
#[macro_export]
macro_rules! assert_eq_error_rate {
@@ -49,7 +51,8 @@ pub use per_things::{
};
pub use rational::{MultiplyRational, Rational128, RationalInfinite};
use sp_std::{cmp::Ordering, fmt::Debug, prelude::*};
use alloc::vec::Vec;
use core::{cmp::Ordering, fmt::Debug};
use traits::{BaseArithmetic, One, SaturatedConversion, Unsigned, Zero};
use codec::{Decode, Encode, MaxEncodedLen};
@@ -429,7 +432,7 @@ mod normalize_tests {
mod threshold_compare_tests {
use super::*;
use crate::traits::Saturating;
use sp_std::cmp::Ordering;
use core::cmp::Ordering;
#[test]
fn epsilon_ord_works() {
@@ -23,12 +23,11 @@ use crate::traits::{
Saturating, UniqueSaturatedInto, Unsigned, Zero,
};
use codec::{CompactAs, Encode};
use num_traits::{Pow, SaturatingAdd, SaturatingSub};
use sp_std::{
use core::{
fmt, ops,
ops::{Add, Sub},
prelude::*,
};
use num_traits::{Pow, SaturatingAdd, SaturatingSub};
/// Get the inner type of a `PerThing`.
pub type InnerOf<P> = <P as PerThing>::Inner;
@@ -414,7 +413,7 @@ pub trait PerThing:
}
/// The rounding method to use for unsigned quantities.
#[derive(Copy, Clone, sp_std::fmt::Debug)]
#[derive(Copy, Clone, core::fmt::Debug)]
pub enum Rounding {
// Towards infinity.
Up,
@@ -427,7 +426,7 @@ pub enum Rounding {
}
/// The rounding method to use.
#[derive(Copy, Clone, sp_std::fmt::Debug)]
#[derive(Copy, Clone, core::fmt::Debug)]
pub enum SignedRounding {
// Towards positive infinity.
High,
@@ -580,8 +579,8 @@ macro_rules! implement_per_thing {
}
#[cfg(feature = "std")]
impl sp_std::fmt::Debug for $name {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
impl core::fmt::Debug for $name {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
if $max == <$type>::max_value() {
// Not a power of ten: show as N/D and approx %
let pc = (self.0 as f64) / (self.0 as f64) * 100f64;
@@ -606,8 +605,8 @@ macro_rules! implement_per_thing {
}
#[cfg(not(feature = "std"))]
impl sp_std::fmt::Debug for $name {
fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
impl core::fmt::Debug for $name {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
if $max == <$type>::max_value() {
// Not a power of ten: show as N/D and approx %
write!(fmt, "{}/{}", self.0, $max)
@@ -16,8 +16,8 @@
// limitations under the License.
use crate::{biguint::BigUint, helpers_128bit, Rounding};
use core::cmp::Ordering;
use num_traits::{Bounded, One, Zero};
use sp_std::{cmp::Ordering, prelude::*};
/// A wrapper for any rational number with infinitely large numerator and denominator.
///
@@ -92,15 +92,15 @@ impl From<Rational128> for RationalInfinite {
pub struct Rational128(u128, u128);
#[cfg(feature = "std")]
impl sp_std::fmt::Debug for Rational128 {
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
impl core::fmt::Debug for Rational128 {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "Rational128({} / {} ≈ {:.8})", self.0, self.1, self.0 as f64 / self.1 as f64)
}
}
#[cfg(not(feature = "std"))]
impl sp_std::fmt::Debug for Rational128 {
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
impl core::fmt::Debug for Rational128 {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "Rational128({} / {})", self.0, self.1)
}
}
@@ -21,7 +21,6 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive
sp-api = { path = "../api", default-features = false }
sp-application-crypto = { path = "../application-crypto", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
sp-std = { path = "../std", default-features = false }
[features]
default = ["std"]
@@ -31,7 +30,6 @@ std = [
"sp-api/std",
"sp-application-crypto/std",
"sp-runtime/std",
"sp-std/std",
]
serde = [
"scale-info/serde",
@@ -19,7 +19,9 @@
#![cfg_attr(not(feature = "std"), no_std)]
use sp_std::vec::Vec;
extern crate alloc;
use alloc::vec::Vec;
mod app {
use sp_application_crypto::{app_crypto, key_types::AUTHORITY_DISCOVERY, sr25519};
@@ -19,8 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"]
sp-api = { path = "../api", default-features = false }
sp-inherents = { path = "../inherents", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
sp-std = { path = "../std", default-features = false }
[features]
default = ["std"]
std = ["sp-api/std", "sp-inherents/std", "sp-runtime/std", "sp-std/std"]
std = ["sp-api/std", "sp-inherents/std", "sp-runtime/std"]
@@ -19,6 +19,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use sp_inherents::{CheckInherentsResult, InherentData};
use sp_runtime::{traits::Block as BlockT, ApplyExtrinsicResult};
@@ -44,7 +46,7 @@ sp_api::decl_runtime_apis! {
/// Generate inherent extrinsics. The inherent data will vary from chain to chain.
fn inherent_extrinsics(
inherent: InherentData,
) -> sp_std::vec::Vec<<Block as BlockT>::Extrinsic>;
) -> alloc::vec::Vec<<Block as BlockT>::Extrinsic>;
/// Check that the inherents are valid. The inherent data will vary from chain to chain.
fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult;
@@ -24,7 +24,6 @@ sp-application-crypto = { path = "../../application-crypto", default-features =
sp-consensus-slots = { path = "../slots", default-features = false }
sp-inherents = { path = "../../inherents", default-features = false }
sp-runtime = { path = "../../runtime", default-features = false }
sp-std = { path = "../../std", default-features = false }
sp-timestamp = { path = "../../timestamp", default-features = false }
[features]
@@ -38,7 +37,6 @@ std = [
"sp-consensus-slots/std",
"sp-inherents/std",
"sp-runtime/std",
"sp-std/std",
"sp-timestamp/std",
]
@@ -19,9 +19,11 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use alloc::vec::Vec;
use codec::{Codec, Decode, Encode};
use sp_runtime::ConsensusEngineId;
use sp_std::vec::Vec;
pub mod digests;
pub mod inherents;
@@ -26,7 +26,6 @@ sp-consensus-slots = { path = "../slots", default-features = false }
sp-core = { path = "../../core", default-features = false }
sp-inherents = { path = "../../inherents", default-features = false }
sp-runtime = { path = "../../runtime", default-features = false }
sp-std = { path = "../../std", default-features = false }
sp-timestamp = { path = "../../timestamp", optional = true }
[features]
@@ -42,7 +41,6 @@ std = [
"sp-core/std",
"sp-inherents/std",
"sp-runtime/std",
"sp-std/std",
"sp-timestamp/std",
]
@@ -22,9 +22,10 @@ use super::{
BabeEpochConfiguration, Randomness, Slot, BABE_ENGINE_ID,
};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use sp_core::sr25519::vrf::VrfSignature;
use sp_runtime::{DigestItem, RuntimeDebug};
use sp_std::vec::Vec;
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
@@ -20,15 +20,18 @@
#![forbid(unsafe_code, missing_docs, unused_variables, unused_imports)]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
pub mod digests;
pub mod inherents;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use sp_runtime::{traits::Header, ConsensusEngineId, RuntimeDebug};
use sp_std::vec::Vec;
use crate::digests::{NextConfigDescriptor, NextEpochDescriptor};
@@ -26,7 +26,6 @@ sp-io = { path = "../../io", default-features = false }
sp-mmr-primitives = { path = "../../merkle-mountain-range", default-features = false }
sp-runtime = { path = "../../runtime", default-features = false }
sp-keystore = { path = "../../keystore", default-features = false }
sp-std = { path = "../../std", default-features = false }
strum = { version = "0.24.1", features = ["derive"], default-features = false }
lazy_static = { version = "1.4.0", optional = true }
@@ -49,7 +48,6 @@ std = [
"sp-keystore/std",
"sp-mmr-primitives/std",
"sp-runtime/std",
"sp-std/std",
"strum/std",
]
@@ -15,9 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use alloc::{vec, vec::Vec};
use codec::{Decode, Encode, Error, Input};
use core::cmp;
use scale_info::TypeInfo;
use sp_std::{cmp, prelude::*};
use crate::{Payload, ValidatorSetId};
@@ -97,10 +98,10 @@ pub struct SignedCommitment<TBlockNumber, TSignature> {
pub signatures: Vec<Option<TSignature>>,
}
impl<TBlockNumber: sp_std::fmt::Debug, TSignature> sp_std::fmt::Display
impl<TBlockNumber: core::fmt::Debug, TSignature> core::fmt::Display
for SignedCommitment<TBlockNumber, TSignature>
{
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let signatures_count = self.signatures.iter().filter(|s| s.is_some()).count();
write!(
f,
@@ -254,8 +255,8 @@ pub enum VersionedFinalityProof<N, S> {
V1(SignedCommitment<N, S>),
}
impl<N: sp_std::fmt::Debug, S> sp_std::fmt::Display for VersionedFinalityProof<N, S> {
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
impl<N: core::fmt::Debug, S> core::fmt::Display for VersionedFinalityProof<N, S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
VersionedFinalityProof::V1(sc) => write!(f, "VersionedFinalityProof::V1({})", sc),
}
@@ -31,6 +31,8 @@
//! it will use a different set of keys. For Polkadot use case we plan to use `secp256k1` for BEEFY,
//! while GRANDPA uses `ed25519`.
extern crate alloc;
mod commitment;
mod payload;
@@ -44,13 +46,13 @@ pub mod test_utils;
pub use commitment::{Commitment, SignedCommitment, VersionedFinalityProof};
pub use payload::{known_payloads, BeefyPayloadId, Payload, PayloadProvider};
use alloc::vec::Vec;
use codec::{Codec, Decode, Encode};
use core::fmt::{Debug, Display};
use scale_info::TypeInfo;
use sp_application_crypto::{AppCrypto, AppPublic, ByteArray, RuntimeAppPublic};
use sp_core::H256;
use sp_runtime::traits::{Hash, Keccak256, NumberFor};
use sp_std::prelude::*;
/// Key type for BEEFY module.
pub const KEY_TYPE: sp_core::crypto::KeyTypeId = sp_application_crypto::key_types::BEEFY;
@@ -26,7 +26,8 @@
//! but we imagine they will be useful for other chains that either want to bridge with Polkadot
//! or are completely standalone, but heavily inspired by Polkadot.
use crate::{ecdsa_crypto::AuthorityId, ConsensusLog, MmrRootHash, Vec, BEEFY_ENGINE_ID};
use crate::{ecdsa_crypto::AuthorityId, ConsensusLog, MmrRootHash, BEEFY_ENGINE_ID};
use alloc::vec::Vec;
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{
@@ -150,10 +151,11 @@ pub use mmr_root_provider::MmrRootProvider;
mod mmr_root_provider {
use super::*;
use crate::{known_payloads, payload::PayloadProvider, Payload};
use alloc::sync::Arc;
use core::marker::PhantomData;
use sp_api::ProvideRuntimeApi;
use sp_mmr_primitives::MmrApi;
use sp_runtime::traits::NumberFor;
use sp_std::{marker::PhantomData, sync::Arc};
/// A [`crate::Payload`] provider where payload is Merkle Mountain Range root hash.
///
@@ -15,10 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use alloc::{vec, vec::Vec};
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_runtime::traits::Block;
use sp_std::prelude::*;
/// Id of different payloads in the [`crate::Commitment`] data.
pub type BeefyPayloadId = [u8; 2];
@@ -23,9 +23,8 @@
//! verification. This allows lowering the data and computation cost of verifying the
//! signed commitment.
use sp_std::prelude::*;
use crate::commitment::{Commitment, SignedCommitment};
use alloc::vec::Vec;
/// A light form of [SignedCommitment].
///
@@ -27,7 +27,6 @@ sp-application-crypto = { path = "../../application-crypto", default-features =
sp-core = { path = "../../core", default-features = false }
sp-keystore = { path = "../../keystore", default-features = false, optional = true }
sp-runtime = { path = "../../runtime", default-features = false }
sp-std = { path = "../../std", default-features = false }
[features]
default = ["std"]
@@ -42,7 +41,6 @@ std = [
"sp-core/std",
"sp-keystore/std",
"sp-runtime/std",
"sp-std/std",
]
# Serde support without relying on std features.
@@ -19,9 +19,12 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
#[cfg(feature = "serde")]
use serde::Serialize;
use alloc::vec::Vec;
use codec::{Codec, Decode, Encode};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
@@ -30,7 +33,6 @@ use sp_runtime::{
traits::{Header as HeaderT, NumberFor},
ConsensusEngineId, RuntimeDebug,
};
use sp_std::vec::Vec;
/// The log target to be used by client code.
pub const CLIENT_LOG_TARGET: &str = "grandpa";
@@ -20,7 +20,6 @@ codec = { package = "parity-scale-codec", version = "3.6.1", default-features =
sp-api = { path = "../../api", default-features = false }
sp-core = { path = "../../core", default-features = false }
sp-runtime = { path = "../../runtime", default-features = false }
sp-std = { path = "../../std", default-features = false }
[features]
default = ["std"]
@@ -29,5 +28,4 @@ std = [
"sp-api/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
]
@@ -19,9 +19,12 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use codec::Decode;
use sp_runtime::ConsensusEngineId;
use sp_std::vec::Vec;
/// The `ConsensusEngineId` of PoW.
pub const POW_ENGINE_ID: ConsensusEngineId = [b'p', b'o', b'w', b'_'];
@@ -26,7 +26,6 @@ sp-application-crypto = { path = "../../application-crypto", default-features =
sp-consensus-slots = { path = "../slots", default-features = false }
sp-core = { path = "../../core", default-features = false, features = ["bandersnatch-experimental"] }
sp-runtime = { path = "../../runtime", default-features = false }
sp-std = { path = "../../std", default-features = false }
[features]
default = ["std"]
@@ -39,7 +38,6 @@ std = [
"sp-consensus-slots/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
]
# Serde support without relying on std features.
@@ -25,8 +25,9 @@ use crate::{
use scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use sp_runtime::{DigestItem, RuntimeDebug};
use sp_std::vec::Vec;
/// Epoch slot claim digest entry.
///
@@ -21,11 +21,13 @@
#![forbid(unsafe_code, missing_docs, unused_variables, unused_imports)]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use alloc::vec::Vec;
use scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::crypto::KeyTypeId;
use sp_runtime::{ConsensusEngineId, RuntimeDebug};
use sp_std::vec::Vec;
pub use sp_consensus_slots::{Slot, SlotDuration};
@@ -18,9 +18,10 @@
//! Utilities related to VRF input, pre-output and signatures.
use crate::{Randomness, TicketBody, TicketId};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use scale_codec::Encode;
use sp_consensus_slots::Slot;
use sp_std::vec::Vec;
pub use sp_core::bandersnatch::{
ring_vrf::{RingProver, RingVerifier, RingVerifierData, RingVrfSignature},
@@ -19,7 +19,6 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
serde = { features = ["alloc", "derive"], optional = true, workspace = true }
sp-std = { path = "../../std", default-features = false }
sp-timestamp = { path = "../../timestamp", default-features = false }
[features]
@@ -28,7 +27,6 @@ std = [
"codec/std",
"scale-info/std",
"serde/std",
"sp-std/std",
"sp-timestamp/std",
]
@@ -28,7 +28,6 @@ ark-ed-on-bls12-377-ext = { version = "0.4.1", default-features = false, optiona
ark-ed-on-bls12-377 = { version = "0.4.0", default-features = false, optional = true }
ark-scale = { version = "0.0.12", default-features = false, features = ["hazmat"], optional = true }
sp-runtime-interface = { path = "../../runtime-interface", default-features = false, optional = true }
sp-std = { path = "../../std", default-features = false, optional = true }
[features]
default = ["std"]
@@ -47,9 +46,8 @@ std = [
"ark-ed-on-bls12-381-bandersnatch?/std",
"ark-scale?/std",
"sp-runtime-interface?/std",
"sp-std?/std",
]
common = ["ark-ec", "ark-scale", "sp-runtime-interface", "sp-std"]
common = ["ark-ec", "ark-scale", "sp-runtime-interface"]
bls12-377 = ["ark-bls12-377", "ark-bls12-377-ext", "common"]
bls12-381 = ["ark-bls12-381", "ark-bls12-381-ext", "common"]
bw6-761 = ["ark-bw6-761", "ark-bw6-761-ext", "common"]
@@ -18,10 +18,10 @@
//! *BLS12-377* types and host functions.
use crate::utils;
use alloc::vec::Vec;
use ark_bls12_377_ext::CurveHooks;
use ark_ec::{pairing::Pairing, CurveConfig};
use sp_runtime_interface::runtime_interface;
use sp_std::vec::Vec;
/// First pairing group definitions.
pub mod g1 {
@@ -18,10 +18,10 @@
//! *BLS12-381* types and host functions.
use crate::utils;
use alloc::vec::Vec;
use ark_bls12_381_ext::CurveHooks;
use ark_ec::{pairing::Pairing, CurveConfig};
use sp_runtime_interface::runtime_interface;
use sp_std::vec::Vec;
/// First pairing group definitions.
pub mod g1 {
@@ -18,10 +18,10 @@
//! *BW6-761* types and host functions.
use crate::utils;
use alloc::vec::Vec;
use ark_bw6_761_ext::CurveHooks;
use ark_ec::{pairing::Pairing, CurveConfig};
use sp_runtime_interface::runtime_interface;
use sp_std::vec::Vec;
/// First pairing group definitions.
pub mod g1 {
@@ -18,10 +18,10 @@
//! *Ed-on-BLS12-377* types and host functions.
use crate::utils;
use alloc::vec::Vec;
use ark_ec::CurveConfig;
use ark_ed_on_bls12_377_ext::CurveHooks;
use sp_runtime_interface::runtime_interface;
use sp_std::vec::Vec;
/// Curve hooks jumping into [`host_calls`] host functions.
#[derive(Copy, Clone)]
@@ -19,10 +19,10 @@
//! computationally expensive operations.
use crate::utils;
use alloc::vec::Vec;
use ark_ec::CurveConfig;
use ark_ed_on_bls12_381_bandersnatch_ext::CurveHooks;
use sp_runtime_interface::runtime_interface;
use sp_std::vec::Vec;
/// Curve hooks jumping into [`host_calls`] host functions.
#[derive(Copy, Clone)]
@@ -32,6 +32,8 @@
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
#[cfg(feature = "bls12-377")]
pub mod bls12_377;
#[cfg(feature = "bls12-381")]
@@ -21,6 +21,7 @@
// curve may be excluded by the build we resort to `#[allow(unused)]` to
// suppress the expected warning.
use alloc::vec::Vec;
use ark_ec::{
pairing::{MillerLoopOutput, Pairing},
short_weierstrass::{Affine as SWAffine, Projective as SWProjective, SWCurveConfig},
@@ -31,7 +32,6 @@ use ark_scale::{
ark_serialize::{CanonicalDeserialize, CanonicalSerialize, Compress, Validate},
scale::{Decode, Encode},
};
use sp_std::vec::Vec;
// SCALE encoding parameters shared by all the enabled modules
const SCALE_USAGE: u8 = ark_scale::make_usage(Compress::No, Validate::No);
@@ -19,9 +19,8 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false }
environmental = { version = "1.1.3", default-features = false }
sp-std = { path = "../std", default-features = false }
sp-storage = { path = "../storage", default-features = false }
[features]
default = ["std"]
std = ["codec/std", "environmental/std", "sp-std/std", "sp-storage/std"]
std = ["codec/std", "environmental/std", "sp-storage/std"]
@@ -23,10 +23,12 @@
//! It is required that each extension implements the [`Extension`] trait.
use crate::Error;
use sp_std::{
any::{Any, TypeId},
use alloc::{
boxed::Box,
collections::btree_map::{BTreeMap, Entry},
};
use core::{
any::{Any, TypeId},
ops::DerefMut,
};
@@ -25,11 +25,10 @@
//!
//! This crate exposes the main [`Externalities`] trait.
use sp_std::{
any::{Any, TypeId},
boxed::Box,
vec::Vec,
};
extern crate alloc;
use alloc::{boxed::Box, vec::Vec};
use core::any::{Any, TypeId};
use sp_storage::{ChildInfo, StateVersion, TrackedStorageKey};
@@ -18,9 +18,8 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-api = { path = "../api", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
sp-std = { path = "../std", default-features = false }
serde_json = { features = ["alloc", "arbitrary_precision"], workspace = true }
[features]
default = ["std"]
std = ["serde_json/std", "sp-api/std", "sp-runtime/std", "sp-std/std"]
std = ["serde_json/std", "sp-api/std", "sp-runtime/std"]
@@ -31,6 +31,8 @@
//! allows to catch and build the raw storage of `RuntimeGenesisConfig` which is the foundation for
//! genesis block.
extern crate alloc;
/// The result type alias, used in build methods. `Err` contains formatted error message.
pub type Result = core::result::Result<(), sp_runtime::RuntimeString>;
@@ -41,7 +43,7 @@ sp_api::decl_runtime_apis! {
///
/// This function instantiates the default `RuntimeGenesisConfig` struct for the runtime and serializes it into a JSON
/// blob. It returns a `Vec<u8>` containing the JSON representation of the default `RuntimeGenesisConfig`.
fn create_default_config() -> sp_std::vec::Vec<u8>;
fn create_default_config() -> alloc::vec::Vec<u8>;
/// Build `RuntimeGenesisConfig` from a JSON blob not using any defaults and store it in the storage.
///
@@ -50,6 +52,6 @@ sp_api::decl_runtime_apis! {
/// It is recommended to log any errors encountered during the process.
///
/// Please note that provided json blob must contain all `RuntimeGenesisConfig` fields, no defaults will be used.
fn build_config(json: sp_std::vec::Vec<u8>) -> Result;
fn build_config(json: alloc::vec::Vec<u8>) -> Result;
}
}
@@ -23,7 +23,6 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive
impl-trait-for-tuples = "0.2.2"
thiserror = { optional = true, workspace = true }
sp-runtime = { path = "../runtime", default-features = false, optional = true }
sp-std = { path = "../std", default-features = false }
[dev-dependencies]
futures = "0.3.21"
@@ -35,6 +34,5 @@ std = [
"codec/std",
"scale-info/std",
"sp-runtime/std",
"sp-std/std",
"thiserror",
]
+3 -1
View File
@@ -162,9 +162,11 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
extern crate alloc;
use codec::{Decode, Encode};
use sp_std::{
use alloc::{
collections::btree_map::{BTreeMap, Entry, IntoIter},
vec::Vec,
};
@@ -24,7 +24,6 @@ sp-api = { path = "../api", default-features = false }
sp-core = { path = "../core", default-features = false }
sp-debug-derive = { path = "../debug-derive", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
sp-std = { path = "../std", default-features = false }
thiserror = { optional = true, workspace = true }
[dev-dependencies]
@@ -43,7 +42,6 @@ std = [
"sp-core/std",
"sp-debug-derive/std",
"sp-runtime/std",
"sp-std/std",
]
# Serde support without relying on std features.
@@ -20,14 +20,16 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
extern crate alloc;
pub use mmr_lib;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::fmt;
use scale_info::TypeInfo;
use sp_debug_derive::RuntimeDebug;
use sp_runtime::traits;
use sp_std::fmt;
#[cfg(not(feature = "std"))]
use sp_std::prelude::Vec;
pub mod utils;
@@ -248,10 +250,10 @@ impl<H: traits::Hash, L: FullLeaf> DataOrHash<H, L> {
pub struct Compact<H, T> {
/// Internal tuple representation.
pub tuple: T,
_hash: sp_std::marker::PhantomData<H>,
_hash: core::marker::PhantomData<H>,
}
impl<H, T> sp_std::ops::Deref for Compact<H, T> {
impl<H, T> core::ops::Deref for Compact<H, T> {
type Target = T;
fn deref(&self) -> &Self::Target {
@@ -20,9 +20,9 @@
use codec::Encode;
use mmr_lib::helper;
use sp_runtime::traits::{CheckedAdd, CheckedSub, Header, One};
#[cfg(not(feature = "std"))]
use sp_std::prelude::Vec;
use alloc::vec::Vec;
use sp_runtime::traits::{CheckedAdd, CheckedSub, Header, One};
use crate::{Error, LeafIndex, NodeIndex};
@@ -131,7 +131,7 @@ impl NodesUtils {
/// Used for nodes added by now finalized blocks.
/// Never read keys using `node_canon_offchain_key` unless you sure that
/// there's no `node_offchain_key` key in the storage.
pub fn node_canon_offchain_key(prefix: &[u8], pos: NodeIndex) -> sp_std::prelude::Vec<u8> {
pub fn node_canon_offchain_key(prefix: &[u8], pos: NodeIndex) -> alloc::vec::Vec<u8> {
(prefix, pos).encode()
}
}
+1 -2
View File
@@ -19,8 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false }
frame-metadata = { version = "16.0.0", default-features = false, features = ["current"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
sp-std = { path = "../std", default-features = false }
[features]
default = ["std"]
std = ["codec/std", "frame-metadata/std", "scale-info/std", "sp-std/std"]
std = ["codec/std", "frame-metadata/std", "scale-info/std"]
+4 -2
View File
@@ -20,6 +20,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
extern crate alloc;
// Re-export.
#[doc(hidden)]
pub use frame_metadata;
@@ -52,8 +54,8 @@ pub fn into_version(metadata: MetadataIR, version: u32) -> Option<RuntimeMetadat
}
/// Returns the supported metadata versions.
pub fn supported_versions() -> sp_std::vec::Vec<u32> {
sp_std::vec![V14, V15]
pub fn supported_versions() -> alloc::vec::Vec<u32> {
alloc::vec![V14, V15]
}
/// Transform the IR to the latest stable metadata version.
-2
View File
@@ -20,7 +20,6 @@ codec = { package = "parity-scale-codec", version = "3.6.1", default-features =
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
sp-api = { default-features = false, path = "../api" }
sp-application-crypto = { default-features = false, path = "../application-crypto" }
sp-std = { default-features = false, path = "../std" }
[features]
default = ["std"]
@@ -29,5 +28,4 @@ std = [
"scale-info/std",
"sp-api/std",
"sp-application-crypto/std",
"sp-std/std",
]
+2
View File
@@ -20,5 +20,7 @@
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
pub mod runtime_api;
pub mod types;
@@ -18,7 +18,7 @@
//! Runtime API for querying mixnet configuration and registering mixnodes.
use super::types::{Mixnode, MixnodesErr, SessionIndex, SessionStatus};
use sp_std::vec::Vec;
use alloc::vec::Vec;
sp_api::decl_runtime_apis! {
/// API to query the mixnet session status and mixnode sets, and to register mixnodes.
+3 -3
View File
@@ -17,9 +17,9 @@
//! Mixnet types used by both host and runtime.
use alloc::vec::Vec;
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_std::vec::Vec;
mod app {
use sp_application_crypto::{app_crypto, key_types::MIXNET, sr25519};
@@ -90,8 +90,8 @@ pub enum MixnodesErr {
},
}
impl sp_std::fmt::Display for MixnodesErr {
fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
impl core::fmt::Display for MixnodesErr {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
MixnodesErr::InsufficientRegistrations { num, min } =>
write!(fmt, "{num} mixnode(s) registered; {min} is the minimum"),
@@ -22,7 +22,6 @@ serde = { features = ["alloc", "derive"], optional = true, workspace = true }
sp-arithmetic = { path = "../arithmetic", default-features = false }
sp-core = { path = "../core", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
sp-std = { path = "../std", default-features = false }
[dev-dependencies]
rand = "0.8.5"
@@ -38,7 +37,6 @@ std = [
"sp-arithmetic/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
]
# Serde support without relying on std features.
@@ -18,6 +18,7 @@
//! Structs and helpers for distributing a voter's stake among various winners.
use crate::{ExtendedBalance, IdentifierT, PerThing128};
use alloc::vec::Vec;
#[cfg(feature = "serde")]
use codec::{Decode, Encode};
use sp_arithmetic::{
@@ -25,7 +26,6 @@ use sp_arithmetic::{
Normalizable, PerThing,
};
use sp_core::RuntimeDebug;
use sp_std::vec::Vec;
/// A voter's stake assignment among a set of targets, represented as ratios.
#[derive(RuntimeDebug, Clone, Default)]
@@ -27,8 +27,8 @@
//! See [`balance`] for more information.
use crate::{BalancingConfig, Edge, ExtendedBalance, IdentifierT, Voter};
use alloc::vec::Vec;
use sp_arithmetic::traits::Zero;
use sp_std::prelude::*;
/// Balance the weight distribution of a given `voters` at most `iterations` times, or up until the
/// point where the biggest difference created per iteration of all stakes is `tolerance`. If this
@@ -18,8 +18,8 @@
//! Helper methods for npos-elections.
use crate::{Assignment, Error, IdentifierT, PerThing128, StakedAssignment, VoteWeight};
use alloc::vec::Vec;
use sp_arithmetic::PerThing;
use sp_std::prelude::*;
/// Converts a vector of ratio assignments into ones with absolute budget value.
///
@@ -74,15 +74,16 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use alloc::{collections::btree_map::BTreeMap, rc::Rc, vec, vec::Vec};
use codec::{Decode, Encode, MaxEncodedLen};
use core::{cell::RefCell, cmp::Ordering};
use scale_info::TypeInfo;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use sp_arithmetic::{traits::Zero, Normalizable, PerThing, Rational128, ThresholdOrd};
use sp_core::{bounded::BoundedVec, RuntimeDebug};
use sp_std::{
cell::RefCell, cmp::Ordering, collections::btree_map::BTreeMap, prelude::*, rc::Rc, vec,
};
#[cfg(test)]
mod mock;
@@ -198,7 +199,7 @@ impl ElectionScore {
}
}
impl sp_std::cmp::Ord for ElectionScore {
impl core::cmp::Ord for ElectionScore {
fn cmp(&self, other: &Self) -> Ordering {
// we delegate this to the lexicographic cmp of slices`, and to incorporate that we want the
// third element to be minimized, we swap them.
@@ -210,7 +211,7 @@ impl sp_std::cmp::Ord for ElectionScore {
}
}
impl sp_std::cmp::PartialOrd for ElectionScore {
impl core::cmp::PartialOrd for ElectionScore {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
@@ -278,8 +279,8 @@ impl<AccountId: Clone> Edge<AccountId> {
}
#[cfg(feature = "std")]
impl<A: IdentifierT> sp_std::fmt::Debug for Edge<A> {
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
impl<A: IdentifierT> core::fmt::Debug for Edge<A> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "Edge({:?}, weight = {:?})", self.who, self.weight)
}
}
@@ -299,7 +300,7 @@ pub struct Voter<AccountId> {
#[cfg(feature = "std")]
impl<A: IdentifierT> std::fmt::Debug for Voter<A> {
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Voter({:?}, budget = {}, edges = {:?})", self.who, self.budget, self.edges)
}
}
@@ -19,12 +19,12 @@
#![cfg(test)]
use alloc::collections::btree_map::BTreeMap;
use sp_arithmetic::{
traits::{One, SaturatedConversion, Zero},
PerThing,
};
use sp_runtime::assert_eq_error_rate;
use sp_std::collections::btree_map::BTreeMap;
use crate::{seq_phragmen, Assignment, ElectionResult, ExtendedBalance, PerThing128, VoteWeight};
@@ -131,7 +131,7 @@ where
if let Some(winner) = candidates
.iter_mut()
.filter(|c| !c.elected)
.min_by(|x, y| x.score.partial_cmp(&y.score).unwrap_or(sp_std::cmp::Ordering::Equal))
.min_by(|x, y| x.score.partial_cmp(&y.score).unwrap_or(core::cmp::Ordering::Equal))
{
winner.elected = true;
for n in &mut voters {
@@ -226,10 +226,10 @@ where
if backing_backed_stake.len() > 0 {
let max_stake = backing_backed_stake
.iter()
.max_by(|x, y| x.partial_cmp(&y).unwrap_or(sp_std::cmp::Ordering::Equal))
.max_by(|x, y| x.partial_cmp(&y).unwrap_or(core::cmp::Ordering::Equal))
.expect("vector with positive length will have a max; qed");
let min_stake = backed_stakes_iter
.min_by(|x, y| x.partial_cmp(&y).unwrap_or(sp_std::cmp::Ordering::Equal))
.min_by(|x, y| x.partial_cmp(&y).unwrap_or(core::cmp::Ordering::Equal))
.expect("iterator with positive length will have a min; qed");
difference = max_stake - min_stake;
@@ -254,7 +254,7 @@ where
support_map
.get(&x.0)
.and_then(|x| support_map.get(&y.0).and_then(|y| x.total.partial_cmp(&y.total)))
.unwrap_or(sp_std::cmp::Ordering::Equal)
.unwrap_or(core::cmp::Ordering::Equal)
});
let mut cumulative_stake = 0.0;
@@ -17,7 +17,8 @@
//! (very) Basic implementation of a graph node used in the reduce algorithm.
use sp_std::{cell::RefCell, fmt, prelude::*, rc::Rc};
use alloc::{rc::Rc, vec::Vec};
use core::{cell::RefCell, fmt};
/// The role that a node can accept.
#[derive(PartialEq, Eq, Ord, PartialOrd, Clone, Debug)]
@@ -49,8 +50,8 @@ impl<A> NodeId<A> {
}
#[cfg(feature = "std")]
impl<A: fmt::Debug> sp_std::fmt::Debug for NodeId<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> sp_std::fmt::Result {
impl<A: fmt::Debug> fmt::Debug for NodeId<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Node({:?}, {:?})",
@@ -24,12 +24,12 @@ use crate::{
balancing, setup_inputs, BalancingConfig, CandidatePtr, ElectionResult, ExtendedBalance,
IdentifierT, PerThing128, VoteWeight, Voter,
};
use alloc::vec::Vec;
use sp_arithmetic::{
helpers_128bit::multiply_by_rational_with_rounding,
traits::{Bounded, Zero},
Rational128, Rounding,
};
use sp_std::prelude::*;
/// The denominator used for loads. Since votes are collected as u64, the smallest ratio that we
/// might collect is `1/approval_stake` where approval stake is the sum of votes. Hence, some number
@@ -25,8 +25,8 @@ use crate::{
balance, setup_inputs, BalancingConfig, CandidatePtr, ElectionResult, ExtendedBalance,
IdentifierT, PerThing128, VoteWeight, Voter,
};
use alloc::{rc::Rc, vec, vec::Vec};
use sp_arithmetic::{traits::Bounded, PerThing, Rational128};
use sp_std::{prelude::*, rc::Rc};
/// Execute the phragmms method.
///
@@ -232,8 +232,8 @@ pub(crate) fn apply_elected<AccountId: IdentifierT>(
mod tests {
use super::*;
use crate::{Assignment, ElectionResult};
use alloc::rc::Rc;
use sp_runtime::{Perbill, Percent};
use sp_std::rc::Rc;
#[test]
fn basic_election_manual_works() {
@@ -26,8 +26,8 @@ use crate::{
Candidate, CandidatePtr, Edge, ExtendedBalance, IdentifierT, Support, SupportMap, Supports,
VoteWeight, Voter,
};
use alloc::{collections::btree_map::BTreeMap, rc::Rc, vec::Vec};
use sp_arithmetic::{traits::Zero, Perbill};
use sp_std::{collections::btree_map::BTreeMap, rc::Rc, vec::Vec};
/// The type used as the threshold.
///
/// Just some reading sugar; Must always be same as [`ExtendedBalance`];
@@ -51,11 +51,12 @@ use crate::{
node::{Node, NodeId, NodeRef, NodeRole},
ExtendedBalance, IdentifierT, StakedAssignment,
};
use sp_arithmetic::traits::{Bounded, Zero};
use sp_std::{
use alloc::{
collections::btree_map::{BTreeMap, Entry::*},
prelude::*,
vec,
vec::Vec,
};
use sp_arithmetic::traits::{Bounded, Zero};
/// Map type used for reduce_4. Can be easily swapped with HashMap.
type Map<A> = BTreeMap<(A, A), A>;
@@ -18,8 +18,8 @@
//! Traits for the npos-election operations.
use crate::ExtendedBalance;
use core::{fmt::Debug, ops::Mul};
use sp_arithmetic::PerThing;
use sp_std::{fmt::Debug, ops::Mul, prelude::*};
/// an aggregator trait for a generic type of a voter/target identifier. This usually maps to
/// substrate's account id.
-2
View File
@@ -22,7 +22,6 @@ sp-api = { path = "../api", default-features = false }
sp-core = { path = "../core", default-features = false }
sp-runtime = { path = "../runtime", optional = true }
sp-staking = { path = "../staking", default-features = false }
sp-std = { path = "../std", default-features = false }
sp-keystore = { path = "../keystore", optional = true }
[features]
@@ -35,5 +34,4 @@ std = [
"sp-keystore/std",
"sp-runtime/std",
"sp-staking/std",
"sp-std/std",
]
+3 -1
View File
@@ -19,6 +19,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use codec::{Decode, Encode};
#[cfg(feature = "std")]
@@ -26,9 +28,9 @@ use sp_api::ProvideRuntimeApi;
#[cfg(feature = "std")]
use sp_runtime::traits::Block as BlockT;
use alloc::vec::Vec;
use sp_core::RuntimeDebug;
use sp_staking::SessionIndex;
use sp_std::vec::Vec;
pub mod runtime_api;
pub use runtime_api::*;
@@ -15,8 +15,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use alloc::vec::Vec;
pub use sp_core::crypto::KeyTypeId;
use sp_std::prelude::*;
sp_api::decl_runtime_apis! {
/// Session keys runtime api.
-2
View File
@@ -23,7 +23,6 @@ impl-trait-for-tuples = "0.2.2"
sp-core = { path = "../core", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
sp-std = { path = "../std", default-features = false }
[features]
default = ["std"]
@@ -33,6 +32,5 @@ std = [
"serde/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
]
runtime-benchmarks = ["sp-runtime/runtime-benchmarks"]
+5 -2
View File
@@ -20,14 +20,17 @@
//! A crate which contains primitives that are useful for implementation that uses staking
//! approaches in general. Definitions related to sessions, slashing, etc go here.
extern crate alloc;
use crate::currency_to_vote::CurrencyToVote;
use alloc::{collections::btree_map::BTreeMap, vec, vec::Vec};
use codec::{Decode, Encode, FullCodec, HasCompact, MaxEncodedLen};
use core::ops::Sub;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{AtLeast32BitUnsigned, Zero},
DispatchError, DispatchResult, RuntimeDebug, Saturating,
};
use sp_std::{collections::btree_map::BTreeMap, ops::Sub, vec, vec::Vec};
pub mod offence;
@@ -172,7 +175,7 @@ pub trait StakingInterface {
+ Saturating;
/// AccountId type used by the staking system.
type AccountId: Clone + sp_std::fmt::Debug;
type AccountId: Clone + core::fmt::Debug;
/// Means of converting Currency to VoteWeight.
type CurrencyToVote: CurrencyToVote<Self::Balance>;
+1 -1
View File
@@ -18,10 +18,10 @@
//! Common traits and types that are useful for describing offences for usage in environments
//! that use staking.
use alloc::vec::Vec;
use codec::{Decode, Encode};
use sp_core::Get;
use sp_runtime::{transaction_validity::TransactionValidityError, DispatchError, Perbill};
use sp_std::vec::Vec;
use crate::SessionIndex;
@@ -28,7 +28,6 @@ tracing = { version = "0.1.29", optional = true }
sp-core = { path = "../core", default-features = false }
sp-externalities = { path = "../externalities", default-features = false }
sp-panic-handler = { path = "../panic-handler", optional = true }
sp-std = { path = "../std", default-features = false }
sp-trie = { path = "../trie", default-features = false }
trie-db = { version = "0.28.0", default-features = false }
@@ -51,7 +50,6 @@ std = [
"sp-externalities/std",
"sp-panic-handler",
"sp-runtime/std",
"sp-std/std",
"sp-trie/std",
"thiserror",
"tracing",
@@ -23,13 +23,13 @@ use crate::{
trie_backend_essence::TrieBackendStorage, ChildStorageCollection, StorageCollection,
StorageKey, StorageValue, UsageInfo,
};
use alloc::vec::Vec;
use codec::Encode;
use core::marker::PhantomData;
use hash_db::Hasher;
use sp_core::storage::{ChildInfo, StateVersion, TrackedStorageKey};
#[cfg(feature = "std")]
use sp_core::traits::RuntimeCode;
use sp_std::vec::Vec;
use sp_trie::{MerkleValue, PrefixedMemoryDB};
/// A struct containing arguments for iterating over the storage.
@@ -179,7 +179,7 @@ pub type BackendTransaction<H> = PrefixedMemoryDB<H>;
/// to it.
///
/// The clone operation (if implemented) should be cheap.
pub trait Backend<H: Hasher>: sp_std::fmt::Debug {
pub trait Backend<H: Hasher>: core::fmt::Debug {
/// An error type when fetching data is not possible.
type Error: super::Error;
@@ -32,12 +32,10 @@ use sp_core::storage::{
use sp_externalities::{Extension, ExtensionStore, Externalities, MultiRemovalResults};
use crate::{log_error, trace, warn};
use sp_std::{
use alloc::{boxed::Box, vec, vec::Vec};
use core::{
any::{Any, TypeId},
boxed::Box,
cmp::Ordering,
vec,
vec::Vec,
};
#[cfg(feature = "std")]
use std::error;
@@ -739,7 +737,7 @@ impl<'a> StorageAppend<'a> {
pub fn append(&mut self, value: Vec<u8>) {
let value = vec![EncodeOpaqueValue(value)];
let item = sp_std::mem::take(self.0);
let item = core::mem::take(self.0);
*self.0 = match Vec::<EncodeOpaqueValue>::append_or_new(item, &value) {
Ok(item) => item,
@@ -20,6 +20,8 @@
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
pub mod backend;
#[cfg(feature = "std")]
mod basic;
@@ -118,8 +120,8 @@ pub type DefaultError = String;
pub struct DefaultError;
#[cfg(not(feature = "std"))]
impl sp_std::fmt::Display for DefaultError {
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
impl core::fmt::Display for DefaultError {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "DefaultError")
}
}
@@ -20,16 +20,14 @@
use super::{Extrinsics, StorageKey, StorageValue};
#[cfg(not(feature = "std"))]
use sp_std::collections::btree_set::BTreeSet as Set;
use alloc::collections::btree_set::BTreeSet as Set;
#[cfg(feature = "std")]
use std::collections::HashSet as Set;
use crate::warn;
use alloc::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
use core::hash::Hash;
use smallvec::SmallVec;
use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
hash::Hash,
};
const PROOF_OVERLAY_NON_EMPTY: &str = "\
An OverlayValue is always created with at least one transaction and dropped as soon
@@ -225,7 +223,7 @@ impl<K: Ord + Hash + Clone, V> OverlayedMap<K, V> {
/// This changeset might be created when there are already open transactions.
/// We need to catch up here so that the child is at the same transaction depth.
pub fn spawn_child(&self) -> Self {
use sp_std::iter::repeat;
use core::iter::repeat;
Self {
changes: Default::default(),
dirty_keys: repeat(Set::new()).take(self.transaction_depth()).collect(),
@@ -242,7 +240,7 @@ impl<K: Ord + Hash + Clone, V> OverlayedMap<K, V> {
/// Get an optional reference to the value stored for the specified key.
pub fn get<Q>(&self, key: &Q) -> Option<&OverlayedEntry<V>>
where
K: sp_std::borrow::Borrow<Q>,
K: core::borrow::Borrow<Q>,
Q: Ord + ?Sized,
{
self.changes.get(key)
@@ -448,7 +446,7 @@ impl OverlayedChangeSet {
/// Get the iterator over all changes that follow the supplied `key`.
pub fn changes_after(&self, key: &[u8]) -> impl Iterator<Item = (&[u8], &OverlayedValue)> {
use sp_std::ops::Bound;
use core::ops::Bound;
let range = (Bound::Excluded(key), Bound::Unbounded);
self.changes.range::<[u8], _>(range).map(|(k, v)| (k.as_slice(), v))
}
@@ -22,6 +22,7 @@ mod offchain;
use self::changeset::OverlayedChangeSet;
use crate::{backend::Backend, stats::StateMachineStats, BackendTransaction, DefaultError};
use alloc::{collections::btree_set::BTreeSet, vec::Vec};
use codec::{Decode, Encode};
use hash_db::Hasher;
pub use offchain::OffchainOverlayedChanges;
@@ -31,12 +32,13 @@ use sp_core::{
};
#[cfg(feature = "std")]
use sp_externalities::{Extension, Extensions};
#[cfg(not(feature = "std"))]
use sp_std::collections::btree_map::BTreeMap as Map;
use sp_std::{collections::btree_set::BTreeSet, vec::Vec};
use sp_trie::{empty_child_trie_root, LayoutV1};
#[cfg(not(feature = "std"))]
use alloc::collections::btree_map::BTreeMap as Map;
#[cfg(feature = "std")]
use std::collections::{hash_map::Entry as MapEntry, HashMap as Map};
#[cfg(feature = "std")]
use std::{
any::{Any, TypeId},
@@ -136,7 +138,7 @@ impl<H: Hasher> Clone for OverlayedChanges<H> {
}
}
impl<H: Hasher> sp_std::fmt::Debug for OverlayedChanges<H> {
impl<H: Hasher> core::fmt::Debug for OverlayedChanges<H> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("OverlayedChanges")
.field("top", &self.top)
@@ -259,7 +261,7 @@ impl<H: Hasher> Clone for StorageTransactionCache<H> {
}
}
impl<H: Hasher> sp_std::fmt::Debug for StorageTransactionCache<H> {
impl<H: Hasher> core::fmt::Debug for StorageTransactionCache<H> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut debug = f.debug_struct("StorageTransactionCache");
@@ -572,7 +574,7 @@ impl<H: Hasher> OverlayedChanges<H> {
},
};
use sp_std::mem::take;
use core::mem::take;
let main_storage_changes = take(&mut self.top).drain_commited();
let child_storage_changes = take(&mut self.children)
.into_iter()
@@ -777,7 +779,7 @@ where
K: Ord,
F: FnMut(&K, &mut V) -> bool,
{
let old = sp_std::mem::replace(map, Map::default());
let old = core::mem::replace(map, Map::default());
for (k, mut v) in old.into_iter() {
if f(&k, &mut v) {
map.insert(k, v);
@@ -18,8 +18,8 @@
//! Overlayed changes for offchain indexing.
use super::changeset::OverlayedMap;
use alloc::vec::Vec;
use sp_core::offchain::OffchainOverlayedChange;
use sp_std::prelude::Vec;
/// In-memory storage for offchain workers recoding changes for the actual offchain storage
/// implementation.
@@ -48,7 +48,7 @@ impl OffchainOverlayedChanges {
/// Drain all elements of changeset.
pub fn drain(&mut self) -> impl Iterator<Item = OffchainOverlayedChangesItemOwned> {
sp_std::mem::take(self).into_iter()
core::mem::take(self).into_iter()
}
/// Remove a key and its associated value from the offchain database.
@@ -297,7 +297,7 @@ struct CachedIter<S, H, C, R>
where
H: Hasher,
{
last_key: sp_std::vec::Vec<u8>,
last_key: alloc::vec::Vec<u8>,
iter: RawIter<S, H, C, R>,
}
@@ -390,9 +390,9 @@ where
}
impl<S: TrieBackendStorage<H>, H: Hasher, C: TrieCacheProvider<H>, R: TrieRecorderProvider<H>>
sp_std::fmt::Debug for TrieBackend<S, H, C, R>
core::fmt::Debug for TrieBackend<S, H, C, R>
{
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "TrieBackend")
}
}
@@ -23,14 +23,15 @@ use crate::{
trie_backend::TrieCacheProvider,
warn, StorageKey, StorageValue,
};
#[cfg(feature = "std")]
use alloc::sync::Arc;
use alloc::{boxed::Box, vec::Vec};
use codec::Codec;
use core::marker::PhantomData;
use hash_db::{self, AsHashDB, HashDB, HashDBRef, Hasher, Prefix};
#[cfg(feature = "std")]
use parking_lot::RwLock;
use sp_core::storage::{ChildInfo, ChildType, StateVersion};
#[cfg(feature = "std")]
use sp_std::sync::Arc;
use sp_std::{boxed::Box, marker::PhantomData, vec::Vec};
use sp_trie::{
child_delta_trie_root, delta_trie_root, empty_child_trie_root,
read_child_trie_first_descedant_value, read_child_trie_hash, read_child_trie_value,
@@ -55,7 +56,7 @@ macro_rules! format {
};
}
type Result<V> = sp_std::result::Result<V, crate::DefaultError>;
type Result<V> = core::result::Result<V, crate::DefaultError>;
/// Patricia trie-based storage trait.
pub trait Storage<H: Hasher>: Send + Sync {
@@ -21,7 +21,6 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive
sp-core = { path = "../core", default-features = false }
sp-crypto-hashing = { path = "../crypto/hashing", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
sp-std = { path = "../std", default-features = false }
sp-api = { path = "../api", default-features = false }
sp-application-crypto = { path = "../application-crypto", default-features = false }
sp-runtime-interface = { path = "../runtime-interface", default-features = false }
@@ -57,7 +56,6 @@ std = [
"sp-externalities/std",
"sp-runtime-interface/std",
"sp-runtime/std",
"sp-std/std",
"thiserror",
"x25519-dalek",
]
@@ -20,13 +20,15 @@
//! A crate which contains statement-store primitives.
extern crate alloc;
use alloc::vec::Vec;
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_application_crypto::RuntimeAppPublic;
#[cfg(feature = "std")]
use sp_core::Pair;
use sp_runtime_interface::pass_by::PassByCodec;
use sp_std::vec::Vec;
/// Statement topic.
pub type Topic = [u8; 32];
@@ -18,11 +18,11 @@
//! Runtime support for the statement store.
use crate::{Hash, Statement, Topic};
use alloc::vec::Vec;
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug;
use sp_runtime_interface::{pass_by::PassByEnum, runtime_interface};
use sp_std::vec::Vec;
#[cfg(feature = "std")]
use sp_externalities::ExternalitiesExt;
-2
View File
@@ -22,7 +22,6 @@ impl-serde = { version = "0.4.0", optional = true, default-features = false }
ref-cast = "1.0.0"
serde = { features = ["alloc", "derive"], optional = true, workspace = true }
sp-debug-derive = { path = "../debug-derive", default-features = false }
sp-std = { path = "../std", default-features = false }
[features]
default = ["std"]
@@ -31,7 +30,6 @@ std = [
"impl-serde/std",
"serde/std",
"sp-debug-derive/std",
"sp-std/std",
]
# Serde support without relying on std features.
+7 -8
View File
@@ -19,18 +19,19 @@
#![cfg_attr(not(feature = "std"), no_std)]
use core::fmt::Display;
extern crate alloc;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use sp_debug_derive::RuntimeDebug;
use alloc::vec::Vec;
use codec::{Decode, Encode};
use ref_cast::RefCast;
use sp_std::{
use core::{
fmt::Display,
ops::{Deref, DerefMut},
vec::Vec,
};
use ref_cast::RefCast;
/// Storage key.
#[derive(PartialEq, Eq, RuntimeDebug)]
@@ -49,9 +50,7 @@ impl AsRef<[u8]> for StorageKey {
}
/// Storage key with read/write tracking information.
#[derive(
PartialEq, Eq, Ord, PartialOrd, sp_std::hash::Hash, RuntimeDebug, Clone, Encode, Decode,
)]
#[derive(PartialEq, Eq, Ord, PartialOrd, core::hash::Hash, RuntimeDebug, Clone, Encode, Decode)]
pub struct TrackedStorageKey {
pub key: Vec<u8>,
pub reads: u32,
@@ -441,7 +440,7 @@ impl From<StateVersion> for u8 {
impl TryFrom<u8> for StateVersion {
type Error = ();
fn try_from(val: u8) -> sp_std::result::Result<StateVersion, ()> {
fn try_from(val: u8) -> core::result::Result<StateVersion, ()> {
match val {
0 => Ok(StateVersion::V0),
1 => Ok(StateVersion::V1),
@@ -21,7 +21,6 @@ serde = { features = ["derive"], optional = true, workspace = true }
sp-application-crypto = { path = "../application-crypto", default-features = false }
sp-core = { path = "../core", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
sp-std = { path = "../std", default-features = false }
[features]
default = ["std"]
@@ -32,7 +31,6 @@ std = [
"sp-application-crypto/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
]
# Serde support without relying on std features.
@@ -19,14 +19,16 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use codec::{Decode, Encode};
pub use sp_application_crypto;
use sp_application_crypto::sr25519;
use alloc::vec::Vec;
pub use sp_core::{hash::H256, RuntimeDebug};
use sp_runtime::traits::{BlakeTwo256, Extrinsic as ExtrinsicT, Verify};
use sp_std::vec::Vec;
/// Extrinsic for test-runtime.
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
@@ -21,7 +21,6 @@ codec = { package = "parity-scale-codec", version = "3.6.1", default-features =
thiserror = { optional = true, workspace = true }
sp-inherents = { path = "../inherents", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
sp-std = { path = "../std", default-features = false }
[features]
default = ["std"]
@@ -30,6 +29,5 @@ std = [
"codec/std",
"sp-inherents/std",
"sp-runtime/std",
"sp-std/std",
"thiserror",
]
-2
View File
@@ -21,7 +21,6 @@ features = ["with-tracing"]
targets = ["wasm32-unknown-unknown", "x86_64-unknown-linux-gnu"]
[dependencies]
sp-std = { path = "../std", default-features = false }
codec = { version = "3.6.1", package = "parity-scale-codec", default-features = false, features = [
"derive",
] }
@@ -36,7 +35,6 @@ default = ["std"]
with-tracing = ["codec/derive", "codec/full"]
std = [
"codec/std",
"sp-std/std",
"tracing-core/std",
"tracing-subscriber",
"tracing/std",
+2
View File
@@ -37,6 +37,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
#[cfg(feature = "std")]
use tracing;
pub use tracing::{
+3 -3
View File
@@ -15,11 +15,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use alloc::{vec, vec::Vec};
use codec::{Decode, Encode};
/// Types for wasm based tracing. Loosly inspired by `tracing-core` but
/// optimised for the specific use case.
use core::{fmt::Debug, format_args};
use sp_std::{vec, vec::Vec, Writer};
/// The Tracing Level the user can filter by this
#[derive(Clone, Encode, Decode, Debug)]
@@ -132,9 +132,9 @@ impl From<bool> for WasmValue {
impl From<core::fmt::Arguments<'_>> for WasmValue {
fn from(inp: core::fmt::Arguments<'_>) -> WasmValue {
let mut buf = Writer::default();
let mut buf = alloc::string::String::default();
core::fmt::write(&mut buf, inp).expect("Writing of arguments doesn't fail");
WasmValue::Formatted(buf.into_inner())
WasmValue::Formatted(buf.into_bytes())
}
}
@@ -20,4 +20,6 @@
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
pub mod runtime_api;
@@ -22,7 +22,6 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive
sp-core = { path = "../core", optional = true }
sp-inherents = { path = "../inherents", default-features = false }
sp-runtime = { path = "../runtime", default-features = false }
sp-std = { path = "../std", default-features = false }
sp-trie = { path = "../trie", optional = true }
[features]
@@ -34,6 +33,5 @@ std = [
"sp-core/std",
"sp-inherents/std",
"sp-runtime/std",
"sp-std/std",
"sp-trie/std",
]
@@ -20,8 +20,11 @@
#![cfg_attr(not(feature = "std"), no_std)]
use sp_std::{prelude::*, result::Result};
extern crate alloc;
use core::result::Result;
use alloc::vec::Vec;
use codec::{Decode, Encode};
use sp_inherents::{InherentData, InherentIdentifier, IsFatalError};
use sp_runtime::traits::{Block as BlockT, NumberFor};
-2
View File
@@ -35,7 +35,6 @@ tracing = { version = "0.1.29", optional = true }
trie-db = { version = "0.28.0", default-features = false }
trie-root = { version = "0.18.0", default-features = false }
sp-core = { path = "../core", default-features = false }
sp-std = { path = "../std", default-features = false }
sp-externalities = { path = "../externalities", default-features = false }
schnellru = { version = "0.2.1", optional = true }
@@ -62,7 +61,6 @@ std = [
"sp-core/std",
"sp-externalities/std",
"sp-runtime/std",
"sp-std/std",
"thiserror",
"tracing",
"trie-db/std",
+1 -1
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use sp_std::{boxed::Box, vec::Vec};
use alloc::{boxed::Box, vec::Vec};
/// Error type used for trie related errors.
#[derive(Debug, PartialEq, Eq, Clone)]
+5 -2
View File
@@ -19,6 +19,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
#[cfg(feature = "std")]
pub mod cache;
mod error;
@@ -33,6 +35,8 @@ mod trie_stream;
#[cfg(feature = "std")]
pub mod proof_size_extension;
use alloc::{borrow::Borrow, boxed::Box, vec, vec::Vec};
use core::marker::PhantomData;
/// Our `NodeCodec`-specific error.
pub use error::Error;
/// Various re-exports from the `hash-db` crate.
@@ -42,7 +46,6 @@ use hash_db::{Hasher, Prefix};
pub use memory_db::{prefixed_key, HashKey, KeyFunction, PrefixedKey};
/// The Substrate format implementation of `NodeCodec`.
pub use node_codec::NodeCodec;
use sp_std::{borrow::Borrow, boxed::Box, marker::PhantomData, vec::Vec};
pub use storage_proof::{CompactProof, StorageProof};
/// Trie codec reexport, mainly child trie support
/// for trie compact proof.
@@ -500,7 +503,7 @@ pub struct KeySpacedDBMut<'a, DB: ?Sized, H>(&'a mut DB, &'a [u8], PhantomData<H
/// Utility function used to merge some byte data (keyspace) and `prefix` data
/// before calling key value database primitives.
fn keyspace_as_prefix_alloc(ks: &[u8], prefix: Prefix) -> (Vec<u8>, Option<u8>) {
let mut result = sp_std::vec![0; ks.len() + prefix.0.len()];
let mut result = vec![0; ks.len() + prefix.0.len()];
result[..ks.len()].copy_from_slice(ks);
result[ks.len()..].copy_from_slice(prefix.0);
(result, prefix.1)
+3 -2
View File
@@ -19,9 +19,10 @@
use super::node_header::{NodeHeader, NodeKind};
use crate::{error::Error, trie_constants};
use alloc::{borrow::Borrow, vec::Vec};
use codec::{Compact, Decode, Encode, Input};
use core::{marker::PhantomData, ops::Range};
use hash_db::Hasher;
use sp_std::{borrow::Borrow, marker::PhantomData, ops::Range, vec::Vec};
use trie_db::{
nibble_ops,
node::{NibbleSlicePlan, NodeHandlePlan, NodePlan, Value, ValuePlan},
@@ -30,7 +31,7 @@ use trie_db::{
/// Helper struct for trie node decoder. This implements `codec::Input` on a byte slice, while
/// tracking the absolute position. This is similar to `std::io::Cursor` but does not implement
/// `Read` and `io` is not in `sp-std`.
/// `Read` and `io` are not in `core` or `alloc`.
struct ByteSliceInput<'a> {
data: &'a [u8],
offset: usize,

Some files were not shown because too many files have changed in this diff Show More