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